2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / opt / nrv15.C
blob23511b284b2628ec32638e9e7c59a0934eb6ee4b
1 // PR debug/39086
2 // { dg-options "-g -O -fno-tree-sra" }
4 struct A { int v; };
6 A ax;
8 struct B
10   static A f1 () { return ax; }
11   static bool f2 ();
12   static A f3 ();
15 struct C
17   A f4 ()
18   {
19     A x;
20     if (__builtin_expect (this->f6 () < this->f12 (), true))
21       x = B::f1 ();
22     else
23       x = this->f7 ();
24     return x;
25   }
26   A f5 ()
27   {
28     A y;
29     if (this->f6 () < this->f12 ())
30       y = B::f1 ();
31     else
32       y = this->f7 ();
33     return y;
34   }
35   void *f6 () const;
36   void *f12 () const;
37   virtual A f7 ();
40 C *dx;
42 struct D
44   C *f8 () const;
47 class E : virtual public D
49   void f11 ();
50   void f9 ();
51   void f10 ();
54 struct G
56   explicit G ();
57   operator bool () const;
60 void
61 E::f11 (void)
63   A d = B::f3 ();
64   d = this->f8 ()->f4 ();
67 void
68 E::f9 ()
70   G c;
71   if (c)
72     {
73       const A e = B::f3 ();
74       C * f = this->f8 ();
75       A d = f->f5 ();
76       if (B::f2 ())
77         ;
78       else if (B::f2 ())
79         f->f4 ();
80     }
83 void
84 E::f10 ()
86   G c;
87   if (c)
88     {
89       const A e = B::f3 ();
90       C * f = this->f8 ();
91       A d = f->f5 ();
92       if (B::f2 ())
93         ;
94       else if (B::f2 ())
95         f->f4 ();
96     }