xref: /llvm-project/clang/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp (revision 9ca5c425826329d5b23300bbc8a1a7c10a19c64d)
1*9ca5c425SRichard Smith // RUN: %clang_cc1 -std=c++11 -fblocks -fsyntax-only -verify %s
2476e3029SDouglas Gregor 
3476e3029SDouglas Gregor // Tests the use of blocks with variadic templates.
4476e3029SDouglas Gregor template<typename ...Args>
f0(Args...args)5476e3029SDouglas Gregor int f0(Args ...args) {
6476e3029SDouglas Gregor   return ^ {
7476e3029SDouglas Gregor     return sizeof...(Args);
8476e3029SDouglas Gregor   }() + ^ {
9476e3029SDouglas Gregor     return sizeof...(args);
10476e3029SDouglas Gregor   }();
11476e3029SDouglas Gregor }
12476e3029SDouglas Gregor 
13476e3029SDouglas Gregor template<typename ...Args>
f1(Args...args)14476e3029SDouglas Gregor int f1(Args ...args) {
15476e3029SDouglas Gregor   return ^ {
16476e3029SDouglas Gregor     return f0(args...);
17476e3029SDouglas Gregor   }();
18476e3029SDouglas Gregor }
19476e3029SDouglas Gregor 
20476e3029SDouglas Gregor template int f0(int, float, double);
21476e3029SDouglas Gregor template int f1(const char*, int, float, double);
22476e3029SDouglas Gregor 
23476e3029SDouglas Gregor template<typename ...Args>
f2(Args...args)24476e3029SDouglas Gregor int f2(Args ...args) {
25476e3029SDouglas Gregor   return ^(Args ...block_args) {
26476e3029SDouglas Gregor     return f1(block_args...);
27476e3029SDouglas Gregor   }(args + 0 ...);
28476e3029SDouglas Gregor }
29476e3029SDouglas Gregor 
30476e3029SDouglas Gregor template int f2(const char*, int, float, double);
31476e3029SDouglas Gregor 
32476e3029SDouglas Gregor template<typename ...Args>
f3(Args...args)33476e3029SDouglas Gregor int f3(Args ...args) {
34476e3029SDouglas Gregor   return ^(Args *...block_args) {
35476e3029SDouglas Gregor     return f1(block_args...);
36476e3029SDouglas Gregor   }(&args...);
37476e3029SDouglas Gregor }
38476e3029SDouglas Gregor 
39476e3029SDouglas Gregor template int f3(const char*, int, float, double);
404385d8b0SDouglas Gregor 
414385d8b0SDouglas Gregor template<typename ...Args>
PR9953(Args...args)424385d8b0SDouglas Gregor int PR9953(Args ...args) {
434385d8b0SDouglas Gregor   return ^(Args *...block_args) {
444385d8b0SDouglas Gregor     return f1(block_args); // expected-error{{expression contains unexpanded parameter pack 'block_args'}}
454385d8b0SDouglas Gregor   }(&args...);
464385d8b0SDouglas Gregor }
47