| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O -fno-tree-sra -fdump-tree-fre1-details" } */ |
| 3 |
|
| 4 |
struct Foo { |
| 5 |
Foo() {}; |
| 6 |
int i; |
| 7 |
short f; |
| 8 |
}; |
| 9 |
struct Bar : public Foo { |
| 10 |
Bar() {}; |
| 11 |
short b; |
| 12 |
}; |
| 13 |
|
| 14 |
extern "C" void abort(void); |
| 15 |
|
| 16 |
int main() |
| 17 |
{ |
| 18 |
Bar b1, b2; |
| 19 |
b2.i = 0; |
| 20 |
b1.f = 0; |
| 21 |
b1.b = 1; |
| 22 |
b2.f = 1; |
| 23 |
b2.b = 2; |
| 24 |
static_cast<Foo&>(b1) = static_cast<Foo&>(b2); |
| 25 |
if (b1.i != 0 || b1.b != 1) |
| 26 |
abort (); |
| 27 |
if (b1.f != 1) |
| 28 |
abort (); |
| 29 |
return 0; |
| 30 |
} |
| 31 |
|
| 32 |
/* { dg-final { scan-tree-dump "Replaced b1.b with 1" "fre1" } } */ |
| 33 |
/* { dg-final { scan-tree-dump "Replaced b1.D.\[0-9\]*.i with 0" "fre1" } } */ |
| 34 |
/* { dg-final { scan-tree-dump "Replaced b1.D.\[0-9\]*.f with 1" "fre1" } } */ |