Douglas Gregor | dcffcbf | 2012-02-09 01:26:17 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -std=c++11 %s |
Douglas Gregor | ae7902c | 2011-08-04 15:30:47 +0000 | [diff] [blame] | 2 | |
| 3 | class C { |
Richard Smith | 440d456 | 2013-05-21 22:21:19 +0000 | [diff] [blame] | 4 | id get(int); |
Douglas Gregor | ae7902c | 2011-08-04 15:30:47 +0000 | [diff] [blame] | 5 | |
| 6 | void f() { |
Richard Smith | 440d456 | 2013-05-21 22:21:19 +0000 | [diff] [blame] | 7 | int foo, bar, baz; |
Douglas Gregor | ae7902c | 2011-08-04 15:30:47 +0000 | [diff] [blame] | 8 | |
| 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 Smith | 3fa3fea | 2013-02-02 02:14:45 +0000 | [diff] [blame] | 14 | [&this] {}; // expected-error {{cannot take the address of an rvalue of type 'C *'}} |
Douglas Gregor | b326ca8 | 2012-02-09 08:26:42 +0000 | [diff] [blame] | 15 | [] {}; |
| 16 | [=] (int i) {}; |
| 17 | [&] (int) mutable -> void {}; |
| 18 | [foo,bar] () { return 3; }; |
| 19 | [=,&foo] () {}; |
| 20 | [this] () {}; |
Richard Smith | 0a664b8 | 2013-05-09 21:36:41 +0000 | [diff] [blame] | 21 | |
Richard Smith | 0d8e964 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 22 | [foo(bar)] () {}; |
| 23 | [foo = bar] () {}; |
| 24 | [foo{bar}] () {}; // expected-error {{<initializer_list>}} |
| 25 | [foo = {bar}] () {}; // expected-error {{<initializer_list>}} |
Richard Smith | 0a664b8 | 2013-05-09 21:36:41 +0000 | [diff] [blame] | 26 | |
| 27 | [foo(bar) baz] () {}; // expected-error {{called object type 'int' is not a function}} |
Richard Smith | 440d456 | 2013-05-21 22:21:19 +0000 | [diff] [blame] | 28 | [foo(bar), baz] () {}; // ok |
Richard Smith | 0a664b8 | 2013-05-09 21:36:41 +0000 | [diff] [blame] | 29 | |
Richard Smith | 440d456 | 2013-05-21 22:21:19 +0000 | [diff] [blame] | 30 | [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 Gregor | ae7902c | 2011-08-04 15:30:47 +0000 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | }; |
| 43 | |