[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / pr61289.C
blobea7ccea304d7e6f6d1201ebb6199bc69db488111
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fno-exceptions" } */
4 struct S
6   inline int fn1 () const { return s; }
7   __attribute__ ((noinline, noclone)) S *fn2 (int);
8   __attribute__ ((noinline, noclone)) void fn3 ();
9   __attribute__ ((noinline, noclone)) static S *fn4 (int);
10   S (int i) : s (i) {}
11   int s;
14 int a = 0;
15 S *b = 0;
17 S *
18 S::fn2 (int i)
20   a++;
21   if (a == 1)
22     return b;
23   if (a > 3)
24     __builtin_abort ();
25   b = this;
26   return new S (i + s);
29 S *
30 S::fn4 (int i)
32   b = new S (i);
33   return b;
36 void
37 S::fn3 ()
39   delete this;
42 void
43 foo ()
45   S *c = S::fn4 (20);
46   for (int i = 0; i < 2;)
47     {
48       S *d = c->fn2 (c->fn1 () + 10);
49       if (d != c)
51   c->fn3 ();
52   c = d;
53   ++i;
55     }
56   c->fn3 ();
59 int
60 main ()
62   foo ();