1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s -DDELAYED_TEMPLATE_PARSING
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fms-extensions %s -DMS_EXTENSIONS
4*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS -DDELAYED_TEMPLATE_PARSING
5*0a6a1f1dSLionel Sambuc
6*0a6a1f1dSLionel Sambuc namespace explicit_argument_variadics {
7*0a6a1f1dSLionel Sambuc
8*0a6a1f1dSLionel Sambuc
print(Ts...)9*0a6a1f1dSLionel Sambuc template<class ... Ts> void print(Ts ... ) { }
10*0a6a1f1dSLionel Sambuc
11*0a6a1f1dSLionel Sambuc struct X { };
12*0a6a1f1dSLionel Sambuc struct Y { };
13*0a6a1f1dSLionel Sambuc struct Z { };
14*0a6a1f1dSLionel Sambuc
test()15*0a6a1f1dSLionel Sambuc int test() {
16*0a6a1f1dSLionel Sambuc {
17*0a6a1f1dSLionel Sambuc auto L = [](auto ... as) { };
18*0a6a1f1dSLionel Sambuc L.operator()<bool>(true);
19*0a6a1f1dSLionel Sambuc }
20*0a6a1f1dSLionel Sambuc {
21*0a6a1f1dSLionel Sambuc auto L = [](auto a) { };
22*0a6a1f1dSLionel Sambuc L.operator()<bool>(false);
23*0a6a1f1dSLionel Sambuc }
24*0a6a1f1dSLionel Sambuc {
25*0a6a1f1dSLionel Sambuc auto L = [](auto a, auto b) { };
26*0a6a1f1dSLionel Sambuc L.operator()<bool>(false, 'a');
27*0a6a1f1dSLionel Sambuc }
28*0a6a1f1dSLionel Sambuc {
29*0a6a1f1dSLionel Sambuc auto L = [](auto a, auto b) { };
30*0a6a1f1dSLionel Sambuc L.operator()<bool, char>(false, 'a');
31*0a6a1f1dSLionel Sambuc }
32*0a6a1f1dSLionel Sambuc {
33*0a6a1f1dSLionel Sambuc auto L = [](auto a, auto b, auto ... cs) { };
34*0a6a1f1dSLionel Sambuc L.operator()<bool, char>(false, 'a');
35*0a6a1f1dSLionel Sambuc L.operator()<bool, char, const char*>(false, 'a', "jim");
36*0a6a1f1dSLionel Sambuc }
37*0a6a1f1dSLionel Sambuc
38*0a6a1f1dSLionel Sambuc {
39*0a6a1f1dSLionel Sambuc auto L = [](auto ... As) {
40*0a6a1f1dSLionel Sambuc };
41*0a6a1f1dSLionel Sambuc L.operator()<bool, double>(false, 3.14, "abc");
42*0a6a1f1dSLionel Sambuc }
43*0a6a1f1dSLionel Sambuc {
44*0a6a1f1dSLionel Sambuc auto L = [](auto A, auto B, auto ... As) {
45*0a6a1f1dSLionel Sambuc };
46*0a6a1f1dSLionel Sambuc L.operator()<bool>(false, 3.14, "abc");
47*0a6a1f1dSLionel Sambuc L.operator()<bool, char>(false, 3.14, "abc"); //expected-warning{{implicit conversion}}
48*0a6a1f1dSLionel Sambuc L.operator()<X, Y, bool, Z>(X{}, Y{}, 3.14, Z{}, X{}); //expected-warning{{implicit conversion}}
49*0a6a1f1dSLionel Sambuc }
50*0a6a1f1dSLionel Sambuc {
51*0a6a1f1dSLionel Sambuc auto L = [](auto ... As) {
52*0a6a1f1dSLionel Sambuc print("\nL::As = ", As ...);
53*0a6a1f1dSLionel Sambuc return [](decltype(As) ... as, auto ... Bs) {
54*0a6a1f1dSLionel Sambuc print("\nL::Inner::as = ", as ...);
55*0a6a1f1dSLionel Sambuc print("\nL::Inner::Bs = ", Bs ...);
56*0a6a1f1dSLionel Sambuc return 4;
57*0a6a1f1dSLionel Sambuc };
58*0a6a1f1dSLionel Sambuc };
59*0a6a1f1dSLionel Sambuc auto M = L.operator()<bool, double>(false, 3.14, "abc");
60*0a6a1f1dSLionel Sambuc M(false, 6.26, "jim", true);
61*0a6a1f1dSLionel Sambuc M.operator()<bool>(true, 6.26, "jim", false, 3.14);
62*0a6a1f1dSLionel Sambuc }
63*0a6a1f1dSLionel Sambuc {
64*0a6a1f1dSLionel Sambuc auto L = [](auto A, auto ... As) {
65*0a6a1f1dSLionel Sambuc print("\nL::As = ", As ...);
66*0a6a1f1dSLionel Sambuc return [](decltype(As) ... as, decltype(A) a, auto ... Bs) {
67*0a6a1f1dSLionel Sambuc print("\nL::Inner::as = ", as ...);
68*0a6a1f1dSLionel Sambuc print("\nL::Inner::Bs = ", Bs ...);
69*0a6a1f1dSLionel Sambuc return 4;
70*0a6a1f1dSLionel Sambuc };
71*0a6a1f1dSLionel Sambuc };
72*0a6a1f1dSLionel Sambuc auto M = L.operator()<bool, double>(false, 3.14, "abc");
73*0a6a1f1dSLionel Sambuc M(6.26, "jim", true);
74*0a6a1f1dSLionel Sambuc M.operator()<X>(6.26, "jim", false, X{}, Y{}, Z{});
75*0a6a1f1dSLionel Sambuc }
76*0a6a1f1dSLionel Sambuc
77*0a6a1f1dSLionel Sambuc return 0;
78*0a6a1f1dSLionel Sambuc }
79*0a6a1f1dSLionel Sambuc int run = test();
80*0a6a1f1dSLionel Sambuc } // end ns explicit_argument_extension
81*0a6a1f1dSLionel Sambuc
82*0a6a1f1dSLionel Sambuc
83*0a6a1f1dSLionel Sambuc
84*0a6a1f1dSLionel Sambuc #ifdef PR18499_FIXED
85*0a6a1f1dSLionel Sambuc namespace variadic_expansion {
86*0a6a1f1dSLionel Sambuc void f(int &, char &);
87*0a6a1f1dSLionel Sambuc
g(T &...t)88*0a6a1f1dSLionel Sambuc template <typename ... T> void g(T &... t) {
89*0a6a1f1dSLionel Sambuc f([&a(t)]()->decltype(auto) {
90*0a6a1f1dSLionel Sambuc return a;
91*0a6a1f1dSLionel Sambuc }() ...);
92*0a6a1f1dSLionel Sambuc f([&a(f([&b(t)]()->decltype(auto) { return b; }()...), t)]()->decltype(auto) {
93*0a6a1f1dSLionel Sambuc return a;
94*0a6a1f1dSLionel Sambuc }()...);
95*0a6a1f1dSLionel Sambuc }
96*0a6a1f1dSLionel Sambuc
h(int i,char c)97*0a6a1f1dSLionel Sambuc void h(int i, char c) { g(i, c); }
98*0a6a1f1dSLionel Sambuc }
99*0a6a1f1dSLionel Sambuc #endif
100*0a6a1f1dSLionel Sambuc
101