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.
llvm-svn: 150123
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 3c5ac22..e816426 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
@@ -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 @@
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);
};