blob: cff0c0995054a324ed02f58c25a1f8e2565ad7cb [file] [log] [blame]
Douglas Gregor73456262012-02-09 10:18:50 +00001// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
2
3void missing_lambda_declarator() {
4 [](){}();
5}
6
7template<typename T> T get();
8
9void 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;
Douglas Gregor940a5502012-02-09 18:40:39 +000020 case 2: return { 1, 2.0 }; // expected-error{{cannot deduce lambda return type from initializer list}}
Douglas Gregor73456262012-02-09 10:18:50 +000021 }
22 }(7);
23}
24
25struct X { };
26
27X 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
36X 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 // FIXME: shouldn't mention blocks
41 return x; // expected-error{{return type 'const X' must match previous return type 'X' when block literal has unspecified explicit return type}}
42 }(5);
43}