C++ dir warning patch part 3/5
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Thu Mar 25 10:17:00 GMT 1999
These patches mainly address warnings in the cp/ directory
exposed by using extra warning flags: -Wstrict-prototypes
-Wmissing-prototypes -Wmissing-declarations and -Wwrite-strings.
This is part 3/5, okay to install?
Thanks,
--Kaveh
Wed Mar 24 18:54:26 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* decl2.c (acceptable_java_type, output_vtable_inherit,
setup_initp, start_objects, finish_objects, do_dtors, do_ctors,
merge_functions, decl_namespace, validate_nonmember_using_decl,
do_nonmember_using_decl): Add static prototype.
(lang_f_options): Const-ify a char*.
(finish_builtin_type): Likewise.
(add_function, arg_assoc_namespace, arg_assoc_class): Add static
prototype.
* errfn.c: Include cp-tree.h.
(cp_thing): Add static prototype.
(compiler_error): Don't protoptype.
(cp_compiler_error): Cast `compiler_error' to `errorfn' before
passing it to `cp_thing'.
* error.c (interesting_scope_p): Add static prototype.
* except.c (build_eh_type_type, build_eh_type_type_ref): Const-ify
a char*.
* init.c (compiler_error): Don't prototype.
(member_init_ok_or_else): Const-ify a char*.
(build_java_class_ref): Add static prototype.
* lex.c (compiler_error): Don't prototype.
(get_time_identifier, interface_strcmp, extend_token_buffer,
handle_cp_pragma): Const-ify a char*.
(is_global, init_filename_times): Add static prototype.
(file_name_nondirectory, cplus_tree_code_name): Const-ify a char*.
(compiler_error): Change from fixed args to variable args.
(yyerror): Const-ify a char*.
diff -rup orig/egcs-CVS19990323/gcc/cp/decl2.c egcs-CVS19990323/gcc/cp/decl2.c
--- orig/egcs-CVS19990323/gcc/cp/decl2.c Tue Mar 23 09:48:59 1999
+++ egcs-CVS19990323/gcc/cp/decl2.c Wed Mar 24 12:01:21 1999
@@ -58,6 +58,18 @@ static int is_namespace_ancestor PROTO((
static void add_using_namespace PROTO((tree, tree, int));
static tree ambiguous_decl PROTO((tree, tree, tree,int));
static tree build_anon_union_vars PROTO((tree, tree*, int, int));
+static int acceptable_java_type PROTO((tree));
+static void output_vtable_inherit PROTO((tree));
+static void setup_initp PROTO((void));
+static void start_objects PROTO((int, int));
+static void finish_objects PROTO((int, int));
+static void do_dtors PROTO((tree));
+static void do_ctors PROTO((tree));
+static tree merge_functions PROTO((tree, tree));
+static tree decl_namespace PROTO((tree));
+static tree validate_nonmember_using_decl PROTO((tree, tree *, tree *));
+static void do_nonmember_using_decl PROTO((tree, tree, tree, tree,
+ tree *, tree *));
extern int current_class_depth;
@@ -441,7 +453,8 @@ int flag_permissive;
if `-fSTRING' is seen as an option.
(If `-fno-STRING' is seen as an option, the opposite value is stored.) */
-static struct { char *string; int *variable; int on_value;} lang_f_options[] =
+static struct { const char *string; int *variable; int on_value;}
+lang_f_options[] =
{
/* C/C++ options. */
{"signed-char", &flag_signed_char, 1},
@@ -1234,7 +1247,7 @@ check_member_template (tmpl)
/* Return true iff TYPE is a valid Java parameter or return type. */
-int
+static int
acceptable_java_type (type)
tree type;
{
@@ -2202,7 +2215,7 @@ finish_anon_union (anon_union_decl)
void
finish_builtin_type (type, name, fields, len, align_type)
tree type;
- char *name;
+ const char *name;
tree fields[];
int len;
tree align_type;
@@ -4268,7 +4281,7 @@ set_decl_namespace (decl, scope, friendp
/* Compute the namespace where a declaration is defined. */
-tree
+static tree
decl_namespace (decl)
tree decl;
{
@@ -4360,6 +4373,9 @@ struct arg_lookup
static int arg_assoc PROTO((struct arg_lookup*, tree));
static int arg_assoc_args PROTO((struct arg_lookup*, tree));
static int arg_assoc_type PROTO((struct arg_lookup*, tree));
+static int add_function PROTO((struct arg_lookup *, tree));
+static int arg_assoc_namespace PROTO((struct arg_lookup *, tree));
+static int arg_assoc_class PROTO((struct arg_lookup *, tree));
/* Add a function to the lookup structure.
Returns 1 on error. */
diff -rup orig/egcs-CVS19990323/gcc/cp/errfn.c egcs-CVS19990323/gcc/cp/errfn.c
--- orig/egcs-CVS19990323/gcc/cp/errfn.c Tue Feb 23 12:21:41 1999
+++ egcs-CVS19990323/gcc/cp/errfn.c Wed Mar 24 13:44:26 1999
@@ -22,6 +22,7 @@ Boston, MA 02111-1307, USA. */
#include "config.h"
#include "system.h"
#include "tree.h"
+#include "cp-tree.h"
#include "toplev.h"
/* cp_printer is the type of a function which converts an argument into
@@ -39,6 +40,7 @@ int cp_silent = 0;
typedef void errorfn (); /* deliberately vague */
+static void cp_thing PROTO ((errorfn *, int, const char *, va_list));
extern char* cp_file_of PROTO((tree));
extern int cp_line_of PROTO((tree));
@@ -246,8 +248,6 @@ cp_pedwarn VPROTO((const char *format, .
va_end (ap);
}
-extern errorfn compiler_error;
-
void
cp_compiler_error VPROTO((const char *format, ...))
{
@@ -263,7 +263,7 @@ cp_compiler_error VPROTO((const char *fo
#endif
if (! cp_silent)
- cp_thing (compiler_error, 0, format, ap);
+ cp_thing ((errorfn *) compiler_error, 0, format, ap);
va_end (ap);
}
diff -rup orig/egcs-CVS19990323/gcc/cp/error.c egcs-CVS19990323/gcc/cp/error.c
--- orig/egcs-CVS19990323/gcc/cp/error.c Tue Mar 23 09:49:05 1999
+++ egcs-CVS19990323/gcc/cp/error.c Wed Mar 24 12:09:26 1999
@@ -110,6 +110,7 @@ static void dump_parameters PROTO((tree,
static void dump_exception_spec PROTO((tree, int));
static char *aggr_variety PROTO((tree));
static tree ident_fndecl PROTO((tree));
+static int interesting_scope_p PROTO((tree));
void
init_error ()
diff -rup orig/egcs-CVS19990323/gcc/cp/except.c egcs-CVS19990323/gcc/cp/except.c
--- orig/egcs-CVS19990323/gcc/cp/except.c Mon Jan 25 15:43:18 1999
+++ egcs-CVS19990323/gcc/cp/except.c Wed Mar 24 12:12:19 1999
@@ -399,7 +399,7 @@ static tree
build_eh_type_type (type)
tree type;
{
- char *typestring;
+ const char *typestring;
tree exp;
if (type == error_mark_node)
@@ -427,7 +427,7 @@ static tree
build_eh_type_type_ref (type)
tree type;
{
- char *typestring;
+ const char *typestring;
tree exp;
if (type == error_mark_node)
diff -rup orig/egcs-CVS19990323/gcc/cp/init.c egcs-CVS19990323/gcc/cp/init.c
--- orig/egcs-CVS19990323/gcc/cp/init.c Fri Mar 19 15:55:05 1999
+++ egcs-CVS19990323/gcc/cp/init.c Wed Mar 24 13:41:09 1999
@@ -32,8 +32,6 @@ Boston, MA 02111-1307, USA. */
#include "expr.h"
#include "toplev.h"
-extern void compiler_error ();
-
/* In C++, structures with well-defined constructors are initialized by
those constructors, unasked. CURRENT_BASE_INIT_LIST
holds a list of stmts for a BASE_INIT term in the grammar.
@@ -54,13 +52,14 @@ static tree build_vec_delete_1 PROTO((tr
static void perform_member_init PROTO((tree, tree, tree, int));
static void sort_base_init PROTO((tree, tree *, tree *));
static tree build_builtin_delete_call PROTO((tree));
-static int member_init_ok_or_else PROTO((tree, tree, char *));
+static int member_init_ok_or_else PROTO((tree, tree, const char *));
static void expand_virtual_init PROTO((tree, tree));
static tree sort_member_init PROTO((tree));
static tree build_partial_cleanup_for PROTO((tree));
static tree initializing_context PROTO((tree));
static void expand_vec_init_try_block PROTO((tree));
static void expand_vec_init_catch_clause PROTO((tree, tree, tree, tree));
+static tree build_java_class_ref PROTO((tree));
/* Cache the identifier nodes for the magic field of a new cookie. */
static tree nc_nelts_field_id;
@@ -848,7 +847,7 @@ static int
member_init_ok_or_else (field, type, member_name)
tree field;
tree type;
- char *member_name;
+ const char *member_name;
{
if (field == error_mark_node)
return 0;
@@ -2061,7 +2060,7 @@ static tree jclass_node = NULL_TREE;
/* Given a Java class, return a decl for the corresponding java.lang.Class. */
-tree
+static tree
build_java_class_ref (type)
tree type;
{
diff -rup orig/egcs-CVS19990323/gcc/cp/lex.c egcs-CVS19990323/gcc/cp/lex.c
--- orig/egcs-CVS19990323/gcc/cp/lex.c Mon Mar 15 21:58:47 1999
+++ egcs-CVS19990323/gcc/cp/lex.c Wed Mar 24 13:39:54 1999
@@ -54,18 +54,16 @@ extern struct obstack permanent_obstack;
extern struct obstack *current_obstack, *saveable_obstack;
extern void yyprint PROTO((FILE *, int, YYSTYPE));
-extern void compiler_error PROTO((char *, HOST_WIDE_INT,
- HOST_WIDE_INT));
-static tree get_time_identifier PROTO((char *));
+static tree get_time_identifier PROTO((const char *));
static int check_newline PROTO((void));
static int skip_white_space PROTO((int));
static void finish_defarg PROTO((void));
static int my_get_run_time PROTO((void));
static int get_last_nonwhite_on_line PROTO((void));
-static int interface_strcmp PROTO((char *));
+static int interface_strcmp PROTO((const char *));
static int readescape PROTO((int *));
-static char *extend_token_buffer PROTO((char *));
+static char *extend_token_buffer PROTO((const char *));
static void consume_string PROTO((struct obstack *, int));
static void set_typedecl_interface_info PROTO((tree, tree));
static void feed_defarg PROTO((tree, tree));
@@ -73,7 +71,7 @@ static int set_vardecl_interface_info PR
static void store_pending_inline PROTO((tree, struct pending_inline *));
static void reinit_parse_for_expr PROTO((struct obstack *));
static int *init_cpp_parse PROTO((void));
-static int handle_cp_pragma PROTO((char *));
+static int handle_cp_pragma PROTO((const char *));
#ifdef HANDLE_GENERIC_PRAGMAS
static int handle_generic_pragma PROTO((int));
#endif
@@ -85,12 +83,14 @@ static int token_cmp PROTO((int *, int *
#endif
static void begin_definition_of_inclass_inline PROTO((struct pending_inline*));
static void parse_float PROTO((PTR));
+static int is_global PROTO((tree));
+static void init_filename_times PROTO((void));
/* Given a file name X, return the nondirectory portion.
Keep in mind that X can be computed more than once. */
char *
file_name_nondirectory (x)
- char *x;
+ const char *x;
{
char *tmp = (char *) rindex (x, '/');
if (DIR_SEPARATOR != '/' && ! tmp)
@@ -98,7 +98,7 @@ file_name_nondirectory (x)
if (tmp)
return (char *) (tmp + 1);
else
- return x;
+ return (char *) x;
}
/* This obstack is needed to hold text. It is not safe to use
@@ -314,7 +314,7 @@ static int ignore_escape_flag = 0;
static tree
get_time_identifier (name)
- char *name;
+ const char *name;
{
tree time_identifier;
int len = strlen (name);
@@ -379,7 +379,7 @@ int cplus_tree_code_length[] = {
Used for printing out the tree and error messages. */
#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-char *cplus_tree_code_name[] = {
+const char *cplus_tree_code_name[] = {
"@@dummy",
#include "cp-tree.def"
};
@@ -429,7 +429,7 @@ lang_identify ()
return "cplusplus";
}
-void
+static void
init_filename_times ()
{
this_filename_time = get_time_identifier ("<top level>");
@@ -1158,15 +1158,15 @@ extract_interface_info ()
static int
interface_strcmp (s)
- char *s;
+ const char *s;
{
/* Set the interface/implementation bits for this scope. */
struct impl_files *ifiles;
- char *s1;
+ const char *s1;
for (ifiles = impl_file_chain; ifiles; ifiles = ifiles->next)
{
- char *t1 = ifiles->filename;
+ const char *t1 = ifiles->filename;
s1 = s;
if (*s1 != *t1 || *s1 == 0)
@@ -2197,7 +2197,7 @@ skip_white_space (c)
static char *
extend_token_buffer (p)
- char *p;
+ const char *p;
{
int offset = p - token_buffer;
@@ -2256,8 +2256,6 @@ pragma_ungetc (arg)
int linemode;
-static int handle_cp_pragma PROTO((char *));
-
static int
check_newline ()
{
@@ -4779,18 +4777,27 @@ dump_time_statistics ()
}
void
-compiler_error (s, v, v2)
- char *s;
- HOST_WIDE_INT v, v2; /* @@also used as pointer */
+compiler_error VPROTO ((const char *msg, ...))
{
+#ifndef ANSI_PROTOTYPES
+ const char *msg;
+#endif
char buf[1024];
- sprintf (buf, s, v, v2);
+ va_list ap;
+
+ VA_START (ap, msg);
+
+#ifndef ANSI_PROTOTYPES
+ msg = va_arg (ap, const char *);
+#endif
+
+ vsprintf (buf, msg, ap);
error_with_file_and_line (input_filename, lineno, "%s (compiler error)", buf);
}
void
yyerror (string)
- char *string;
+ const char *string;
{
extern int end_of_file;
char buf[200];
@@ -4820,7 +4827,7 @@ yyerror (string)
static int
handle_cp_pragma (pname)
- char *pname;
+ const char *pname;
{
register int token;
More information about the Gcc-patches
mailing list