This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Constify IDENTIFIER_POINTER; reduce calls to get_identifier


This is a large patch with three mostly unrelated changes in it - but
they touch the same files and they were tested together.  They are
side effects of my work in progress to share cpplib's hash table with
the C front end's table.

1) Constify IDENTIFIER_POINTER, clean up the resulting small mess.
   This is the bulk of the patch, as it involves mechanical changes all
   over the place, but is not particularly complicated or newsworthy.

2) Add entries for the IDENTIFIER_NODEs for __FUNCTION__,
   __PRETTY_FUNCTION__, and __func__ to c_global_trees.  Currently, in
   we look them all up each time declare_function_name is called,
   which is once per function definition.  Pure waste of time.  Also
   cause __func__ not to be visible at file scope, per C99.

3) Rewrite make_function_rtl and make_decl_rtl.  They do all the same
   things, but they no longer call get_identifier when they don't have
   to.  Nor do they call ggc_alloc_string to create strings that are
   immediately discarded.  (I think someone thought get_identifier
   didn't copy its argument.)

Bootstrapped i386-linux.  I don't believe there were any regressions
in the test suite, but there's so many "normal" unexpected failures
that it's very hard to tell.  Also, C++ diagnostic reporting is broken
again.

zw

	* c-common.c (declare_function_name): Use func_id_node,
	function_id_node, and pretty_function_id_node.  Do not make
	__func__ visible at file scope.
	* c-common.h (c_tree_index): Add CTI_FUNCTION_ID,
	CTI_PRETTY_FUNCTION_ID, and CTI_FUNC_ID.
	(function_id_node, pretty_function_id_node, func_id_node): New
	macros.
	* c-decl.c (init_decl_processing): Initialize function_id_node,
	pretty_function_id_node, and func_id_node.
	(c_make_fname_decl): Correct comment.

	* tree.h (struct tree_identifier): Constify pointer member.

	* c-decl.c (pushdecl, implicit_decl_warning): Constify a char *.
	* c-pragma.h (struct weak_syms): Constify name and value members.
	(add_weak): Constify arguments.

	* calls.c (special_function_p): Constify a char *.
	(expand_call): Remove variable which is initialized and then
	never used.
	* dependence.c (struct def_use, struct induction, struct subscript):
	Constify 'variable' member.
	(get_low_bound, have_induction_variable): Constify char * argument.
	(find_induction_variable): Add braces to avoid dangling else.
	(classify_dependence): Constify char * arrays.
	* profile.c (output_func_start_profiler): Constify a char *.
	* stor-layout.c (finalize_record_size): Constify a char *.
	* tree.c (is_attribute_p): Constify a char *.
	* varasm.c (add_weak, remove_from_pending_weak_list): Constify argument.

	* varasm.c (make_function_rtl, make_decl_rtl): Rearrange code
	for comprehensibility.  Do not call get_identifier if we did
	not change the DECL_ASSEMBLER_NAME of the decl.  Use alloca to
	create temporary string constants, not ggc_alloc_string.  No
	need to copy result of ASM_FORMAT_PRIVATE_NAME.  Use const
	char * to hold IDENTIFIER_POINTERs.

ch:
	* inout.c (add_enum_to_list): Use DECL_NAME directly, don't
	get its IDENTIFIER_POINTER and immediately call get_identifier
	on it.
	* lex.c (yywrap): Constify a char *.
cp:
	* class.c (build_secondary_vtable): Constify a char *.
	* decl.c (init_decl_processing): Initialize function_id_node,
	pretty_function_id_node, and func_id_node.
	* input.c (struct input_source): Constify 'str'.
	(feed_input): Constify first argument.
	* mangle.c (write_identifier): Constify argument.
	* pt.c (mangle_class_name_for_template): Constify argument.
f:
	* ansify.c: Use #line, not # <number>.
java:
	* jcf-parse.c (set_source_filename): Constify a char *.
	* jcf-write.c (append_innerclasses_attribute,
	make_class_file_name): Constify a char *.  Don't recycle a
	variable for an unrelated purpose.
	* parse.y: (build_alias_initializer_parameter_list): Constify a char *.
	(breakdown_qualified): Do not modify IDENTIFIER_POINTER strings.

===================================================================
Index: c-common.c
--- c-common.c	2000/08/25 15:27:55	1.144
+++ c-common.c	2000/08/26 18:18:35
@@ -130,6 +130,12 @@ enum cpp_token cpp_token;
 
 	tree void_list_node;
 
+  The identifiers __FUNCTION__, __PRETTY_FUNCTION__, and __func__.
+
+	tree function_id_node;
+	tree pretty_function_id_node;
+	tree func_id_node;
+
 */
 
 tree c_global_trees[CTI_MAX];
@@ -271,13 +277,14 @@ declare_function_name ()
       else
 	name = "";
       printable_name = (*decl_printable_name) (current_function_decl, 2);
+
+      /* ISO C99 defines __func__, which is a variable, not a string
+	 constant, and which is not a defined symbol at file scope.  */
+      (*make_fname_decl) (func_id_node, name, 0);
     }
   
-  (*make_fname_decl) (get_identifier ("__FUNCTION__"), name, 0);
-  (*make_fname_decl) (get_identifier ("__PRETTY_FUNCTION__"), printable_name, 1);
-  /* The ISO C people "of course" couldn't use __FUNCTION__ in the
-     ISO C 99 standard; instead a new variable is invented.  */
-  (*make_fname_decl) (get_identifier ("__func__"), name, 0);
+  (*make_fname_decl) (function_id_node, name, 0);
+  (*make_fname_decl) (pretty_function_id_node, printable_name, 1);
 }
 
 /* Given a chain of STRING_CST nodes,
===================================================================
Index: c-common.h
--- c-common.h	2000/08/25 00:58:24	1.30
+++ c-common.h	2000/08/26 18:18:35
@@ -118,6 +118,11 @@ enum c_tree_index
     CTI_G77_LONGINT_TYPE,
     CTI_G77_ULONGINT_TYPE,
 
+    /* These are not types, but we have to look them up all the time.  */
+    CTI_FUNCTION_ID,
+    CTI_PRETTY_FUNCTION_ID,
+    CTI_FUNC_ID,
+
     CTI_MAX
 };
 
@@ -152,6 +157,10 @@ enum c_tree_index
 #define g77_uinteger_type_node		c_global_trees[CTI_G77_UINTEGER_TYPE]
 #define g77_longint_type_node		c_global_trees[CTI_G77_LONGINT_TYPE]
 #define g77_ulongint_type_node		c_global_trees[CTI_G77_ULONGINT_TYPE]
+
+#define function_id_node		c_global_trees[CTI_FUNCTION_ID]
+#define pretty_function_id_node		c_global_trees[CTI_PRETTY_FUNCTION_ID]
+#define func_id_node			c_global_trees[CTI_FUNC_ID]
 
 extern tree c_global_trees[CTI_MAX];
 
===================================================================
Index: c-decl.c
--- c-decl.c	2000/08/25 00:58:25	1.146
+++ c-decl.c	2000/08/26 18:18:37
@@ -2444,7 +2444,7 @@ pushdecl (x)
 		   /* No shadow warnings for vars made for inlining.  */
 		   && ! DECL_FROM_INLINE (x))
 	    {
-	      char *id = IDENTIFIER_POINTER (name);
+	      const char *id = IDENTIFIER_POINTER (name);
 
 	      if (TREE_CODE (x) == PARM_DECL
 		  && current_binding_level->level_chain->parm_flag)
@@ -2565,7 +2565,7 @@ void
 implicit_decl_warning (id)
      tree id;
 {
-  char *name = IDENTIFIER_POINTER (id);
+  const char *name = IDENTIFIER_POINTER (id);
   if (mesg_implicit_function_declaration == 2)
     error ("implicit declaration of function `%s'", name);
   else if (mesg_implicit_function_declaration == 1)
@@ -3190,7 +3190,11 @@ init_decl_processing ()
 
   pedantic_lvalues = pedantic;
 
-  /* Create the global bindings for __FUNCTION__ and __PRETTY_FUNCTION__.  */
+  /* Create the global bindings for __FUNCTION__, __PRETTY_FUNCTION__,
+     and __func__.  */
+  function_id_node = get_identifier ("__FUNCTION__");
+  pretty_function_id_node = get_identifier ("__PRETTY_FUNCTION__");
+  func_id_node = get_identifier ("__func__");
   make_fname_decl = c_make_fname_decl;
   declare_function_name ();
 
@@ -3220,7 +3224,7 @@ init_decl_processing ()
    delayed emission of static data, we mark the decl as emitted
    so it is not placed in the output.  Anything using it must therefore pull
    out the STRING_CST initializer directly.  This does mean that these names
-   are string merging candidates, which C99 does not permit.  */
+   are string merging candidates, which is wrong for C99's __func__.  FIXME.  */
 
 static tree
 c_make_fname_decl (id, name, type_dep)
===================================================================
Index: c-pragma.h
--- c-pragma.h	2000/01/12 22:47:12	1.13
+++ c-pragma.h	2000/08/26 18:18:37
@@ -47,14 +47,14 @@ Boston, MA 02111-1307, USA.  */
 struct weak_syms
 {
   struct weak_syms * next;
-  char * name;
-  char * value;
+  const char * name;
+  const char * value;
 };
 
 /* Declared in varasm.c */
 extern struct weak_syms * weak_decls;
 
-extern int add_weak PARAMS ((char *, char *));
+extern int add_weak PARAMS ((const char *, const char *));
 #endif /* HANDLE_PRAGMA_WEAK */
 
 
===================================================================
Index: calls.c
--- calls.c	2000/08/22 19:30:49	1.151
+++ calls.c	2000/08/26 18:18:38
@@ -683,8 +683,8 @@ special_function_p (fndecl, flags)
 	 think they are.  */
       && DECL_CONTEXT (fndecl) == NULL_TREE && TREE_PUBLIC (fndecl))
     {
-      char *name = IDENTIFIER_POINTER (DECL_NAME (fndecl));
-      char *tname = name;
+      const char *name = IDENTIFIER_POINTER (DECL_NAME (fndecl));
+      const char *tname = name;
 
       /* We assume that alloca will always be called by name.  It
 	 makes no sense to pass it as a pointer-to-function to
@@ -2070,7 +2070,6 @@ expand_call (exp, target, ignore)
   /* Declaration of the function being called,
      or 0 if the function is computed (not known by name).  */
   tree fndecl = 0;
-  char *name = 0;
   rtx insn;
   int try_tail_call = 1;
   int try_tail_recursion = 1;
@@ -2294,9 +2293,6 @@ expand_call (exp, target, ignore)
       if (temp != (rtx) (HOST_WIDE_INT) - 1)
 	return temp;
     }
-
-  if (fndecl && DECL_NAME (fndecl))
-    name = IDENTIFIER_POINTER (DECL_NAME (fndecl));
 
   /* Figure out the amount to which the stack should be aligned.  */
 #ifdef PREFERRED_STACK_BOUNDARY
===================================================================
Index: dependence.c
--- dependence.c	2000/08/24 19:00:49	1.3
+++ dependence.c	2000/08/26 18:18:39
@@ -89,7 +89,7 @@ typedef struct def_use
   /* this expression */
   tree expression;
   /* our name */
-  char *variable;
+  const char *variable;
   /* def or use */
   enum def_use_type type;
   /* status flags */
@@ -126,7 +126,7 @@ typedef struct loop
 typedef struct induction
 {
   /* our name */
-  char *variable;
+  const char *variable;
   /* increment.  Currently only +1 or -1 */
   int  increment;
   /* lower bound */
@@ -161,7 +161,7 @@ typedef struct subscript
   /* Y in X * i + Y */
   int offset;
   /* our name */
-  char *variable;
+  const char *variable;
   /* next subscript term.  Currently null. */
   struct subscript *next;
 } subscript;
@@ -186,8 +186,8 @@ void init_dependence_analysis PARAMS ((t
 static void build_def_use PARAMS ((tree, enum def_use_type));
 static loop* add_loop PARAMS ((tree, tree, int));
 static int find_induction_variable PARAMS ((tree, tree, tree, loop*));
-static int get_low_bound PARAMS ((tree, char*));
-static int have_induction_variable PARAMS ((tree, char*));
+static int get_low_bound PARAMS ((tree, const char*));
+static int have_induction_variable PARAMS ((tree, const char*));
 static void link_loops PARAMS ((void));
 static void get_node_dependence PARAMS ((void));
 static void check_node_dependence PARAMS ((def_use*));
@@ -518,17 +518,21 @@ find_induction_variable (init_node, cond
       if (TREE_CODE (TREE_OPERAND (cond_node, 0)) == VAR_DECL
 	  && IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (cond_node, 0))) 
 	     == ind_ptr->variable)
-	if (TREE_CODE (TREE_OPERAND (cond_node, 1)) == INTEGER_CST)
-	  ind_ptr->high_bound = TREE_INT_CST_LOW (TREE_OPERAND (cond_node, 1));
-	else
-	  ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX;
+	{
+	  if (TREE_CODE (TREE_OPERAND (cond_node, 1)) == INTEGER_CST)
+	    ind_ptr->high_bound = TREE_INT_CST_LOW(TREE_OPERAND(cond_node, 1));
+	  else
+	    ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX;
+	}
       else if (TREE_CODE (TREE_OPERAND (cond_node, 1)) == VAR_DECL
 	  && IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (cond_node, 1)))
 	       == ind_ptr->variable)
-	if (TREE_CODE (TREE_OPERAND (cond_node, 0)) == INTEGER_CST)
-	  ind_ptr->high_bound = TREE_INT_CST_LOW (TREE_OPERAND (cond_node, 0));
-	else
-	  ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX;
+	{
+	  if (TREE_CODE (TREE_OPERAND (cond_node, 0)) == INTEGER_CST)
+	    ind_ptr->high_bound = TREE_INT_CST_LOW(TREE_OPERAND(cond_node, 0));
+	  else
+	    ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX;
+	}
       ind_ptr->next = 0;
       return 1;
     }
@@ -540,7 +544,7 @@ find_induction_variable (init_node, cond
 static int
 get_low_bound (node, variable)
      tree node;
-     char *variable;
+     const char *variable;
 {
 
   if (TREE_CODE (node) == SCOPE_STMT)
@@ -577,7 +581,7 @@ get_low_bound (node, variable)
 static int
 have_induction_variable (outer_loop, ind_var)
      tree outer_loop;
-     char *ind_var;
+     const char *ind_var;
 {
   induction *ind_ptr;
   loop *loop_ptr;
@@ -981,8 +985,8 @@ classify_dependence (icoefficients, ocoe
      int *separability;
      int count;
 {
-  char *iiv_used [MAX_SUBSCRIPTS];
-  char *oiv_used [MAX_SUBSCRIPTS];
+  const char *iiv_used [MAX_SUBSCRIPTS];
+  const char *oiv_used [MAX_SUBSCRIPTS];
   int ocoeff [MAX_SUBSCRIPTS];
   int icoeff [MAX_SUBSCRIPTS];
   int idx, cidx;
===================================================================
Index: profile.c
--- profile.c	2000/05/19 22:27:27	1.44
+++ profile.c	2000/08/26 18:18:39
@@ -1069,7 +1069,8 @@ void
 output_func_start_profiler ()
 {
   tree fnname, fndecl;
-  char *name, *cfnname;
+  char *name;
+  const char *cfnname;
   rtx table_address;
   enum machine_mode mode = mode_for_size (LONG_TYPE_SIZE, MODE_INT, 0);
   int save_flag_inline_functions = flag_inline_functions;
===================================================================
Index: stor-layout.c
--- stor-layout.c	2000/08/24 20:31:33	1.82
+++ stor-layout.c	2000/08/26 18:18:39
@@ -991,7 +991,7 @@ finalize_record_size (rli)
 
 	  if (TYPE_NAME (rli->t))
 	    {
-	      char *name;
+	      const char *name;
 
 	      if (TREE_CODE (TYPE_NAME (rli->t)) == IDENTIFIER_NODE)
 		name = IDENTIFIER_POINTER (TYPE_NAME (rli->t));
===================================================================
Index: tree.c
--- tree.c	2000/08/05 00:50:00	1.153
+++ tree.c	2000/08/26 18:18:41
@@ -3785,7 +3785,7 @@ is_attribute_p (attr, ident)
      tree ident;
 {
   int ident_len, attr_len;
-  char *p;
+  const char *p;
 
   if (TREE_CODE (ident) != IDENTIFIER_NODE)
     return 0;
===================================================================
Index: tree.h
--- tree.h	2000/08/25 00:58:26	1.191
+++ tree.h	2000/08/26 18:18:42
@@ -737,7 +737,7 @@ struct tree_identifier
 {
   struct tree_common common;
   int length;
-  char *pointer;
+  const char *pointer;
 };
 
 /* In a TREE_LIST node.  */
===================================================================
Index: varasm.c
--- varasm.c	2000/08/24 20:31:34	1.129
+++ varasm.c	2000/08/26 18:18:43
@@ -175,7 +175,7 @@ static int output_addressed_constants	PA
 static void output_after_function_constants PARAMS ((void));
 static void output_constructor		PARAMS ((tree, int));
 #ifdef ASM_WEAKEN_LABEL
-static void remove_from_pending_weak_list	PARAMS ((char *));
+static void remove_from_pending_weak_list	PARAMS ((const char *));
 #endif
 #ifdef ASM_OUTPUT_BSS
 static void asm_output_bss		PARAMS ((FILE *, tree, const char *, int, int));
@@ -519,8 +519,27 @@ void
 make_function_rtl (decl)
      tree decl;
 {
-  char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-  char *new_name = name;
+  const char *name;
+  const char *new_name;
+
+  if (DECL_RTL (decl) != 0)
+    {
+      /* ??? Another way to do this would be to do what halfpic.c does
+	 and maintain a hashed table of such critters.  */
+      /* ??? Another way to do this would be to pass a flag bit to
+	 ENCODE_SECTION_INFO saying whether this is a new decl or not.  */
+      /* Let the target reassign the RTL if it wants.
+	 This is necessary, for example, when one machine specific
+	 decl attribute overrides another.  */
+#ifdef REDO_SECTION_INFO_P
+      if (REDO_SECTION_INFO_P (decl))
+	ENCODE_SECTION_INFO (decl);
+#endif
+      return;
+    }
+
+  name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+  new_name = name;
 
   /* Rename a nested function to avoid conflicts, unless it's a member of
      a local class, in which case the class name is already unique.  */
@@ -530,60 +549,45 @@ make_function_rtl (decl)
       && DECL_RTL (decl) == 0)
     {
       char *label;
-
-      name = IDENTIFIER_POINTER (DECL_NAME (decl));
       ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
-      name = ggc_alloc_string (label, -1);
       var_labelno++;
+      new_name = label;
     }
-  else
+  /* When -fprefix-function-name is used, every function name is
+     prefixed.  Even static functions are prefixed because they
+     could be declared latter.  Note that a nested function name
+     is not prefixed.  */
+  else if (flag_prefix_function_name)
     {
-      /* When -fprefix-function-name is used, every function name is
-         prefixed.  Even static functions are prefixed because they
-         could be declared latter.  Note that a nested function name
-         is not prefixed.  */
-      if (flag_prefix_function_name)
-        {
-	  size_t name_len = strlen (name);
+      size_t name_len = IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl));
+      char *pname;
 
-          new_name = ggc_alloc_string (NULL, name_len + CHKR_PREFIX_SIZE);
-	  memcpy (new_name, CHKR_PREFIX, CHKR_PREFIX_SIZE);
-	  memcpy (new_name + CHKR_PREFIX_SIZE, name, name_len + 1);
-          name = new_name;
-        }
+      pname = alloca (name_len + CHKR_PREFIX_SIZE + 1);
+      memcpy (pname, CHKR_PREFIX, CHKR_PREFIX_SIZE);
+      memcpy (pname + CHKR_PREFIX_SIZE, name, name_len + 1);
+      new_name = pname;
     }
 
-  if (DECL_RTL (decl) == 0)
+  if (name != new_name)
     {
-      DECL_ASSEMBLER_NAME (decl) = get_identifier (name);
-      DECL_RTL (decl)
-	= gen_rtx_MEM (DECL_MODE (decl),
-		       gen_rtx_SYMBOL_REF (Pmode, name));
-
-      /* Optionally set flags or add text to the name to record
-	 information such as that it is a function name.  If the name
-	 is changed, the macro ASM_OUTPUT_LABELREF will have to know
-	 how to strip this information.  */
-#ifdef ENCODE_SECTION_INFO
-      ENCODE_SECTION_INFO (decl);
-#endif
+      DECL_ASSEMBLER_NAME (decl) = get_identifier (new_name);
+      name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
     }
-  else
-    {
-      /* ??? Another way to do this would be to do what halfpic.c does
-	 and maintain a hashed table of such critters.  */
-      /* ??? Another way to do this would be to pass a flag bit to
-	 ENCODE_SECTION_INFO saying whether this is a new decl or not.  */
-      /* Let the target reassign the RTL if it wants.
-	 This is necessary, for example, when one machine specific
-	 decl attribute overrides another.  */
-#ifdef REDO_SECTION_INFO_P
-      if (REDO_SECTION_INFO_P (decl))
-	ENCODE_SECTION_INFO (decl);
+
+  DECL_RTL (decl)
+    = gen_rtx_MEM (DECL_MODE (decl),
+		   gen_rtx_SYMBOL_REF (Pmode, name));
+
+  /* Optionally set flags or add text to the name to record
+     information such as that it is a function name.  If the name
+     is changed, the macro ASM_OUTPUT_LABELREF will have to know
+     how to strip this information.  */
+#ifdef ENCODE_SECTION_INFO
+  ENCODE_SECTION_INFO (decl);
 #endif
-    }
 }
 
+
 /* Given NAME, a putative register name, discard any customary prefixes.  */
 
 static const char *
@@ -673,54 +677,57 @@ make_decl_rtl (decl, asmspec, top_level)
      const char *asmspec;
      int top_level;
 {
-  register char *name = 0;
+  const char *name = 0;
+  const char *new_name = 0;
   int reg_number;
-
-  reg_number = decode_reg_name (asmspec);
 
-  if (DECL_ASSEMBLER_NAME (decl) != NULL_TREE)
-    name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-
-  if (reg_number == -2)
+  /* For a duplicate declaration, we can be called twice on the
+     same DECL node.  Don't discard the RTL already made.  */
+  if (DECL_RTL (decl) != 0)
     {
-      /* ASMSPEC is given, and not the name of a register.  */
-      size_t len = strlen (asmspec);
+      /* If the old RTL had the wrong mode, fix the mode.  */
+      if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
+	{
+	  rtx rtl = DECL_RTL (decl);
+	  PUT_MODE (rtl, DECL_MODE (decl));
+	}
 
-      name = ggc_alloc_string (NULL, len + 1);
-      name[0] = '*';
-      memcpy (&name[1], asmspec, len + 1);
+      /* ??? Another way to do this would be to do what halfpic.c does
+	 and maintain a hashed table of such critters.  */
+      /* ??? Another way to do this would be to pass a flag bit to
+	 ENCODE_SECTION_INFO saying whether this is a new decl or not.  */
+      /* Let the target reassign the RTL if it wants.
+	 This is necessary, for example, when one machine specific
+	 decl attribute overrides another.  */
+#ifdef REDO_SECTION_INFO_P
+      if (REDO_SECTION_INFO_P (decl))
+	ENCODE_SECTION_INFO (decl);
+#endif
+      return;
     }
 
-  /* For a duplicate declaration, we can be called twice on the
-     same DECL node.  Don't discard the RTL already made.  */
-  if (DECL_RTL (decl) == 0)
+  new_name = name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+
+  reg_number = decode_reg_name (asmspec);
+  if (reg_number == -2)
+    /* ASMSPEC is given, and not the name of a register.  */
+    new_name = asmspec;
+
+  if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
     {
       /* First detect errors in declaring global registers.  */
-      if (TREE_CODE (decl) != FUNCTION_DECL
-	  && DECL_REGISTER (decl) && reg_number == -1)
-	error_with_decl (decl,
-			 "register name not specified for `%s'");
-      else if (TREE_CODE (decl) != FUNCTION_DECL
-	       && DECL_REGISTER (decl) && reg_number < 0)
+      if (reg_number == -1)
+	error_with_decl (decl, "register name not specified for `%s'");
+      else if (reg_number < 0)
+	error_with_decl (decl, "invalid register name for `%s'");
+      else if (TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
 	error_with_decl (decl,
-			 "invalid register name for `%s'");
-      else if ((reg_number >= 0 || reg_number == -3)
-	       && (TREE_CODE (decl) == FUNCTION_DECL
-		   && ! DECL_REGISTER (decl)))
-	error_with_decl (decl,
-			 "register name given for non-register variable `%s'");
-      else if (TREE_CODE (decl) != FUNCTION_DECL
-	       && DECL_REGISTER (decl)
-	       && TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
-	error_with_decl (decl,
 			 "data type of `%s' isn't suitable for a register");
-      else if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl)
-	       && ! HARD_REGNO_MODE_OK (reg_number,
-					TYPE_MODE (TREE_TYPE (decl))))
+      else if (! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl))))
 	error_with_decl (decl,
-			 "register number for `%s' isn't suitable for data type");
+			 "register specified for `%s' isn't suitable for data type");
       /* Now handle properly declared static register variables.  */
-      else if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
+      else
 	{
 	  int nregs;
 
@@ -754,96 +761,81 @@ make_decl_rtl (decl, asmspec, top_level)
 	      while (nregs > 0)
 		globalize_reg (reg_number + --nregs);
 	    }
-	}
-      /* Specifying a section attribute on a variable forces it into a
-         non-.bss section, and thus it cannot be common. */
-      else if (TREE_CODE (decl) == VAR_DECL
-	       && DECL_SECTION_NAME (decl) != NULL_TREE
-	       && DECL_INITIAL (decl) == NULL_TREE
-	       && DECL_COMMON (decl))
-          DECL_COMMON (decl) = 0;
-
-      /* Now handle ordinary static variables and functions (in memory).
-	 Also handle vars declared register invalidly.  */
-      if (DECL_RTL (decl) == 0)
-	{
-	  /* Can't use just the variable's own name for a variable
-	     whose scope is less than the whole file, unless it's a member
-	     of a local class (which will already be unambiguous).
-	     Concatenate a distinguishing number.  */
-	  if (!top_level && !TREE_PUBLIC (decl)
-	      && ! (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)))
-	      && asmspec == 0)
-	    {
-	      char *label;
 
-	      ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
-	      name = ggc_alloc_string (label, -1);
-	      var_labelno++;
-	    }
+	  /* As a register variable, it has no section.  */
+	  return;
+	}
+    }
 
-	  if (name == 0)
-	    abort ();
+  /* Now handle ordinary static variables and functions (in memory).
+     Also handle vars declared register invalidly.  */
 
-	  /* When -fprefix-function-name is used, the functions
-	     names are prefixed.  Only nested function names are not
-	     prefixed.  */
-	  if (flag_prefix_function_name && TREE_CODE (decl) == FUNCTION_DECL)
-	    {
-	      size_t name_len = strlen (name);
-	      char *new_name;
+  if (reg_number >= 0 || reg_number == -3)
+    error_with_decl (decl,
+		     "register name given for non-register variable `%s'");
+
+  /* Specifying a section attribute on a variable forces it into a
+     non-.bss section, and thus it cannot be common. */
+  if (TREE_CODE (decl) == VAR_DECL
+      && DECL_SECTION_NAME (decl) != NULL_TREE
+      && DECL_INITIAL (decl) == NULL_TREE
+      && DECL_COMMON (decl))
+    DECL_COMMON (decl) = 0;
+
+  /* Can't use just the variable's own name for a variable
+     whose scope is less than the whole file, unless it's a member
+     of a local class (which will already be unambiguous).
+     Concatenate a distinguishing number.  */
+  if (!top_level && !TREE_PUBLIC (decl)
+      && ! (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)))
+      && asmspec == 0)
+    {
+      char *label;
+      ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
+      var_labelno++;
+      new_name = label;
+    }
 
-	      new_name = ggc_alloc_string (NULL, name_len + CHKR_PREFIX_SIZE);
-	      memcpy (new_name, CHKR_PREFIX, CHKR_PREFIX_SIZE);
-	      memcpy (new_name + CHKR_PREFIX_SIZE, name, name_len + 1);
-	      name = new_name;
-	    }
+  /* When -fprefix-function-name is used, the functions
+     names are prefixed.  Only nested function names are not
+     prefixed.  */
+  else if (flag_prefix_function_name && TREE_CODE (decl) == FUNCTION_DECL)
+    {
+      size_t name_len = IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl));
+      char *pname;
 
-	  /* If this variable is to be treated as volatile, show its
-	     tree node has side effects.   */
-	  if ((flag_volatile_global && TREE_CODE (decl) == VAR_DECL
-	       && TREE_PUBLIC (decl))
-	      || ((flag_volatile_static && TREE_CODE (decl) == VAR_DECL
-		   && (TREE_PUBLIC (decl) || TREE_STATIC (decl)))))
-	    TREE_SIDE_EFFECTS (decl) = 1;
-
-	  DECL_ASSEMBLER_NAME (decl)
-	    = get_identifier (name[0] == '*' ? name + 1 : name);
-	  DECL_RTL (decl) = gen_rtx_MEM (DECL_MODE (decl),
-					 gen_rtx_SYMBOL_REF (Pmode, name));
-	  if (TREE_CODE (decl) != FUNCTION_DECL)
-	    set_mem_attributes (DECL_RTL (decl), decl, 1);
-
-	  /* Optionally set flags or add text to the name to record information
-	     such as that it is a function name.
-	     If the name is changed, the macro ASM_OUTPUT_LABELREF
-	     will have to know how to strip this information.  */
-#ifdef ENCODE_SECTION_INFO
-	  ENCODE_SECTION_INFO (decl);
-#endif
-	}
+      pname = alloca (name_len + CHKR_PREFIX_SIZE + 1);
+      memcpy (pname, CHKR_PREFIX, CHKR_PREFIX_SIZE);
+      memcpy (pname + CHKR_PREFIX_SIZE, name, name_len + 1);
+      new_name = pname;
     }
-  else
+
+  if (name != new_name)
     {
-      /* If the old RTL had the wrong mode, fix the mode.  */
-      if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
-	{
-	  rtx rtl = DECL_RTL (decl);
-	  PUT_MODE (rtl, DECL_MODE (decl));
-	}
+      DECL_ASSEMBLER_NAME (decl) = get_identifier (new_name);
+      name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+    }
 
-      /* ??? Another way to do this would be to do what halfpic.c does
-	 and maintain a hashed table of such critters.  */
-      /* ??? Another way to do this would be to pass a flag bit to
-	 ENCODE_SECTION_INFO saying whether this is a new decl or not.  */
-      /* Let the target reassign the RTL if it wants.
-	 This is necessary, for example, when one machine specific
-	 decl attribute overrides another.  */
-#ifdef REDO_SECTION_INFO_P
-      if (REDO_SECTION_INFO_P (decl))
-	ENCODE_SECTION_INFO (decl);
+  /* If this variable is to be treated as volatile, show its
+     tree node has side effects.   */
+  if ((flag_volatile_global && TREE_CODE (decl) == VAR_DECL
+       && TREE_PUBLIC (decl))
+      || ((flag_volatile_static && TREE_CODE (decl) == VAR_DECL
+	   && (TREE_PUBLIC (decl) || TREE_STATIC (decl)))))
+    TREE_SIDE_EFFECTS (decl) = 1;
+
+  DECL_RTL (decl) = gen_rtx_MEM (DECL_MODE (decl),
+				 gen_rtx_SYMBOL_REF (Pmode, name));
+  if (TREE_CODE (decl) != FUNCTION_DECL)
+    set_mem_attributes (DECL_RTL (decl), decl, 1);
+
+  /* Optionally set flags or add text to the name to record information
+     such as that it is a function name.
+     If the name is changed, the macro ASM_OUTPUT_LABELREF
+     will have to know how to strip this information.  */
+#ifdef ENCODE_SECTION_INFO
+  ENCODE_SECTION_INFO (decl);
 #endif
-    }
 }
 
 /* Make the rtl for variable VAR be volatile.
@@ -4656,8 +4648,8 @@ output_constructor (exp, size)
    
 int
 add_weak (name, value)
-     char *name;
-     char *value;
+     const char *name;
+     const char *value;
 {
   struct weak_syms *weak;
 
@@ -4724,7 +4716,7 @@ weak_finish ()
 #ifdef ASM_WEAKEN_LABEL
 static void
 remove_from_pending_weak_list (name)
-     char *name ATTRIBUTE_UNUSED;
+     const char *name ATTRIBUTE_UNUSED;
 {
 #ifdef HANDLE_PRAGMA_WEAK
   if (HANDLE_PRAGMA_WEAK)
===================================================================
Index: ch/inout.c
--- ch/inout.c	2000/02/11 15:48:23	1.13
+++ ch/inout.c	2000/08/26 18:18:43
@@ -130,8 +130,7 @@ static tree add_enum_to_list (type, cont
       if (wrk->context == context && wrk->type == type)
 	{
 	  /* yes, found. look if the ptrdecl is valid in this scope */
-	  char  *name = IDENTIFIER_POINTER (DECL_NAME (wrk->ptrdecl));
-	  tree   var  = get_identifier (name);
+	  tree   var  = DECL_NAME (wrk->ptrdecl);
 	  tree   decl = lookup_name (var);
 	    
 	  if (decl == NULL_TREE)
===================================================================
Index: ch/lex.c
--- ch/lex.c	2000/05/09 19:55:48	1.15
+++ ch/lex.c	2000/08/26 18:18:44
@@ -2158,7 +2158,7 @@ yywrap ()
   if (next_file_to_seize && !grant_only_flag)
     {
       FILE *grt_in = NULL;
-      char *seizefile_name_chars
+      const char *seizefile_name_chars
 	= IDENTIFIER_POINTER (TREE_VALUE (next_file_to_seize));
 
       /* find a seize file, open it.  If it's not at the path the
===================================================================
Index: cp/class.c
--- cp/class.c	2000/08/21 04:39:29	1.332
+++ cp/class.c	2000/08/26 18:18:47
@@ -855,7 +855,8 @@ build_secondary_vtable (binfo, for_type)
   tree new_decl;
   tree offset;
   tree path = binfo;
-  char *buf, *buf2;
+  char *buf;
+  const char *buf2;
   char joiner = '_';
   int i;
 
===================================================================
Index: cp/decl.c
--- cp/decl.c	2000/08/25 07:28:33	1.675
+++ cp/decl.c	2000/08/26 18:18:50
@@ -6642,6 +6642,10 @@ init_decl_processing ()
     flag_weak = 0;
 
   /* Create the global bindings for __FUNCTION__ and __PRETTY_FUNCTION__.  */
+  function_id_node = get_identifier ("__FUNCTION__");
+  pretty_function_id_node = get_identifier ("__PRETTY_FUNCTION__");
+  func_id_node = get_identifier ("__func__");
+
   make_fname_decl = cp_make_fname_decl;
   declare_function_name ();
 
===================================================================
Index: cp/input.c
--- cp/input.c	2000/05/09 19:55:50	1.17
+++ cp/input.c	2000/08/26 18:18:50
@@ -45,7 +45,7 @@ static struct putback_buffer putback = {
 
 struct input_source {
   /* saved string */
-  char *str;
+  const char *str;
   int length;
   /* current position, when reading as input */
   int offset;
@@ -67,7 +67,7 @@ extern unsigned char *yy_cur, *yy_lim;
 extern int yy_get_token ();
 #endif
 
-extern void feed_input PARAMS ((char *, int, const char *, int));
+extern void feed_input PARAMS ((const char *, int, const char *, int));
 extern void put_input PARAMS ((int));
 extern void put_back PARAMS ((int));
 extern int getch PARAMS ((void));
@@ -109,7 +109,7 @@ free_input (inp)
 inline
 void
 feed_input (str, len, file, line)
-     char *str;
+     const char *str;
      int len;
      const char *file;
      int line;
===================================================================
Index: cp/mangle.c
--- cp/mangle.c	2000/08/25 07:28:34	1.15
+++ cp/mangle.c	2000/08/26 18:18:50
@@ -160,7 +160,7 @@ static void write_source_name PARAMS ((t
 static void write_number PARAMS ((unsigned HOST_WIDE_INT, int,
 				  unsigned int));
 static void write_integer_cst PARAMS ((tree));
-static void write_identifier PARAMS ((char *));
+static void write_identifier PARAMS ((const char *));
 static void write_special_name_constructor PARAMS ((tree));
 static void write_special_name_destructor PARAMS ((tree));
 static void write_type PARAMS ((tree));
@@ -1038,7 +1038,7 @@ write_integer_cst (cst)
 
 static void
 write_identifier (identifier)
-     char *identifier;
+     const char *identifier;
 {
   MANGLE_TRACE ("identifier", identifier);
   write_string (identifier);
===================================================================
Index: cp/pt.c
--- cp/pt.c	2000/08/23 17:12:23	1.460
+++ cp/pt.c	2000/08/26 18:18:52
@@ -103,7 +103,7 @@ static void add_pending_template PARAMS 
 static int push_tinst_level PARAMS ((tree));
 static void reopen_tinst_level PARAMS ((tree));
 static tree classtype_mangled_name PARAMS ((tree));
-static char *mangle_class_name_for_template PARAMS ((char *, tree, tree));
+static char *mangle_class_name_for_template PARAMS ((const char *, tree, tree));
 static tree tsubst_initializer_list PARAMS ((tree, tree));
 static int list_eq PARAMS ((tree, tree));
 static tree get_class_bindings PARAMS ((tree, tree, tree));
@@ -3504,7 +3504,7 @@ comp_template_args (oldargs, newargs)
 
 static char *
 mangle_class_name_for_template (name, parms, arglist)
-     char *name;
+     const char *name;
      tree parms, arglist;
 {
   static struct obstack scratch_obstack;
===================================================================
Index: f/ansify.c
--- f/ansify.c	2000/06/21 20:11:14	1.9
+++ f/ansify.c	2000/08/26 18:18:52
@@ -47,7 +47,7 @@ main(int argc, char **argv)
   printf ("\
 /* This file is automatically generated from `%s',\n\
    which you should modify instead.  */\n\
-# 1 \"%s\"\n\
+#line 1 \"%s\"\n\
 ",
 	  argv[1], argv[1]);
 
===================================================================
Index: java/jcf-parse.c
--- java/jcf-parse.c	2000/08/11 22:01:37	1.51
+++ java/jcf-parse.c	2000/08/26 18:18:52
@@ -99,7 +99,7 @@ set_source_filename (jcf, index)
      int index;
 {
   tree sfname_id = get_name_constant (jcf, index);
-  char *sfname = IDENTIFIER_POINTER (sfname_id);
+  const char *sfname = IDENTIFIER_POINTER (sfname_id);
   if (input_filename != NULL)
     {
       int old_len = strlen (input_filename);
===================================================================
Index: java/jcf-write.c
--- java/jcf-write.c	2000/08/16 00:05:29	1.67
+++ java/jcf-write.c	2000/08/26 18:18:53
@@ -3161,7 +3161,7 @@ append_innerclasses_attribute (state, cl
      process: itself, up and down. */
   while (class && INNER_CLASS_TYPE_P (class))
     {
-      char *n;
+      const char *n;
 
       decl = TYPE_NAME (class);
       n = IDENTIFIER_POINTER (DECL_NAME (decl)) + 
@@ -3218,8 +3218,8 @@ static char *
 make_class_file_name (clas)
      tree clas;
 {
-  const char *dname, *slash;
-  char *cname, *r;
+  const char *dname, *cname, *slash;
+  char *r;
   struct stat sb;
 
   cname = IDENTIFIER_POINTER (identifier_subst (DECL_NAME (TYPE_NAME (clas)),
@@ -3261,10 +3261,10 @@ make_class_file_name (clas)
   dname = r + (slash - dname) + 1;
   while (1)
     {
-      cname = strchr (dname, DIR_SEPARATOR);
-      if (cname == NULL)
+      char *s = strchr (dname, DIR_SEPARATOR);
+      if (s == NULL)
 	break;
-      *cname = '\0';
+      *s = '\0';
       if (stat (r, &sb) == -1)
 	{
 	  /* Try to make it.  */
@@ -3275,9 +3275,9 @@ make_class_file_name (clas)
 	      return NULL;
 	    }
 	}
-      *cname = DIR_SEPARATOR;
+      *s = DIR_SEPARATOR;
       /* Skip consecutive separators.  */
-      for (dname = cname + 1; *dname && *dname == DIR_SEPARATOR; ++dname)
+      for (dname = s + 1; *dname && *dname == DIR_SEPARATOR; ++dname)
 	;
     }
 
===================================================================
Index: java/parse.y
--- java/parse.y	2000/08/24 20:34:39	1.204
+++ java/parse.y	2000/08/26 18:18:56
@@ -5014,7 +5014,7 @@ build_alias_initializer_parameter_list (
   for (field = TYPE_FIELDS (class_type); field; field = TREE_CHAIN (field))
     if (FIELD_LOCAL_ALIAS (field))
       {
-	char *buffer = IDENTIFIER_POINTER (DECL_NAME (field));
+	const char *buffer = IDENTIFIER_POINTER (DECL_NAME (field));
 	tree purpose = NULL_TREE, value = NULL_TREE, name = NULL_TREE;
 
 	switch (mode)
@@ -10746,12 +10746,14 @@ static int
 breakdown_qualified (left, right, source)
     tree *left, *right, source;
 {
-  char *p = IDENTIFIER_POINTER (source), *base;
+  char *p, *base;
   int   l = IDENTIFIER_LENGTH (source);
 
+  base = alloca (l + 1);
+  memcpy (base, IDENTIFIER_POINTER (source), l + 1);
+
   /* Breakdown NAME into REMAINDER . IDENTIFIER */
-  base = p;
-  p += (l-1);
+  p = base + l - 1;
   while (*p != '.' && p != base)
     p--;
 
@@ -10762,8 +10764,7 @@ breakdown_qualified (left, right, source
   *p = '\0';
   if (right)
     *right = get_identifier (p+1);
-  *left = get_identifier (IDENTIFIER_POINTER (source));
-  *p = '.';
+  *left = get_identifier (base);
   
   return 0;
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]