Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Andy Gibbs | 8e8fb3b | 2012-10-19 12:44:48 +0000 | [diff] [blame] | 2 | // expected-no-diagnostics |
Douglas Gregor | 199d991 | 2009-06-05 00:53:49 +0000 | [diff] [blame] | 3 | |
| 4 | // template<unsigned M, unsigned N> |
| 5 | // struct Ackermann { |
| 6 | // enum { |
Daniel Dunbar | 70b8742 | 2009-07-11 22:44:48 +0000 | [diff] [blame] | 7 | // value = M ? (N ? Ackermann<M-1, Ackermann<M, N-1> >::value |
Douglas Gregor | 199d991 | 2009-06-05 00:53:49 +0000 | [diff] [blame] | 8 | // : Ackermann<M-1, 1>::value) |
| 9 | // : N + 1 |
| 10 | // }; |
| 11 | // }; |
| 12 | |
| 13 | template<unsigned M, unsigned N> |
| 14 | struct Ackermann { |
| 15 | enum { |
| 16 | value = Ackermann<M-1, Ackermann<M, N-1>::value >::value |
| 17 | }; |
| 18 | }; |
| 19 | |
| 20 | template<unsigned M> struct Ackermann<M, 0> { |
| 21 | enum { |
| 22 | value = Ackermann<M-1, 1>::value |
| 23 | }; |
| 24 | }; |
| 25 | |
| 26 | template<unsigned N> struct Ackermann<0, N> { |
| 27 | enum { |
| 28 | value = N + 1 |
| 29 | }; |
| 30 | }; |
| 31 | |
| 32 | template<> struct Ackermann<0, 0> { |
| 33 | enum { |
| 34 | value = 1 |
| 35 | }; |
| 36 | }; |
| 37 | |
Daniel Dunbar | 70b8742 | 2009-07-11 22:44:48 +0000 | [diff] [blame] | 38 | int g0[Ackermann<3, 4>::value == 125 ? 1 : -1]; |
| 39 | |