gcc/testsuite/g++.dg/ipa/ipa-pta-2.C
raw| 1 | // { dg-do run } |
| 2 | // { dg-options "-O2 -fipa-pta" } |
| 3 | |
| 4 | extern "C" void abort (void); |
| 5 | |
| 6 | struct Y { ~Y(); int i; }; |
| 7 | |
| 8 | Y::~Y () {} |
| 9 | |
| 10 | static Y __attribute__((noinline)) foo () |
| 11 | { |
| 12 | Y res; |
| 13 | res.i = 3; |
| 14 | return res; |
| 15 | } |
| 16 | |
| 17 | static Y __attribute__((noinline)) bar () |
| 18 | { |
| 19 | Y res; |
| 20 | res.i = 42; |
| 21 | return res; |
| 22 | } |
| 23 | |
| 24 | static Y (*fn) (); |
| 25 | |
| 26 | int a; |
| 27 | int main() |
| 28 | { |
| 29 | if (a) |
| 30 | fn = foo; |
| 31 | else |
| 32 | fn = bar; |
| 33 | Y res = fn (); |
| 34 | if (res.i != 42) |
| 35 | abort (); |
| 36 | return 0; |
| 37 | } |