aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaExpr.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index ae5dc55825..fc7f32ec6d 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -9624,8 +9624,12 @@ static ExprResult captureInLambda(Sema &S, LambdaScopeInfo *LSI,
// to be re-"exported" from the lambda expression itself.
S.PushExpressionEvaluationContext(Sema::PotentiallyEvaluated);
+ // C++ [expr.prim.labda]p12:
+ // An entity captured by a lambda-expression is odr-used (3.2) in
+ // the scope containing the lambda-expression.
Expr *Ref = new (S.Context) DeclRefExpr(Var, Type.getNonReferenceType(),
VK_LValue, Loc);
+ Var->setUsed(true);
// When the field has array type, create index variables for each
// dimension of the array. We use these index variables to subscript
@@ -9999,7 +10003,7 @@ void Sema::MarkMemberReferenced(MemberExpr *E) {
MarkExprReferenced(*this, E->getMemberLoc(), E->getMemberDecl(), E);
}
-/// \brief Perform marking for a reference to an aribitrary declaration. It
+/// \brief Perform marking for a reference to an arbitrary declaration. It
/// marks the declaration referenced, and performs odr-use checking for functions
/// and variables. This method should not be used when building an normal
/// expression which refers to a variable.