1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -Wno-c++1y-extensions -std=c++11 %s
2
3class C {
4  id get(int);
5
6  void f() {
7    int foo, bar, baz;
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}}
14    [&this] {}; // expected-error {{cannot take the address of an rvalue of type 'C *'}}
15    [] {};
16    [=] (int i) {};
17    [&] (int) mutable -> void {};
18    [foo,bar] () { return 3; };
19    [=,&foo] () {};
20    [this] () {};
21
22    [foo(bar)] () {};
23    [foo = bar] () {};
24    [foo{bar}] () {};
25    [foo = {bar}] () {}; // expected-error {{<initializer_list>}}
26
27    [foo(bar) baz] () {}; // expected-error {{called object type 'int' is not a function}}
28    [foo(bar), baz] () {}; // ok
29
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}}
40  }
41
42};
43
44struct Func {
45  template <typename F>
46  Func(F&&);
47};
48
49int getInt();
50
51void test() {
52  [val = getInt()]() { };
53  Func{
54    [val = getInt()]() { }
55  };
56}
57