| 1 |
// { dg-do run } |
| 2 |
// PRMS Id: 3744 |
| 3 |
// Bug: unswitching a COND_EXPR initializer fails to set SIDE_EFFECTS on the |
| 4 |
// result, so expand_expr ignores it. |
| 5 |
|
| 6 |
extern "C" { |
| 7 |
int printf(const char *,...); |
| 8 |
void exit(int); |
| 9 |
} |
| 10 |
|
| 11 |
struct A { |
| 12 |
int x; |
| 13 |
int y; |
| 14 |
|
| 15 |
A() : x(0), y(0) { } |
| 16 |
}; |
| 17 |
|
| 18 |
struct S { |
| 19 |
S() : flags(0) { } |
| 20 |
unsigned flags; |
| 21 |
A from; |
| 22 |
void foo(const A &pos); |
| 23 |
}; |
| 24 |
|
| 25 |
void S::foo(const A &pos) |
| 26 |
{ |
| 27 |
A a = flags ? from : pos; |
| 28 |
printf("%d %d\n", a.x, a.y); |
| 29 |
if (a.x != 17 || a.y != 12) |
| 30 |
exit (1); |
| 31 |
} |
| 32 |
|
| 33 |
int main() |
| 34 |
{ |
| 35 |
A pos; |
| 36 |
pos.x = 17; |
| 37 |
pos.y = 12; |
| 38 |
S s; |
| 39 |
s.foo(pos); |
| 40 |
return 0; |
| 41 |
} |