| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target lto } */ |
| 3 |
/* { dg-options "-flto -O2" } */ |
| 4 |
|
| 5 |
struct foo { int x; char a[]; }; |
| 6 |
|
| 7 |
void test_bar(void* b); |
| 8 |
|
| 9 |
__attribute__((noinline)) |
| 10 |
int test_foo(struct foo* a, void* b) |
| 11 |
{ |
| 12 |
a->x = 1; |
| 13 |
test_bar(b); |
| 14 |
return a->x; |
| 15 |
} |
| 16 |
|
| 17 |
int main() |
| 18 |
{ |
| 19 |
struct foo y; |
| 20 |
|
| 21 |
if (2 != test_foo(&y, &y)) |
| 22 |
__builtin_abort(); |
| 23 |
|
| 24 |
return 0; |
| 25 |
} |
| 26 |
|
| 27 |
// TU2 |
| 28 |
struct foo { int x; char a[0]; }; |
| 29 |
|
| 30 |
void test_bar(void* b) |
| 31 |
{ |
| 32 |
struct foo *p = b; |
| 33 |
p->x = 2; |
| 34 |
} |
| 35 |
|