aboutsummaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2011-01-25 00:07:25 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2011-01-24 23:07:25 +0000
commite8ba94fc1fe2d7d96bfc2fa5293c1bb0b86a5b52 (patch)
tree22cf10e472b5ae4e466e1ea53c1f2933f186775d /gcc/varasm.c
parent71c67403a2faf26b64c2bf525e392953a2707aa3 (diff)
downloadgcc-e8ba94fc1fe2d7d96bfc2fa5293c1bb0b86a5b52.zip
gcc-e8ba94fc1fe2d7d96bfc2fa5293c1bb0b86a5b52.tar.gz
gcc-e8ba94fc1fe2d7d96bfc2fa5293c1bb0b86a5b52.tar.bz2
re PR c/21659 ([unit-at-a-time] "weak declaration must precede definition" error missing at >= O1)
PR c/21659 * doc/extend.texi (weak pragma): Drop claim that it must appear before definition. * varasm.c (merge_weak, declare_weak): Only sanity check that DECL is not output at a time it is declared weak. From-SVN: r169184
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index bbebd87..afd9942 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -5139,20 +5139,16 @@ merge_weak (tree newdecl, tree olddecl)
/* NEWDECL is weak, but OLDDECL is not. */
/* If we already output the OLDDECL, we're in trouble; we can't
- go back and make it weak. This error cannot be caught in
- declare_weak because the NEWDECL and OLDDECL was not yet
- been merged; therefore, TREE_ASM_WRITTEN was not set. */
- if (TREE_ASM_WRITTEN (olddecl))
- error ("weak declaration of %q+D must precede definition",
- newdecl);
+ go back and make it weak. This should never happen in
+ unit-at-a-time compilation. */
+ gcc_assert (!TREE_ASM_WRITTEN (olddecl));
/* If we've already generated rtl referencing OLDDECL, we may
have done so in a way that will not function properly with
- a weak symbol. */
- else if (TREE_USED (olddecl)
- && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl)))
- warning (0, "weak declaration of %q+D after first use results "
- "in unspecified behavior", newdecl);
+ a weak symbol. Again in unit-at-a-time this should be
+ impossible. */
+ gcc_assert (!TREE_USED (olddecl)
+ || !TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl)));
if (TARGET_SUPPORTS_WEAK)
{
@@ -5184,10 +5180,9 @@ merge_weak (tree newdecl, tree olddecl)
void
declare_weak (tree decl)
{
+ gcc_assert (TREE_CODE (decl) != FUNCTION_DECL || !TREE_ASM_WRITTEN (decl));
if (! TREE_PUBLIC (decl))
error ("weak declaration of %q+D must be public", decl);
- else if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl))
- error ("weak declaration of %q+D must precede definition", decl);
else if (!TARGET_SUPPORTS_WEAK)
warning (0, "weak declaration of %q+D not supported", decl);