blob: db934c3ab77b6a8014f70255e0195e184281f2e3 [file] [log] [blame]
Eli Friedmane81d7e92012-01-07 01:08:17 +00001// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
2
Eli Friedman72899c32012-01-07 04:59:52 +00003namespace std { class type_info; };
4
Eli Friedmane81d7e92012-01-07 01:08:17 +00005namespace 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 {
Eli Friedman72899c32012-01-07 04:59:52 +000015 int Member;
Eli Friedmane81d7e92012-01-07 01:08:17 +000016
Eli Friedman72899c32012-01-07 04:59:52 +000017 static void Overload(int);
18 void Overload();
19 virtual C& Overload(float);
20
21 void ExplicitCapture() {
Eli Friedmane81d7e92012-01-07 01:08:17 +000022 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}}
Eli Friedman72899c32012-01-07 04:59:52 +000032 [&Overload] () {}; // expected-error {{does not name a variable}} expected-error {{not supported yet}}
Eli Friedmane81d7e92012-01-07 01:08:17 +000033 [&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 }
Eli Friedman72899c32012-01-07 04:59:52 +000037
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 }
Eli Friedmane81d7e92012-01-07 01:08:17 +000049 };
50
51 void f() {
52 [this] () {}; // expected-error {{invalid use of 'this'}} expected-error {{not supported yet}}
53 }
54}
Eli Friedman84b007f2012-01-26 03:00:14 +000055
56namespace 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}