From 656bc62a73f204286c8dc21fb5ed418b9c39b2fb Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 9 Feb 2012 08:26:42 +0000 Subject: [PATCH] Remove the "unsupported" error for lambda expressions. It's annoying, and rapidly becoming untrue. llvm-svn: 150165 --- .../clang/Basic/DiagnosticSemaKinds.td | 1 - clang/lib/Sema/SemaLambda.cpp | 2 - clang/test/CXX/class/class.local/p1-0x.cpp | 2 +- .../expr.prim/expr.prim.lambda/blocks.cpp | 6 +- .../expr/expr.prim/expr.prim.lambda/p10.cpp | 9 +-- .../expr/expr.prim/expr.prim.lambda/p14.cpp | 12 ++- .../expr/expr.prim/expr.prim.lambda/p15.cpp | 6 +- .../expr/expr.prim/expr.prim.lambda/p2.cpp | 20 ++--- .../expr/expr.prim/expr.prim.lambda/p3.cpp | 3 +- .../expr/expr.prim/expr.prim.lambda/p5.cpp | 3 +- .../expr/expr.prim/expr.prim.lambda/p7.cpp | 15 ++-- .../expr/expr.prim/expr.prim.lambda/p8.cpp | 16 ++-- .../test/Parser/cxx0x-lambda-expressions.cpp | 14 ++-- .../Parser/objcxx0x-lambda-expressions.mm | 12 +-- clang/test/SemaCXX/lambda-expressions.cpp | 76 +++++++++---------- 15 files changed, 90 insertions(+), 107 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index c8b783cb4f81..94798d0084fc 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4099,7 +4099,6 @@ def err_throw_incomplete_ptr : Error< def err_return_in_constructor_handler : Error< "return in the catch of a function try block of a constructor is illegal">; -def err_lambda_unsupported : Error<"lambda expressions are not supported yet">; def err_capture_more_than_once : Error< "%0 can appear only once in a capture list">; def err_reference_capture_with_reference_default : Error< diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index afc4d5de27c6..d59018dedc92 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -379,7 +379,5 @@ ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, break; } - Diag(StartLoc, diag::err_lambda_unsupported); - return MaybeBindToTemporary(Lambda); } diff --git a/clang/test/CXX/class/class.local/p1-0x.cpp b/clang/test/CXX/class/class.local/p1-0x.cpp index b8e1f680005a..49125f5f9b06 100644 --- a/clang/test/CXX/class/class.local/p1-0x.cpp +++ b/clang/test/CXX/class/class.local/p1-0x.cpp @@ -7,7 +7,7 @@ void f() { int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing function 'f'}} int cc = c; }; - (void)[]() mutable { // expected-error {{not supported yet}} + (void)[]() mutable { int x = 3; // expected-note{{'x' declared here}} struct C { int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing lambda expression}} diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp index 2ed738d3fd18..ba2b70e4c3de 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp @@ -2,9 +2,7 @@ void block_capture_errors() { __block int var; // expected-note 2{{'var' declared here}} - (void)[var] { }; // expected-error{{__block variable 'var' cannot be captured in a lambda}} \ - // expected-error{{lambda expressions are not supported yet}} + (void)[var] { }; // expected-error{{__block variable 'var' cannot be captured in a lambda}} - (void)[=] { var = 17; }; // expected-error{{__block variable 'var' cannot be captured in a lambda}} \ - // expected-error{{lambda expressions are not supported yet}} + (void)[=] { var = 17; }; // expected-error{{__block variable 'var' cannot be captured in a lambda}} } diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp index 6f09c53e576e..b596bd5324dd 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp @@ -17,10 +17,9 @@ class X0 { void explicit_capture() { 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}} + (void)[&Overload] () {}; // expected-error {{does not name a variable}} + (void)[&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}} + (void)[&AmbiguousVar] () {}; // expected-error {{reference to 'AmbiguousVar' is ambiguous}} + (void)[&Variable] () {}; // expected-error {{use of undeclared identifier 'Variable'; did you mean 'variable'}} } }; diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp index 2dcaa5ddf634..ad603e17193d 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp @@ -8,10 +8,8 @@ class NonCopyable { void capture_by_copy(NonCopyable nc, NonCopyable &ncr) { // FIXME: error messages should talk about capture - (void)[nc] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} \ - // expected-error{{lambda expressions are not supported yet}} - (void)[ncr] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} \ - // expected-error{{lambda expressions are not supported yet}} + (void)[nc] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} + (void)[ncr] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} } struct NonTrivial { @@ -28,7 +26,7 @@ struct CopyCtorDefault { }; void capture_with_default_args(CopyCtorDefault cct) { - (void)[=] () -> void { cct.foo(); }; // expected-error{{lambda expressions are not supported yet}} + (void)[=] () -> void { cct.foo(); }; } struct ExpectedArrayLayout { @@ -37,7 +35,7 @@ struct ExpectedArrayLayout { void capture_array() { CopyCtorDefault array[3]; - auto x = [=]() -> void { // expected-error{{lambda expressions are not supported yet}} + auto x = [=]() -> void { capture(array[0]); }; static_assert(sizeof(x) == sizeof(ExpectedArrayLayout), "layout mismatch"); @@ -51,7 +49,7 @@ struct ExpectedLayout { }; void test_layout(char a, short b) { - auto x = [=] () -> void { // expected-error{{lambda expressions are not supported yet}} + auto x = [=] () -> void { capture(a); capture(b); }; diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp index 605265b80a08..c4deba9c9743 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp @@ -6,7 +6,7 @@ class NonCopyable { void capture_by_ref(NonCopyable nc, NonCopyable &ncr) { int array[3]; - (void)[&nc] () -> void {}; // expected-error{{lambda expressions are not supported yet}} - (void)[&ncr] () -> void {}; // expected-error{{lambda expressions are not supported yet}} - (void)[&array] () -> void {}; // expected-error{{lambda expressions are not supported yet}} + (void)[&nc] () -> void {}; + (void)[&ncr] () -> void {}; + (void)[&array] () -> void {}; } diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp index 48c00aa7c686..c6ed308d79a1 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp @@ -2,9 +2,8 @@ // prvalue void prvalue() { - auto&& x = []()->void { }; // expected-error{{lambda expressions are not supported yet}} - auto& y = []()->void { }; // expected-error{{cannot bind to a temporary of type}} \ - // expected-error{{lambda expressions are not supported yet}} + auto&& x = []()->void { }; + auto& y = []()->void { }; // expected-error{{cannot bind to a temporary of type}} } namespace std { @@ -16,11 +15,9 @@ struct P { }; void unevaluated_operand(P &p, int i) { - int i2 = sizeof([]()->void{}()); // expected-error{{lambda expression in an unevaluated operand}} \ - // expected-error{{lambda expressions are not supported yet}} - const std::type_info &ti1 = typeid([&]() -> P& { return p; }()); // expected-error{{lambda expressions are not supported yet}} - const std::type_info &ti2 = typeid([&]() -> int { return i; }()); // expected-error{{lambda expression in an unevaluated operand}} \ - // expected-error{{lambda expressions are not supported yet}} + int i2 = sizeof([]()->void{}()); // expected-error{{lambda expression in an unevaluated operand}} + const std::type_info &ti1 = typeid([&]() -> P& { return p; }()); + const std::type_info &ti2 = typeid([&]() -> int { return i; }()); // expected-error{{lambda expression in an unevaluated operand}} } template @@ -36,13 +33,10 @@ struct Boom { void odr_used(P &p, Boom boom_int, Boom boom_float, Boom boom_double) { const std::type_info &ti1 - = typeid([=,&p]() -> P& { boom_int.tickle(); return p; }()); // expected-error{{lambda expressions are not supported yet}} \ - // expected-note{{in instantiation of member function 'Boom::Boom' requested here}} + = typeid([=,&p]() -> P& { boom_int.tickle(); return p; }()); // expected-note{{in instantiation of member function 'Boom::Boom' requested here}} const std::type_info &ti2 = typeid([=]() -> int { boom_float.tickle(); return 0; }()); // expected-error{{lambda expression in an unevaluated operand}} \ - // expected-error{{lambda expressions are not supported yet}} \ // expected-note{{in instantiation of member function 'Boom::Boom' requested here}} - auto foo = [=]() -> int { boom_double.tickle(); return 0; }; // expected-error{{lambda expressions are not supported yet}} \ - // expected-note{{in instantiation of member function 'Boom::Boom' requested here}} + auto foo = [=]() -> int { boom_double.tickle(); return 0; }; // expected-note{{in instantiation of member function 'Boom::Boom' requested here}} } diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp index 103f79d01582..562f92a78bbc 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp @@ -1,7 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify void test_nonaggregate(int i) { - auto lambda = [i]() -> void {}; // expected-error{{lambda expressions are not supported yet}} \ - // expected-note 3{{candidate constructor}} + auto lambda = [i]() -> void {}; // expected-note 3{{candidate constructor}} decltype(lambda) foo = { 1 }; // expected-error{{no matching constructor}} } diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp index 93ba6f61c75b..ff6e7b4438d6 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp @@ -1,7 +1,6 @@ // RUN: %clang_cc1 -std=c++11 %s -verify int test_default_args() { - (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}} + (void)[](int i = 5, // expected-error{{default arguments can only be specified for parameters in a function declaration}} int j = 17) {}; // expected-error{{default arguments can only be specified for parameters in a function declaration}} } 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 e816426cbf9a..21c8e22092bd 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,8 +2,7 @@ // Check that analysis-based warnings work in lambda bodies. void analysis_based_warnings() { - (void)[]() -> int { }; // expected-warning{{control reaches end of non-void function}} \ - // expected-error{{lambda expressions are not supported yet}} + (void)[]() -> int { }; // expected-warning{{control reaches end of non-void function}} } // Check that we get the right types of captured variables (the @@ -12,32 +11,32 @@ int &check_const_int(int&); float &check_const_int(const int&); void test_capture_constness(int i, const int ic) { - (void)[i,ic] ()->void { // expected-error{{lambda expressions are not supported yet}} + (void)[i,ic] ()->void { float &fr1 = check_const_int(i); float &fr2 = check_const_int(ic); }; - (void)[=] ()->void { // expected-error{{lambda expressions are not supported yet}} + (void)[=] ()->void { float &fr1 = check_const_int(i); float &fr2 = check_const_int(ic); }; - (void)[i,ic] () mutable ->void { // expected-error{{lambda expressions are not supported yet}} + (void)[i,ic] () mutable ->void { int &ir = check_const_int(i); float &fr = check_const_int(ic); }; - (void)[=] () mutable ->void { // expected-error{{lambda expressions are not supported yet}} + (void)[=] () mutable ->void { int &ir = check_const_int(i); float &fr = check_const_int(ic); }; - (void)[&i,&ic] ()->void { // expected-error{{lambda expressions are not supported yet}} + (void)[&i,&ic] ()->void { int &ir = check_const_int(i); float &fr = check_const_int(ic); }; - (void)[&] ()->void { // expected-error{{lambda expressions are not supported yet}} + (void)[&] ()->void { int &ir = check_const_int(i); float &fr = check_const_int(ic); }; diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp index 53d2c757721d..8f524e08245a 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp @@ -4,13 +4,13 @@ class X0 { void explicit_capture() { int foo; - (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}} + (void)[foo, foo] () {}; // expected-error {{'foo' can appear only once}} + (void)[this, this] () {}; // expected-error {{'this' can appear only once}} + (void)[=, foo] () {}; // expected-error {{'&' must precede a capture when}} + (void)[=, &foo] () {}; + (void)[=, this] () {}; // expected-error {{'this' cannot appear}} + (void)[&, foo] () {}; + (void)[&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}} + (void)[&, this] () {}; } }; diff --git a/clang/test/Parser/cxx0x-lambda-expressions.cpp b/clang/test/Parser/cxx0x-lambda-expressions.cpp index 07a4701653c9..aa2a9cf7fd2e 100644 --- a/clang/test/Parser/cxx0x-lambda-expressions.cpp +++ b/clang/test/Parser/cxx0x-lambda-expressions.cpp @@ -12,13 +12,13 @@ class C { [&this] {}; // expected-error {{'this' cannot be captured by reference}} [&,] {}; // expected-error {{expected variable name or 'this' in lambda capture list}} [=,] {}; // expected-error {{expected variable name or 'this' in lambda capture list}} - [] {}; // expected-error {{lambda expressions are not supported yet}} - [=] (int i) {}; // expected-error {{lambda expressions are not supported yet}} - [&] (int) mutable -> void {}; // expected-error {{lambda expressions are not supported yet}} - [foo,bar] () { return 3; }; // expected-error {{lambda expressions are not supported yet}} - [=,&foo] () {}; // expected-error {{lambda expressions are not supported yet}} - [&,foo] () {}; // expected-error {{lambda expressions are not supported yet}} - [this] () {}; // expected-error {{lambda expressions are not supported yet}} + [] {}; + [=] (int i) {}; + [&] (int) mutable -> void {}; + [foo,bar] () { return 3; }; + [=,&foo] () {}; + [&,foo] () {}; + [this] () {}; return 1; } diff --git a/clang/test/Parser/objcxx0x-lambda-expressions.mm b/clang/test/Parser/objcxx0x-lambda-expressions.mm index b37f52520c8c..1eab15bee98e 100644 --- a/clang/test/Parser/objcxx0x-lambda-expressions.mm +++ b/clang/test/Parser/objcxx0x-lambda-expressions.mm @@ -11,12 +11,12 @@ class C { []; // expected-error {{expected body of lambda expression}} [=,foo+] {}; // expected-error {{expected ',' or ']' in lambda capture list}} [&this] {}; // expected-error {{address expression must be an lvalue}} - [] {}; // expected-error {{lambda expressions are not supported yet}} - [=] (int i) {}; // expected-error {{lambda expressions are not supported yet}} - [&] (int) mutable -> void {}; // expected-error {{lambda expressions are not supported yet}} - [foo,bar] () { return 3; }; // expected-error {{lambda expressions are not supported yet}} - [=,&foo] () {}; // expected-error {{lambda expressions are not supported yet}} - [this] () {}; // expected-error {{lambda expressions are not supported yet}} + [] {}; + [=] (int i) {}; + [&] (int) mutable -> void {}; + [foo,bar] () { return 3; }; + [=,&foo] () {}; + [this] () {}; } }; diff --git a/clang/test/SemaCXX/lambda-expressions.cpp b/clang/test/SemaCXX/lambda-expressions.cpp index a414fc98e7c2..afdff999d44e 100644 --- a/clang/test/SemaCXX/lambda-expressions.cpp +++ b/clang/test/SemaCXX/lambda-expressions.cpp @@ -11,76 +11,76 @@ namespace ExplicitCapture { 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}} } }