diff options
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ipa.c | 30 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr43288.c | 1 | ||||
-rw-r--r-- | gcc/varasm.c | 34 |
5 files changed, 61 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3ee158eeba6..12fb62697fe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2010-03-10 Jan Hubicka <jh@suse.cz> + + PR c/43288 + * ipa.c (function_and_variable_visibility) Normalize COMMON bits. + * varasm.c (get_variable_section): Don't do that here... + (make_decl_rtl): ... and here. + (do_assemble_alias): Produce decl RTL. + (assemble_alias): Likewise. + 2010-03-10 Jakub Jelinek <jakub@redhat.com> PR debug/43290 diff --git a/gcc/ipa.c b/gcc/ipa.c index 63de1d99d44..f81d41a4a28 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -407,12 +407,38 @@ function_and_variable_visibility (bool whole_program) && !DECL_EXTERNAL (node->decl) && !node->local.externally_visible); } + for (vnode = varpool_nodes; vnode; vnode = vnode->next) + { + /* weak flag makes no sense on local variables. */ + gcc_assert (!DECL_WEAK (vnode->decl) + || TREE_PUBLIC (vnode->decl) || DECL_EXTERNAL (vnode->decl)); + /* In several cases declarations can not be common: + + - when declaration has initializer + - when it is in weak + - when it has specific section + - when it resides in non-generic address space. + - if declaration is local, it will get into .local common section + so common flag is not needed. Frontends still produce these in + certain cases, such as for: + + static int a __attribute__ ((common)) + + Canonicalize things here and clear the redundant flag. */ + if (DECL_COMMON (vnode->decl) + && (!(TREE_PUBLIC (vnode->decl) || DECL_EXTERNAL (vnode->decl)) + || (DECL_INITIAL (vnode->decl) + && DECL_INITIAL (vnode->decl) != error_mark_node) + || DECL_WEAK (vnode->decl) + || DECL_SECTION_NAME (vnode->decl) != NULL + || ! (ADDR_SPACE_GENERIC_P + (TYPE_ADDR_SPACE (TREE_TYPE (vnode->decl)))))) + DECL_COMMON (vnode->decl) = 0; + } for (vnode = varpool_nodes_queue; vnode; vnode = vnode->next_needed) { if (!vnode->finalized) continue; - gcc_assert ((!DECL_WEAK (vnode->decl) && !DECL_COMMON (vnode->decl)) - || TREE_PUBLIC (vnode->decl) || DECL_EXTERNAL (vnode->decl)); if (vnode->needed && (DECL_COMDAT (vnode->decl) || TREE_PUBLIC (vnode->decl)) && (!whole_program diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7c29203abc9..ebabe972e10 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-03-10 Jan Hubicka <jh@suse.cz> + + * gcc.dg/compile/pr43288.c: New test. + 2010-03-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * g++.old-deja/g++.pt/asm1.C: Don't detect pic via looking for the @@ -6,7 +10,7 @@ * gcc.c-torture/compile/20000804-1.c: Likewise. * gcc.target/i386/clobbers.c: Likewise. -2010-03-10 Tobias Burnus <burnus@net-b.de +2010-03-10 Tobias Burnus <burnus@net-b.de> PR fortran/43303 * gfortran.dg/c_assoc_3.f90: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr43288.c b/gcc/testsuite/gcc.c-torture/compile/pr43288.c new file mode 100644 index 00000000000..73af0d9ec0a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr43288.c @@ -0,0 +1 @@ +static int a __attribute__ ((common)); diff --git a/gcc/varasm.c b/gcc/varasm.c index 310647e7e2b..6b8222f8e9a 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1174,12 +1174,13 @@ get_variable_section (tree decl, bool prefer_noswitch_p) if (TREE_TYPE (decl) != error_mark_node) as = TYPE_ADDR_SPACE (TREE_TYPE (decl)); - /* If the decl has been given an explicit section name, or it resides - in a non-generic address space, then it isn't common, and shouldn't - be handled as such. */ - if (DECL_COMMON (decl) && DECL_SECTION_NAME (decl) == NULL - && ADDR_SPACE_GENERIC_P (as)) + if (DECL_COMMON (decl)) { + /* If the decl has been given an explicit section name, or it resides + in a non-generic address space, then it isn't common, and shouldn't + be handled as such. */ + gcc_assert (DECL_SECTION_NAME (decl) == NULL + && ADDR_SPACE_GENERIC_P (as)); if (DECL_THREAD_LOCAL_P (decl)) return tls_comm_section; /* This cannot be common bss for an emulated TLS object without @@ -1434,15 +1435,16 @@ make_decl_rtl (tree decl) /* Specifying a section attribute on a variable forces it into a non-.bss section, and thus it cannot be common. */ - if (TREE_CODE (decl) == VAR_DECL - && DECL_SECTION_NAME (decl) != NULL_TREE - && DECL_INITIAL (decl) == NULL_TREE - && DECL_COMMON (decl)) - DECL_COMMON (decl) = 0; + gcc_assert (!(TREE_CODE (decl) == VAR_DECL + && DECL_SECTION_NAME (decl) != NULL_TREE + && DECL_INITIAL (decl) == NULL_TREE + && DECL_COMMON (decl)) + || !DECL_COMMON (decl)); /* Variables can't be both common and weak. */ - if (TREE_CODE (decl) == VAR_DECL && DECL_WEAK (decl)) - DECL_COMMON (decl) = 0; + gcc_assert (TREE_CODE (decl) != VAR_DECL + || !DECL_WEAK (decl) + || !DECL_COMMON (decl)); if (use_object_blocks_p () && use_blocks_for_decl_p (decl)) x = create_block_symbol (name, get_block_for_decl (decl), -1); @@ -5507,6 +5509,10 @@ do_assemble_alias (tree decl, tree target) if (TREE_ASM_WRITTEN (decl)) return; + /* We must force creation of DECL_RTL for debug info generation, even though + we don't use it here. */ + make_decl_rtl (decl); + TREE_ASM_WRITTEN (decl) = 1; TREE_ASM_WRITTEN (DECL_ASSEMBLER_NAME (decl)) = 1; @@ -5724,10 +5730,6 @@ assemble_alias (tree decl, tree target) # endif #endif } - - /* We must force creation of DECL_RTL for debug info generation, even though - we don't use it here. */ - make_decl_rtl (decl); TREE_USED (decl) = 1; /* A quirk of the initial implementation of aliases required that the user |