A patch for more constification
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Sun Jan 24 08:41:00 GMT 1999
Another constify patch. Okay to install?
--Kaveh
Sun Jan 24 09:54:16 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* bitmap.c (bitmap_print): Qualify a char* with the `const' keyword.
* bitmap.h (bitmap_print): Likewise.
* c-decl.c (redeclaration_error_message, duplicate_decls,
pushdecl, builtin_function, grokdeclarator, grokfield): Likewise.
* c-lang.c (build_objc_string): Likewise.
* c-lex.c (yyerror): Likewise.
* c-lex.h (yyerror): Likewise.
* c-pragma.c (handle_pragma_token): Likewise.
* c-pragma.h (handle_pragma_token): Likewise.
* c-tree.h (build_objc_string, builtin_function, grokfield,
build_indirect_ref, lvalue_or_else, readonly_warning, error_init,
pedwarn_init): Likewise.
* c-typeck.c (convert_for_assignment, warn_for_assignment,
push_string, get_spelling, warning_init, incomplete_type_error,
build_indirect_ref, build_unary_op, lvalue_or_else,
readonly_warning, build_c_cast, convert_for_assignment,
warn_for_assignment, spelling, push_member_name, print_spelling,
error_init, pedwarn_init, start_init): Likewise.
* objc/objc-act.c (build_objc_string): Likewise.
* print-tree.c (print_node_brief, print_node): Likewise.
* tree.h (lvalue_or_else, print_node, print_node_brief): Likewise.
diff -rup orig/egcs-CVS19990123/gcc/bitmap.c egcs-CVS19990123/gcc/bitmap.c
--- orig/egcs-CVS19990123/gcc/bitmap.c Sat Jan 23 23:56:42 1999
+++ egcs-CVS19990123/gcc/bitmap.c Sun Jan 24 07:57:08 1999
@@ -613,10 +613,10 @@ void
bitmap_print (file, head, prefix, suffix)
FILE *file;
bitmap head;
- char *prefix;
- char *suffix;
+ const char *prefix;
+ const char *suffix;
{
- char *comma = "";
+ const char *comma = "";
int i;
fputs (prefix, file);
diff -rup orig/egcs-CVS19990123/gcc/bitmap.h egcs-CVS19990123/gcc/bitmap.h
--- orig/egcs-CVS19990123/gcc/bitmap.h Sat Jan 23 23:56:42 1999
+++ egcs-CVS19990123/gcc/bitmap.h Sun Jan 24 07:57:13 1999
@@ -89,7 +89,7 @@ extern void bitmap_debug PROTO((bitmap))
extern void bitmap_debug_file PROTO((FILE *, bitmap));
/* Print a bitmap */
-extern void bitmap_print PROTO((FILE *, bitmap, char *, char *));
+extern void bitmap_print PROTO((FILE *, bitmap, const char *, const char *));
/* Initialize a bitmap header. */
extern bitmap bitmap_initialize PROTO((bitmap));
diff -rup orig/egcs-CVS19990123/gcc/c-decl.c egcs-CVS19990123/gcc/c-decl.c
--- orig/egcs-CVS19990123/gcc/c-decl.c Sat Jan 23 23:56:43 1999
+++ egcs-CVS19990123/gcc/c-decl.c Sun Jan 24 08:37:50 1999
@@ -426,7 +426,7 @@ tree static_ctors, static_dtors;
static struct binding_level * make_binding_level PROTO((void));
static void clear_limbo_values PROTO((tree));
static int duplicate_decls PROTO((tree, tree, int));
-static char *redeclaration_error_message PROTO((tree, tree));
+static const char *redeclaration_error_message PROTO((tree, tree));
static void storedecls PROTO((tree));
static void storetags PROTO((tree));
static tree lookup_tag PROTO((enum tree_code, tree,
@@ -1520,7 +1520,7 @@ duplicate_decls (newdecl, olddecl, diffe
&& DECL_INITIAL (newdecl) != 0);
tree oldtype = TREE_TYPE (olddecl);
tree newtype = TREE_TYPE (newdecl);
- char *errmsg = 0;
+ const char *errmsg = 0;
if (TREE_CODE_CLASS (TREE_CODE (olddecl)) == 'd')
DECL_MACHINE_ATTRIBUTES (newdecl)
@@ -2531,7 +2531,7 @@ pushdecl (x)
/* No shadow warnings for vars made for inlining. */
&& ! DECL_FROM_INLINE (x))
{
- char *warnstring = 0;
+ const char *warnstring = 0;
if (TREE_CODE (x) == PARM_DECL
&& current_binding_level->level_chain->parm_flag)
@@ -2664,7 +2664,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;
{
@@ -3616,10 +3616,10 @@ init_decl_processing ()
tree
builtin_function (name, type, function_code, library_name)
- char *name;
+ const char *name;
tree type;
enum built_in_function function_code;
- char *library_name;
+ const char *library_name;
{
tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
DECL_EXTERNAL (decl) = 1;
@@ -4390,7 +4390,7 @@ grokdeclarator (declarator, declspecs, d
int explicit_char = 0;
int defaulted_int = 0;
tree typedef_decl = 0;
- char *name;
+ const char *name;
tree typedef_type = 0;
int funcdef_flag = 0;
enum tree_code innermost_code = ERROR_MARK;
@@ -5771,8 +5771,8 @@ start_struct (code, name)
tree
grokfield (filename, line, declarator, declspecs, width)
- char *filename;
- int line;
+ const char *filename ATTRIBUTE_UNUSED;
+ int line ATTRIBUTE_UNUSED;
tree declarator, declspecs, width;
{
tree value;
diff -rup orig/egcs-CVS19990123/gcc/c-lang.c egcs-CVS19990123/gcc/c-lang.c
--- orig/egcs-CVS19990123/gcc/c-lang.c Sat Jan 23 23:56:44 1999
+++ egcs-CVS19990123/gcc/c-lang.c Sun Jan 24 08:22:28 1999
@@ -149,7 +149,7 @@ recognize_objc_keyword ()
tree
build_objc_string (len, str)
int len ATTRIBUTE_UNUSED;
- char *str ATTRIBUTE_UNUSED;
+ const char *str ATTRIBUTE_UNUSED;
{
abort ();
return NULL_TREE;
diff -rup orig/egcs-CVS19990123/gcc/c-lex.c egcs-CVS19990123/gcc/c-lex.c
--- orig/egcs-CVS19990123/gcc/c-lex.c Sat Jan 23 23:56:44 1999
+++ egcs-CVS19990123/gcc/c-lex.c Sun Jan 24 08:13:59 1999
@@ -1041,7 +1041,7 @@ readescape (ignore_ptr)
void
yyerror (string)
- char *string;
+ const char *string;
{
char buf[200];
diff -rup orig/egcs-CVS19990123/gcc/c-lex.h egcs-CVS19990123/gcc/c-lex.h
--- orig/egcs-CVS19990123/gcc/c-lex.h Sat Jan 23 23:56:44 1999
+++ egcs-CVS19990123/gcc/c-lex.h Sun Jan 24 08:02:17 1999
@@ -81,7 +81,7 @@ extern void position_after_white_space P
extern int check_newline PROTO((void));
extern int yylex PROTO((void));
-extern void yyerror PROTO((char *));
+extern void yyerror PROTO((const char *));
extern void forget_protocol_qualifiers PROTO((void));
extern void remember_protocol_qualifiers PROTO((void));
diff -rup orig/egcs-CVS19990123/gcc/c-pragma.c egcs-CVS19990123/gcc/c-pragma.c
--- orig/egcs-CVS19990123/gcc/c-pragma.c Sat Jan 23 23:56:45 1999
+++ egcs-CVS19990123/gcc/c-pragma.c Sun Jan 24 08:20:11 1999
@@ -231,7 +231,7 @@ add_weak (name, value)
int
handle_pragma_token (string, token)
- char * string;
+ const char * string;
tree token;
{
static enum pragma_state state = ps_start;
diff -rup orig/egcs-CVS19990123/gcc/c-pragma.h egcs-CVS19990123/gcc/c-pragma.h
--- orig/egcs-CVS19990123/gcc/c-pragma.h Sat Jan 23 23:56:45 1999
+++ egcs-CVS19990123/gcc/c-pragma.h Sun Jan 24 08:20:27 1999
@@ -94,7 +94,7 @@ enum pragma_state
};
/* Handle a C style pragma */
-extern int handle_pragma_token PROTO((char *, tree));
+extern int handle_pragma_token PROTO((const char *, tree));
#endif /* HANDLE_GENERIC_PRAGMAS */
#endif /* _C_PRAGMA_H */
diff -rup orig/egcs-CVS19990123/gcc/c-tree.h egcs-CVS19990123/gcc/c-tree.h
--- orig/egcs-CVS19990123/gcc/c-tree.h Sat Jan 23 23:56:45 1999
+++ egcs-CVS19990123/gcc/c-tree.h Sun Jan 24 08:46:56 1999
@@ -170,7 +170,7 @@ extern int maybe_objc_comptypes
extern tree maybe_building_objc_message_expr PROTO((void));
extern tree maybe_objc_method_name PROTO((tree));
extern int recognize_objc_keyword PROTO((void));
-extern tree build_objc_string PROTO((int, char *));
+extern tree build_objc_string PROTO((int, const char *));
/* in c-aux-info.c */
extern void gen_aux_info_record PROTO((tree, int, int, int));
@@ -282,7 +282,9 @@ extern tree boolean_false_node;
extern tree build_enumerator PROTO((tree, tree));
/* Declare a predefined function. Return the declaration. */
-extern tree builtin_function PROTO((char *, tree, enum built_in_function function_, char *));
+extern tree builtin_function PROTO((const char *, tree,
+ enum built_in_function function_,
+ const char *));
/* Add qualifiers to a type, in the fashion for C. */
extern tree c_build_qualified_type PROTO((tree, int));
#define c_build_type_variant(TYPE, CONST_P, VOLATILE_P) \
@@ -307,7 +309,8 @@ extern tree get_parm_info
extern tree getdecls PROTO((void));
extern tree gettags PROTO((void));
extern int global_bindings_p PROTO((void));
-extern tree grokfield PROTO((char *, int, tree, tree, tree));
+extern tree grokfield PROTO((const char *, int,
+ tree, tree, tree));
extern tree groktypename PROTO((tree));
extern tree groktypename_in_parm_context PROTO((tree));
extern tree implicitly_declare PROTO((tree));
@@ -365,7 +368,7 @@ extern tree c_alignof PROTO((tree));
extern tree c_alignof_expr PROTO((tree));
extern tree default_conversion PROTO((tree));
extern tree build_component_ref PROTO((tree, tree));
-extern tree build_indirect_ref PROTO((tree, char *));
+extern tree build_indirect_ref PROTO((tree, const char *));
extern tree build_array_ref PROTO((tree, tree));
extern tree build_function_call PROTO((tree, tree));
extern tree parser_build_binary_op PROTO((enum tree_code,
@@ -375,8 +378,8 @@ extern tree build_binary_op
extern tree build_unary_op PROTO((enum tree_code,
tree, int));
extern int lvalue_p PROTO((tree));
-extern int lvalue_or_else PROTO((tree, char *));
-extern void readonly_warning PROTO((tree, char *));
+extern int lvalue_or_else PROTO((tree, const char *));
+extern void readonly_warning PROTO((tree, const char *));
extern int mark_addressable PROTO((tree));
extern tree build_conditional_expr PROTO((tree, tree, tree));
extern tree build_compound_expr PROTO((tree));
@@ -385,10 +388,12 @@ extern tree build_modify_expr
tree));
extern tree initializer_constant_valid_p PROTO((tree, tree));
extern void store_init_value PROTO((tree, tree));
-extern void error_init PROTO((char *, char *,
- char *));
-extern void pedwarn_init PROTO((char *, char *,
- char *));
+extern void error_init PROTO((const char *,
+ const char *,
+ const char *));
+extern void pedwarn_init PROTO((const char *,
+ const char *,
+ const char *));
extern void start_init PROTO((tree, tree, int));
extern void finish_init PROTO((void));
extern void really_start_incremental_init PROTO((tree));
diff -rup orig/egcs-CVS19990123/gcc/c-typeck.c egcs-CVS19990123/gcc/c-typeck.c
--- orig/egcs-CVS19990123/gcc/c-typeck.c Sat Jan 23 23:56:45 1999
+++ egcs-CVS19990123/gcc/c-typeck.c Sun Jan 24 09:06:07 1999
@@ -55,18 +55,19 @@ static tree pointer_diff PROTO((tree, t
static tree unary_complex_lvalue PROTO((enum tree_code, tree));
static void pedantic_lvalue_warning PROTO((enum tree_code));
static tree internal_build_compound_expr PROTO((tree, int));
-static tree convert_for_assignment PROTO((tree, tree, char *, tree,
+static tree convert_for_assignment PROTO((tree, tree, const char *, tree,
+ tree, int));
+static void warn_for_assignment PROTO((const char *, const char *,
tree, int));
-static void warn_for_assignment PROTO((char *, char *, tree, int));
static tree valid_compound_expr_initializer PROTO((tree, tree));
-static void push_string PROTO((char *));
+static void push_string PROTO((const char *));
static void push_member_name PROTO((tree));
static void push_array_bounds PROTO((int));
static int spelling_length PROTO((void));
static char *print_spelling PROTO((char *));
-static char *get_spelling PROTO((char *));
-static void warning_init PROTO((char *, char *,
- char *));
+static const char *get_spelling PROTO((const char *));
+static void warning_init PROTO((const char *, const char *,
+ const char *));
static tree digest_init PROTO((tree, tree, int, int));
static void check_init_type_bitfields PROTO((tree));
static void output_init_element PROTO((tree, tree, tree, int));
@@ -101,7 +102,7 @@ incomplete_type_error (value, type)
tree value;
tree type;
{
- char *errmsg;
+ const char *errmsg;
/* Avoid duplicate error message. */
if (TREE_CODE (type) == ERROR_MARK)
@@ -1321,7 +1322,7 @@ build_component_ref (datum, component)
tree
build_indirect_ref (ptr, errorstring)
tree ptr;
- char *errorstring;
+ const char *errorstring;
{
register tree pointer = default_conversion (ptr);
register tree type = TREE_TYPE (pointer);
@@ -2790,7 +2791,7 @@ build_unary_op (code, xarg, noconvert)
register tree arg = xarg;
register tree argtype = 0;
register enum tree_code typecode = TREE_CODE (TREE_TYPE (arg));
- char *errstring = NULL;
+ const char *errstring = NULL;
tree val;
if (typecode == ERROR_MARK)
@@ -3224,7 +3225,7 @@ lvalue_p (ref)
int
lvalue_or_else (ref, string)
tree ref;
- char *string;
+ const char *string;
{
int win = lvalue_p (ref);
if (! win)
@@ -3291,7 +3292,7 @@ pedantic_lvalue_warning (code)
void
readonly_warning (arg, string)
tree arg;
- char *string;
+ const char *string;
{
char buf[80];
strcpy (buf, string);
@@ -3725,7 +3726,7 @@ build_c_cast (type, expr)
if (field)
{
- char *name;
+ const char *name;
tree t;
if (pedantic)
@@ -4033,7 +4034,7 @@ build_modify_expr (lhs, modifycode, rhs)
static tree
convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
tree type, rhs;
- char *errtype;
+ const char *errtype;
tree fundecl, funname;
int parmnum;
{
@@ -4293,8 +4294,8 @@ convert_for_assignment (type, rhs, errty
static void
warn_for_assignment (msg, opname, function, argnum)
- char *msg;
- char *opname;
+ const char *msg;
+ const char *opname;
tree function;
int argnum;
{
@@ -4304,6 +4305,7 @@ warn_for_assignment (msg, opname, functi
if (opname == 0)
{
tree selector = maybe_building_objc_message_expr ();
+ char * new_opname;
if (selector && argnum > 2)
{
@@ -4313,16 +4315,18 @@ warn_for_assignment (msg, opname, functi
if (function)
{
/* Function name is known; supply it. */
- opname = (char *) alloca (IDENTIFIER_LENGTH (function)
- + sizeof (argstring) + 25 /*%d*/ + 1);
- sprintf (opname, argstring, argnum, IDENTIFIER_POINTER (function));
+ new_opname = (char *) alloca (IDENTIFIER_LENGTH (function)
+ + sizeof (argstring) + 25 /*%d*/ + 1);
+ sprintf (new_opname, argstring, argnum,
+ IDENTIFIER_POINTER (function));
}
else
{
/* Function name unknown (call through ptr); just give arg number. */
- opname = (char *) alloca (sizeof (argnofun) + 25 /*%d*/ + 1);
- sprintf (opname, argnofun, argnum);
+ new_opname = (char *) alloca (sizeof (argnofun) + 25 /*%d*/ + 1);
+ sprintf (new_opname, argnofun, argnum);
}
+ opname = new_opname;
}
pedwarn (msg, opname);
}
@@ -4563,7 +4567,7 @@ struct spelling
union
{
int i;
- char *s;
+ const char *s;
} u;
};
@@ -4619,7 +4623,7 @@ static int spelling_size; /* Size of th
static void
push_string (string)
- char *string;
+ const char *string;
{
PUSH_SPELLING (SPELLING_STRING, string, u.s);
}
@@ -4631,7 +4635,7 @@ push_member_name (decl)
tree decl;
{
- char *string
+ const char *string
= DECL_NAME (decl) ? IDENTIFIER_POINTER (DECL_NAME (decl)) : "<anonymous>";
PUSH_SPELLING (SPELLING_MEMBER, string, u.s);
}
@@ -4671,7 +4675,6 @@ print_spelling (buffer)
register char *buffer;
{
register char *d = buffer;
- register char *s;
register struct spelling *p;
for (p = spelling_base; p < spelling; p++)
@@ -4682,6 +4685,7 @@ print_spelling (buffer)
}
else
{
+ register const char *s;
if (p->kind == SPELLING_MEMBER)
*d++ = '.';
for (s = p->u.s; (*d = *s++); d++)
@@ -4697,9 +4701,9 @@ char initialization_message;
/* Interpret the spelling of the given ERRTYPE message. */
-static char *
+static const char *
get_spelling (errtype)
- char *errtype;
+ const char *errtype;
{
static char *buffer;
static int size = -1;
@@ -4734,7 +4738,7 @@ get_spelling (errtype)
void
error_init (format, local, ofwhat)
- char *format, *local, *ofwhat;
+ const char *format, *local, *ofwhat;
{
char *buffer;
@@ -4760,7 +4764,7 @@ error_init (format, local, ofwhat)
void
pedwarn_init (format, local, ofwhat)
- char *format, *local, *ofwhat;
+ const char *format, *local, *ofwhat;
{
char *buffer;
@@ -4786,7 +4790,7 @@ pedwarn_init (format, local, ofwhat)
static void
warning_init (format, local, ofwhat)
- char *format, *local, *ofwhat;
+ const char *format, *local, *ofwhat;
{
char *buffer;
@@ -5184,7 +5188,7 @@ start_init (decl, asmspec_tree, top_leve
tree asmspec_tree;
int top_level;
{
- char *locus;
+ const char *locus;
struct initializer_stack *p
= (struct initializer_stack *) xmalloc (sizeof (struct initializer_stack));
char *asmspec = 0;
diff -rup orig/egcs-CVS19990123/gcc/objc/objc-act.c egcs-CVS19990123/gcc/objc/objc-act.c
--- orig/egcs-CVS19990123/gcc/objc/objc-act.c Sat Jan 23 23:57:55 1999
+++ egcs-CVS19990123/gcc/objc/objc-act.c Sun Jan 24 08:23:30 1999
@@ -1320,7 +1320,7 @@ my_build_string (len, str)
tree
build_objc_string (len, str)
int len;
- char *str;
+ const char *str;
{
tree s = build_string (len, str);
diff -rup orig/egcs-CVS19990123/gcc/print-tree.c egcs-CVS19990123/gcc/print-tree.c
--- orig/egcs-CVS19990123/gcc/print-tree.c Sat Jan 23 23:57:42 1999
+++ egcs-CVS19990123/gcc/print-tree.c Sun Jan 24 08:31:31 1999
@@ -64,7 +64,7 @@ debug_tree (node)
void
print_node_brief (file, prefix, node, indent)
FILE *file;
- char *prefix;
+ const char *prefix;
tree node;
int indent;
{
@@ -176,7 +176,7 @@ indent_to (file, column)
void
print_node (file, prefix, node, indent)
FILE *file;
- char *prefix;
+ const char *prefix;
tree node;
int indent;
{
diff -rup orig/egcs-CVS19990123/gcc/tree.h egcs-CVS19990123/gcc/tree.h
--- orig/egcs-CVS19990123/gcc/tree.h Sun Jan 24 09:26:15 1999
+++ egcs-CVS19990123/gcc/tree.h Sun Jan 24 08:44:28 1999
@@ -1669,7 +1669,7 @@ extern int staticp PROTO((tree));
/* Gets an error if argument X is not an lvalue.
Also returns 1 if X is an lvalue, 0 if not. */
-extern int lvalue_or_else PROTO((tree, char *));
+extern int lvalue_or_else PROTO((tree, const char *));
/* save_expr (EXP) returns an expression equivalent to EXP
but it can be used multiple times within context CTX
@@ -2205,8 +2205,8 @@ extern void print_rtl PROTO ((FILE *,
/* In print-tree.c */
extern void debug_tree PROTO ((tree));
#ifdef BUFSIZ
-extern void print_node PROTO ((FILE *, char *, tree, int));
-extern void print_node_brief PROTO ((FILE *, char *, tree, int));
+extern void print_node PROTO ((FILE *, const char *, tree, int));
+extern void print_node_brief PROTO ((FILE *, const char *, tree, int));
extern void indent_to PROTO ((FILE *, int));
#endif
More information about the Gcc-patches
mailing list