Debian Codegraph @

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

raw
1 /* PR tree-optimization/96979 */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c++17 -O2" } */
4
5 using u64 = unsigned long long;
6
7 constexpr inline u64
8 foo (const char *str) noexcept
9 {
10 u64 value = 0xcbf29ce484222325ULL;
11 for (u64 i = 0; str[i]; i++)
12 value = (value ^ u64(str[i])) * 0x100000001b3ULL;
13 return value;
14 }
15
16 struct V
17 {
18 enum W
19 {
20 #define A(n) n,
21 #define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) A(n##5) A(n##6) A(n##7) A(n##8) A(n##9)
22 #define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) B(n##5) B(n##6) B(n##7) B(n##8) B(n##9)
23 #define D(n) C(n##0) C(n##1) C(n##2) C(n##3) C(n##4) C(n##5) C(n##6) C(n##7) C(n##8) C(n##9)
24 #define E D(foo1) D(foo2) D(foo3)
25 E
26 last
27 };
28
29 constexpr static W
30 bar (const u64 h) noexcept
31 {
32 switch (h)
33 {
34 #undef A
35 #define F(n) #n
36 #define A(n) case foo (F(n)): return n;
37 E
38 }
39 return last;
40 }
41 };
42
43 int
44 baz (const char *s)
45 {
46 const u64 h = foo (s);
47 return V::bar (h);
48 }