tree-ssa-math-opts: Fix is_widening_mult_rhs_p - unbreak bootstrap [PR113705]
[official-gcc.git] / gcc / testsuite / g++.dg / opt / pr113705.C
blob39fb047077ef5c4da2adc14b7dd09205877f32d7
1 // PR middle-end/113705
2 // { dg-do compile { target c++17 } }
3 // { dg-options "-O2 -w" }
5 void foo ();
6 template <typename T> struct A : T { long bar () const; };
7 int a;
9 template <typename T>
10 long
11 A<T>::bar () const
13   return this->baz ()[a];
16 struct B {
17   struct { long b[1]; long c; } u;
18   unsigned d;
19   int e;
20   B (const B &);
21   ~B ();
22   const long *baz () const;
23   unsigned qux () const;
26 B::B (const B &)
28   if (__builtin_expect (e, 0))
29     u.c = 0;
32 B::~B ()
34   if (__builtin_expect (e, 0))
35     foo ();
38 const long *
39 B::baz () const
41   return u.b;
44 unsigned
45 B::qux () const
47   return d;
50 struct C { A<B> corge () const; A<B> *f; };
52 A<B>
53 C::corge () const
55   return f[1];
58 void
59 test (C r, long *h, unsigned short *d)
61   for (int j = 0; j < 8; ++j)
62     {
63       A g = r.corge ();
64       *d = g.qux ();
65       for (unsigned i = 0; i < *d; ++i)
66         *h++ = g.bar ();
67     }