1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
2 // RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify -DCPP1Y
3
missing_lambda_declarator()4 void missing_lambda_declarator() {
5 [](){}();
6 }
7
8 template<typename T> T get();
9
infer_void_return_type(int i)10 void infer_void_return_type(int i) {
11 if (i > 17)
12 return []() { }();
13
14 if (i > 11)
15 return []() { return; }();
16
17 return [](int x) {
18 switch (x) {
19 case 0: return get<void>();
20 case 1: return;
21 case 2: return { 1, 2.0 }; //expected-error{{cannot deduce}}
22 }
23 }(7);
24 }
25
26 struct X { };
27
infer_X_return_type(X x)28 X infer_X_return_type(X x) {
29 return [&x](int y) {
30 if (y > 0)
31 return X();
32 else
33 return x;
34 }(5);
35 }
36
infer_X_return_type_2(X x)37 X infer_X_return_type_2(X x) {
38 return [x](int y) {
39 if (y > 0)
40 return X();
41 else
42 return x; // ok even in c++11, per dr1048.
43 }(5);
44 }
45
46 struct Incomplete; // expected-note{{forward declaration of 'Incomplete'}}
test_result_type(int N)47 void test_result_type(int N) {
48 auto l1 = [] () -> Incomplete { }; // expected-error{{incomplete result type 'Incomplete' in lambda expression}}
49
50 typedef int vla[N];
51 auto l2 = [] () -> vla { }; // expected-error{{function cannot return array type 'vla' (aka 'int [N]')}}
52 }
53