[cfe-commits] r125517 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/CXX/class.access/p4.cpp
John McCall
rjmccall at apple.com
Mon Feb 14 12:37:25 PST 2011
Author: rjmccall
Date: Mon Feb 14 14:37:25 2011
New Revision: 125517
URL: http://llvm.org/viewvc/llvm-project?rev=125517&view=rev
Log:
Change the context correctly when instantiating a static data member definition.
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CXX/class.access/p4.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=125517&r1=125516&r2=125517&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Feb 14 14:37:25 2011
@@ -2434,13 +2434,13 @@
// 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();
Modified: cfe/trunk/test/CXX/class.access/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/p4.cpp?rev=125517&r1=125516&r2=125517&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/p4.cpp (original)
+++ cfe/trunk/test/CXX/class.access/p4.cpp Mon Feb 14 14:37:25 2011
@@ -498,3 +498,13 @@
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>;
+}
More information about the cfe-commits
mailing list