aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/expr/expr.prim/expr.prim.lambda
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-09 00:47:04 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-09 00:47:04 +0000
commit503384f731b5abcbf870b0a5224eb920e631db0a (patch)
tree0af31e2390158648077180f89fe1f0e19f4eed6f /test/CXX/expr/expr.prim/expr.prim.lambda
parent91c2a1192cdd4e7b2b4ac7838c5aceef200ea251 (diff)
Various interrelated cleanups for lambdas:
- Complete the lambda class when we finish the lambda expression (previously, it was left in the "being completed" state) - Actually return the LambdaExpr object and bind to the resulting temporary when needed. - Detect when cleanups are needed while capturing a variable into a lambda (e.g., due to default arguments in the copy constructor), and make sure those cleanups apply for the whole of the lambda expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150123 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/expr/expr.prim/expr.prim.lambda')
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp12
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp20
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp4
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp2
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp14
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp16
6 files changed, 43 insertions, 25 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 497307ff75..6f09c53e57 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -std=c++11 %s -verify
-int GlobalVar; // expected-note 2{{declared here}}
+int GlobalVar; // expected-note {{declared here}}
namespace N {
int AmbiguousVar; // expected-note {{candidate}}
@@ -16,9 +16,11 @@ class X0 {
virtual X0& Overload(float);
void explicit_capture() {
- [&Overload] () {}; // expected-error {{does not name a variable}} expected-error {{not supported yet}}
- [&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}} expected-error {{not supported yet}}
- [&AmbiguousVar] () {} // expected-error {{reference to 'AmbiguousVar' is ambiguous}} expected-error {{not supported yet}}
- [&Globalvar] () {}; // expected-error {{use of undeclared identifier 'Globalvar'; did you mean 'GlobalVar}}
+ int variable; // expected-note {{declared here}}
+ (void)[&Overload] () {}; // expected-error {{does not name a variable}} expected-error {{not supported yet}}
+ (void)[&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}} expected-error {{not supported yet}}
+ (void)[&AmbiguousVar] () {}; // expected-error {{reference to 'AmbiguousVar' is ambiguous}} expected-error {{not supported yet}}
+ (void)[&Variable] () {}; // expected-error {{use of undeclared identifier 'Variable'; did you mean 'variable'}} \
+ // expected-error{{lambda expressions are not supported yet}}
}
};
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
index 0bbb9ae744..4c876d7480 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
@@ -6,10 +6,26 @@ class NonCopyable {
void capture_by_copy(NonCopyable nc, NonCopyable &ncr) {
// FIXME: error messages should talk about capture
- [nc] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} \
+ (void)[nc] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} \
// expected-error{{lambda expressions are not supported yet}}
- [ncr] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} \
+ (void)[ncr] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} \
// expected-error{{lambda expressions are not supported yet}}
}
+struct NonTrivial {
+ NonTrivial();
+ NonTrivial(const NonTrivial &);
+ ~NonTrivial();
+};
+
+struct CopyCtorDefault {
+ CopyCtorDefault(const CopyCtorDefault&, NonTrivial nt = NonTrivial());
+
+ void foo() const;
+};
+
+void capture_with_default_args(CopyCtorDefault cct) {
+ (void)[=] () -> void { cct.foo(); }; // expected-error{{lambda expressions are not supported yet}}
+}
+
// FIXME: arrays!
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp
index 7264fa18d0..e17d8b5101 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp
@@ -5,6 +5,6 @@ class NonCopyable {
};
void capture_by_ref(NonCopyable nc, NonCopyable &ncr) {
- [&nc] () -> void {}; // expected-error{{lambda expressions are not supported yet}}
- [&ncr] () -> void {}; // expected-error{{lambda expressions are not supported yet}}
+ (void)[&nc] () -> void {}; // expected-error{{lambda expressions are not supported yet}}
+ (void)[&ncr] () -> void {}; // expected-error{{lambda expressions are not supported yet}}
}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
index a6fca9b2c4..93ba6f61c7 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -std=c++11 %s -verify
int test_default_args() {
- [](int i = 5, // expected-error{{default arguments can only be specified for parameters in a function declaration}} \
+ (void)[](int i = 5, // expected-error{{default arguments can only be specified for parameters in a function declaration}} \
// expected-error{{lambda expressions are not supported yet}}
int j = 17) {}; // expected-error{{default arguments can only be specified for parameters in a function declaration}}
}
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 3c5ac220a1..e816426cbf 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
@@ -2,7 +2,7 @@
// Check that analysis-based warnings work in lambda bodies.
void analysis_based_warnings() {
- []() -> int { }; // expected-warning{{control reaches end of non-void function}} \
+ (void)[]() -> int { }; // expected-warning{{control reaches end of non-void function}} \
// expected-error{{lambda expressions are not supported yet}}
}
@@ -12,32 +12,32 @@ 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}}
+ (void)[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}}
+ (void)[=] ()->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}}
+ (void)[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}}
+ (void)[=] () 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}}
+ (void)[&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}}
+ (void)[&] ()->void { // expected-error{{lambda expressions are not supported yet}}
int &ir = check_const_int(i);
float &fr = check_const_int(ic);
};
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
index 4bd5760bc4..53d2c75772 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
@@ -4,13 +4,13 @@ class X0 {
void explicit_capture() {
int foo;
- [foo, foo] () {}; // expected-error {{'foo' can appear only once}} expected-error {{not supported yet}}
- [this, this] () {}; // expected-error {{'this' can appear only once}} expected-error {{not supported yet}}
- [=, foo] () {}; // expected-error {{'&' must precede a capture when}} expected-error {{not supported yet}}
- [=, &foo] () {}; // expected-error {{not supported yet}}
- [=, this] () {}; // expected-error {{'this' cannot appear}} expected-error {{not supported yet}}
- [&, foo] () {}; // expected-error {{not supported yet}}
- [&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}} expected-error {{not supported yet}}
- [&, this] () {}; // expected-error {{not supported yet}}
+ (void)[foo, foo] () {}; // expected-error {{'foo' can appear only once}} expected-error {{not supported yet}}
+ (void)[this, this] () {}; // expected-error {{'this' can appear only once}} expected-error {{not supported yet}}
+ (void)[=, foo] () {}; // expected-error {{'&' must precede a capture when}} expected-error {{not supported yet}}
+ (void)[=, &foo] () {}; // expected-error {{not supported yet}}
+ (void)[=, this] () {}; // expected-error {{'this' cannot appear}} expected-error {{not supported yet}}
+ (void)[&, foo] () {}; // expected-error {{not supported yet}}
+ (void)[&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}} expected-error {{not supported yet}}
+ (void)[&, this] () {}; // expected-error {{not supported yet}}
}
};