In gcc/objc/: 2010-11-13 Nicola Pero <nicola.pero@meta-innovation.com>
[official-gcc.git] / gcc / testsuite / g++.dg / otr-fold-1.C
blob2364730487e6109068c871e45fc195c163e8c8c1
1 /* Verify that virtual calls are folded even when a typecast to an
2    ancestor is involved along the way.  */
3 /* { dg-do run } */
4 /* { dg-options "-O -fdump-tree-optimized-slim"  } */
6 extern "C" void abort (void);
8 class Distraction
10 public:
11   float f;
12   double d;
13   Distraction ()
14   {
15     f = 8.3;
16     d = 10.2;
17   }
18   virtual float bar (float z);
21 class A
23 public:
24   int data;
25   virtual int foo (int i);
29 class B : public Distraction, public A
31 public:
32   virtual int foo (int i);
35 float Distraction::bar (float z)
37   f += z;
38   return f/2;
41 int A::foo (int i)
43   return i + 1;
46 int B::foo (int i)
48   return i + 2;
51 int __attribute__ ((noinline,noclone)) get_input(void)
53   return 1;
56 static inline int middleman_1 (class A *obj, int i)
58   return obj->foo (i);
61 static inline int middleman_2 (class B *obj, int i)
63   return middleman_1 (obj, i);
66 int main (int argc, char *argv[])
68   class B b;
70   if (middleman_2 (&b, get_input ()) != 3)
71     abort ();
72   return 0;
75 /* { dg-final { scan-tree-dump "= B::.*foo"  "optimized"  } } */
76 /* { dg-final { cleanup-tree-dump "optimized" } } */