2003-07-17 Geoffrey Keating <geoffk@apple.com>
+ 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.
+
* c-opts.c (this_input_filename): New.
(finish_options): Take new parameter, name of file being compiled.
Update callers. Set this_input_filename.
c-opts.o : c-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
c-pragma.h flags.h toplev.h langhooks.h tree-inline.h diagnostic.h \
- intl.h debug.h $(C_COMMON_H) opts.h options.h $(PARAMS_H)
+ intl.h debug.h $(C_COMMON_H) opts.h options.h $(PARAMS_H) \
+ $(LANGHOOKS_DEF_H)
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
$< $(OUTPUT_OPTION) @TARGET_SYSTEM_ROOT_DEFINE@
langhooks.o : langhooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) toplev.h \
tree-inline.h $(RTL_H) insn-config.h $(INTEGRATE_H) langhooks.h \
- $(LANGHOOKS_DEF_H) flags.h
+ $(LANGHOOKS_DEF_H) flags.h $(GGC_H) gt-langhooks.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
$(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)/reg-stack.c $(srcdir)/cfglayout.c $(srcdir)/langhooks.c \
$(srcdir)/sdbout.c $(srcdir)/stmt.c $(srcdir)/stor-layout.c \
$(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \
$(out_file) \
gt-dwarf2out.h gt-ra-build.h gt-reg-stack.h gt-dwarf2asm.h \
gt-dbxout.h gt-c-common.h gt-c-decl.h gt-c-parse.h \
gt-c-pragma.h gt-c-objc-common.h gtype-c.h gt-input.h gt-cfglayout.h \
-gt-stringpool.h : s-gtype ; @true
+gt-stringpool.h gt-langhooks.h : s-gtype ; @true
gtyp-gen.h: Makefile
echo "/* This file is machine generated. Do not edit. */" > tmp-gtyp.h
extern void set_Wformat (int);
extern tree handle_format_attribute (tree *, tree, tree, int, bool *);
extern tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
+extern void c_static_assembler_name (tree);
extern void c_common_insert_default_attributes (tree);
extern int c_common_handle_option (size_t code, const char *arg, int value);
extern void c_common_handle_filename (const char *filename);
#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
#include "debug.h" /* For debug_hooks. */
#include "opts.h"
#include "options.h"
+#include "langhooks-def.h"
#ifndef DOLLARS_IN_IDENTIFIERS
# define DOLLARS_IN_IDENTIFIERS true
fatal_error ("when writing output to %s: %m", out_fname);
}
+/* A wrapper around lhd_set_decl_assembler_name that gives static
+ variables their C names if they are at the top level and only one
+ translation unit is being compiled, for backwards compatibility
+ with certain bizzare assembler hacks (like crtstuff.c). */
+
+void
+c_static_assembler_name (tree decl)
+{
+ if (num_in_fnames == 1
+ && TREE_STATIC (decl) && !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);
+}
+
/* Either of two environment variables can specify output of
dependencies. Their value is either "OUTPUT_FILE" or "OUTPUT_FILE
DEPS_TARGET", where OUTPUT_FILE is the file to write deps info to
#include "flags.h"
#include "langhooks.h"
#include "langhooks-def.h"
+#include "ggc.h"
/* Do nothing; in many cases the default hook. */
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)
&& (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
/* Clean up. */
free (vec);
}
+
+#include "gt-langhooks.h"
#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
+2003-07-17 Geoffrey Keating <geoffk@apple.com>
+
+ PR 11498
+ * gcc.c-torture/compile/mangle-1.c: New file.
+
2003-07-17 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/7809
--- /dev/null
+int foo(void)
+{
+ static int x asm ("x") = 3;
+ return x++;
+}
+
+int X2 asm ("x.0") = 4;
+int X3 asm ("_x.0") = 5;
+
static GTY(()) int const_labelno;
-/* Number for making the label on the next
- static variable internal to a function. */
-
-static GTY(()) int var_labelno;
-
/* Carry information from ASM_DECLARE_OBJECT_NAME
to ASM_FINISH_DECLARE_OBJECT. */
void
make_decl_rtl (tree decl, const char *asmspec)
{
- int top_level = (DECL_CONTEXT (decl) == NULL_TREE
- || (TREE_CODE (DECL_CONTEXT (decl))
- == TRANSLATION_UNIT_DECL));
const char *name = 0;
- const char *new_name = 0;
int reg_number;
rtx x;
return;
}
- new_name = name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-
reg_number = decode_reg_name (asmspec);
if (reg_number == -2)
{
char *starred = alloca (strlen (asmspec) + 2);
starred[0] = '*';
strcpy (starred + 1, asmspec);
- new_name = starred;
+ SET_DECL_ASSEMBLER_NAME (decl, get_identifier (starred));
}
+ name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+
if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
{
/* First detect errors in declaring global registers. */
if (TREE_CODE (decl) == VAR_DECL && DECL_WEAK (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
- && name == IDENTIFIER_POINTER (DECL_NAME (decl)))
- {
- char *label;
-
- ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
- var_labelno++;
- new_name = label;
- }
-
- if (name != new_name)
- {
- SET_DECL_ASSEMBLER_NAME (decl, get_identifier (new_name));
- name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
- }
-
x = gen_rtx_SYMBOL_REF (Pmode, name);
SYMBOL_REF_WEAK (x) = DECL_WEAK (decl);
SYMBOL_REF_DECL (x) = decl;