Debian Codegraph @

gcc/testsuite/g++.dg/tree-ssa/pr14703.C

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-optimized -fno-ipa-reference" } */
3 /* { dg-skip-if "requires hosted libstdc++ for iostream" { ! hostedlib } } */
4 #include <iostream>
5
6 namespace {
7 template <unsigned long long L> class fib {
8 public:
9 static const unsigned long long value = fib<L - 1>::value + fib<L - 2>::value;
10 };
11
12 template <> class fib<0> {
13 public:
14 static const unsigned long long value = 1;
15 };
16
17 template <> class fib<1> {
18 public:
19 static const unsigned long long value = 1;
20 };
21
22 template<unsigned long long L> inline unsigned long long fibconst()
23 {
24 return fibconst<L - 1>() + fibconst<L - 2>();
25 }
26
27 template <> inline unsigned long long fibconst<0>()
28 {
29 return 1ull;
30 }
31
32 template <> inline unsigned long long fibconst<1>()
33 {
34 return 1ull;
35 }
36
37 template <> inline unsigned long long fibconst<2>()
38 {
39 return 2ull;
40 }
41
42 }
43
44 int main()
45 {
46 ::std::cerr << "fib<90>::value == " << fib<90>::value << "\n";
47 ::std::cerr << "fibcst<90>() == " << fibconst<90>() << "\n";
48 }
49 // { dg-final { scan-tree-dump-not "fibconst" "optimized" } }