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 | 73d90928c0462daf0665fd7f8e44ca00d896540d (patch) | |
tree | bec61ee71da76e2e8058e67a5ca9eb15f357a24d /test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp | |
parent | ef7d78bd5be466c369b04af742ed8268244d4fe7 (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 'test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp')
-rw-r--r-- | test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp index b596bd5324..245e27042b 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp @@ -23,3 +23,18 @@ class X0 { (void)[&Variable] () {}; // expected-error {{use of undeclared identifier 'Variable'; did you mean 'variable'}} } }; + +void test_reaching_scope() { + int local; // expected-note{{declared here}} + static int local_static; // expected-note{{'local_static' declared here}} + (void)[=]() { + struct InnerLocal { + void member() { + (void)[local, // expected-error{{reference to local variable 'local' declared in enclosing function 'test_reaching_scope'}} + local_static]() { // expected-error{{'local_static' cannot be captured because it does not have automatic storage duration}} + return 0; + }; + } + }; + }; +} |