p4.cpp revision 53393f23d8b767f976427a6d45b310bf37dd91c4
1// 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;
20    case 2: return { 1, 2.0 }; // expected-error{{cannot deduce lambda return type from initializer list}}
21    }
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}
44
45struct Incomplete; // expected-note{{forward declaration of 'Incomplete'}}
46void 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