diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-08 20:56:50 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-08 20:56:50 +0000 |
commit | 1e3767ac5449db6a1ede192d5e4217e34fa61f26 (patch) | |
tree | 9332829d73de14da542d4117980e904a1a72834c /test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp | |
parent | 76e3da57b0e8cf72d221f44d54566ef206341668 (diff) |
When computing the type of a local variable reference within a lambda,
only add 'const' for variables captured by copy in potentially
evaluated expressions of non-mutable lambdas. (The "by copy" part was
missing).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150088 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp')
-rw-r--r-- | test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp index 239b6d4f46..0696f603b6 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp @@ -6,7 +6,40 @@ void analysis_based_warnings() { // expected-error{{lambda expressions are not supported yet}} } -// FIXME: Also check translation of captured vars to data members, -// most of which isn't in the AST. +// Check that we get the right types of captured variables (the semantic-analysis part of +int &check_const_int(int&); +float &check_const_int(const int&); + +void test_capture_constness(int i, const int ic) { + [i,ic] ()->void { // expected-error{{lambda expressions are not supported yet}} + float &fr1 = check_const_int(i); + float &fr2 = check_const_int(ic); + }; + + [=] ()->void { // expected-error{{lambda expressions are not supported yet}} + float &fr1 = check_const_int(i); + float &fr2 = check_const_int(ic); + }; + + [i,ic] () mutable ->void { // expected-error{{lambda expressions are not supported yet}} + int &ir = check_const_int(i); + float &fr = check_const_int(ic); + }; + + [=] () mutable ->void { // expected-error{{lambda expressions are not supported yet}} + int &ir = check_const_int(i); + float &fr = check_const_int(ic); + }; + + [&i,&ic] ()->void { // expected-error{{lambda expressions are not supported yet}} + int &ir = check_const_int(i); + float &fr = check_const_int(ic); + }; + + [&] ()->void { // expected-error{{lambda expressions are not supported yet}} + int &ir = check_const_int(i); + float &fr = check_const_int(ic); + }; +} |