2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / opt / preinc1.C
blob89a0116b03547b23d7014d333638c90cc5f0b71b
1 // PR optimization/6086
2 // { dg-do run }
3 // { dg-options "-O" }
4  
5 extern "C" void abort (void);
7 struct A
9   A (int x, int y);
10   int a, b;
11   int foo () { return a; }
12   int bar () { return b; }
15 struct B
17   virtual ~B ();
18   virtual A baz () const;
21 struct C
23   A foo () const;
24   B *c;
27 A C::foo () const
29   int x, y;
30   x = c->baz ().foo ();
31   y = c->baz ().bar ();
32   return A (x, y);
35 A B::baz () const
37   return A (4, 8);
40 A::A (int x, int y)
42   a = x;
43   b = y;
46 B::~B ()
50 int
51 main ()
53   C the_c;
54   B the_b;
55   the_c.c = &the_b;
56   if (the_c.foo().a != 4)
57     abort ();
58   return 0;