Debian Codegraph @

gcc/testsuite/g++.dg/ipa/pr52939.C

raw
1 /* Verify that we do not ICE on invalid devirtualizations (which might
2 be OK at run-time because never executed). */
3 /* { dg-do run } */
4 /* { dg-options "-O3 -fno-early-inlining -fno-inline" } */
5
6 extern "C" void abort (void);
7
8 class A
9 {
10 public:
11 int data;
12 virtual int foo (int i);
13 };
14
15 class B : public A
16 {
17 public:
18 virtual int foo (int i);
19 virtual int bar (int i);
20 };
21
22 int A::foo (int i)
23 {
24 return i + 1;
25 }
26
27 int B::foo (int i)
28 {
29 return i + 2;
30 }
31
32 int B::bar (int i)
33 {
34 return i + 3;
35 }
36
37 static int middleman (class A *obj, int i)
38 {
39 class B *b = (class B *) obj;
40
41 if (i != 1)
42 return b->bar (i);
43 else
44 return i;
45 }
46
47 int __attribute__ ((noinline,noclone)) get_input(void)
48 {
49 return 1;
50 }
51
52 int main (int argc, char *argv[])
53 {
54 class A o;
55 if (middleman (&o, get_input ()) != 1)
56 abort ();
57 return 0;
58 }