1 | // RUN: %clang_cc1 -fsyntax-only %s |
2 | |
3 | template<unsigned I> |
4 | struct FibonacciEval; |
5 | |
6 | template<unsigned I> |
7 | struct Fibonacci { |
8 | enum { value = FibonacciEval<I-1>::value + FibonacciEval<I-2>::value }; |
9 | }; |
10 | |
11 | template<unsigned I> |
12 | struct FibonacciEval { |
13 | enum { value = Fibonacci<I>::value }; |
14 | }; |
15 | |
16 | template<> struct Fibonacci<0> { |
17 | enum { value = 0 }; |
18 | }; |
19 | |
20 | template<> struct Fibonacci<1> { |
21 | enum { value = 1 }; |
22 | }; |
23 | |
24 | int array5[Fibonacci<5>::value == 5? 1 : -1]; |
25 | int array10[Fibonacci<10>::value == 55? 1 : -1]; |
26 | |
27 | template<unsigned I> |
28 | struct FibonacciEval2; |
29 | |
30 | template<unsigned I> |
31 | struct Fibonacci2 { |
32 | static const unsigned value |
33 | = FibonacciEval2<I-1>::value + FibonacciEval2<I-2>::value; |
34 | }; |
35 | |
36 | template<unsigned I> |
37 | struct FibonacciEval2 { |
38 | static const unsigned value = Fibonacci2<I>::value; |
39 | }; |
40 | |
41 | template<> struct Fibonacci2<0> { |
42 | static const unsigned value = 0; |
43 | }; |
44 | |
45 | template<> struct Fibonacci2<1> { |
46 | static const unsigned value = 1; |
47 | }; |
48 | |
49 | int array5_2[Fibonacci2<5>::value == 5? 1 : -1]; |
50 | int array10_2[Fibonacci2<10>::value == 55? 1 : -1]; |
51 | |
52 | template<unsigned I> |
53 | struct Fibonacci3 { |
54 | static const unsigned value = Fibonacci3<I-1>::value + Fibonacci3<I-2>::value; |
55 | }; |
56 | |
57 | template<> struct Fibonacci3<0> { |
58 | static const unsigned value = 0; |
59 | }; |
60 | |
61 | template<> struct Fibonacci3<1> { |
62 | static const unsigned value = 1; |
63 | }; |
64 | |
65 | int array5_3[Fibonacci3<5>::value == 5? 1 : -1]; |
66 | int array10_3[Fibonacci3<10>::value == 55? 1 : -1]; |
67 | |