2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / opt / pr22167.C
blob07af744624ab163d3c0ef1bedade6b0219de36ab
1 // Derived from PR22167, which failed on some RISC targets.  The call to
2 // foo() has two successors, one normal and one exceptional, and both
3 // successors use &a[0] and x.  Expressions involving &a[0] can be hoisted
4 // before the call but those involving x cannot.
5 // { dg-options "-Os" }
6 // { dg-do run }
8 int a[4];
10 struct S {
11   S() : x (0) {}
12   ~S() { a[0] = x; }
13   int x;
16 void
17 foo (int *x)
19   if (*x == 1)
20     throw 1;
21   *x = 1;
24 int
25 main()
27   S s;
28   foo (&s.x);
29   if (a[0] == s.x)
30     a[0]++;
31   return a[0];