summaryrefslogtreecommitdiffstats
path: root/gcc/langhooks.c
diff options
context:
space:
mode:
authorgeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2003-07-17 21:52:51 +0000
committergeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2003-07-17 21:52:51 +0000
commita6df3a0e9417a01a9e1f9098acdc0e6646830254 (patch)
tree29814f71f7c3a3908af1f0248cd905e9f4e13d0f /gcc/langhooks.c
parent9f8e734884ccd7eef482d5acd474014b8b8ac832 (diff)
downloadppe42-gcc-a6df3a0e9417a01a9e1f9098acdc0e6646830254.tar.gz
ppe42-gcc-a6df3a0e9417a01a9e1f9098acdc0e6646830254.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69527 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/langhooks.c')
-rw-r--r--gcc/langhooks.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index 6b0c5bdba08..e86cfb2b553 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"
OpenPOWER on IntegriCloud