summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-08 20:56:50 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-08 20:56:50 +0000
commitc70fe353ea52a1dbf13d0b7266e445b3fa1fda66 (patch)
tree42d57ac1485bdaf08518d405e32caf270dff14f6 /clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
parent21f4692c622fedfecab3571c12b37ce6d72a4c0e (diff)
downloadbcm5719-llvm-c70fe353ea52a1dbf13d0b7266e445b3fa1fda66.tar.gz
bcm5719-llvm-c70fe353ea52a1dbf13d0b7266e445b3fa1fda66.zip
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). llvm-svn: 150088
Diffstat (limited to 'clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp')
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
index 239b6d4f469..0696f603b68 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
+++ b/clang/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);
+ };
+}
OpenPOWER on IntegriCloud