| Faisal Vali | 2b391ab | 2013-09-26 19:54:12 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify -emit-llvm | 
|  | 2 | namespace return_type_deduction_ok { | 
|  | 3 | auto l = [](auto a) ->auto { return a; }(2); | 
|  | 4 | auto l2 = [](auto a) ->decltype(auto) { return a; }(2); | 
|  | 5 | auto l3 = [](auto a) { return a; }(2); | 
|  | 6 |  | 
|  | 7 | } | 
|  | 8 |  | 
|  | 9 | namespace lambda_capturing { | 
|  | 10 | // FIXME: Once return type deduction is implemented for generic lambdas | 
|  | 11 | // this will need to be updated. | 
|  | 12 | void test() { | 
|  | 13 | int i = 10; | 
|  | 14 | auto L = [=](auto a) -> int { //expected-error{{unimplemented}} | 
|  | 15 | return i + a; | 
|  | 16 | }; | 
|  | 17 | L(3); | 
|  | 18 | } | 
|  | 19 |  | 
|  | 20 | } | 
|  | 21 |  | 
|  | 22 | namespace nested_generic_lambdas { | 
|  | 23 | void test() { | 
|  | 24 | auto L = [](auto a) -> int { | 
|  | 25 | auto M = [](auto b, decltype(a) b2) -> int { //expected-error{{unimplemented}} | 
|  | 26 | return 1; | 
|  | 27 | }; | 
|  | 28 | M(a, a); | 
|  | 29 | }; | 
|  | 30 | L(3); //expected-note{{in instantiation of}} | 
|  | 31 | } | 
|  | 32 | template<class T> void foo(T) { | 
|  | 33 | auto L = [](auto a) { return a; }; //expected-error{{unimplemented}} | 
|  | 34 | } | 
|  | 35 | template void foo(int); //expected-note{{in instantiation of}} | 
|  | 36 | } | 
|  | 37 |  | 
|  | 38 | namespace conversion_operator { | 
|  | 39 | void test() { | 
|  | 40 | auto L = [](auto a) -> int { return a; }; | 
|  | 41 | int (*fp)(int) = L;  //expected-error{{no viable conversion}} | 
|  | 42 | } | 
|  | 43 | } | 
|  | 44 |  | 
|  | 45 | namespace generic_lambda_as_default_argument_ok { | 
|  | 46 | void test(int i = [](auto a)->int { return a; }(3)) { | 
|  | 47 |  | 
|  | 48 | } | 
|  | 49 |  | 
|  | 50 | } | 
|  | 51 |  |