From 116f30c3fe6af8ea6211f5cf8e0ac3b67fee1f18 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Fri, 24 Sep 2010 13:21:30 +0000 Subject: [PATCH] c-decl.c (pop_scope): Always set file-scope DECL_CONTEXT. 2010-09-24 Richard Guenther * c-decl.c (pop_scope): Always set file-scope DECL_CONTEXT. Make sure to not call set_type_context with error_mark_node. * langhooks.c (lhd_set_decl_assembler_name): Use DECL_FILE_SCOPE_P. * gcc.dg/lto/20091006-2_0.c: Prune warnings. From-SVN: r164591 --- gcc/ChangeLog | 6 ++++++ gcc/c-decl.c | 13 ++++++------- gcc/langhooks.c | 2 +- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/lto/20091006-2_0.c | 1 + 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 75d35baf4522..d8c5125c17cb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-09-24 Richard Guenther + + * c-decl.c (pop_scope): Always set file-scope DECL_CONTEXT. + Make sure to not call set_type_context with error_mark_node. + * langhooks.c (lhd_set_decl_assembler_name): Use DECL_FILE_SCOPE_P. + 2010-09-24 Richard Guenther * Makefile.in (OBJS-onestep): Remove. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index f8be06b479f5..35f3d29664e0 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1203,15 +1203,14 @@ pop_scope (void) DECL_CHAIN (extp) = BLOCK_VARS (block); BLOCK_VARS (block) = extp; } - /* 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) + /* If this is the file scope set DECL_CONTEXT of each decl to + the TRANSLATION_UNIT_DECL. This makes same_translation_unit_p + work. */ + if (scope == file_scope) { DECL_CONTEXT (p) = context; - if (TREE_CODE (p) == TYPE_DECL) + if (TREE_CODE (p) == TYPE_DECL + && TREE_TYPE (p) != error_mark_node) set_type_context (TREE_TYPE (p), context); } diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 7a585085ef04..ce7522b1585b 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -176,7 +176,7 @@ lhd_set_decl_assembler_name (tree decl) is less than the whole compilation. Concatenate a distinguishing number - we use the DECL_UID. */ - if (TREE_PUBLIC (decl) || DECL_CONTEXT (decl) == NULL_TREE) + if (TREE_PUBLIC (decl) || DECL_FILE_SCOPE_P (decl)) id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl)); else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e3c92a3ccb6e..ea031cc25714 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-09-24 Richard Guenther + + * gcc.dg/lto/20091006-2_0.c: Prune warnings. + 2010-09-24 Marcus Shawcroft * g++.dg/debug/dwarf2/nested-2.C: Permit the ARM @ character diff --git a/gcc/testsuite/gcc.dg/lto/20091006-2_0.c b/gcc/testsuite/gcc.dg/lto/20091006-2_0.c index f8189920cfda..abe12c40c68c 100644 --- a/gcc/testsuite/gcc.dg/lto/20091006-2_0.c +++ b/gcc/testsuite/gcc.dg/lto/20091006-2_0.c @@ -1,4 +1,5 @@ /* { dg-lto-do link } */ +/* { dg-extra-ld-options "-w" } */ extern int a[10]; int main() { return 0; }