Fix for PR39557
[official-gcc.git] / gcc / testsuite / g++.dg / tree-ssa / dom-invalid.C
blob5513d3650c6803ee8cebb6349ab312e99a8d2505
1 // PR tree-optimization/39557
2 // invalid post-dom info leads to infinite loop
3 // { dg-do run }
4 // { dg-options "-Wall -fno-exceptions -O2 -fprofile-use -fno-rtti" }
6 struct C
8  virtual const char *bar () const;
9 };
11 struct D
13  D () : d1 (0) { }
14  C *d2[4];
15  int d1;
16  inline const C & baz (int i) const { return *d2[i]; }
19 struct E
21  unsigned char e1[2];
22  D e2;
23  bool foo () const { return (e1[1] & 1) != 0; }
24  virtual const char *bar () const __attribute__ ((noinline));
27 const char *
28 C::bar () const
30  return 0;
33 C c;
35 const char *
36 E::bar () const
38  const char *e = __null;
39  if (foo () && (e = c.C::bar ()))
40    return e;
41  for (int i = 0, n = e2.d1; i < n; i++)
42    if ((e = e2.baz (i).C::bar ()))
43      return e;
44  return e;
47 int
48 main ()
50  E e;
51  e.bar ();
52 } // { dg-message  "note: file" "" }