blob: 905bd6b1e8b45aa9f5c21a2fad705a73688945ee [file] [log] [blame]
Douglas Gregordcffcbf2012-02-09 01:26:17 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -std=c++11 %s
Douglas Gregorae7902c2011-08-04 15:30:47 +00002
3class C {
Richard Smith440d4562013-05-21 22:21:19 +00004 id get(int);
Douglas Gregorae7902c2011-08-04 15:30:47 +00005
6 void f() {
Richard Smith440d4562013-05-21 22:21:19 +00007 int foo, bar, baz;
Douglas Gregorae7902c2011-08-04 15:30:47 +00008
9 // fail to parse as a lambda introducer, so we get objc message parsing errors instead
10 [foo,+] {}; // expected-error {{expected expression}}
11
12 []; // expected-error {{expected body of lambda expression}}
13 [=,foo+] {}; // expected-error {{expected ',' or ']' in lambda capture list}}
Richard Smith3fa3fea2013-02-02 02:14:45 +000014 [&this] {}; // expected-error {{cannot take the address of an rvalue of type 'C *'}}
Douglas Gregorb326ca82012-02-09 08:26:42 +000015 [] {};
16 [=] (int i) {};
17 [&] (int) mutable -> void {};
18 [foo,bar] () { return 3; };
19 [=,&foo] () {};
20 [this] () {};
Richard Smith0a664b82013-05-09 21:36:41 +000021
Richard Smith0d8e9642013-05-16 06:20:58 +000022 [foo(bar)] () {};
23 [foo = bar] () {};
24 [foo{bar}] () {}; // expected-error {{<initializer_list>}}
25 [foo = {bar}] () {}; // expected-error {{<initializer_list>}}
Richard Smith0a664b82013-05-09 21:36:41 +000026
27 [foo(bar) baz] () {}; // expected-error {{called object type 'int' is not a function}}
Richard Smith440d4562013-05-21 22:21:19 +000028 [foo(bar), baz] () {}; // ok
Richard Smith0a664b82013-05-09 21:36:41 +000029
Richard Smith440d4562013-05-21 22:21:19 +000030 [foo = bar baz]; // expected-warning {{receiver type 'int'}} expected-warning {{instance method '-baz'}}
31
32 [get(bar) baz]; // expected-warning {{instance method '-baz'}}
33 [get(bar), baz]; // expected-error {{expected body of lambda}}
34
35 [foo = bar ++ baz]; // expected-warning {{receiver type 'int'}} expected-warning {{instance method '-baz'}}
36 [foo = bar + baz]; // expected-error {{expected body of lambda}}
37 [foo = { bar, baz }]; // expected-error {{<initializer_list>}} expected-error {{expected body of lambda}}
38 [foo = { bar } baz ]; // expected-warning {{receiver type 'int'}} expected-warning {{instance method '-baz'}}
39 [foo = { bar }, baz ]; // expected-error {{<initializer_list>}} expected-error {{expected body of lambda}}
Douglas Gregorae7902c2011-08-04 15:30:47 +000040 }
41
42};
43