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