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