C++ dir warning patch part 4/5
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Thu Mar 25 10:18: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 4/5, okay to install?
Thanks,
--Kaveh
Wed Mar 24 18:54:26 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* parse.y (cond_stmt_keyword): Const-ify a char*.
(parse_decl): Add static prototype.
* pt.c (template_args_equal, print_template_context): Likewise.
(print_candidates, check_default_tmpl_args): Const-ify a char*.
(instantiate_class_template): Likewise.
* repo.c (get_base_filename, open_repo_file, init_repo): Likewise.
* rtti.c (call_void_fn, expand_generic_desc, expand_si_desc,
expand_class_desc, expand_ptr_desc, expand_attr_desc): Likewise.
* search.c (lookup_field_info, lookup_member): Likewise.
(lookup_member): Cast the first argument of `bzero' to a PTR.
* sig.c (compiler_error): Don't prototype.
(build_signature_pointer_or_reference_nam): Const-ify a char*.
(get_sigtable_name, build_member_function_pointer): Likewise.
diff -rup orig/egcs-CVS19990323/gcc/cp/parse.y egcs-CVS19990323/gcc/cp/parse.y
--- orig/egcs-CVS19990323/gcc/cp/parse.y Wed Mar 17 09:19:47 1999
+++ egcs-CVS19990323/gcc/cp/parse.y Wed Mar 24 13:50:16 1999
@@ -60,9 +60,10 @@ extern int end_of_file;
/* Contains the statement keyword (if/while/do) to include in an
error message if the user supplies an empty conditional expression. */
-static char *cond_stmt_keyword;
+static const char *cond_stmt_keyword;
static tree empty_parms PROTO((void));
+static int parse_decl PROTO((tree, tree, tree, int, tree *));
/* Nonzero if we have an `extern "C"' acting as an extern specifier. */
int have_extern_spec;
diff -rup orig/egcs-CVS19990323/gcc/cp/pt.c egcs-CVS19990323/gcc/cp/pt.c
--- orig/egcs-CVS19990323/gcc/cp/pt.c Tue Mar 23 09:49:32 1999
+++ egcs-CVS19990323/gcc/cp/pt.c Wed Mar 24 13:55:24 1999
@@ -149,6 +149,8 @@ static tree try_class_unification PROTO(
static int coerce_template_template_parms PROTO((tree, tree, int,
tree, tree));
static tree determine_specialization PROTO((tree, tree, tree *, int));
+static int template_args_equal PROTO((tree, tree));
+static void print_template_context PROTO((int));
/* We use TREE_VECs to hold template arguments. If there is only one
level of template arguments, then the TREE_VEC contains the
@@ -896,7 +898,7 @@ print_candidates (fns)
{
tree fn;
- char* str = "candidates are:";
+ const char *str = "candidates are:";
for (fn = fns; fn != NULL_TREE; fn = TREE_CHAIN (fn))
{
@@ -2136,7 +2138,7 @@ check_default_tmpl_args (decl, parms, is
int is_primary;
int is_partial;
{
- char* msg;
+ const char *msg;
int last_level_to_check;
/* [temp.param]
@@ -3266,7 +3268,7 @@ coerce_template_parms (parms, args, in_d
/* Returns 1 if template args OT and NT are equivalent. */
-int
+static int
template_args_equal (ot, nt)
tree ot, nt;
{
@@ -4653,7 +4655,7 @@ instantiate_class_template (type)
if (t == error_mark_node)
{
- char *str = "candidates are:";
+ const char *str = "candidates are:";
cp_error ("ambiguous class template instantiation for `%#T'", type);
for (t = DECL_TEMPLATE_SPECIALIZATIONS (template); t;
t = TREE_CHAIN (t))
diff -rup orig/egcs-CVS19990323/gcc/cp/repo.c egcs-CVS19990323/gcc/cp/repo.c
--- orig/egcs-CVS19990323/gcc/cp/repo.c Wed Dec 16 16:16:05 1998
+++ egcs-CVS19990323/gcc/cp/repo.c Wed Mar 24 14:02:46 1999
@@ -37,8 +37,8 @@ extern char *getpwd PROTO((void));
static tree repo_get_id PROTO((tree));
static char *extract_string PROTO((char **));
-static char *get_base_filename PROTO((char *));
-static void open_repo_file PROTO((char *));
+static char *get_base_filename PROTO((const char *));
+static void open_repo_file PROTO((const char *));
static char *afgets PROTO((FILE *));
static void reopen_repo_file_for_write PROTO((void));
@@ -239,7 +239,7 @@ extract_string (pp)
static char *
get_base_filename (filename)
- char *filename;
+ const char *filename;
{
char *p = getenv ("COLLECT_GCC_OPTIONS");
char *output = NULL;
@@ -270,10 +270,10 @@ get_base_filename (filename)
static void
open_repo_file (filename)
- char *filename;
+ const char *filename;
{
- register char *p;
- char *s = get_base_filename (filename);
+ register const char *p;
+ const char *s = get_base_filename (filename);
if (s == NULL)
return;
@@ -304,7 +304,7 @@ afgets (stream)
void
init_repo (filename)
- char *filename;
+ const char *filename;
{
char *buf;
diff -rup orig/egcs-CVS19990323/gcc/cp/rtti.c egcs-CVS19990323/gcc/cp/rtti.c
--- orig/egcs-CVS19990323/gcc/cp/rtti.c Mon Jan 25 15:43:21 1999
+++ egcs-CVS19990323/gcc/cp/rtti.c Wed Mar 24 14:08:34 1999
@@ -35,7 +35,7 @@ Boston, MA 02111-1307, USA. */
extern struct obstack permanent_obstack;
-static tree call_void_fn PROTO((char *));
+static tree call_void_fn PROTO((const char *));
static tree build_headof_sub PROTO((tree));
static tree build_headof PROTO((tree));
static tree get_tinfo_var PROTO((tree));
@@ -45,7 +45,7 @@ static void expand_si_desc PROTO((tree,
static void expand_class_desc PROTO((tree, tree));
static void expand_attr_desc PROTO((tree, tree));
static void expand_ptr_desc PROTO((tree, tree));
-static void expand_generic_desc PROTO((tree, tree, char *));
+static void expand_generic_desc PROTO((tree, tree, const char *));
static tree throw_bad_cast PROTO((void));
static tree throw_bad_typeid PROTO((void));
@@ -133,7 +133,7 @@ build_headof (exp)
static tree
call_void_fn (name)
- char *name;
+ const char *name;
{
tree d = get_identifier (name);
tree type;
@@ -719,7 +719,7 @@ expand_si_desc (tdecl, type)
tree type;
{
tree t, elems, fn;
- char *name = build_overload_name (type, 1, 1);
+ const char *name = build_overload_name (type, 1, 1);
tree name_string = combine_strings (build_string (strlen (name)+1, name));
type = BINFO_TYPE (TREE_VEC_ELT (TYPE_BINFO_BASETYPES (type), 0));
@@ -767,7 +767,7 @@ expand_class_desc (tdecl, type)
{
tree name_string;
tree fn, tmp;
- char *name;
+ const char *name;
int i = CLASSTYPE_N_BASECLASSES (type);
int base_cnt = 0;
@@ -827,7 +827,7 @@ expand_class_desc (tdecl, type)
if (TREE_VIA_VIRTUAL (binfo))
{
tree t = BINFO_TYPE (binfo);
- char *name;
+ const char *name;
tree field;
FORMAT_VBASE_NAME (name, t);
@@ -947,7 +947,7 @@ expand_ptr_desc (tdecl, type)
tree type;
{
tree t, elems, fn;
- char *name = build_overload_name (type, 1, 1);
+ const char *name = build_overload_name (type, 1, 1);
tree name_string = combine_strings (build_string (strlen (name)+1, name));
type = TREE_TYPE (type);
@@ -994,7 +994,7 @@ expand_attr_desc (tdecl, type)
tree type;
{
tree elems, t, fn;
- char *name = build_overload_name (type, 1, 1);
+ const char *name = build_overload_name (type, 1, 1);
tree name_string = combine_strings (build_string (strlen (name)+1, name));
tree attrval = build_int_2 (TYPE_QUALS (type), 0);
@@ -1040,9 +1040,9 @@ static void
expand_generic_desc (tdecl, type, fnname)
tree tdecl;
tree type;
- char *fnname;
+ const char *fnname;
{
- char *name = build_overload_name (type, 1, 1);
+ const char *name = build_overload_name (type, 1, 1);
tree name_string = combine_strings (build_string (strlen (name)+1, name));
tree elems = tree_cons
(NULL_TREE, decay_conversion (tdecl), tree_cons
diff -rup orig/egcs-CVS19990323/gcc/cp/search.c egcs-CVS19990323/gcc/cp/search.c
--- orig/egcs-CVS19990323/gcc/cp/search.c Mon Mar 15 19:11:01 1999
+++ egcs-CVS19990323/gcc/cp/search.c Wed Mar 24 14:10:04 1999
@@ -1063,7 +1063,7 @@ struct lookup_field_info {
/* If non-zero, RVAL was found by looking through a dependent base. */
int from_dep_base_p;
/* If something went wrong, a message indicating what. */
- char *errstr;
+ const char *errstr;
};
/* Returns non-zero if BINFO is not hidden by the value found by the
@@ -1251,7 +1251,7 @@ lookup_member (xbasetype, name, protect,
we know that binfo of a virtual base class will always == itself when
found along any line. (mrs) */
- char *errstr = 0;
+ const char *errstr = 0;
if (xbasetype == current_class_type && TYPE_BEING_DEFINED (xbasetype)
&& IDENTIFIER_CLASS_VALUE (name))
@@ -1362,7 +1362,7 @@ lookup_member (xbasetype, name, protect,
n_calls_lookup_field++;
#endif /* GATHER_STATISTICS */
- bzero (&lfi, sizeof (lfi));
+ bzero ((PTR) &lfi, sizeof (lfi));
lfi.type = type;
lfi.name = name;
lfi.want_type = want_type;
diff -rup orig/egcs-CVS19990323/gcc/cp/sig.c egcs-CVS19990323/gcc/cp/sig.c
--- orig/egcs-CVS19990323/gcc/cp/sig.c Sat Mar 13 11:54:15 1999
+++ egcs-CVS19990323/gcc/cp/sig.c Wed Mar 24 14:13:10 1999
@@ -33,8 +33,6 @@ extern struct obstack *current_obstack;
extern struct obstack permanent_obstack;
extern struct obstack *saveable_obstack;
-extern void compiler_error ();
-
static tree save_this PROTO((tree));
static tree build_sptr_ref PROTO((tree));
static tree build_member_function_pointer PROTO((tree));
@@ -63,14 +61,14 @@ build_signature_pointer_or_reference_nam
int type_quals;
int refp;
{
- char * sig_name = TYPE_NAME_STRING (to_type);
+ const char * sig_name = TYPE_NAME_STRING (to_type);
int name_len = TYPE_NAME_LENGTH (to_type) + 3 /* Enough room for
C,V,R. */;
char * name;
- char *const_rep = (type_quals & TYPE_QUAL_CONST) ? "C" : "";
- char *restrict_rep = (type_quals & TYPE_QUAL_RESTRICT) ? "R" : "";
- char *volatile_rep = (type_quals & TYPE_QUAL_VOLATILE) ? "C" : "";
+ const char *const_rep = (type_quals & TYPE_QUAL_CONST) ? "C" : "";
+ const char *restrict_rep = (type_quals & TYPE_QUAL_RESTRICT) ? "R" : "";
+ const char *volatile_rep = (type_quals & TYPE_QUAL_VOLATILE) ? "C" : "";
if (refp)
{
@@ -288,8 +286,8 @@ get_sigtable_name (sig_type, rhs_type)
char *buf = (char *) alloca (sizeof (SIGTABLE_NAME_FORMAT_LONG)
+ IDENTIFIER_LENGTH (sig_type_id)
+ IDENTIFIER_LENGTH (rhs_type_id) + 20);
- char *sig_ptr = IDENTIFIER_POINTER (sig_type_id);
- char *rhs_ptr = IDENTIFIER_POINTER (rhs_type_id);
+ const char *sig_ptr = IDENTIFIER_POINTER (sig_type_id);
+ const char *rhs_ptr = IDENTIFIER_POINTER (rhs_type_id);
int i, j;
for (i = 0; sig_ptr[i] == OPERATOR_TYPENAME_FORMAT[i]; i++)
@@ -316,7 +314,7 @@ static tree
build_member_function_pointer (member)
tree member;
{
- char *namstr = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (member));
+ const char *namstr = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (member));
int namlen = IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (member));
char *name;
tree entry;
diff -rup orig/egcs-CVS19990323/gcc/cp/parse.c egcs-CVS19990323/gcc/cp/parse.c
--- orig/egcs-CVS19990323/gcc/cp/parse.c Tue Mar 23 10:28:04 1999
+++ egcs-CVS19990323/gcc/cp/parse.c Wed Mar 24 13:50:35 1999
@@ -126,9 +126,10 @@ extern int end_of_file;
/* Contains the statement keyword (if/while/do) to include in an
error message if the user supplies an empty conditional expression. */
-static char *cond_stmt_keyword;
+static const char *cond_stmt_keyword;
static tree empty_parms PROTO((void));
+static int parse_decl PROTO((tree, tree, tree, int, tree *));
/* Nonzero if we have an `extern "C"' acting as an extern specifier. */
int have_extern_spec;
More information about the Gcc-patches
mailing list