Constification patch (3/5)

Zack Weinberg zack@wolery.cumb.org
Tue May 9 12:46:00 GMT 2000


Constification patch, C++ front end.

zw

	* cp-tree.h: Constify tree_srcloc.filename, tinst_level.file,
	and pending_inline.filename.  Update prototypes.
	* decl.c (define_label): Constify filename parameter.
	* decl2.c (warn_if_unknown_interface): Constify local char *.
	* input.c Constify input_source.filename. Don't declare
	input_filename or lineno.  Constify filename parameter to feed_input.
	* lex.c (init_parse): Constify parameter and return value.
	(cp_pragma_interface, cp_pragma_implementation): Constify
	filename argument.
	(reinit_parse_for_method, reinit_parse_for_block,
	reinit_parse_for_expr, feed_defarg, handle_cp_pragma):
	Constify local char *.
	* pt.c: Don't declare lineno or input_filename.
	(print_template_context, tsubst_friend_function, tsubst_decl,
	tsubst, instantiate_decl): Constify local char *.
	* semantics.c (expand_body): Constify local char *.
	* tree.c (build_srcloc): Constify filename parameter.
	* typeck.c (c_expand_asm_operands): Constify filename
	parameter.

===================================================================
Index: cp/cp-tree.h
--- cp/cp-tree.h	2000/05/05 03:10:41	1.451
+++ cp/cp-tree.h	2000/05/08 20:16:07
@@ -399,7 +399,7 @@ struct tree_wrapper
 struct tree_srcloc
 {
   char common[sizeof (struct tree_common)];
-  char *filename;
+  const char *filename;
   int linenum;
 };
 
@@ -3338,7 +3338,7 @@ struct tinst_level
 {
   tree decl;
   int line;
-  char *file;
+  const char *file;
   struct tinst_level *next;
 };
 
@@ -3533,7 +3533,7 @@ struct pending_inline
 {
   struct pending_inline *next;	/* pointer to next in chain */
   int lineno;			/* line number we got the text from */
-  char *filename;		/* name of file we were processing */
+  const char *filename;		/* name of file we were processing */
   tree fndecl;			/* FUNCTION_DECL that brought us here */
   int token;			/* token we were scanning */
   int token_value;		/* value of token we were scanning (YYSTYPE) */
@@ -3910,7 +3910,7 @@ extern void push_class_level_binding		PA
 extern tree implicitly_declare			PARAMS ((tree));
 extern tree lookup_label			PARAMS ((tree));
 extern tree declare_local_label                 PARAMS ((tree));
-extern tree define_label			PARAMS ((char *, int, tree));
+extern tree define_label			PARAMS ((const char *, int, tree));
 extern void push_switch				PARAMS ((void));
 extern void pop_switch				PARAMS ((void));
 extern void define_case_label			PARAMS ((void));
@@ -4593,7 +4593,7 @@ extern tree build_x_modify_expr			PARAMS
 extern tree build_modify_expr			PARAMS ((tree, enum tree_code, tree));
 extern tree dubious_conversion_warnings         PARAMS ((tree, tree, const char *, tree, int));
 extern tree convert_for_initialization		PARAMS ((tree, tree, tree, int, const char *, tree, int));
-extern void c_expand_asm_operands		PARAMS ((tree, tree, tree, tree, int, char *, int));
+extern void c_expand_asm_operands		PARAMS ((tree, tree, tree, tree, int, const char *, int));
 extern void c_expand_return			PARAMS ((tree));
 extern tree c_expand_start_case			PARAMS ((tree));
 extern int comp_ptr_ttypes			PARAMS ((tree, tree));
===================================================================
Index: cp/decl.c
--- cp/decl.c	2000/05/05 03:10:42	1.602
+++ cp/decl.c	2000/05/08 20:16:18
@@ -4794,7 +4794,7 @@ declare_local_label (id)
 
 tree
 define_label (filename, line, name)
-     char *filename;
+     const char *filename;
      int line;
      tree name;
 {
===================================================================
Index: cp/decl2.c
--- cp/decl2.c	2000/05/04 14:54:18	1.344
+++ cp/decl2.c	2000/05/08 20:16:22
@@ -867,7 +867,7 @@ warn_if_unknown_interface (decl)
     {
       struct tinst_level *til = tinst_for_decl ();
       int sl = lineno;
-      char *sf = input_filename;
+      const char *sf = input_filename;
 
       if (til)
 	{
===================================================================
Index: cp/input.c
--- cp/input.c	2000/02/26 20:15:45	1.16
+++ cp/input.c	2000/05/08 20:16:22
@@ -54,7 +54,7 @@ struct input_source {
   /* values to restore after reading all of current string */
   struct pending_input *input;
 #if !USE_CPPLIB
-  char *filename;
+  const char *filename;
   int lineno;
   struct putback_buffer putback;
 #endif
@@ -62,15 +62,12 @@ struct input_source {
 
 static struct input_source *input, *free_inputs;
 
-extern char *input_filename;
-extern int lineno;
-
 #if USE_CPPLIB
 extern unsigned char *yy_cur, *yy_lim;
 extern int yy_get_token ();
 #endif
 
-extern void feed_input PARAMS ((char *, int, char *, int));
+extern void feed_input PARAMS ((char *, int, const char *, int));
 extern void put_input PARAMS ((int));
 extern void put_back PARAMS ((int));
 extern int getch PARAMS ((void));
@@ -114,7 +111,7 @@ void
 feed_input (str, len, file, line)
      char *str;
      int len;
-     char *file;
+     const char *file;
      int line;
 {
   struct input_source *inp = allocate_input ();
===================================================================
Index: cp/lex.c
--- cp/lex.c	2000/04/28 00:59:40	1.195
+++ cp/lex.c	2000/05/08 20:16:25
@@ -65,8 +65,8 @@ static void feed_defarg PARAMS ((tree, t
 static void store_pending_inline PARAMS ((tree, struct pending_inline *));
 static void reinit_parse_for_expr PARAMS ((struct obstack *));
 static int *init_cpp_parse PARAMS ((void));
-static void cp_pragma_interface PARAMS ((char *));
-static void cp_pragma_implementation PARAMS ((char *));
+static void cp_pragma_interface PARAMS ((const char *));
+static void cp_pragma_implementation PARAMS ((const char *));
 static int handle_cp_pragma PARAMS ((const char *));
 #ifdef HANDLE_GENERIC_PRAGMAS
 static int handle_generic_pragma PARAMS ((int));
@@ -510,9 +510,9 @@ init_cpp_parse ()
   return token_count;
 }
 
-char *
+const char *
 init_parse (filename)
-     char *filename;
+     const char *filename;
 {
   extern int flag_no_gnu_keywords;
   extern int flag_operator_names;
@@ -1188,7 +1188,7 @@ interface_strcmp (s)
 
 static void
 cp_pragma_interface (main_filename)
-     char *main_filename;
+     const char *main_filename;
 {
   tree fileinfo 
     = TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
@@ -1235,7 +1235,7 @@ cp_pragma_interface (main_filename)
 
 static void
 cp_pragma_implementation (main_filename)
-     char *main_filename;
+     const char *main_filename;
 {
   struct impl_files *ifiles = impl_file_chain;
   for (; ifiles; ifiles = ifiles->next)
@@ -1514,7 +1514,7 @@ reinit_parse_for_method (yychar, decl)
 {
   int len;
   int starting_lineno = lineno;
-  char *starting_filename = input_filename;
+  const char *starting_filename = input_filename;
 
   reinit_parse_for_block (yychar, &inline_text_obstack);
 
@@ -1562,7 +1562,7 @@ reinit_parse_for_block (pyychar, obstack
   register int c;
   int blev = 1;
   int starting_lineno = lineno;
-  char *starting_filename = input_filename;
+  const char *starting_filename = input_filename;
   int len;
   int look_for_semicolon = 0;
   int look_for_lbrac = 0;
@@ -1728,7 +1728,7 @@ reinit_parse_for_expr (obstackp)
 {
   register int c;
   int starting_lineno = lineno;
-  char *starting_filename = input_filename;
+  const char *starting_filename = input_filename;
   int len;
   int plev = 0;
 
@@ -1868,7 +1868,7 @@ feed_defarg (f, p)
      tree f, p;
 {
   tree d = TREE_PURPOSE (p);
-  char *file;
+  const char *file;
   int line;
   if (TREE_CODE (f) == FUNCTION_DECL)
     {
@@ -2589,7 +2589,7 @@ handle_cp_pragma (pname)
     }
   else if (! strcmp (pname, "interface"))
     {
-      char *main_filename = input_filename;
+      const char *main_filename = input_filename;
 
       main_filename = file_name_nondirectory (main_filename);
 
@@ -2616,7 +2616,7 @@ handle_cp_pragma (pname)
     }
   else if (! strcmp (pname, "implementation"))
     {
-      char *main_filename = main_input_filename ? main_input_filename : input_filename;
+      const char *main_filename = main_input_filename ? main_input_filename : input_filename;
 
       main_filename = file_name_nondirectory (main_filename);
 
===================================================================
Index: cp/pt.c
--- cp/pt.c	2000/05/04 18:15:23	1.425
+++ cp/pt.c	2000/05/08 20:16:32
@@ -51,9 +51,6 @@ typedef int (*tree_fn_t) PARAMS ((tree, 
 
 extern struct obstack permanent_obstack;
 
-extern int lineno;
-extern char *input_filename;
-
 /* The PENDING_TEMPLATES is a TREE_LIST of templates whose
    instantiations have been deferred, either because their definitions
    were not yet available, or because we were putting off doing the
@@ -4240,7 +4237,7 @@ print_template_context (err)
 {
   struct tinst_level *p = current_tinst_level;
   int line = lineno;
-  char *file = input_filename;
+  const char *file = input_filename;
 
   if (err && p)
     {
@@ -4375,7 +4372,7 @@ tsubst_friend_function (decl, args)
 {
   tree new_friend;
   int line = lineno;
-  char *file = input_filename;
+  const char *file = input_filename;
 
   lineno = DECL_SOURCE_LINE (decl);
   input_filename = DECL_SOURCE_FILE (decl);
@@ -5389,7 +5386,7 @@ tsubst_decl (t, args, type, in_decl)
      tree in_decl;
 {
   int saved_lineno;
-  char* saved_filename;
+  const char *saved_filename;
   tree r = NULL_TREE;
 
   /* Set the filename and linenumber to improve error-reporting.  */
@@ -6454,7 +6451,7 @@ tsubst (t, args, complain, in_decl)
 	    || (code == REFERENCE_TYPE && TREE_CODE (type) == VOID_TYPE))
 	  {
 	    static int   last_line = 0;
-	    static char* last_file = 0;
+	    static const char* last_file = 0;
 
 	    /* We keep track of the last time we issued this error
 	       message to avoid spewing a ton of messages during a
@@ -9434,7 +9431,7 @@ instantiate_decl (d, defer_ok)
   tree gen_tmpl;
   int pattern_defined;
   int line = lineno;
-  char *file = input_filename;
+  const char *file = input_filename;
 
   /* This function should only be used to instantiate templates for
      functions and static member variables.  */
===================================================================
Index: cp/semantics.c
--- cp/semantics.c	2000/05/05 03:10:42	1.139
+++ cp/semantics.c	2000/05/08 20:16:33
@@ -2694,7 +2694,7 @@ expand_body (fn)
      tree fn;
 {
   int saved_lineno;
-  char *saved_input_filename;
+  const char *saved_input_filename;
 
   /* When the parser calls us after finishing the body of a template
      function, we don't really want to expand the body.  When we're
===================================================================
Index: cp/tree.c
--- cp/tree.c	2000/05/04 14:54:18	1.196
+++ cp/tree.c	2000/05/08 20:16:35
@@ -40,7 +40,7 @@ static int list_hash PARAMS ((tree, tree
 static tree list_hash_lookup PARAMS ((int, tree, tree, tree));
 static cp_lvalue_kind lvalue_p_1 PARAMS ((tree, int));
 static tree no_linkage_helper PARAMS ((tree *, int *, void *));
-static tree build_srcloc PARAMS ((char *, int));
+static tree build_srcloc PARAMS ((const char *, int));
 static void mark_list_hash PARAMS ((void *));
 static int statement_code_p PARAMS ((enum tree_code));
 static tree mark_local_for_remap_r PARAMS ((tree *, int *, void *));
@@ -1989,7 +1989,7 @@ build_int_wrapper (i)
 
 static tree
 build_srcloc (file, line)
-     char *file;
+     const char *file;
      int line;
 {
   tree t;
===================================================================
Index: cp/typeck.c
--- cp/typeck.c	2000/05/06 21:55:07	1.283
+++ cp/typeck.c	2000/05/08 20:16:38
@@ -6638,7 +6638,7 @@ void
 c_expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
      tree string, outputs, inputs, clobbers;
      int vol;
-     char *filename;
+     const char *filename;
      int line;
 {
   int noutputs = list_length (outputs);


More information about the Gcc-patches mailing list