Remove the "unsupported" error for lambda expressions. It's annoying,
and rapidly becoming untrue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150165 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp
index a414fc9..afdff99 100644
--- a/test/SemaCXX/lambda-expressions.cpp
+++ b/test/SemaCXX/lambda-expressions.cpp
@@ -11,76 +11,76 @@
virtual C& Overload(float);
void ImplicitThisCapture() {
- [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}} expected-error {{not supported yet}}
- [&](){(void)Member;}; // expected-error {{not supported yet}}
- // 'this' captures below don't actually work yet
- [this](){(void)Member;}; // expected-error{{lambda expressions are not supported yet}}
- [this]{[this]{};}; // expected-error 2{{lambda expressions are not supported yet}}
- []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}} expected-error 2 {{not supported yet}}
- []{Overload(3);}; // expected-error {{not supported yet}}
- []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}} expected-error {{not supported yet}}
- []{(void)typeid(Overload());};// expected-error {{not supported yet}}
- []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}} expected-error {{not supported yet}}
+ [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}}
+ [&](){(void)Member;};
+
+ [this](){(void)Member;};
+ [this]{[this]{};};
+ []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}}
+ []{Overload(3);};
+ []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}}
+ []{(void)typeid(Overload());};
+ []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}}
}
};
void f() {
- [this] () {}; // expected-error {{'this' cannot be captured in this context}} expected-error {{not supported yet}}
+ [this] () {}; // expected-error {{'this' cannot be captured in this context}}
}
}
namespace ReturnDeduction {
void test() {
- [](){ return 1; }; // expected-error {{not supported yet}}
- [](){ return 1; }; // expected-error {{not supported yet}}
- [](){ return ({return 1; 1;}); }; // expected-error {{not supported yet}}
- [](){ return ({return 'c'; 1;}); }; // expected-error {{not supported yet}} expected-error {{must match previous return type}}
- []()->int{ return 'c'; return 1; }; // expected-error {{not supported yet}}
- [](){ return 'c'; return 1; }; // expected-error {{not supported yet}} expected-error {{must match previous return type}}
- []() { return; return (void)0; }; // expected-error {{not supported yet}}
+ [](){ return 1; };
+ [](){ return 1; };
+ [](){ return ({return 1; 1;}); };
+ [](){ return ({return 'c'; 1;}); }; // expected-error {{must match previous return type}}
+ []()->int{ return 'c'; return 1; };
+ [](){ return 'c'; return 1; }; // expected-error {{must match previous return type}}
+ []() { return; return (void)0; };
// FIXME: Need to check structure of lambda body
- [](){ return 1; return 1; }; // expected-error {{not supported yet}}
+ [](){ return 1; return 1; };
}
}
namespace ImplicitCapture {
void test() {
int a = 0; // expected-note 5 {{declared}}
- []() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}} expected-error {{not supported yet}}
- [&]() { return a; }; // expected-error {{not supported yet}}
- [=]() { return a; }; // expected-error {{not supported yet}}
- [=]() { int* b = &a; }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}} expected-error {{not supported yet}}
- [=]() { return [&]() { return a; }; }; // expected-error 2 {{not supported yet}}
- []() { return [&]() { return a; }; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} expected-error 2 {{not supported yet}}
- []() { return ^{ return a; }; };// expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} expected-error {{not supported yet}}
- []() { return [&a] { return a; }; }; // expected-error 2 {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note 2 {{lambda expression begins here}} expected-error 2 {{not supported yet}}
- [=]() { return [&a] { return a; }; }; // expected-error 2 {{not supported yet}}
+ []() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}}
+ [&]() { return a; };
+ [=]() { return a; };
+ [=]() { int* b = &a; }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}}
+ [=]() { return [&]() { return a; }; };
+ []() { return [&]() { return a; }; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+ []() { return ^{ return a; }; };// expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+ []() { return [&a] { return a; }; }; // expected-error 2 {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note 2 {{lambda expression begins here}}
+ [=]() { return [&a] { return a; }; }; //
const int b = 2;
- []() { return b; }; // expected-error {{not supported yet}}
+ []() { return b; };
union { // expected-note {{declared}}
int c;
float d;
};
d = 3;
- [=]() { return c; }; // expected-error {{unnamed variable cannot be implicitly captured in a lambda expression}} expected-error {{not supported yet}}
+ [=]() { return c; }; // expected-error {{unnamed variable cannot be implicitly captured in a lambda expression}}
__block int e; // expected-note 3 {{declared}}
- [&]() { return e; }; // expected-error {{__block variable 'e' cannot be captured in a lambda expression}} expected-error {{not supported yet}}
- [&e]() { return e; }; // expected-error 2 {{__block variable 'e' cannot be captured in a lambda expression}} expected-error {{not supported yet}}
+ [&]() { return e; }; // expected-error {{__block variable 'e' cannot be captured in a lambda expression}}
+ [&e]() { return e; }; // expected-error 2 {{__block variable 'e' cannot be captured in a lambda expression}}
int f[10]; // expected-note {{declared}}
- [&]() { return f[2]; }; // expected-error {{not supported yet}}
- (void) ^{ return []() { return f[2]; }; }; // expected-error {{cannot refer to declaration with an array type inside block}} expected-error {{not supported yet}}
+ [&]() { return f[2]; };
+ (void) ^{ return []() { return f[2]; }; }; // expected-error {{cannot refer to declaration with an array type inside block}}
struct G { G(); G(G&); int a; }; // expected-note 6 {{not viable}}
G g;
- [=]() { const G* gg = &g; return gg->a; }; // expected-error {{not supported yet}}
- [=]() { return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error {{no matching constructor for initialization of 'const ImplicitCapture::G'}} expected-error 2 {{not supported yet}}
- (void)^{ return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error 2 {{no matching constructor for initialization of 'const ImplicitCapture::G'}} expected-error {{not supported yet}}
+ [=]() { const G* gg = &g; return gg->a; };
+ [=]() { return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error {{no matching constructor for initialization of 'const ImplicitCapture::G'}}
+ (void)^{ return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error 2 {{no matching constructor for initialization of 'const ImplicitCapture::G'}}
const int h = a; // expected-note {{declared}}
- []() { return h; }; // expected-error {{variable 'h' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} expected-error {{not supported yet}}
+ []() { return h; }; // expected-error {{variable 'h' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
}
}