This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
A `const' patch for tree.[ch]
- To: egcs-patches at cygnus dot com
- Subject: A `const' patch for tree.[ch]
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Sun, 24 Jan 1999 01:40:59 -0500 (EST)
This patch adds `const' to char* pointers in tree.[ch].
Okay to install?
--Kaveh
Sun Jan 24 01:08:05 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* tree.c (tree_node_kind_names, print_obstack_name,
(get_identifier, (maybe_get_identifier, (build_string,
(build_expr_wfl, (is_attribute_p, lookup_attribute,
print_obstack_statistics, get_file_function_name_long, tree_check,
tree_class_check, expr_check): Qualify a char* with the `const'
keyword.
* tree.h (get_identifier, maybe_get_identifier, build_string,
build_expr_wfl, is_attribute_p, lookup_attribute,
print_obstack_statistics, print_obstack_name, tree_check,
tree_class_check, expr_check): Likewise.
diff -rup orig/egcs-CVS19990123/gcc/tree.c egcs-CVS19990123/gcc/tree.c
--- orig/egcs-CVS19990123/gcc/tree.c Sat Jan 23 13:00:45 1999
+++ egcs-CVS19990123/gcc/tree.c Sat Jan 23 23:30:18 1999
@@ -225,7 +225,7 @@ int tree_node_counts[(int)all_kinds];
int tree_node_sizes[(int)all_kinds];
int id_string_size = 0;
-char *tree_node_kind_names[] = {
+const char *tree_node_kind_names[] = {
"decls",
"types",
"blocks",
@@ -743,10 +743,10 @@ void
print_obstack_name (object, file, prefix)
char *object;
FILE *file;
- char *prefix;
+ const char *prefix;
{
struct obstack *obstack = NULL;
- char *obstack_name = NULL;
+ const char *obstack_name = NULL;
struct function *p;
for (p = outer_function_chain; p; p = p->next)
@@ -1241,7 +1241,7 @@ copy_list (list)
tree
get_identifier (text)
- register char *text;
+ register const char *text;
{
register int hi;
register int i;
@@ -1304,7 +1304,7 @@ get_identifier (text)
tree
maybe_get_identifier (text)
- register char *text;
+ register const char *text;
{
register int hi;
register int i;
@@ -1502,7 +1502,7 @@ build_real_from_int_cst (type, i)
tree
build_string (len, str)
int len;
- char *str;
+ const char *str;
{
/* Put the string in saveable_obstack since it will be placed in the RTL
for an "asm" statement and will also be kept around a while if
@@ -3220,10 +3220,10 @@ build_block (vars, tags, subblocks, supe
tree
build_expr_wfl (node, file, line, col)
tree node;
- char *file;
+ const char *file;
int line, col;
{
- static char *last_file = 0;
+ static const char *last_file = 0;
static tree last_filenode = NULL_TREE;
register tree wfl = make_node (EXPR_WITH_FILE_LOCATION);
@@ -3432,7 +3432,7 @@ valid_machine_attribute (attr_name, attr
int
is_attribute_p (attr, ident)
- char *attr;
+ const char *attr;
tree ident;
{
int ident_len, attr_len;
@@ -3477,7 +3477,7 @@ is_attribute_p (attr, ident)
tree
lookup_attribute (attr_name, list)
- char *attr_name;
+ const char *attr_name;
tree list;
{
tree l;
@@ -4730,7 +4730,7 @@ print_inline_obstack_statistics ()
void
print_obstack_statistics (str, o)
- char *str;
+ const char *str;
struct obstack *o;
{
struct _obstack_chunk *chunk = o->chunk;
@@ -4855,7 +4855,7 @@ append_random_chars (template)
tree
get_file_function_name_long (type)
- char *type;
+ const char *type;
{
char *buf;
register char *p;
@@ -4867,8 +4867,8 @@ get_file_function_name_long (type)
/* We don't have anything that we know to be unique to this translation
unit, so use what we do have and throw in some randomness. */
- char *name = weak_global_object_name;
- char *file = main_input_filename;
+ const char *name = weak_global_object_name;
+ const char *file = main_input_filename;
if (! name)
name = "";
@@ -5038,7 +5038,7 @@ tree
tree_check (node, code, file, line, nofatal)
tree node;
enum tree_code code;
- char *file;
+ const char *file;
int line;
int nofatal;
{
@@ -5058,7 +5058,7 @@ tree
tree_class_check (node, cl, file, line, nofatal)
tree node;
char cl;
- char *file;
+ const char *file;
int line;
int nofatal;
{
@@ -5077,7 +5077,7 @@ tree
expr_check (node, ignored, file, line, nofatal)
tree node;
int ignored;
- char *file;
+ const char *file;
int line;
int nofatal;
{
diff -rup orig/egcs-CVS19990123/gcc/tree.h egcs-CVS19990123/gcc/tree.h
--- orig/egcs-CVS19990123/gcc/tree.h Sat Jan 23 13:00:34 1999
+++ egcs-CVS19990123/gcc/tree.h Sat Jan 23 23:14:47 1999
@@ -1413,13 +1413,13 @@ extern tree make_tree_vec PROTO((int));
/* Return the (unique) IDENTIFIER_NODE node for a given name.
The name is supplied as a char *. */
-extern tree get_identifier PROTO((char *));
+extern tree get_identifier PROTO((const char *));
/* If an identifier with the name TEXT (a null-terminated string) has
previously been referred to, return that node; otherwise return
NULL_TREE. */
-extern tree maybe_get_identifier PROTO((char *));
+extern tree maybe_get_identifier PROTO((const char *));
/* Construct various types of nodes. */
@@ -1434,14 +1434,14 @@ extern tree build_int_2_wide PROTO((HOS
extern tree build_real PROTO((tree, REAL_VALUE_TYPE));
extern tree build_real_from_int_cst PROTO((tree, tree));
extern tree build_complex PROTO((tree, tree, tree));
-extern tree build_string PROTO((int, char *));
+extern tree build_string PROTO((int, const char *));
extern tree build1 PROTO((enum tree_code, tree, tree));
extern tree build_tree_list PROTO((tree, tree));
extern tree build_decl_list PROTO((tree, tree));
extern tree build_expr_list PROTO((tree, tree));
extern tree build_decl PROTO((enum tree_code, tree, tree));
extern tree build_block PROTO((tree, tree, tree, tree, tree));
-extern tree build_expr_wfl PROTO((tree, char *, int, int));
+extern tree build_expr_wfl PROTO((tree, const char *, int, int));
/* Construct various nodes representing data types. */
@@ -1506,12 +1506,12 @@ extern int valid_machine_attribute PROTO
/* Given a tree node and a string, return non-zero if the tree node is
a valid attribute name for the string. */
-extern int is_attribute_p PROTO((char *, tree));
+extern int is_attribute_p PROTO((const char *, tree));
/* Given an attribute name and a list of attributes, return the list element
of the attribute or NULL_TREE if not found. */
-extern tree lookup_attribute PROTO((char *, tree));
+extern tree lookup_attribute PROTO((const char *, tree));
/* Given two attributes lists, return a list of their union. */
@@ -1894,7 +1894,7 @@ extern void (*incomplete_decl_finalize_h
/* In tree.c */
extern char *perm_calloc PROTO((int, long));
extern tree get_file_function_name PROTO((int));
-extern tree get_file_function_name_long PROTO((char *));
+extern tree get_file_function_name_long PROTO((const char *));
extern tree get_set_constructor_bits PROTO((tree, char *, int));
extern tree get_set_constructor_bytes PROTO((tree,
unsigned char *, int));
@@ -2149,9 +2149,10 @@ extern void rtl_in_current_obstack PROTO
extern void rtl_in_saveable_obstack PROTO ((void));
extern void init_tree_codes PROTO ((void));
extern void dump_tree_statistics PROTO ((void));
-extern void print_obstack_statistics PROTO ((char *, struct obstack *));
+extern void print_obstack_statistics PROTO ((const char *,
+ struct obstack *));
#ifdef BUFSIZ
-extern void print_obstack_name PROTO ((char *, FILE *, char *));
+extern void print_obstack_name PROTO ((char *, FILE *, const char *));
#endif
extern void expand_function_end PROTO ((char *, int, int));
extern void expand_function_start PROTO ((tree, int));
@@ -2161,9 +2162,12 @@ extern void start_identifier_warnings PR
extern void gcc_obstack_init PROTO ((struct obstack *));
extern void init_obstacks PROTO ((void));
extern void obfree PROTO ((char *));
-extern tree tree_check PROTO ((tree, enum tree_code, char*, int, int));
-extern tree tree_class_check PROTO ((tree, char, char*, int, int));
-extern tree expr_check PROTO ((tree, int, char*, int, int));
+extern tree tree_check PROTO ((tree, enum tree_code,
+ const char *, int, int));
+extern tree tree_class_check PROTO ((tree, char, const char *,
+ int, int));
+extern tree expr_check PROTO ((tree, int, const char *,
+ int, int));
/* In function.c */
extern void setjmp_protect_args PROTO ((void));