1 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y
3 namespace test_factorial
{
5 auto Fact
= [](auto Self
, unsigned n
) -> unsigned {
6 return !n
? 1 : Self(Self
, n
- 1) * n
;
9 auto six
= Fact(Fact
, 3);
13 namespace overload_generic_lambda
{
14 template <class F1
, class F2
> struct overload
: F1
, F2
{
17 overload(F1 f1
, F2 f2
) : F1(f1
), F2(f2
) { }
20 auto NumParams
= [](auto Self
, auto h
, auto ... rest
) -> unsigned {
21 return 1 + Self(Self
, rest
...);
23 auto Base
= [](auto Self
, auto h
) -> unsigned {
26 overload
<decltype(Base
), decltype(NumParams
)> O(Base
, NumParams
);
27 int num_params
= O(O
, 5, 3, "abc", 3.14, 'a');
31 namespace overload_generic_lambda_return_type_deduction
{
32 template <class F1
, class F2
> struct overload
: F1
, F2
{
35 overload(F1 f1
, F2 f2
) : F1(f1
), F2(f2
) { }
38 auto NumParams
= [](auto Self
, auto h
, auto ... rest
) {
39 return 1 + Self(Self
, rest
...);
41 auto Base
= [](auto Self
, auto h
) {
44 overload
<decltype(Base
), decltype(NumParams
)> O(Base
, NumParams
);
45 int num_params
= O(O
, 5, 3, "abc", 3.14, 'a');
48 namespace test_standard_p5
{
49 // FIXME: This test should eventually compile without an explicit trailing return type
50 auto glambda
= [](auto a
, auto&& b
) ->bool { return a
< b
; };
51 bool b
= glambda(3, 3.14); // OK
54 namespace test_deduction_failure
{
56 auto g
= [](auto *a
) { //expected-note{{candidate template ignored}}
62 g(3); //expected-error{{no matching function}}
68 namespace test_instantiation_or_sfinae_failure
{
71 auto L
= [](auto *a
) {
72 return (*a
)(a
); }; //expected-error{{called object type 'double' is not a function}}
74 L(&d
); //expected-note{{in instantiation of}}
75 auto M
= [](auto b
) { return b
; };
79 auto L
= [](auto *a
) ->decltype (a
->foo()) { //expected-note2{{candidate template ignored:}}
82 L(&d
); //expected-error{{no matching function for call}}
83 auto M
= [](auto b
) { return b
; };
84 L(&M
); //expected-error{{no matching function for call}}
94 auto GL
= [](auto a
, decltype(a
) b
) //expected-note{{candidate function}}
95 -> int { return a
+ b
; };
99 GL(3, X
{}); //expected-error{{no matching function}}
103 auto l
= [](auto *a
) -> int {
104 (*a
)(a
); return 0; }; //expected-error{{called object type 'double' is not a function}}
107 l(&d
); //expected-note{{in instantiation of}}
112 namespace nested_lambdas
{
114 auto L
= [](auto a
) {
127 auto L
= get_lambda();