diff options
author | Geoffrey Keating <geoffk@apple.com> | 2003-07-17 21:52:51 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 2003-07-17 21:52:51 +0000 |
commit | 26e0dcb3262e0b0dae53d60ef6a8ea3cce6b2e40 (patch) | |
tree | 29814f71f7c3a3908af1f0248cd905e9f4e13d0f /gcc/langhooks.c | |
parent | 89e9faee226678f1298961f6ef75243f2c1b3b2c (diff) | |
download | gcc-26e0dcb3262e0b0dae53d60ef6a8ea3cce6b2e40.zip gcc-26e0dcb3262e0b0dae53d60ef6a8ea3cce6b2e40.tar.gz gcc-26e0dcb3262e0b0dae53d60ef6a8ea3cce6b2e40.tar.bz2 |
re PR middle-end/11498 (asm can't be used to give a variable its own name)
PR 11498
* Makefile.in (c-opts.o): Add $(LANGHOOKS_DEF_H).
(langhooks.o): Add $(GGC_H), gt-langhooks.h.
(GTFILES): Add langhooks.c.
(gt-langhooks.h): New.
* c-common.h (c_static_assembler_name): Prototype.
* c-lang.c (LANG_HOOKS_SET_DECL_ASSEMBLER_NAME): Define.
* objc/objc-lang.c (LANG_HOOKS_SET_DECL_ASSEMBLER_NAME): Define.
* c-opts.c: Include langhooks-def.h.
(c_static_assembler_name): New.
* langhooks.c: Include ggc.h. Include gt-langhooks.h.
(var_labelno): New.
(lhd_set_decl_assembler_name): Give static objects with context
unique names.
* varasm.c (var_labelno): Delete.
(make_decl_rtl): Don't change the assembler name once it's set.
From-SVN: r69527
Diffstat (limited to 'gcc/langhooks.c')
-rw-r--r-- | gcc/langhooks.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 6b0c5bd..e86cfb2 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA. */ #include "flags.h" #include "langhooks.h" #include "langhooks-def.h" +#include "ggc.h" /* Do nothing; in many cases the default hook. */ @@ -136,6 +137,11 @@ 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) @@ -149,12 +155,28 @@ lhd_set_decl_assembler_name (tree decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl) || TREE_PUBLIC (decl)))) - /* By default, assume the name to use in assembly code is the - same as that used in the source language. (That's correct - for C, and GCC used to set DECL_ASSEMBLER_NAME to the same - value as DECL_NAME in build_decl, so this choice provides - backwards compatibility with existing front-ends. */ - SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl)); + { + /* By default, assume the name to use in assembly code is the + same as that used in the source language. (That's correct + for C, and GCC used to set DECL_ASSEMBLER_NAME to the same + value as DECL_NAME in build_decl, so this choice provides + backwards compatibility with existing front-ends. + + 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)) + { + const char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); + char *label; + + ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno); + var_labelno++; + 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 these DECLs -- unless they're in language-dependent code, in @@ -456,3 +478,5 @@ write_global_declarations (void) /* Clean up. */ free (vec); } + +#include "gt-langhooks.h" |