Debian Codegraph @

clang/test/Parser/objcxx0x-lambda-expressions.mm

raw
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -Wno-c++1y-extensions -std=c++11 %s
2
3 class 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 // expected-error {{expected identifier}}
16 [] {};
17 [=] (int i) {};
18 [&] (int) mutable -> void {};
19 [foo,bar] () { return 3; };
20 [=,&foo] () {};
21 [this] () {};
22
23 [foo(bar)] () {};
24 [foo = bar] () {};
25 [foo{bar}] () {};
26 [foo = {bar}] () {}; // expected-error {{<initializer_list>}}
27
28 [foo(bar) baz] () {}; // expected-error {{called object type 'int' is not a function}} \
29 // expected-error {{expected ';'}}
30 [foo(bar), baz] () {}; // ok
31
32 [foo = bar baz]; // expected-warning {{receiver type 'int'}} expected-warning {{instance method '-baz'}}
33
34 [get(bar) baz]; // expected-warning {{instance method '-baz'}}
35 [get(bar), baz]; // expected-error {{expected body of lambda}}
36
37 [foo = bar ++ baz]; // expected-warning {{receiver type 'int'}} expected-warning {{instance method '-baz'}}
38 [foo = bar + baz]; // expected-error {{expected body of lambda}}
39 [foo = { bar, baz }]; // expected-error {{<initializer_list>}} expected-error {{expected body of lambda}}
40 [foo = { bar } baz ]; // expected-warning {{receiver type 'int'}} expected-warning {{instance method '-baz'}}
41 [foo = { bar }, baz ]; // expected-error {{<initializer_list>}} expected-error {{expected body of lambda}}
42 }
43
44 };
45
46 struct Func {
47 template <typename F>
48 Func(F&&);
49 };
50
51 int getInt();
52
53 void test() {
54 [val = getInt()]() { };
55 Func{
56 [val = getInt()]() { }
57 };
58 }