C++ dir warning patch part 1/5
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Thu Mar 25 10:16: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 1/5, okay to install?
Thanks,
--Kaveh
Wed Mar 24 18:54:26 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* call.c (op_error): Const-ify a char*.
(add_candidate, source_type, add_warning): Add static prototype.
(print_z_candidates): Const-ify a char*.
* class.c (resolve_address_of_overloaded_function,
fixed_type_or_null, build_vtable_entry_ref): Add static prototype.
(get_vtable_name, finish_struct_1): Const-ify a char*.
* cvt.c (convert_to_reference): Likewise.
* decl.c (redeclaration_error_message, record_builtin_type,
record_unknown_type, member_function_or_else, bad_specifiers):
Likewise.
(find_binding, select_decl, unqualified_namespace_lookup,
lookup_flags, qualify_lookup, record_builtin_java_type, tag_name):
Add static prototype.
(warn_extern_redeclared_static, duplicate_decls, pushdecl,
implicitly_declare, record_builtin_java_type, define_function,
grok_op_properties, tag_name): Const-ify a char*.
diff -rup orig/egcs-CVS19990323/gcc/cp/call.c egcs-CVS19990323/gcc/cp/call.c
--- orig/egcs-CVS19990323/gcc/cp/call.c Mon Mar 15 08:20:07 1999
+++ egcs-CVS19990323/gcc/cp/call.c Wed Mar 24 11:10:48 1999
@@ -49,7 +49,7 @@ static int compare_ics PROTO((tree, tree
static tree build_over_call PROTO((struct z_candidate *, tree, int));
static tree convert_like PROTO((tree, tree));
static void op_error PROTO((enum tree_code, enum tree_code, tree, tree,
- tree, char *));
+ tree, const char *));
static tree build_object_call PROTO((tree, tree));
static tree resolve_args PROTO((tree));
static struct z_candidate * build_user_type_conversion_1
@@ -90,6 +90,10 @@ static int is_subseq PROTO((tree, tree))
static int is_properly_derived_from PROTO((tree, tree));
static int maybe_handle_ref_bind PROTO((tree*, tree*));
static void maybe_handle_implicit_object PROTO((tree*));
+static struct z_candidate * add_candidate PROTO((struct z_candidate *,
+ tree, tree, int));
+static tree source_type PROTO((tree));
+static void add_warning PROTO((struct z_candidate *, struct z_candidate *));
tree
build_vfield_ref (datum, type)
@@ -2085,7 +2089,7 @@ static void
print_z_candidates (candidates)
struct z_candidate *candidates;
{
- char *str = "candidates are:";
+ const char *str = "candidates are:";
for (; candidates; candidates = candidates->next)
{
if (TREE_CODE (candidates->fn) == IDENTIFIER_NODE)
@@ -2518,9 +2522,9 @@ static void
op_error (code, code2, arg1, arg2, arg3, problem)
enum tree_code code, code2;
tree arg1, arg2, arg3;
- char *problem;
+ const char *problem;
{
- char * opname
+ const char * opname
= (code == MODIFY_EXPR ? assignop_tab [code2] : opname_tab [code]);
switch (code)
diff -rup orig/egcs-CVS19990323/gcc/cp/class.c egcs-CVS19990323/gcc/cp/class.c
--- orig/egcs-CVS19990323/gcc/cp/class.c Wed Mar 10 19:41:17 1999
+++ egcs-CVS19990323/gcc/cp/class.c Wed Mar 24 11:15:19 1999
@@ -134,6 +134,10 @@ static void check_member_decl_is_same_in
static tree make_method_vec PROTO((int));
static void free_method_vec PROTO((tree));
static tree add_implicitly_declared_members PROTO((tree, int, int, int));
+static tree fixed_type_or_null PROTO((tree, int *));
+static tree resolve_address_of_overloaded_function PROTO((tree, tree, int,
+ int, tree));
+static void build_vtable_entry_ref PROTO((tree, tree, tree));
/* Way of stacking language names. */
tree *current_lang_base, *current_lang_stack;
@@ -604,7 +608,7 @@ get_vtable_name (type)
tree type_id = build_typename_overload (type);
char *buf = (char *) alloca (strlen (VTABLE_NAME_FORMAT)
+ IDENTIFIER_LENGTH (type_id) + 2);
- char *ptr = IDENTIFIER_POINTER (type_id);
+ const char *ptr = IDENTIFIER_POINTER (type_id);
int i;
for (i = 0; ptr[i] == OPERATOR_TYPENAME_FORMAT[i]; i++) ;
#if 0
@@ -3718,7 +3722,7 @@ finish_struct_1 (t, warn_anon)
if (code == UNION_TYPE)
{
- char *fie = NULL;
+ const char *fie = NULL;
if (TYPE_NEEDS_CONSTRUCTING (type))
fie = "constructor";
else if (TYPE_NEEDS_DESTRUCTOR (type))
@@ -4497,7 +4501,7 @@ finish_struct (t, attributes, warn_anon)
*NONNULL is set iff INSTANCE can be known to be nonnull, regardless
of our knowledge of its type. */
-tree
+static tree
fixed_type_or_null (instance, nonnull)
tree instance;
int *nonnull;
diff -rup orig/egcs-CVS19990323/gcc/cp/cvt.c egcs-CVS19990323/gcc/cp/cvt.c
--- orig/egcs-CVS19990323/gcc/cp/cvt.c Tue Mar 23 09:48:28 1999
+++ egcs-CVS19990323/gcc/cp/cvt.c Wed Mar 24 11:18:40 1999
@@ -456,7 +456,7 @@ convert_to_reference (reftype, expr, con
if (! real_lvalue_p (expr)
&& !CP_TYPE_CONST_NON_VOLATILE_P (ttl))
{
- char* msg;
+ const char *msg;
if (CP_TYPE_VOLATILE_P (ttl) && decl)
msg = "initialization of volatile reference type `%#T'";
diff -rup orig/egcs-CVS19990323/gcc/cp/decl.c egcs-CVS19990323/gcc/cp/decl.c
--- orig/egcs-CVS19990323/gcc/cp/decl.c Tue Mar 23 09:48:44 1999
+++ egcs-CVS19990323/gcc/cp/decl.c Wed Mar 24 11:37:45 1999
@@ -134,7 +134,7 @@ static struct stack_level *decl_stack;
static tree grokparms PROTO((tree, int));
static tree lookup_nested_type PROTO((tree, tree));
-static char *redeclaration_error_message PROTO((tree, tree));
+static const char *redeclaration_error_message PROTO((tree, tree));
static struct stack_level *push_decl_level PROTO((struct stack_level *,
struct obstack *));
@@ -167,10 +167,10 @@ static tree lookup_tag PROTO((enum tree_
struct binding_level *, int));
static void set_identifier_type_value_with_scope
PROTO((tree, tree, struct binding_level *));
-static void record_builtin_type PROTO((enum rid, char *, tree));
-static void record_unknown_type PROTO((tree, char *));
-static int member_function_or_else PROTO((tree, tree, char *));
-static void bad_specifiers PROTO((tree, char *, int, int, int, int,
+static void record_builtin_type PROTO((enum rid, const char *, tree));
+static void record_unknown_type PROTO((tree, const char *));
+static int member_function_or_else PROTO((tree, tree, const char *));
+static void bad_specifiers PROTO((tree, const char *, int, int, int, int,
int));
static void lang_print_error_function PROTO((char *));
static tree maybe_process_template_type_declaration PROTO((tree, int, struct binding_level*));
@@ -181,6 +181,13 @@ static void push_binding PROTO((tree, tr
static void add_binding PROTO((tree, tree));
static void pop_binding PROTO((tree, tree));
static tree local_variable_p PROTO((tree));
+static tree find_binding PROTO((tree, tree));
+static tree select_decl PROTO((tree, int));
+static tree unqualified_namespace_lookup PROTO((tree, int));
+static int lookup_flags PROTO((int, int));
+static tree qualify_lookup PROTO((tree, int));
+static tree record_builtin_java_type PROTO((const char *, int));
+static const char *tag_name PROTO((enum tag_types code));
#if defined (DEBUG_CP_BINDING_LEVELS)
static void indent PROTO((void));
@@ -2815,9 +2822,9 @@ warn_extern_redeclared_static (newdecl,
{
tree name;
- static char *explicit_extern_static_warning
+ static const char *explicit_extern_static_warning
= "`%D' was declared `extern' and later `static'";
- static char *implicit_extern_static_warning
+ static const char *implicit_extern_static_warning
= "`%D' was declared implicitly `extern' and later `static'";
if (TREE_CODE (newdecl) == TYPE_DECL)
@@ -3042,7 +3049,7 @@ duplicate_decls (newdecl, olddecl)
return 1;
else
{
- char *errmsg = redeclaration_error_message (newdecl, olddecl);
+ const char *errmsg = redeclaration_error_message (newdecl, olddecl);
if (errmsg)
{
cp_error (errmsg, newdecl);
@@ -3888,7 +3895,7 @@ pushdecl (x)
/* No shadow warnings for vars made for inlining. */
&& ! DECL_FROM_INLINE (x))
{
- char *warnstring = NULL;
+ const char *warnstring = NULL;
if (oldlocal != NULL_TREE && TREE_CODE (oldlocal) == PARM_DECL)
warnstring = "declaration of `%s' shadows a parameter";
@@ -4365,7 +4372,7 @@ implicitly_declare (functionid)
Otherwise return an error message format string with a %s
where the identifier should go. */
-static char *
+static const char *
redeclaration_error_message (newdecl, olddecl)
tree newdecl, olddecl;
{
@@ -5729,7 +5736,7 @@ static int builtin_type_tdescs_len, buil
static void
record_builtin_type (rid_index, name, type)
enum rid rid_index;
- char *name;
+ const char *name;
tree type;
{
tree rname = NULL_TREE, tname = NULL_TREE;
@@ -5772,7 +5779,7 @@ record_builtin_type (rid_index, name, ty
static tree
record_builtin_java_type (name, size)
- char *name;
+ const char *name;
int size;
{
tree type, decl;
@@ -5801,7 +5808,7 @@ record_builtin_java_type (name, size)
static void
record_unknown_type (type, name)
tree type;
- char *name;
+ const char *name;
{
tree decl = pushdecl (build_decl (TYPE_DECL, get_identifier (name), type));
/* Make sure the "unknown type" typedecl gets ignored for debug info. */
@@ -6617,11 +6624,11 @@ lang_print_error_function (file)
tree
define_function (name, type, function_code, pfn, library_name)
- char *name;
+ const char *name;
tree type;
enum built_in_function function_code;
void (*pfn) PROTO((tree));
- char *library_name;
+ const char *library_name;
{
tree decl = build_lang_decl (FUNCTION_DECL, get_identifier (name), type);
DECL_EXTERNAL (decl) = 1;
@@ -8293,7 +8300,7 @@ complete_array_type (type, initial_value
static int
member_function_or_else (ctype, cur_type, string)
tree ctype, cur_type;
- char *string;
+ const char *string;
{
if (ctype && ctype != cur_type)
{
@@ -8311,7 +8318,7 @@ member_function_or_else (ctype, cur_type
static void
bad_specifiers (object, type, virtualp, quals, inlinep, friendp, raises)
tree object;
- char *type;
+ const char *type;
int virtualp, quals, friendp, raises, inlinep;
{
if (virtualp)
@@ -11913,7 +11920,7 @@ grok_op_properties (decl, virtualp, frie
else if (! friendp)
{
int ref = (TREE_CODE (t) == REFERENCE_TYPE);
- char *what = 0;
+ const char *what = 0;
if (ref)
t = TYPE_MAIN_VARIANT (TREE_TYPE (t));
@@ -12068,7 +12075,7 @@ grok_op_properties (decl, virtualp, frie
}
}
-static char *
+static const char *
tag_name (code)
enum tag_types code;
{
More information about the Gcc-patches
mailing list