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