1 // PR middle-end/48661
2 // { dg-do run }
3 
4 extern "C" void abort ();
5 
6 __attribute__((noinline))
7 double
foo(double x,double y)8 foo (double x, double y)
9 {
10   asm volatile ("" : : : "memory");
11   return x + y;
12 }
13 
14 __attribute__((noinline, noclone))
15 void
bar(int x)16 bar (int x)
17 {
18   if (x != 123)
19     abort ();
20 }
21 
22 struct A
23 {
24   double a1, a2;
25 };
26 
27 struct B
28 {
29   virtual int m () const = 0 ;
30 };
31 
32 struct C
33 {
~CC34   virtual ~C () {}
35 };
36 
37 struct D : virtual public B, public C
38 {
DD39   explicit D (const A &x) : d(123) { foo (x.a2, x.a1); }
mD40   int m () const { return d; }
41   int d;
42 };
43 
44 struct E
45 {
EE46   E () : d(0) {}
nE47   virtual void n (const B &x) { d = x.m (); x.m (); x.m (); }
48   int d;
49 };
50 
51 void
test()52 test ()
53 {
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);
63 }
64 
65 void
baz()66 baz ()
67 {
68   A a;
69   D p2 (a);
70 }
71 
72 int
main()73 main ()
74 {
75   test ();
76   return 0;
77 }
78