p4.cpp revision a0c2b21e0d84ad289781e08e14148da6b8b8b76d
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