summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
blob: 5513d3650c6803ee8cebb6349ab312e99a8d2505 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// PR tree-optimization/39557
// invalid post-dom info leads to infinite loop
// { dg-do run }
// { dg-options "-Wall -fno-exceptions -O2 -fprofile-use -fno-rtti" }

struct C
{
 virtual const char *bar () const;
};

struct D
{
 D () : d1 (0) { }
 C *d2[4];
 int d1;
 inline const C & baz (int i) const { return *d2[i]; }
};

struct E
{
 unsigned char e1[2];
 D e2;
 bool foo () const { return (e1[1] & 1) != 0; }
 virtual const char *bar () const __attribute__ ((noinline));
};

const char *
C::bar () const
{
 return 0;
}

C c;

const char *
E::bar () const
{
 const char *e = __null;
 if (foo () && (e = c.C::bar ()))
   return e;
 for (int i = 0, n = e2.d1; i < n; i++)
   if ((e = e2.baz (i).C::bar ()))
     return e;
 return e;
}

int
main ()
{
 E e;
 e.bar ();
} // { dg-message  "note: file" "" }