1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc // expected-no-diagnostics 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc // template<unsigned M, unsigned N> 5*f4a2713aSLionel Sambuc // struct Ackermann { 6*f4a2713aSLionel Sambuc // enum { 7*f4a2713aSLionel Sambuc // value = M ? (N ? Ackermann<M-1, Ackermann<M, N-1> >::value 8*f4a2713aSLionel Sambuc // : Ackermann<M-1, 1>::value) 9*f4a2713aSLionel Sambuc // : N + 1 10*f4a2713aSLionel Sambuc // }; 11*f4a2713aSLionel Sambuc // }; 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc template<unsigned M, unsigned N> 14*f4a2713aSLionel Sambuc struct Ackermann { 15*f4a2713aSLionel Sambuc enum { 16*f4a2713aSLionel Sambuc value = Ackermann<M-1, Ackermann<M, N-1>::value >::value 17*f4a2713aSLionel Sambuc }; 18*f4a2713aSLionel Sambuc }; 19*f4a2713aSLionel Sambuc 20*f4a2713aSLionel Sambuc template<unsigned M> struct Ackermann<M, 0> { 21*f4a2713aSLionel Sambuc enum { 22*f4a2713aSLionel Sambuc value = Ackermann<M-1, 1>::value 23*f4a2713aSLionel Sambuc }; 24*f4a2713aSLionel Sambuc }; 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc template<unsigned N> struct Ackermann<0, N> { 27*f4a2713aSLionel Sambuc enum { 28*f4a2713aSLionel Sambuc value = N + 1 29*f4a2713aSLionel Sambuc }; 30*f4a2713aSLionel Sambuc }; 31*f4a2713aSLionel Sambuc 32*f4a2713aSLionel Sambuc template<> struct Ackermann<0, 0> { 33*f4a2713aSLionel Sambuc enum { 34*f4a2713aSLionel Sambuc value = 1 35*f4a2713aSLionel Sambuc }; 36*f4a2713aSLionel Sambuc }; 37*f4a2713aSLionel Sambuc 38*f4a2713aSLionel Sambuc int g0[Ackermann<3, 4>::value == 125 ? 1 : -1]; 39*f4a2713aSLionel Sambuc 40