blob: e8a1ec772e81f96d179302afc0de6ff41e839d9a [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only %s
Douglas Gregor5953d8b2009-03-19 17:26:29 +00002
3// FIXME: The Fibonacci/FibonacciEval dance is here to work around our
4// inability to parse injected-class-name<template-argument-list>.
5template<unsigned I>
6struct FibonacciEval;
7
8template<unsigned I>
9struct Fibonacci {
10 enum { value = FibonacciEval<I-1>::value + FibonacciEval<I-2>::value };
11};
12
13template<unsigned I>
14struct FibonacciEval {
15 enum { value = Fibonacci<I>::value };
16};
17
18template<> struct Fibonacci<0> {
19 enum { value = 0 };
20};
21
22template<> struct Fibonacci<1> {
23 enum { value = 1 };
24};
25
26int array5[Fibonacci<5>::value == 5? 1 : -1];
27int array10[Fibonacci<10>::value == 55? 1 : -1];
Douglas Gregor3d7a12a2009-03-25 23:32:15 +000028
29template<unsigned I>
30struct FibonacciEval2;
31
32template<unsigned I>
33struct Fibonacci2 {
34 static const unsigned value
35 = FibonacciEval2<I-1>::value + FibonacciEval2<I-2>::value;
36};
37
38template<unsigned I>
39struct FibonacciEval2 {
40 static const unsigned value = Fibonacci2<I>::value;
41};
42
43template<> struct Fibonacci2<0> {
44 static const unsigned value = 0;
45};
46
47template<> struct Fibonacci2<1> {
48 static const unsigned value = 1;
49};
50
51int array5_2[Fibonacci2<5>::value == 5? 1 : -1];
52int array10_2[Fibonacci2<10>::value == 55? 1 : -1];