diff options
author | Jakub Jelinek <jakub@redhat.com> | 2010-01-14 23:41:02 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2010-01-14 23:41:02 +0100 |
commit | 5b1cbe1453663b9abd6df089c2882071f2335fb2 (patch) | |
tree | cce96a1384605a32918e26237bbc9b895bbda31d /gcc/varasm.c | |
parent | 7d2a845248174754046207cb2e634b64aea86b01 (diff) | |
download | gcc-5b1cbe1453663b9abd6df089c2882071f2335fb2.zip gcc-5b1cbe1453663b9abd6df089c2882071f2335fb2.tar.gz gcc-5b1cbe1453663b9abd6df089c2882071f2335fb2.tar.bz2 |
re PR c++/42608 (Undefined reference not reported in case of explicit template instantiation)
PR c++/42608
* varasm.c (declare_weak): Add weak attribute to decl if it
doesn't have one already.
(assemble_external): Only add decls to weak_decls if they also
have weak attribute.
* g++.dg/template/instantiate11.C: New test.
From-SVN: r155919
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index fab6219..7ed5905 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -2337,13 +2337,15 @@ assemble_external (tree decl ATTRIBUTE_UNUSED) /* We want to output annotation for weak and external symbols at very last to check if they are references or not. */ - if (SUPPORTS_WEAK && DECL_WEAK (decl) + if (SUPPORTS_WEAK + && DECL_WEAK (decl) /* TREE_STATIC is a weird and abused creature which is not generally the right test for whether an entity has been locally emitted, inlined or otherwise not-really-extern, but for declarations that can be weak, it happens to be match. */ && !TREE_STATIC (decl) + && lookup_attribute ("weak", DECL_ATTRIBUTES (decl)) && value_member (decl, weak_decls) == NULL_TREE) weak_decls = tree_cons (NULL, decl, weak_decls); @@ -5227,6 +5229,9 @@ declare_weak (tree decl) warning (0, "weak declaration of %q+D not supported", decl); mark_weak (decl); + if (!lookup_attribute ("weak", DECL_ATTRIBUTES (decl))) + DECL_ATTRIBUTES (decl) + = tree_cons (get_identifier ("weak"), NULL, DECL_ATTRIBUTES (decl)); } static void |