| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-ipa-sra -fdump-tree-optimized-slim" } */ |
| 3 |
|
| 4 |
/* Test that even though destructors end with clobbering all of *this, it |
| 5 |
should not prevent IPA-SRA. */ |
| 6 |
|
| 7 |
namespace { |
| 8 |
|
| 9 |
class foo |
| 10 |
{ |
| 11 |
public: |
| 12 |
short move_offset_of_a; |
| 13 |
int *a; |
| 14 |
foo(int c) |
| 15 |
{ |
| 16 |
a = new int[c]; |
| 17 |
a[0] = 4; |
| 18 |
} |
| 19 |
__attribute__((noinline)) ~foo(); |
| 20 |
int f () |
| 21 |
{ |
| 22 |
return a[0] + 1; |
| 23 |
} |
| 24 |
}; |
| 25 |
|
| 26 |
volatile int v1 = 4; |
| 27 |
|
| 28 |
__attribute__((noinline)) foo::~foo() |
| 29 |
{ |
| 30 |
delete[] a; |
| 31 |
return; |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
volatile int v2 = 20; |
| 38 |
|
| 39 |
int test (void) |
| 40 |
{ |
| 41 |
foo shouldnotexist(v2); |
| 42 |
v2 = shouldnotexist.f(); |
| 43 |
return 0; |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
/* { dg-final { scan-ipa-dump "Will split parameter 0" "sra" } } */ |
| 48 |
/* { dg-final { scan-tree-dump-not "shouldnotexist" "optimized" } } */ |