]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
langhooks.c: Don't include gt-langhooks.h.
authorZack Weinberg <zack@gcc.gnu.org>
Mon, 5 Jul 2004 17:28:37 +0000 (17:28 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Mon, 5 Jul 2004 17:28:37 +0000 (17:28 +0000)
* langhooks.c: Don't include gt-langhooks.h.
(var_labelno): Delete.
(lhd_set_decl_assembler_name): Do not append a distinguishing
number to file-scope internal-linkage declarations for the first
input file, even if they have DECL_CONTEXT set.  Use DECL_UID of
the declaration itself (if at block scope), or its containing
TRANSLATION_UNIT_DECL (if at file scope) for the distinguishing
number.

* opts.c (cur_in_fname): New global.
* opts.h: Declare it.
* tree.c: Include opts.h.
(make_node_stat): If creating a TRANSLATION_UNIT_DECL, give it
DECL_UID equal to cur_in_fname.
(copy_node_stat): Do not change DECL_UID when copying a
TRANSLATION_UNIT_DECL.
(build_common_tree_nodes): Adjust next_decl_uid to reserve the
range 0 .. num_in_fnames-1 for TRANSLATION_UNIT_DECLs.

* c-decl.c (c_static_assembler_name): Delete.
* c-tree.h (c_static_assembler_name): Delete prototype.
* c-lang.c, objc/objc-lang.c: Don't override
LANG_HOOKS_SET_DECL_ASSEMBLER_NAME.

* Makefile.in (tree.o): Update dependencies.
(GTFILES): Remove langhooks.c.

cp:
* decl.c (cxx_init_decl_processing): Call
build_common_tree_nodes before creating the global NAMESPACE_DECL.

From-SVN: r84123

12 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/c-decl.c
gcc/c-lang.c
gcc/c-tree.h
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/langhooks.c
gcc/objc/objc-lang.c
gcc/opts.c
gcc/opts.h
gcc/tree.c

index e6d474f43cc852f1e46e68545ced35b515d5ed79..3d06b8874ec6e480aec154fb4c1c3737241fca9e 100644 (file)
@@ -1,3 +1,32 @@
+2004-07-05  Zack Weinberg  <zack@codesourcery.com>
+
+       * langhooks.c: Don't include gt-langhooks.h.
+       (var_labelno): Delete.
+       (lhd_set_decl_assembler_name): Do not append a distinguishing
+       number to file-scope internal-linkage declarations for the first
+       input file, even if they have DECL_CONTEXT set.  Use DECL_UID of
+       the declaration itself (if at block scope), or its containing
+       TRANSLATION_UNIT_DECL (if at file scope) for the distinguishing
+       number.
+
+       * opts.c (cur_in_fname): New global.
+       * opts.h: Declare it.
+       * tree.c: Include opts.h.
+       (make_node_stat): If creating a TRANSLATION_UNIT_DECL, give it
+       DECL_UID equal to cur_in_fname.
+       (copy_node_stat): Do not change DECL_UID when copying a
+       TRANSLATION_UNIT_DECL.
+       (build_common_tree_nodes): Adjust next_decl_uid to reserve the
+       range 0 .. num_in_fnames-1 for TRANSLATION_UNIT_DECLs.
+
+       * c-decl.c (c_static_assembler_name): Delete.
+       * c-tree.h (c_static_assembler_name): Delete prototype.
+       * c-lang.c, objc/objc-lang.c: Don't override
+       LANG_HOOKS_SET_DECL_ASSEMBLER_NAME.
+
+       * Makefile.in (tree.o): Update dependencies.
+       (GTFILES): Remove langhooks.c.
+
 2004-07-05  Roger Sayle  <roger@eyesopen.com>
 
        * fold-const.c (fold) <TRUNC_MOD_EXPR>: Optimize unsigned modulus
        (walk_type_fields): New function.
        (walk_tree): Use it.
        * tree-nested.c (create_tmp_var_for): Show seen in BIND_EXPR.
-       
+
        * tree-sra.c (struct sra_walk_fns): Init function now returns bool.
        (sra_walk_modify_expr): Allow init function to fail.
        (scan_init): Now returns bool.
        (generate_element_init): If can't understand INIT, return false.
        (scalarize_init): Return false if generate_element_init does.
-       
+
        * tree-pretty-print.c (dump_generic_node, case ARRAY_TYPE): Properly
        print bounds.
 
        (make_tree_binfo_stat): Declare.
        (make_tree_binfo): New.
        (enum tree_node_kind): Add binfo_kind.
-       
+
        * objc/objc-act.c (start_class, objc_declare_protocols,
        start_protocols): Use TYPE_LANG_SLOT_1.
        * objc/objc-act.h (CLASS_BINFO_ELTS, PROTOCOL_BINFO_ELTS): Rename
        (struct assign_parm_data_one): New.
        (assign_parms_initialize_all, assign_parms_augmented_arg_list,
        assign_parm_find_data_types, assign_parms_setup_varargs,
-       assign_parm_find_entry_rtl, assign_parm_is_stack_parm, 
+       assign_parm_find_entry_rtl, assign_parm_is_stack_parm,
        assign_parm_find_stack_rtl, assign_parm_adjust_entry_rtl,
        assign_parm_adjust_stack_rtl, assign_parm_setup_block_p,
        assign_parm_setup_block, assign_parm_setup_reg,
        (bitmap_insert_into_set): No point in inserting the value if
        it's invariant.
        (bitmap_set_contains): New function.
-       (bitmap_set_replace_value): Add comment on why we do it 
+       (bitmap_set_replace_value): Add comment on why we do it
        this way.
        (set_contains): Removed.
        (bitmap_set_subtract_from_value_set): New name of
        gen_mem_addressof, flush_addressof, put_addressof_into_stack,
        purge_bitfield_addressof_replacements, purge_addressof_replacements,
        purge_addressof_1, insns_for_mem_hash, insns_for_mem_comp,
-       struct insns_for_mem_walk_info, insns_for_mem_walk, 
+       struct insns_for_mem_walk_info, insns_for_mem_walk,
        compute_insns_for_mem, is_addressof, purge_addressof, setjmp_protect,
        setjmp_protect_args): Remove.
        (push_function_context_to): Don't handle var_refs_queue.
        (walk_tree, case POINTER_TYPE): Deal with mutually recursive pointers.
 
        * tree-sra.c (generate_element_init): Remove any useless conversions.
-       
+
        * gimplify.c (gimplify_conversion): Remove stripping useless
        conversions from here.
        (gimplify_expr): Put it here, in place of call to STRIP_MAIN_TYPE_NOPS.
index 491e58a47d60b4cb09ef8ddcf829d465464286c0..5da0f951f4baf46071e127e0688f548441676e82 100644 (file)
@@ -1569,7 +1569,7 @@ langhooks.o : langhooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H)
    $(LANGHOOKS_DEF_H) $(FLAGS_H) $(GGC_H) gt-langhooks.h diagnostic.h
 tree.o : tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(FLAGS_H) function.h \
    toplev.h $(GGC_H) $(HASHTAB_H) $(TARGET_H) output.h $(TM_P_H) langhooks.h \
-   real.h gt-tree.h tree-iterator.h $(BASIC_BLOCK_H) $(TREE_FLOW_H)
+   real.h gt-tree.h tree-iterator.h $(BASIC_BLOCK_H) $(TREE_FLOW_H) opts.h
 tree-dump.o: tree-dump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
    $(C_TREE_H) $(FLAGS_H) langhooks.h toplev.h output.h c-pragma.h $(RTL_H) \
    $(GGC_H) $(EXPR_H) $(SPLAY_TREE_H) $(TREE_DUMP_H) tree-iterator.h
@@ -2337,7 +2337,7 @@ GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \
   $(srcdir)/fold-const.c $(srcdir)/function.c \
   $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \
   $(srcdir)/profile.c $(srcdir)/ra-build.c $(srcdir)/regclass.c \
-  $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c $(srcdir)/langhooks.c \
+  $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c \
   $(srcdir)/sdbout.c $(srcdir)/stmt.c $(srcdir)/stor-layout.c \
   $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \
   $(srcdir)/tree-mudflap.c $(srcdir)/tree-flow.h \
index b6abc3ccc940f3d0848430372b859b305f0c3f50..56351512ff48cea6abad991388694247706ba86d 100644 (file)
@@ -6576,22 +6576,6 @@ make_pointer_declarator (tree type_quals_attrs, tree target)
   return build1 (INDIRECT_REF, quals, itarget);
 }
 
-/* A wrapper around lhd_set_decl_assembler_name that gives static
-   variables their C names if they are at file scope and only one
-   translation unit is being compiled, for backwards compatibility
-   with certain bizarre assembler hacks (like crtstuff.c).  */
-
-void
-c_static_assembler_name (tree decl)
-{
-  if (num_in_fnames == 1
-      && !TREE_PUBLIC (decl) && DECL_CONTEXT (decl)
-      && TREE_CODE (DECL_CONTEXT (decl)) == TRANSLATION_UNIT_DECL)
-    SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl));
-  else
-    lhd_set_decl_assembler_name (decl);
-}
-
 /* Perform final processing on file-scope data.  */
 static void
 c_write_global_declarations_1 (tree globals)
index 14ffea6972be530d4c0439e3fc6cff8d7a6a8a83..f58a89905876ecbd575c168c3dbde7cfb63eb597 100644 (file)
@@ -76,8 +76,6 @@ enum c_language_kind c_language = clk_c;
 #define LANG_HOOKS_UNSAFE_FOR_REEVAL c_common_unsafe_for_reeval
 #undef LANG_HOOKS_STATICP
 #define LANG_HOOKS_STATICP c_staticp
-#undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
-#define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME c_static_assembler_name
 #undef LANG_HOOKS_NO_BODY_BLOCKS
 #define LANG_HOOKS_NO_BODY_BLOCKS true
 #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
index ad731d422a438c78e43def400df0fed8fabfa349..6083b1fbafaf891a72147af9bd5ce765a6e9807b 100644 (file)
@@ -189,7 +189,6 @@ extern tree start_struct (enum tree_code, tree);
 extern void store_parm_decls (void);
 extern tree xref_tag (enum tree_code, tree);
 extern int c_expand_decl (tree);
-extern void c_static_assembler_name (tree);
 extern tree make_pointer_declarator (tree, tree);
 
 /* in c-objc-common.c */
index a760aa96beb6eb737fcf004aa99ebc36f7a35b91..77aaf45568bac308386c4b16b186bbcb26ceedfa 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-05  Zack Weinberg  <zack@codesourcery.com>
+
+       * decl.c (cxx_init_decl_processing): Call
+       build_common_tree_nodes before creating the global NAMESPACE_DECL.
+
 2004-07-05  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
 
        PR c++/2518
 
 2004-06-27  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
-       PR c++/14123    
+       PR c++/14123
        * cxx-pretty-print.c (pp_cxx_ptr_operator): Properly put
        paranthesis in case of pointers to array members.
        * error.c (dump_type_prefix): Likewise.
        (dump_type_suffix): Maybe issue a whitespace when printing
-       ARRAY_TYPE. 
+       ARRAY_TYPE.
 
 2004-06-27  Mark Mitchell  <mark@codesourcery.com>
 
        (pp_non_consecutive_character): Likewise.
        (dump_scope): Use pp_cxx_colon_colon.
        (dump_template_parameter): Use pp_cxx_identifier,
-       pp_cxx_tree_identifier and pp_cxx_whitespace. 
+       pp_cxx_tree_identifier and pp_cxx_whitespace.
        (dump_templat_bindings): Replace use of pp_string with sequence
        of pp_cxx_whitespace and pp_equal.
        (dump_type): Use pp_cxx_identifier, pp_cxx_tree_identifier,
        pp_cxx_colon_colon, pp_cxx_whitespace throughout.  Don't set
-       padding here. 
+       padding here.
        (dump_aggr_type): Use pp_cxx_identifier amd pp_cxx_tree_identifier.
        (dump_type_prefix): Don't set padding.  Use pp_cxx_whitespace,
        pp_cxx_left_parent, pp_cxx_colon_colon and pp_cxx_star troughout.
        (dump_template_decl): Likewise.
        (dump_function_decl): Likewise.  Set padding as appropriate.
        (dump_parameters): Use pp_cxx_left_paren, pp_cxx_identifier and
-       pp_cxx_right_paren. 
+       pp_cxx_right_paren.
        (dump_exception_spec): Likewise.
        (dump_function_name): Use pp_cxx_tree_identifier and
-       pp_cxx_identifier. 
+       pp_cxx_identifier.
        (dump_template_parms): Use pp_cxx_begin_template_argument_list and
        pp_cxx_end_template_argument_list.
        (dump_expr): Use pp_cxx_left_paren, pp_cxx_right_paren,
        pp_cxx_colon_colon, pp_cxx_identifier, pp_cxx_tree_identifier and
-       pp_cxx_whitespace throughout. 
+       pp_cxx_whitespace throughout.
        (dump_binary_op): Use pp_cxx_whitespace, pp_cxx_left_paren and
-       pp_cxx_right_paren. 
+       pp_cxx_right_paren.
        (dump_unary_op): Likewise.
        (reinit_cxx_pp): New function.
        (type_as_string); Use it.
        (cp_parser_set_decl_spec_type): Likewise.
        * pt.c: Do not include lex.h.
        * semantics.c: Likewise.
-       (finish_member_class_template): Remove. 
-       
+       (finish_member_class_template): Remove.
+
 2004-06-23  Roger Sayle  <roger@eyesopen.com>
 
        * call.c (build_cxx_call): Don't call expand_tree_builtin.  No
index e591a257846b957d8bec31ee1c82b3acd196d09e..bee0402b954a68339094332b0a394496020cefeb 100644 (file)
@@ -2887,6 +2887,8 @@ cxx_init_decl_processing (void)
   tree void_ftype;
   tree void_ftype_ptr;
 
+  build_common_tree_nodes (flag_signed_char);
+
   /* Create all the identifiers we need.  */
   initialize_predefined_identifiers ();
 
@@ -2926,8 +2928,6 @@ cxx_init_decl_processing (void)
   /* Initially, C.  */
   current_lang_name = lang_name_c;
 
-  build_common_tree_nodes (flag_signed_char);
-
   error_mark_list = build_tree_list (error_mark_node, error_mark_node);
   TREE_TYPE (error_mark_list) = error_mark_node;
 
index 13be0aaf24c5b318f966753f06f0d5d77ed33ce6..1b2a84e20ed4707282bd118d0d52395511d3777a 100644 (file)
@@ -157,11 +157,6 @@ lhd_warn_unused_global_decl (tree decl)
   return true;
 }
 
-/* Number for making the label on the next
-   static variable internal to a function.  */
-
-static GTY(()) int var_labelno;
-
 /* Set the DECL_ASSEMBLER_NAME for DECL.  */
 void
 lhd_set_decl_assembler_name (tree decl)
@@ -184,18 +179,33 @@ lhd_set_decl_assembler_name (tree decl)
 
          Can't use just the variable's own name for a variable whose
         scope is less than the whole compilation.  Concatenate a
-        distinguishing number.  */
-      if (!TREE_PUBLIC (decl) && DECL_CONTEXT (decl))
+        distinguishing number.  If the decl is at block scope, the
+        number assigned is the DECL_UID; if the decl is at file
+        scope, the number is the DECL_UID of the surrounding
+        TRANSLATION_UNIT_DECL, except for the T_U_D with UID 0.
+        Those (the file-scope internal-linkage declarations from the
+        first input file) get no suffix, which is consistent with
+        what has historically been done for file-scope declarations
+        with internal linkage.  */
+      if (TREE_PUBLIC (decl)
+         || DECL_CONTEXT (decl) == NULL_TREE
+         || (TREE_CODE (DECL_CONTEXT (decl)) == TRANSLATION_UNIT_DECL
+             && DECL_UID (DECL_CONTEXT (decl)) == 0))
+       SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl));
+      else
        {
          const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
          char *label;
-         
-         ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
-         var_labelno++;
+         unsigned int uid;
+
+         if (TREE_CODE (DECL_CONTEXT (decl)) == TRANSLATION_UNIT_DECL)
+           uid = DECL_UID (DECL_CONTEXT (decl));
+         else
+           uid = DECL_UID (decl);
+
+         ASM_FORMAT_PRIVATE_NAME (label, name, uid);
          SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label));
        }
-      else
-       SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl));
     }
   else
     /* Nobody should ever be asking for the DECL_ASSEMBLER_NAME of
@@ -581,5 +591,3 @@ lhd_make_node (enum tree_code code)
 {
   return make_node (code);
 }
-
-#include "gt-langhooks.h"
index b59a47b1bc0c3f91586b3c3e24015e727a73bce3..fde6cbd0907385f919a13be6f1f9163d44176d20 100644 (file)
@@ -73,8 +73,6 @@ enum c_language_kind c_language = clk_objc;
 #define LANG_HOOKS_UNSAFE_FOR_REEVAL c_common_unsafe_for_reeval
 #undef LANG_HOOKS_STATICP
 #define LANG_HOOKS_STATICP c_staticp
-#undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
-#define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME c_static_assembler_name
 #undef LANG_HOOKS_NO_BODY_BLOCKS
 #define LANG_HOOKS_NO_BODY_BLOCKS true
 #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
index 5a4873c80ce3c54f0a013cf367f4d8d3d148d2b8..b54a63fc45ae30ad43a0717cbbdfd408bc9b665f 100644 (file)
@@ -92,6 +92,7 @@ static bool flag_peel_loops_set, flag_branch_probabilities_set;
 /* Input file names.  */
 const char **in_fnames;
 unsigned num_in_fnames;
+unsigned cur_in_fname;
 
 static size_t find_opt (const char *, int);
 static int common_handle_option (size_t scode, const char *arg, int value);
index 17b2bca3f84fc6e0f41bc913fc13089fa64ca69a..69eb3b8a55d66f6b1e932da7c16395bcf313fb7f 100644 (file)
@@ -57,4 +57,8 @@ extern const char **in_fnames;
 
 extern unsigned num_in_fnames;
 
+/* Current input filename index.  */
+
+extern unsigned cur_in_fname;
+
 #endif
index a4bbd668bb324365def7ef001875dfab66649270..9183a5cc86416a76476d357602d976b40e93c0df 100644 (file)
@@ -48,6 +48,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "tree-iterator.h"
 #include "basic-block.h"
 #include "tree-flow.h"
+#include "opts.h"
 
 /* obstack.[ch] explicitly declined to prototype this.  */
 extern int _obstack_allocated_p (struct obstack *h, void *obj);
@@ -309,7 +310,10 @@ make_node_stat (enum tree_code code MEM_STAT_DECL)
       DECL_USER_ALIGN (t) = 0;
       DECL_IN_SYSTEM_HEADER (t) = in_system_header;
       DECL_SOURCE_LOCATION (t) = input_location;
-      DECL_UID (t) = next_decl_uid++;
+      if (code == TRANSLATION_UNIT_DECL)
+       DECL_UID (t) = cur_in_fname;
+      else
+       DECL_UID (t) = next_decl_uid++;
 
       /* We have not yet computed the alias set for this declaration.  */
       DECL_POINTER_ALIAS_SET (t) = -1;
@@ -382,7 +386,7 @@ copy_node_stat (tree node MEM_STAT_DECL)
   TREE_VISITED (t) = 0;
   t->common.ann = 0;
 
-  if (TREE_CODE_CLASS (code) == 'd')
+  if (TREE_CODE_CLASS (code) == 'd' && code != TRANSLATION_UNIT_DECL)
     DECL_UID (t) = next_decl_uid++;
   else if (TREE_CODE_CLASS (code) == 't')
     {
@@ -5310,6 +5314,14 @@ make_or_reuse_type (unsigned size, int unsignedp)
 void
 build_common_tree_nodes (int signed_char)
 {
+  /* This function is called after command line parsing is complete,
+     but before any DECL nodes should have been created.  Therefore,
+     now is the appropriate time to adjust next_decl_uid so that the
+     range 0 .. num_in_fnames-1 is reserved for TRANSLATION_UNIT_DECLs.  */
+  if (next_decl_uid)
+    abort ();
+  next_decl_uid = num_in_fnames;
+
   error_mark_node = make_node (ERROR_MARK);
   TREE_TYPE (error_mark_node) = error_mark_node;