aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-10 09:26:04 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-10 09:26:04 +0000
commit73d90928c0462daf0665fd7f8e44ca00d896540d (patch)
treebec61ee71da76e2e8058e67a5ca9eb15f357a24d /lib
parentef7d78bd5be466c369b04af742ed8268244d4fe7 (diff)
Add various tests for captures and the reaching scope of the lambda
expression. Implement C++11 [expr.prim.lambda]p12's requirement that capturing a variable will odr-use it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150237 91177308-0d34-0410-b5e6-96231b3b80d8
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.