Debian Codegraph @

gcc/testsuite/g++.dg/torture/pr42462.C

raw
1 /* { dg-do run } */
2 /* { dg-require-effective-target indirect_jumps } */
3
4 #define INLINE inline __attribute__((always_inline))
5 extern "C" void abort (void);
6
7 template<class> struct Foo {
8 inline bool isFalse() { return false; }
9 template <bool> void f1() {}
10 template <bool> INLINE void f2() { f1<false>(); }
11 template <bool> void f3() { f2<false>(); }
12 template <bool> INLINE void f4() { f3<false>(); }
13 int exec2();
14 void execute();
15 inline void unused();
16 };
17
18 template<class T> inline void Foo<T>::unused() {
19 f4<true>();
20 }
21
22 static int counter = 0;
23
24 template<class T> int Foo<T>::exec2() {
25 static void* table[2] = { &&begin, &&end };
26 if (counter++ > 10)
27 return 0;
28 goto *(table[0]);
29 begin:
30 if (isFalse()) f1<false>();
31 end:
32 return 1;
33 }
34
35 template<class T> void Foo<T>::execute() {
36 int r = 1;
37 while (r) { r = exec2(); }
38 }
39
40 template class Foo<int>;
41
42 int main() {
43 Foo<int> c;
44 c.execute();
45 if (counter < 10)
46 abort ();
47 return 0;
48 }