Fix test-suite fallout of default -Wreturn-type.
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / devirt-36.C
bloba8e6387a6939cddc638c626c3914c9ff3fd62bcd
1 /* { dg-options "-O2 -fdump-ipa-devirt-details -fdump-tree-fre1-details"  } */
2 struct A {virtual int t(void) {return 1;}};
3 struct B:A {B(); virtual int t(void) {return 2;}};
4 struct C {int a; struct B b;};
5 void test2(struct A *);
6 int
7 m(struct B *b)
9   struct C *c = new (C);
10   struct A *a = &c->b;
11   a->t(); // This call should be devirtualized by 
12           // FRE because we know type from ctor call
13   ((struct B *)a)->B::t(); // Make devirt possible 
14                            // C++ FE won't produce inline body without this
15   test2(a);
16   return a->t();  // This call should be devirtualized speculatively because
17                   //  test2 may change the type of A by placement new.
18                   // C++ standard is bit imprecise about this.
20 /* { dg-final { scan-tree-dump "converting indirect call to function virtual int B::t"  "fre1"  } } */
21 /* { dg-final { scan-ipa-dump "to virtual int B::t"  "devirt"  } } */
22 /* { dg-final { scan-ipa-dump "1 speculatively devirtualized"  "devirt"  } } */