diff options
| author | Douglas Gregor <dgregor@apple.com> | 2012-02-10 09:26:04 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2012-02-10 09:26:04 +0000 |
| commit | f02455e5ee45a96b32dee2f44f9f46e2546beb8e (patch) | |
| tree | 0a6dd078d26a06edcda980cfb7d308df3eb57132 /clang/lib | |
| parent | 12695101ec453c4b000f9be5ab56e81a37218d4a (diff) | |
| download | bcm5719-llvm-f02455e5ee45a96b32dee2f44f9f46e2546beb8e.tar.gz bcm5719-llvm-f02455e5ee45a96b32dee2f44f9f46e2546beb8e.zip | |
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.
llvm-svn: 150237
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ae5dc55825b..fc7f32ec6d0 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/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. |

