Patch to constify tree_code_name

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Fri Aug 13 07:54:00 GMT 1999


	This patch constifies tree_code_name.  There were some related
cascading effects on various function decls in the toplevel dir and
the language subdirs.  Tested on Solaris 2 and Irix6.

	Okay to install?

		Thanks,
		--Kaveh


1999-08-12  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* tree.c (tree_code_name): Constify a char*.

	* tree.h (tree_code_name, decl_printable_name): Likewise.

	* function.h (struct function): Likewise.

	* toplev.c (decl_name, decl_printable_name): Likewise.

	* vax/vms.h (MAYBE_VMS_FUNCTION_PROLOGUE): Likewise.

	* objc/objc-act.c (decl_printable_name): Remove redundant prototype.
	(init_objc): Remove function pointer cast.

	
diff -rup orig/egcs-CVS19990811/gcc/tree.c egcs-CVS19990811/gcc/tree.c
--- orig/egcs-CVS19990811/gcc/tree.c	Wed Aug  4 16:34:35 1999
+++ egcs-CVS19990811/gcc/tree.c	Thu Aug 12 12:57:03 1999
@@ -193,7 +193,7 @@ int tree_code_length[MAX_TREE_CODES] = {
    Used for printing out the tree and error messages.  */
 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
 
-char *tree_code_name[MAX_TREE_CODES] = {
+const char *tree_code_name[MAX_TREE_CODES] = {
 #include "tree.def"
 };
 #undef DEFTREECODE
diff -rup orig/egcs-CVS19990811/gcc/tree.h egcs-CVS19990811/gcc/tree.h
--- orig/egcs-CVS19990811/gcc/tree.h	Mon Aug  9 19:26:04 1999
+++ egcs-CVS19990811/gcc/tree.h	Thu Aug 12 12:57:03 1999
@@ -63,7 +63,7 @@ extern int tree_code_length[MAX_TREE_COD
 
 /* Names of tree components.  */
 
-extern char *tree_code_name[MAX_TREE_CODES];
+extern const char *tree_code_name[MAX_TREE_CODES];
 
 /* Codes that identify the various built in functions
    so that expand_call can identify them quickly.  */
@@ -1910,7 +1910,7 @@ extern int all_types_permanent;
      2: and any other information that might be interesting, such as function
         parameter types in C++.  */
 
-extern char *(*decl_printable_name)		PROTO((tree, int));
+extern const char *(*decl_printable_name)	PROTO((tree, int));
 
 /* Pointer to function to finish handling an incomplete decl at the
    end of compilation.  */
diff -rup orig/egcs-CVS19990811/gcc/function.h egcs-CVS19990811/gcc/function.h
--- orig/egcs-CVS19990811/gcc/function.h	Mon Aug  9 15:42:00 1999
+++ egcs-CVS19990811/gcc/function.h	Thu Aug 12 12:57:47 1999
@@ -186,7 +186,7 @@ struct function
   /* For function.c.  */
 
   /* Name of this function.  */
-  char *name;
+  const char *name;
   /* Points to the FUNCTION_DECL of this function. */
   tree decl;
 
@@ -280,7 +280,7 @@ struct function
 
   /* Language-specific reason why the current function cannot be made
      inline.  */
-  char *cannot_inline;
+  const char *cannot_inline;
 
   /* Nonzero if instrumentation calls for function entry and exit should be
      generated.  */
diff -rup orig/egcs-CVS19990811/gcc/toplev.c egcs-CVS19990811/gcc/toplev.c
--- orig/egcs-CVS19990811/gcc/toplev.c	Mon Aug  9 15:42:20 1999
+++ egcs-CVS19990811/gcc/toplev.c	Thu Aug 12 12:57:03 1999
@@ -186,7 +186,7 @@ void pedwarn_with_file_and_line PVPROTO(
 					 int line, const char *s, ...));
 void sorry PVPROTO((const char *s, ...));
 static void set_target_switch PROTO((const char *));
-static char *decl_name PROTO((tree, int));
+static const char *decl_name PROTO((tree, int));
 static void vmessage PROTO((const char *, const char *, va_list));
 static void v_message_with_file_and_line PROTO((const char *, int, int,
 						const char *, va_list));
@@ -362,7 +362,7 @@ int sorrycount = 0;
      2: and any other information that might be interesting, such as function
         parameter types in C++.  */
 
-char *(*decl_printable_name)		PROTO ((tree, int));
+const char *(*decl_printable_name)	PROTO ((tree, int));
 
 /* Pointer to function to compute rtl for a language-specific tree code.  */
 
@@ -1494,7 +1494,7 @@ fatal_insn_not_found (insn)
 
 /* This is the default decl_printable_name function.  */
 
-static char *
+static const char *
 decl_name (decl, verbosity)
      tree decl;
      int verbosity ATTRIBUTE_UNUSED;
diff -rup orig/egcs-CVS19990811/gcc/config/vax/vms.h egcs-CVS19990811/gcc/config/vax/vms.h
--- orig/egcs-CVS19990811/gcc/config/vax/vms.h	Mon Aug  9 15:42:43 1999
+++ egcs-CVS19990811/gcc/config/vax/vms.h	Thu Aug 12 12:57:01 1999
@@ -94,7 +94,7 @@ Boston, MA 02111-1307, USA.  */
  * setting of -4 will end up adding them right back again, but don't bother.
  */
 #define MAYBE_VMS_FUNCTION_PROLOGUE(FILE)	\
-{ char *p = current_function_name;		\
+{ const char *p = current_function_name;	\
   int is_main = strcmp ("main", p) == 0;	\
   while (!is_main && *p != '\0')		\
     {						\
diff -rup orig/egcs-CVS19990811/gcc/objc/objc-act.c egcs-CVS19990811/gcc/objc/objc-act.c
--- orig/egcs-CVS19990811/gcc/objc/objc-act.c	Mon Aug  9 19:26:07 1999
+++ egcs-CVS19990811/gcc/objc/objc-act.c	Thu Aug 12 12:57:03 1999
@@ -203,9 +203,6 @@ static int check_methods_accessible		PRO
 static void encode_aggregate_within		PROTO((tree, int, int,
 					               int, int));
 
-/* We handle printing method names ourselves for ObjC */
-extern char *(*decl_printable_name) ();
-
 /* Misc. bookkeeping */
 
 typedef struct hashed_entry 	*hash;
@@ -8213,7 +8210,7 @@ init_objc ()
   synth_module_prologue ();
 
   /* Change the default error function */
-  decl_printable_name = (char* (*)()) objc_printable_name;
+  decl_printable_name = objc_printable_name;
 }
 
 static void


1999-08-12  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* lang.c (chill_print_error_function): Constify a char*.

diff -rup orig/egcs-CVS19990811/gcc/ch/lang.c egcs-CVS19990811/gcc/ch/lang.c
--- orig/egcs-CVS19990811/gcc/ch/lang.c	Mon Aug  9 19:26:09 1999
+++ egcs-CVS19990811/gcc/ch/lang.c	Thu Aug 12 12:57:01 1999
@@ -262,8 +262,8 @@ chill_print_error_function (file)
     }
   else
     {
-      char *kind = "function";
-      char *name = (*decl_printable_name) (current_function_decl, 2);
+      const char *kind = "function";
+      const char *name = (*decl_printable_name) (current_function_decl, 2);
       fprintf (stderr, "In %s `%s':\n", kind, name);
     }
 }



1999-08-12  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* cp-tree.h (fndecl_as_string, type_as_string,
	type_as_string_real, args_as_string, decl_as_string,
	expr_as_string, code_as_string, language_as_string,
	parm_as_string, op_as_string, assop_as_string, cv_as_string,
	lang_decl_name, cp_file_of, lang_printable_name): Constify a char*.

	* errfn.c (cp_printer): Likewise.

	* error.c (cp_printer, fndecl_as_string, type_as_string_real,
	type_as_string, expr_as_string, decl_as_string, lang_decl_name,
	cp_file_of, 

diff -rup orig/egcs-CVS19990811/gcc/cp/cp-tree.h egcs-CVS19990811/gcc/cp/cp-tree.h
--- orig/egcs-CVS19990811/gcc/cp/cp-tree.h	Mon Aug  9 07:42:42 1999
+++ egcs-CVS19990811/gcc/cp/cp-tree.h	Thu Aug 12 13:08:44 1999
@@ -3099,20 +3099,20 @@ extern void cp_deprecated               
 
 /* in error.c */
 extern void init_error				PROTO((void));
-extern char *fndecl_as_string			PROTO((tree, int));
-extern char *type_as_string			PROTO((tree, int));
-extern char *type_as_string_real		PROTO((tree, int, int));
-extern char *args_as_string			PROTO((tree, int));
-extern char *decl_as_string			PROTO((tree, int));
-extern char *expr_as_string			PROTO((tree, int));
-extern char *code_as_string			PROTO((enum tree_code, int));
-extern char *language_as_string			PROTO((enum languages, int));
-extern char *parm_as_string			PROTO((int, int));
-extern char *op_as_string			PROTO((enum tree_code, int));
-extern char *assop_as_string			PROTO((enum tree_code, int));
-extern char *cv_as_string			PROTO((tree, int));
-extern char *lang_decl_name			PROTO((tree, int));
-extern char *cp_file_of				PROTO((tree));
+extern const char *fndecl_as_string		PROTO((tree, int));
+extern const char *type_as_string		PROTO((tree, int));
+extern const char *type_as_string_real		PROTO((tree, int, int));
+extern const char *args_as_string		PROTO((tree, int));
+extern const char *decl_as_string		PROTO((tree, int));
+extern const char *expr_as_string		PROTO((tree, int));
+extern const char *code_as_string		PROTO((enum tree_code, int));
+extern const char *language_as_string		PROTO((enum languages, int));
+extern const char *parm_as_string		PROTO((int, int));
+extern const char *op_as_string			PROTO((enum tree_code, int));
+extern const char *assop_as_string		PROTO((enum tree_code, int));
+extern const char *cv_as_string			PROTO((tree, int));
+extern const char *lang_decl_name		PROTO((tree, int));
+extern const char *cp_file_of			PROTO((tree));
 extern int cp_line_of				PROTO((tree));
 
 /* in except.c */
@@ -3481,7 +3481,7 @@ extern tree fnaddr_from_vtable_entry		PR
 extern tree function_arg_chain			PROTO((tree));
 extern int promotes_to_aggr_type		PROTO((tree, enum tree_code));
 extern int is_aggr_type_2			PROTO((tree, tree));
-extern char *lang_printable_name		PROTO((tree, int));
+extern const char *lang_printable_name		PROTO((tree, int));
 extern tree build_exception_variant		PROTO((tree, tree));
 extern tree copy_template_template_parm		PROTO((tree));
 extern tree copy_to_permanent			PROTO((tree));
diff -rup orig/egcs-CVS19990811/gcc/cp/errfn.c egcs-CVS19990811/gcc/cp/errfn.c
--- orig/egcs-CVS19990811/gcc/cp/errfn.c	Sat Aug  7 18:17:02 1999
+++ egcs-CVS19990811/gcc/cp/errfn.c	Thu Aug 12 12:57:02 1999
@@ -30,7 +30,7 @@ Boston, MA 02111-1307, USA.  */
    with all memory management; the functions in this file will not free
    the char*s returned.  See error.c for an example use of this code.  */
 
-typedef char* cp_printer PROTO((tree, int));
+typedef const char *cp_printer PROTO((tree, int));
 extern cp_printer * cp_printers[256];
 
 /* Whether or not we should try to be quiet for errors and warnings; this is
diff -rup orig/egcs-CVS19990811/gcc/cp/error.c egcs-CVS19990811/gcc/cp/error.c
--- orig/egcs-CVS19990811/gcc/cp/error.c	Sat Aug  7 18:17:02 1999
+++ egcs-CVS19990811/gcc/cp/error.c	Thu Aug 12 13:08:24 1999
@@ -26,7 +26,7 @@ Boston, MA 02111-1307, USA.  */
 #include "obstack.h"
 #include "toplev.h"
 
-typedef char* cp_printer ();
+typedef const char *cp_printer ();
 
 #define A args_as_string
 #define C code_as_string
@@ -1871,7 +1871,7 @@ dump_unary_op (opstring, t, nop)
 
 /* Print a function decl with exception specification included. */
 
-char *
+const char *
 fndecl_as_string (fndecl, print_default_args_p)
      tree fndecl;
      int print_default_args_p;
@@ -1891,7 +1891,7 @@ fndecl_as_string (fndecl, print_default_
    when describing a typedef, we use the name of the type described,
    rather than the name of the typedef.  */
 
-char *
+const char *
 type_as_string_real (typ, v, canonical_name)
      tree typ;
      int v;
@@ -1907,7 +1907,7 @@ type_as_string_real (typ, v, canonical_n
 }
 
 
-char *
+const char *
 type_as_string (typ, v)
      tree typ;
      int v;
@@ -1915,7 +1915,7 @@ type_as_string (typ, v)
   return type_as_string_real (typ, v, 0);
 }
 
-char *
+const char *
 expr_as_string (decl, v)
      tree decl;
      int v ATTRIBUTE_UNUSED;
@@ -1932,7 +1932,7 @@ expr_as_string (decl, v)
 /* A cross between type_as_string and fndecl_as_string.
    Only called from substitute_nice_name.  */
 
-char *
+const char *
 decl_as_string (decl, v)
      tree decl;
      int v;
@@ -1948,7 +1948,7 @@ decl_as_string (decl, v)
 
 /* Generate the three forms of printable names for lang_printable_name.  */
 
-char *
+const char *
 lang_decl_name (decl, v)
      tree decl;
      int v;
@@ -1980,7 +1980,7 @@ lang_decl_name (decl, v)
 }
   
 
-char *
+const char *
 cp_file_of (t)
      tree t;
 {
@@ -2018,7 +2018,7 @@ cp_line_of (t)
   return line;
 }
 
-char *
+const char *
 code_as_string (c, v)
      enum tree_code c;
      int v ATTRIBUTE_UNUSED;
@@ -2026,7 +2026,7 @@ code_as_string (c, v)
   return tree_code_name [c];
 }
 
-char *
+const char *
 language_as_string (c, v)
      enum languages c;
      int v ATTRIBUTE_UNUSED;
@@ -2050,7 +2050,7 @@ language_as_string (c, v)
 
 /* Return the proper printed version of a parameter to a C++ function.  */
 
-char *
+const char *
 parm_as_string (p, v)
      int p;
      int v ATTRIBUTE_UNUSED;
@@ -2062,7 +2062,7 @@ parm_as_string (p, v)
   return digit_buffer;
 }
 
-char *
+const char *
 op_as_string (p, v)
      enum tree_code p;
      int v ATTRIBUTE_UNUSED;
@@ -2076,7 +2076,7 @@ op_as_string (p, v)
   return buf;
 }
 
-char *
+const char *
 assop_as_string (p, v)
      enum tree_code p;
      int v ATTRIBUTE_UNUSED;
@@ -2090,7 +2090,7 @@ assop_as_string (p, v)
   return buf;
 }
 
-char *
+const char *
 args_as_string (p, v)
      tree p;
      int v;
@@ -2115,7 +2115,7 @@ args_as_string (p, v)
   return (char *)obstack_base (&scratch_obstack);
 }
 
-char *
+const char *
 cv_as_string (p, v)
      tree p;
      int v ATTRIBUTE_UNUSED;
diff -rup orig/egcs-CVS19990811/gcc/cp/tree.c egcs-CVS19990811/gcc/cp/tree.c
--- orig/egcs-CVS19990811/gcc/cp/tree.c	Tue Aug 10 07:42:49 1999
+++ egcs-CVS19990811/gcc/cp/tree.c	Thu Aug 12 12:57:02 1999
@@ -1456,7 +1456,7 @@ is_aggr_type_2 (t1, t2)
 
 #define PRINT_RING_SIZE 4
 
-char *
+const char *
 lang_printable_name (decl, v)
      tree decl;
      int v;



1999-08-12  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* com.c (lang_printable_name): Constify a char*.

diff -rup orig/egcs-CVS19990811/gcc/f/com.c egcs-CVS19990811/gcc/f/com.c
--- orig/egcs-CVS19990811/gcc/f/com.c	Mon Aug  9 19:26:17 1999
+++ egcs-CVS19990811/gcc/f/com.c	Thu Aug 12 12:57:02 1999
@@ -502,7 +502,7 @@ static void delete_block (tree block);
 static int duplicate_decls (tree newdecl, tree olddecl);
 static void finish_decl (tree decl, tree init, bool is_top_level);
 static void finish_function (int nested);
-static char *lang_printable_name (tree decl, int v);
+static const char *lang_printable_name (tree decl, int v);
 static tree lookup_name_current_level (tree name);
 static struct binding_level *make_binding_level (void);
 static void pop_f_function_context (void);
@@ -14417,7 +14417,7 @@ finish_function (int nested)
    per se, but if that comes up, it should be easy to check (being a
    nested function and all).  */
 
-static char *
+static const char *
 lang_printable_name (tree decl, int v)
 {
   /* Just to keep GCC quiet about the unused variable.



1999-08-12  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* java-tree.h (lang_printable_name): Constify a char*.

	* lang.c (lang_printable_name): Likewise.

diff -rup orig/egcs-CVS19990811/gcc/java/java-tree.h egcs-CVS19990811/gcc/java/java-tree.h
--- orig/egcs-CVS19990811/gcc/java/java-tree.h	Tue Aug 10 12:48:56 1999
+++ egcs-CVS19990811/gcc/java/java-tree.h	Thu Aug 12 12:57:02 1999
@@ -565,7 +565,7 @@ extern tree prepare_eh_table_type PROTO 
 extern void java_set_exception_lang_code PROTO ((void));
 extern tree generate_name PROTO ((void));
 extern void pop_labeled_block PROTO ((void));
-extern char *lang_printable_name PROTO ((tree, int));
+extern const char *lang_printable_name PROTO ((tree, int));
 extern tree maybe_add_interface PROTO ((tree, tree));
 extern void set_super_info PROTO ((int, tree, tree, int));
 extern int get_access_flags_from_decl PROTO ((tree));
diff -rup orig/egcs-CVS19990811/gcc/java/lang.c egcs-CVS19990811/gcc/java/lang.c
--- orig/egcs-CVS19990811/gcc/java/lang.c	Tue Aug 10 12:48:58 1999
+++ egcs-CVS19990811/gcc/java/lang.c	Thu Aug 12 12:57:02 1999
@@ -439,7 +439,7 @@ put_decl_node (node)
    The value of the hook decl_printable_name is this function,
    which is also called directly by lang_print_error. */
 
-char *
+const char *
 lang_printable_name (decl, v)
      tree decl;
      int v  __attribute__ ((__unused__));


More information about the Gcc-patches mailing list