1 // RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s 2 3 namespace std { class type_info; }; 4 5 namespace ExplicitCapture { 6 int GlobalVar; // expected-note {{declared here}} 7 8 namespace N { 9 int AmbiguousVar; // expected-note {{candidate}} 10 } 11 int AmbiguousVar; // expected-note {{candidate}} 12 using namespace N; 13 14 class C { 15 int Member; 16 17 static void Overload(int); 18 void Overload(); 19 virtual C& Overload(float); 20 21 void ExplicitCapture() { 22 int foo; 23 24 [foo, foo] () {}; // expected-error {{'foo' can appear only once}} expected-error {{not supported yet}} 25 [this, this] () {}; // expected-error {{'this' can appear only once}} expected-error {{not supported yet}} 26 [=, foo] () {}; // expected-error {{'&' must precede a capture when}} expected-error {{not supported yet}} 27 [=, &foo] () {}; // expected-error {{not supported yet}} 28 [=, this] () {}; // expected-error {{'this' cannot appear}} expected-error {{not supported yet}} 29 [&, foo] () {}; // expected-error {{not supported yet}} 30 [&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}} expected-error {{not supported yet}} 31 [&, this] () {}; // expected-error {{not supported yet}} 32 [&Overload] () {}; // expected-error {{does not name a variable}} expected-error {{not supported yet}} 33 [&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}} expected-error {{not supported yet}} 34 [&AmbiguousVar] () {} // expected-error {{reference to 'AmbiguousVar' is ambiguous}} expected-error {{not supported yet}} 35 [&Globalvar] () {}; // expected-error {{use of undeclared identifier 'Globalvar'; did you mean 'GlobalVar}} 36 } 37 38 void ImplicitThisCapture() { 39 [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}} expected-error {{not supported yet}} 40 [&](){(void)Member;}; // expected-error {{not supported yet}} 41 [this](){(void)Member;}; // expected-error {{not supported yet}} 42 [this]{[this]{};};// expected-error 2 {{not supported yet}} 43 []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}} expected-error 2 {{not supported yet}} 44 []{Overload(3);}; // expected-error {{not supported yet}} 45 []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}} expected-error {{not supported yet}} 46 []{(void)typeid(Overload());};// expected-error {{not supported yet}} 47 []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}} expected-error {{not supported yet}} 48 } 49 }; 50 51 void f() { 52 [this] () {}; // expected-error {{invalid use of 'this'}} expected-error {{not supported yet}} 53 } 54 } 55 56 namespace ReturnDeduction { 57 void test() { 58 [](){ return 1; }; // expected-error {{not supported yet}} 59 [](){ return 1; }; // expected-error {{not supported yet}} 60 [](){ return ({return 1; 1;}); }; // expected-error {{not supported yet}} 61 [](){ return ({return 'c'; 1;}); }; // expected-error {{not supported yet}} expected-error {{must match previous return type}} 62 []()->int{ return 'c'; return 1; }; // expected-error {{not supported yet}} 63 [](){ return 'c'; return 1; }; // expected-error {{not supported yet}} expected-error {{must match previous return type}} 64 // FIXME: Need to check structure of lambda body 65 [](){ return 1; return 1; }; // expected-error {{not supported yet}} 66 } 67 } 68