aboutsummaryrefslogtreecommitdiff
path: root/gcc/langhooks.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2004-07-05 17:28:37 +0000
committerZack Weinberg <zack@gcc.gnu.org>2004-07-05 17:28:37 +0000
commit6de66680858ea8af546c6d74bd77f236e234607a (patch)
tree3123dea64dc9e9124841c660cee9869693ee9f00 /gcc/langhooks.c
parentab0e8f666d04db063342c726ea95a91401ec7545 (diff)
downloadgcc-6de66680858ea8af546c6d74bd77f236e234607a.zip
gcc-6de66680858ea8af546c6d74bd77f236e234607a.tar.gz
gcc-6de66680858ea8af546c6d74bd77f236e234607a.tar.bz2
langhooks.c: Don't include gt-langhooks.h.
* 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
Diffstat (limited to 'gcc/langhooks.c')
-rw-r--r--gcc/langhooks.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index 13be0aa..1b2a84e 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -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"