1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++1z -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
2*0a6a1f1dSLionel Sambuc
3*0a6a1f1dSLionel Sambuc template<int> struct A {};
4*0a6a1f1dSLionel Sambuc template<int ...N> void foldr(A<(N + ...)>);
5*0a6a1f1dSLionel Sambuc template<int ...N> void foldl(A<(... + N)>);
6*0a6a1f1dSLionel Sambuc template<int ...N> void foldr1(A<(N + ... + 1)>);
7*0a6a1f1dSLionel Sambuc template<int ...N> void foldl1(A<(1 + ... + N)>);
use()8*0a6a1f1dSLionel Sambuc void use() {
9*0a6a1f1dSLionel Sambuc foldr<1, 2, 3>({});
10*0a6a1f1dSLionel Sambuc foldl<1, 2, 3>({});
11*0a6a1f1dSLionel Sambuc foldr1<1, 2, 3>({});
12*0a6a1f1dSLionel Sambuc foldl1<1, 2, 3>({});
13*0a6a1f1dSLionel Sambuc // CHECK-DAG: @_Z5foldrIJLi1ELi2ELi3EEEv1AIXfrplT_EE(
14*0a6a1f1dSLionel Sambuc // CHECK-DAG: @_Z5foldlIJLi1ELi2ELi3EEEv1AIXflplT_EE(
15*0a6a1f1dSLionel Sambuc // CHECK-DAG: @_Z6foldr1IJLi1ELi2ELi3EEEv1AIXfRplT_Li1EEE(
16*0a6a1f1dSLionel Sambuc // CHECK-DAG: @_Z6foldl1IJLi1ELi2ELi3EEEv1AIXfLplLi1ET_EE(
17*0a6a1f1dSLionel Sambuc }
18*0a6a1f1dSLionel Sambuc
19*0a6a1f1dSLionel Sambuc template<int ...N> using Foldr = A<(N + ...)>;
20*0a6a1f1dSLionel Sambuc template<int ...N> using Foldl = A<(... + N)>;
21*0a6a1f1dSLionel Sambuc template<int ...N> using Foldr1 = A<(N + ... + 1)>;
22*0a6a1f1dSLionel Sambuc template<int ...N> using Foldl1 = A<(1 + ... + N)>;
23*0a6a1f1dSLionel Sambuc
24*0a6a1f1dSLionel Sambuc template<int ...A> struct Partial {
25*0a6a1f1dSLionel Sambuc template<int ...B> void foldr(Foldr<A..., B..., A..., B...>);
26*0a6a1f1dSLionel Sambuc template<int ...B> void foldl(Foldl<A..., B..., A..., B...>);
27*0a6a1f1dSLionel Sambuc template<int ...B> void foldr1(Foldr1<A..., B..., A..., B...>);
28*0a6a1f1dSLionel Sambuc template<int ...B> void foldl1(Foldl1<A..., B..., A..., B...>);
29*0a6a1f1dSLionel Sambuc };
use(Partial<1,2> p)30*0a6a1f1dSLionel Sambuc void use(Partial<1, 2> p) {
31*0a6a1f1dSLionel Sambuc p.foldr<3, 4>({});
32*0a6a1f1dSLionel Sambuc p.foldl<3, 4>({});
33*0a6a1f1dSLionel Sambuc p.foldr1<3, 4>({});
34*0a6a1f1dSLionel Sambuc p.foldl1<3, 4>({});
35*0a6a1f1dSLionel Sambuc // CHECK-DAG: @_ZN7PartialIJLi1ELi2EEE5foldrIJLi3ELi4EEEEv1AIXplLi1EplLi2EfRplT_plLi1EplLi2EfrplT_EE(
36*0a6a1f1dSLionel Sambuc // CHECK-DAG: @_ZN7PartialIJLi1ELi2EEE5foldlIJLi3ELi4EEEEv1AIXfLplplplfLplplLi1ELi2ET_Li1ELi2ET_EE
37*0a6a1f1dSLionel Sambuc // CHECK-DAG: @_ZN7PartialIJLi1ELi2EEE6foldr1IJLi3ELi4EEEEv1AIXplLi1EplLi2EfRplT_plLi1EplLi2EfRplT_Li1EEE(
38*0a6a1f1dSLionel Sambuc // CHECK-DAG: @_ZN7PartialIJLi1ELi2EEE6foldl1IJLi3ELi4EEEEv1AIXfLplplplfLplplplLi1ELi1ELi2ET_Li1ELi2ET_EE(
39*0a6a1f1dSLionel Sambuc }
40*0a6a1f1dSLionel Sambuc
41*0a6a1f1dSLionel Sambuc extern int n;
f()42*0a6a1f1dSLionel Sambuc template<int ...N> void f() {
43*0a6a1f1dSLionel Sambuc (n = ... = N);
44*0a6a1f1dSLionel Sambuc }
45*0a6a1f1dSLionel Sambuc template void f<>();
46