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