Commit 5b02f0e0 by Zack Weinberg

c-decl.c (pop_scope): Do not set DECL_CONTEXT on file-scope decls when...

	* c-decl.c (pop_scope): Do not set DECL_CONTEXT on file-scope
	decls when there is only one input translation unit.
	* langhooks.c (lhd_set_decl_assembler_name): Partially revert
	change of 2004-07-05; do not treat declarations with
	DECL_CONTEXT a TRANSLATION_UNIT_DECL specially.
	* opts.c (cur_in_fname): Delete.
	* opts.h: Likewise.
	* tree.c: Revert changes of 2004-07-05; no special treatment
	for TRANSLATION_UNIT_DECLs.
	* Makefile.in (tree.o): Update dependencies.

From-SVN: r84306
parent 95bcca47
2004-07-08 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (pop_scope): Do not set DECL_CONTEXT on file-scope
decls when there is only one input translation unit.
* langhooks.c (lhd_set_decl_assembler_name): Partially revert
change of 2004-07-05; do not treat declarations with
DECL_CONTEXT a TRANSLATION_UNIT_DECL specially.
* opts.c (cur_in_fname): Delete.
* opts.h: Likewise.
* tree.c: Revert changes of 2004-07-05; no special treatment
for TRANSLATION_UNIT_DECLs.
* Makefile.in (tree.o): Update dependencies.
2004-07-08 Roger Sayle <roger@eyesopen.com>
* builtins.c (fold_builtin_strcpy): Merge functionality from
......
......@@ -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) 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) opts.h
real.h gt-tree.h tree-iterator.h $(BASIC_BLOCK_H) $(TREE_FLOW_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
......
......@@ -760,10 +760,12 @@ pop_scope (void)
TREE_CHAIN (p) = BLOCK_VARS (block);
BLOCK_VARS (block) = p;
}
/* If this is the file scope, must set DECL_CONTEXT on
these. Do so even for externals, so that
same_translation_unit_p works. */
if (scope == file_scope)
/* If this is the file scope, and we are processing more
than one translation unit in this compilation, set
DECL_CONTEXT of each decl to the TRANSLATION_UNIT_DECL.
This makes same_translation_unit_p work, and causes
static declarations to be given disambiguating suffixes. */
if (scope == file_scope && num_in_fnames > 1)
DECL_CONTEXT (p) = context;
/* Fall through. */
......
......@@ -179,31 +179,15 @@ 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 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))
distinguishing number - we use the DECL_UID. */
if (TREE_PUBLIC (decl) || DECL_CONTEXT (decl) == NULL_TREE)
SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl));
else
{
const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
char *label;
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);
ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label));
}
}
......
......@@ -92,7 +92,6 @@ 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);
......
......@@ -57,8 +57,4 @@ extern const char **in_fnames;
extern unsigned num_in_fnames;
/* Current input filename index. */
extern unsigned cur_in_fname;
#endif
......@@ -48,7 +48,6 @@ 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);
......@@ -310,9 +309,6 @@ 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;
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. */
......@@ -386,7 +382,7 @@ copy_node_stat (tree node MEM_STAT_DECL)
TREE_VISITED (t) = 0;
t->common.ann = 0;
if (TREE_CODE_CLASS (code) == 'd' && code != TRANSLATION_UNIT_DECL)
if (TREE_CODE_CLASS (code) == 'd')
DECL_UID (t) = next_decl_uid++;
else if (TREE_CODE_CLASS (code) == 't')
{
......@@ -5363,14 +5359,6 @@ 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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment