Fix test-suite fallout of default -Wreturn-type.
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / devirt-3.C
blobba0d3fa44ef3e280ab94e4a99519d39e376f3536
1 /* Verify that simple virtual calls on an object refrence are
2    converted to simple calls by ipa-cp.  */
3 /* { dg-do run } */
4 /* { dg-options "-O3 -fno-early-inlining -fno-inline -fdump-ipa-cp -fdump-tree-optimized"  } */
6 extern "C" void abort (void);
8 class A
10 public:
11   int data;
12   virtual float distraction (float f);
13   virtual int foo (int i);
16 class B : public A
18 public:
19   virtual int foo (int i);
22 class C : public A
24 public:
25   virtual int foo (int i);
28 float A::distraction (float f)
30   f += 6.2;
31   return f/2;
34 int A::foo (int i)
36   return i + 1;
39 int B::foo (int i)
41   return i + 2;
44 int C::foo (int i)
46   return i + 3;
49 static int middleman (class A &obj, int i)
51   return obj.foo (i);
54 int __attribute__ ((noinline,noclone)) get_input(void)
56   return 1;
59 int main (int argc, char *argv[])
61   class B b;
62   if (middleman (b, get_input ()) != 3)
63     abort ();
64   return 0;
67 /* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target.*B::foo"  "cp"  } } */
68 /* { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 0 "optimized"} } */