Change the context correctly when instantiating a static data member definition.

llvm-svn: 125517
This commit is contained in:
John McCall 2011-02-14 20:37:25 +00:00
parent c9987fbbfe
commit 2957e3ef49
2 changed files with 13 additions and 3 deletions

View File

@ -2434,13 +2434,13 @@ void Sema::InstantiateStaticDataMemberDefinition(
// Enter the scope of this instantiation. We don't use
// PushDeclContext because we don't have a scope.
DeclContext *PreviousContext = CurContext;
CurContext = Var->getDeclContext();
ContextRAII previousContext(*this, Var->getDeclContext());
VarDecl *OldVar = Var;
Var = cast_or_null<VarDecl>(SubstDecl(Def, Var->getDeclContext(),
getTemplateInstantiationArgs(Var)));
CurContext = PreviousContext;
previousContext.pop();
if (Var) {
MemberSpecializationInfo *MSInfo = OldVar->getMemberSpecializationInfo();

View File

@ -498,3 +498,13 @@ namespace rdar8876150 {
return !b;
}
}
namespace test23 {
template <typename T> class A {
A();
static A instance;
};
template <typename T> A<T> A<T>::instance;
template class A<int>;
}