diff options
author | Mark Mitchell <mark@codesourcery.com> | 2005-01-31 06:16:54 +0000 |
---|---|---|
committer | Mark Mitchell <mark@codesourcery.com> | 2005-01-31 06:16:54 +0000 |
commit | b81192d6e980bd3f95695f04a29908d4df8a507c (patch) | |
tree | f7c2fcad7da81ca7390ed264d37a6079512631d9 /gcc/cp/decl.c | |
parent | a8647c1c31c1bccb24475aa50478588dfc973573 (diff) |
PR c++/19555
* cp-tree.h (DECL_USE_TEMPLATE): Expand documentation.
* decl.c (duplicate_decls): Do not discard
DECL_IMPLICIT_INSTANTIATION when merging declarations.
(start_decl): Do not SET_DECL_TEMPLATE_SPECIALIZATION for
variables that do not have DECL_USE_TEMPLATE.
PR c++/19555
* g++.dg/template/static10.C: New test.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@94469 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e2408e36b82..e72b183c6b6 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1669,6 +1669,13 @@ duplicate_decls (tree newdecl, tree olddecl) DECL_COMDAT (newdecl) |= DECL_COMDAT (olddecl); DECL_TEMPLATE_INSTANTIATED (newdecl) |= DECL_TEMPLATE_INSTANTIATED (olddecl); + /* If the OLDDECL is an implicit instantiation, then the NEWDECL + must be too. But, it may not yet be marked as such if the + caller has created NEWDECL, but has not yet figured out that + it is a redeclaration. */ + if (DECL_IMPLICIT_INSTANTIATION (olddecl) + && !DECL_USE_TEMPLATE (newdecl)) + SET_DECL_IMPLICIT_INSTANTIATION (newdecl); /* Don't really know how much of the language-specific values we should copy from old to new. */ DECL_IN_AGGR_P (newdecl) = DECL_IN_AGGR_P (olddecl); @@ -3695,10 +3702,15 @@ start_decl (const cp_declarator *declarator, /* cp_finish_decl sets DECL_EXTERNAL if DECL_IN_AGGR_P is set. */ DECL_IN_AGGR_P (decl) = 0; - if ((DECL_LANG_SPECIFIC (decl) && DECL_USE_TEMPLATE (decl)) + if (DECL_LANG_SPECIFIC (decl) && DECL_USE_TEMPLATE (decl) || CLASSTYPE_TEMPLATE_INSTANTIATION (context)) { - SET_DECL_TEMPLATE_SPECIALIZATION (decl); + /* Do not mark DECL as an explicit specialization if it was + not already marked as an instantiation; a declaration + should never be marked as a specialization unless we know + what template is being specialized. */ + if (DECL_LANG_SPECIFIC (decl) && DECL_USE_TEMPLATE (decl)) + SET_DECL_TEMPLATE_SPECIALIZATION (decl); /* [temp.expl.spec] An explicit specialization of a static data member of a template is a definition if the declaration includes an initializer; otherwise, it is a declaration. |