Whenever we instantiate a function definition or class, enter a new
potentially-evaluated expression context, to ensure that used
declarations get properly marked. Fixes PR7123.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103624 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 06b9539..589b995 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1175,6 +1175,8 @@
// Enter the scope of this instantiation. We don't use
// PushDeclContext because we don't have a scope.
ContextRAII SavedContext(*this, Instantiation);
+ EnterExpressionEvaluationContext EvalContext(*this,
+ Action::PotentiallyEvaluated);
// If this is an instantiation of a local class, merge this local
// instantiation scope with the enclosing scope. Otherwise, every
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index d3d6c22..adba32e 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2011,6 +2011,8 @@
if (Recursive)
PendingImplicitInstantiations.swap(SavedPendingImplicitInstantiations);
+ EnterExpressionEvaluationContext EvalContext(*this,
+ Action::PotentiallyEvaluated);
ActOnStartOfFunctionDef(0, DeclPtrTy::make(Function));
// Introduce a new scope where local variable instantiations will be