]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
top level:
authorZack Weinberg <zack@wolery.cumb.org>
Tue, 29 Aug 2000 21:39:49 +0000 (21:39 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Tue, 29 Aug 2000 21:39:49 +0000 (21:39 +0000)
* 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.

From-SVN: r36055

27 files changed:
gcc/ChangeLog
gcc/c-common.c
gcc/c-common.h
gcc/c-decl.c
gcc/c-pragma.h
gcc/calls.c
gcc/ch/ChangeLog
gcc/ch/inout.c
gcc/ch/lex.c
gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/decl.c
gcc/cp/input.c
gcc/cp/mangle.c
gcc/cp/pt.c
gcc/dependence.c
gcc/f/ChangeLog
gcc/f/ansify.c
gcc/java/ChangeLog
gcc/java/jcf-parse.c
gcc/java/jcf-write.c
gcc/java/parse.y
gcc/profile.c
gcc/stor-layout.c
gcc/tree.c
gcc/tree.h
gcc/varasm.c

index 79d622e3c30c779a216b7ab7b473ab557c84f3ec..3ef282b1621827812d98997b8b4f372ca55f0b50 100644 (file)
@@ -1,3 +1,42 @@
+2000-08-29  Zack Weinberg  <zack@wolery.cumb.org>
+
+       * 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.
+
 2000-08-29  Richard Henderson  <rth@cygnus.com>
 
        * config/ia64/ia64.md (muldi3): Use grfr_register_operand
index cf145ca1ecbce79575ed1035b5f5406f5e2cc6e7..7fcdbebfcc7a6721fb20e80e292d66988d8d5358 100644 (file)
@@ -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 ab294ed12001efdd6f275889e02603f272312f71..2d9e7b0daf008d404edb6de9f82776c7fb09fd96 100644 (file)
@@ -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
 };
 
@@ -153,6 +158,10 @@ enum c_tree_index
 #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];
 
 typedef enum c_language_kind
index 545ac880d98f30a501e9b4f6b35cfd0131bd2f79..6820cedcfccbd3c78b11d9cdcdae062c3a60e45a 100644 (file)
@@ -2439,7 +2439,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)
@@ -2560,7 +2560,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)
@@ -3187,7 +3187,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 ();
 
@@ -3217,7 +3221,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 be94442f5eab43395c97e9cb54e75033abeeac46..65b1cc4df711d69bcbc4f102397ec7bed1978cdb 100644 (file)
@@ -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 605c5ae9393ac331b9f81fbc25f4221bcf95f799..ed35daf9a64b88cb43e005080e0ea5b92bc72e60 100644 (file)
@@ -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;
@@ -2289,9 +2288,6 @@ expand_call (exp, target, ignore)
        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
   preferred_stack_boundary = PREFERRED_STACK_BOUNDARY;
index 9c15d173b6991056c4b488b2b8e9a58c2ef30d71..44049ccd1755cb8e97630df3975b4494b06a0edb 100644 (file)
@@ -1,3 +1,9 @@
+2000-08-29  Zack Weinberg  <zack@wolery.cumb.org>
+
+       * 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 *.
+
 2000-08-24  Mark Mitchell  <mark@codesourcery.com>
 
        * Make-lang.in (cc1chill): Don't depend on c-iterate.o.
index 56164ac3857945a13ee557a734cfa7f3d1a5f710..ff2de0a3619fc1fea2885ca537f878da330bf257 100644 (file)
@@ -130,8 +130,7 @@ static tree add_enum_to_list (type, context)
       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 cd433caf9b99d8df5f197c1f2328ee3f2c15b741..868d8eda03e48cd5e878a1b1a0182fa8ac534918 100644 (file)
@@ -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 325872dc80f1c1afe9137ee08141565b9ed6bca4..84954e7a703ee370c42931a15db0a114daf93290 100644 (file)
@@ -1,3 +1,13 @@
+2000-08-29  Zack Weinberg  <zack@wolery.cumb.org>
+
+       * 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.
+
 2000-08-29  Mark Mitchell  <mark@codesourcery.com>
 
        * typeck.c (mark_addressable): Remove code that pokes around in
index dfbdc94a78b89b441b56ae4996efed73c0f4aaed..c10f09d340920f8a03687f4e277738ddfd8543d4 100644 (file)
@@ -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 552070b6e1d098995fd8d20a4827aac41084fcb9..e84232d64b5fbd5f84d9d2a7731cd63e2981e318 100644 (file)
@@ -6671,6 +6671,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 8c96c37963d01138d40eae77d6a32d01f9870022..431fed792a8b1684211914899274f4ce85390b5c 100644 (file)
@@ -45,7 +45,7 @@ static struct putback_buffer putback = {NULL, 0, -1};
 
 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 98f59ab6c5fc49f645bce695b66c281106a679df..fb4d166baab326ca5da2622b52d532fe9481e8b6 100644 (file)
@@ -156,7 +156,7 @@ static void write_source_name PARAMS ((tree));
 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));
@@ -1053,7 +1053,7 @@ write_integer_cst (cst)
 
 static void
 write_identifier (identifier)
-     char *identifier;
+     const char *identifier;
 {
   MANGLE_TRACE ("identifier", identifier);
   write_string (identifier);
index 59fe306fb18d42b200df12ad22d53f36ac280254..9da72eeed919053d89eefd572313833ded3c101a 100644 (file)
@@ -103,7 +103,7 @@ static void add_pending_template PARAMS ((tree));
 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 ac6abda19a21ccb0811338fde4e76f1eed7b042e..141d9ac9d409f782ceb7e9089175af1853c4b8c2 100644 (file)
@@ -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 ((tree));
 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,23 @@ find_induction_variable (init_node, cond_node, incr_node, loop_def)
       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 +546,7 @@ find_induction_variable (init_node, cond_node, incr_node, loop_def)
 static int
 get_low_bound (node, variable)
      tree node;
-     char *variable;
+     const char *variable;
 {
 
   if (TREE_CODE (node) == SCOPE_STMT)
@@ -577,7 +583,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 +987,8 @@ classify_dependence (icoefficients, ocoefficients, complexity, separability,
      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 6a108209d46eb313d8c67cde10d45d7d7e7934f9..19ca37992766da6bc599fd54772416fccce57dc5 100644 (file)
@@ -1,3 +1,7 @@
+2000-08-29  Zack Weinberg  <zack@wolery.cumb.org>
+
+       * ansify.c: Use #line, not # <number>.
+
 2000-08-24  Greg McGary  <greg@mcgary.org>
 
        * intdoc.c (ARRAY_SIZE): Remove macro.
index 1c6f92d0fcae899f963d049a5f7134b1a932a2e0..ec9910779e78b0bde4579b1285f88720ee5093e2 100644 (file)
@@ -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 55b429562bec83a9ad9f324eeb3d8cf18f0a9408..4dfa874e472ca38a2da1830a3a6fb9e49f799cbe 100644 (file)
@@ -1,3 +1,12 @@
+2000-08-29  Zack Weinberg  <zack@wolery.cumb.org>
+
+       * 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.
+
 2000-08-29  Alexandre Petit-Bianco  <apbianco@cygnus.com>
 
        * expr.c (can_widen_reference_to): Fixed indentation.
index 4b00c432f47b0dc7c9154df8f59b413b6e7010ff..02becc074839d194fe7e760e7dfc244e9d8086a0 100644 (file)
@@ -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 7ab1518fb8e120befce9a853a8f8c402475c1d66..6a6d7e1cb5bb776dcd28cafd0f312a4698c5707d 100644 (file)
@@ -3161,7 +3161,7 @@ append_innerclasses_attribute (state, class)
      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 d67b6c7cc71c56476c6c0630a25df0d7a4e4d2e7..4676153b92ef0b89a4422fc7c0bddcdb7df35c0d 100644 (file)
@@ -5014,7 +5014,7 @@ build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
   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 627d6e403dcf5c621447eefb9fb4bac401e9df9f..fa6b2302bd26793faa54eeae749e76fa86e33f5b 100644 (file)
@@ -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 43ae6f2cf472278016cebefebc189960154e4235..af219ccbe91120a0e87653dace28d34dac1a3017 100644 (file)
@@ -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 6e9648770aee9f25af6b3f3a257dddd1e9fed290..e1a4a7d0eb67b590d0ed34b7d811c536148e956d 100644 (file)
@@ -3786,7 +3786,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 93a54161572e0bf4f8e5e3c11391534bb4edf07e..e9b0da4d73011c3eb7e31c7d799ca479d8ffced2 100644 (file)
@@ -737,7 +737,7 @@ struct tree_identifier
 {
   struct tree_common common;
   int length;
-  char *pointer;
+  const char *pointer;
 };
 
 /* In a TREE_LIST node.  */
index b30d08901c3f88f2c160d29e35612880bbc8effb..5193dd6cb9c6b2b8aa7c36436bdb487b04797e17 100644 (file)
@@ -175,7 +175,7 @@ static int output_addressed_constants       PARAMS ((tree));
 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)
-       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)
+      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,
                         "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);
            }
+
+         /* As a register variable, it has no section.  */
+         return;
        }
-      /* 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++;
-           }
+  /* Now handle ordinary static variables and functions (in memory).
+     Also handle vars declared register invalidly.  */
 
-         if (name == 0)
-           abort ();
+  if (reg_number >= 0 || reg_number == -3)
+    error_with_decl (decl,
+                    "register name given for non-register variable `%s'");
 
-         /* 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;
+  /* 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)