OSDN Git Service

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