diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-10-14 21:29:40 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-10-14 21:29:40 +0000 |
commit | 1028c9f0afc1cc5f4951b39b7067fa57c1fea07b (patch) | |
tree | 67145dd0903f4a08427f127d015b5f7ebdceaf1e /lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 663b5a0be7261c29bc4c526a71cffcfa02d4153e (diff) |
Give explicit and implicit instantiations of static data members of
class templates the proper linkage.
Daniel, please look over the CodeGenModule bits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84140 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 28c0fa6ab9..060cc55983 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1191,14 +1191,14 @@ void Sema::InstantiateStaticDataMemberDefinition( } // Never instantiate an explicit specialization. - if (Def->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) + if (Var->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) return; // C++0x [temp.explicit]p9: // Except for inline functions, other explicit instantiation declarations // have the effect of suppressing the implicit instantiation of the entity // to which they refer. - if (Def->getTemplateSpecializationKind() + if (Var->getTemplateSpecializationKind() == TSK_ExplicitInstantiationDeclaration) return; @@ -1218,12 +1218,14 @@ void Sema::InstantiateStaticDataMemberDefinition( DeclContext *PreviousContext = CurContext; CurContext = Var->getDeclContext(); + VarDecl *OldVar = Var; Var = cast_or_null<VarDecl>(SubstDecl(Def, Var->getDeclContext(), getTemplateInstantiationArgs(Var))); - CurContext = PreviousContext; if (Var) { + Var->setPreviousDeclaration(OldVar); + Var->setTemplateSpecializationKind(OldVar->getTemplateSpecializationKind()); DeclGroupRef DG(Var); Consumer.HandleTopLevelDecl(DG); } |