aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaLambda.cpp28
-rw-r--r--lib/Sema/TreeTransform.h24
2 files changed, 28 insertions, 24 deletions
diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp
index f97b5232ac..0ce1c74163 100644
--- a/lib/Sema/SemaLambda.cpp
+++ b/lib/Sema/SemaLambda.cpp
@@ -521,19 +521,21 @@ ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body,
// C++11 [expr.prim.lambda]p2:
// A lambda-expression shall not appear in an unevaluated operand
// (Clause 5).
- switch (ExprEvalContexts.back().Context) {
- case Unevaluated:
- // We don't actually diagnose this case immediately, because we
- // could be within a context where we might find out later that
- // the expression is potentially evaluated (e.g., for typeid).
- ExprEvalContexts.back().Lambdas.push_back(Lambda);
- break;
-
- case ConstantEvaluated:
- case PotentiallyEvaluated:
- case PotentiallyEvaluatedIfUsed:
- break;
- }
+ if (!CurContext->isDependentContext()) {
+ switch (ExprEvalContexts.back().Context) {
+ case Unevaluated:
+ // We don't actually diagnose this case immediately, because we
+ // could be within a context where we might find out later that
+ // the expression is potentially evaluated (e.g., for typeid).
+ ExprEvalContexts.back().Lambdas.push_back(Lambda);
+ break;
+ case ConstantEvaluated:
+ case PotentiallyEvaluated:
+ case PotentiallyEvaluatedIfUsed:
+ break;
+ }
+ }
+
return MaybeBindToTemporary(Lambda);
}
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index ba6ec82c81..a63b9c804a 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -7672,6 +7672,13 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
E->getCallOperator()->getLocEnd());
getDerived().transformAttrs(E->getCallOperator(), CallOperator);
+ // FIXME: Instantiation-specific.
+ CallOperator->setInstantiationOfMemberFunction(E->getCallOperator(),
+ TSK_ImplicitInstantiation);
+
+ // Introduce the context of the call operator.
+ Sema::ContextRAII SavedContext(getSema(), CallOperator);
+
// Enter the scope of the lambda.
sema::LambdaScopeInfo *LSI
= getSema().enterLambdaScope(CallOperator, E->getIntroducerRange(),
@@ -7741,17 +7748,12 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
}
// Instantiate the body of the lambda expression.
- StmtResult Body;
- {
- Sema::ContextRAII SavedContext(getSema(), CallOperator);
-
- Body = getDerived().TransformStmt(E->getBody());
- if (Body.isInvalid()) {
- getSema().ActOnLambdaError(E->getLocStart(), /*CurScope=*/0,
- /*IsInstantiation=*/true);
- return ExprError();
- }
- }
+ StmtResult Body = getDerived().TransformStmt(E->getBody());
+ if (Body.isInvalid()) {
+ getSema().ActOnLambdaError(E->getLocStart(), /*CurScope=*/0,
+ /*IsInstantiation=*/true);
+ return ExprError();
+ }
return getSema().ActOnLambdaExpr(E->getLocStart(), Body.take(),
/*CurScope=*/0,