Rebase.
[official-gcc.git] / gcc / testsuite / g++.dg / torture / pr48661.C
blob8de2142f737ffb688bda51341b5d4c1024591f80
1 // PR middle-end/48661
2 // { dg-do run }
4 extern "C" void abort ();
6 __attribute__((noinline))
7 double
8 foo (double x, double y)
10   asm volatile ("" : : : "memory");
11   return x + y;
14 __attribute__((noinline, noclone))
15 void
16 bar (int x)
18   if (x != 123)
19     abort ();
22 struct A
24   double a1, a2;
27 struct B 
29   virtual int m () const = 0 ;
32 struct C
34   virtual ~C () {}
37 struct D : virtual public B, public C
38
39   explicit D (const A &x) : d(123) { foo (x.a2, x.a1); }
40   int m () const { return d; }
41   int d;
42 }; 
44 struct E
46   E () : d(0) {}
47   virtual void n (const B &x) { d = x.m (); x.m (); x.m (); }
48   int d;
51 void
52 test ()
54   A a;
55   a.a1 = 0;
56   a.a2 = 1;
57   E p;
58   D q (a);
59   const B &b = q;
60   bar (b.m ());
61   p.n (b);
62   bar (p.d);
65 void
66 baz ()
68   A a;
69   D p2 (a);
72 int
73 main ()
75   test ();
76   return 0;