1 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y 2 3 //FIXME: These tests were written when return type deduction had not been implemented 4 // for generic lambdas, hence 5 template<class T> T id(T t); 6 template<class ... Ts> int vfoo(Ts&& ... ts); 7 auto GL1 = [](auto a, int i) -> int { return id(a); }; 8 9 auto GL2 = [](auto ... As) -> int { return vfoo(As...); }; 10 auto GL3 = [](int i, char c, auto* ... As) -> int { return vfoo(As...); }; 11 12 auto GL4 = [](int i, char c, auto* ... As) -> int { return vfoo(As...); }; 13 14 15 void foo() { 16 auto GL1 = [](auto a, int i) -> int { return id(a); }; 17 18 auto GL2 = [](auto ... As) -> int { return vfoo(As...); }; 19 } 20 21 int main() 22 { 23 auto l1 = [](auto a) -> int { return a + 5; }; 24 auto l2 = [](auto *p) -> int { return p + 5; }; 25 26 struct A { int i; char f(int) { return 'c'; } }; 27 auto l3 = [](auto &&ur, 28 auto &lr, 29 auto v, 30 int i, 31 auto* p, 32 auto A::*memvar, 33 auto (A::*memfun)(int), 34 char c, 35 decltype (v)* pv 36 , auto (&array)[5] 37 ) -> int { return v + i + c 38 + array[0]; 39 }; 40 int arr[5] = {0, 1, 2, 3, 4 }; 41 int lval = 0; 42 double d = 3.14; 43 l3(3, lval, d, lval, &lval, &A::i, &A::f, 'c', &d, arr); 44 auto l4 = [](decltype(auto) a) -> int { return 0; }; //expected-error{{decltype(auto)}} 45 { 46 struct Local { 47 static int ifi(int i) { return i; } 48 static char cfi(int) { return 'a'; } 49 static double dfi(int i) { return i + 3.14; } 50 static Local localfi(int) { return Local{}; } 51 }; 52 auto l4 = [](auto (*fp)(int)) -> int { return fp(3); }; //expected-error{{no viable conversion from returned value of type 'Local' to function return type 'int'}} 53 l4(&Local::ifi); 54 l4(&Local::cfi); 55 l4(&Local::dfi); 56 l4(&Local::localfi); //expected-note{{in instantiation of function template specialization}} 57 } 58 { 59 auto unnamed_parameter = [](auto, auto) -> void { }; 60 unnamed_parameter(3, '4'); 61 } 62 { 63 auto l = [](auto 64 (*)(auto)) { }; //expected-error{{'auto' not allowed}} 65 //FIXME: These diagnostics might need some work. 66 auto l2 = [](char auto::*pm) { }; //expected-error{{cannot combine with previous}}\ 67 expected-error{{'pm' does not point into a class}} 68 auto l3 = [](char (auto::*pmf)()) { }; //expected-error{{'auto' not allowed}}\ 69 expected-error{{'pmf' does not point into a class}}\ 70 expected-error{{function cannot return function type 'char ()'}} 71 } 72 } 73 74 75