| 1 |
/* { dg-do run } |
| 2 |
* { dg-options "-std=gnu23 -O2" } |
| 3 |
*/ |
| 4 |
|
| 5 |
/* This used to check that an incompatible definition of |
| 6 |
* a tagged type without tag can be assumed not to alias. |
| 7 |
* and that this is exploited during optimization. |
| 8 |
* Because PR117490 we now check the opposite. */ |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
typedef struct { int x; } foo_t; |
| 13 |
|
| 14 |
[[gnu::noinline,gnu::noipa]] |
| 15 |
int test_foo(foo_t* a, void* b) |
| 16 |
{ |
| 17 |
a->x = 1; |
| 18 |
|
| 19 |
struct { int x; }* p = b; |
| 20 |
p->x = 2; |
| 21 |
|
| 22 |
return a->x; |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
int main() |
| 27 |
{ |
| 28 |
foo_t y; |
| 29 |
|
| 30 |
if (2 != test_foo(&y, &y)) |
| 31 |
__builtin_abort(); |
| 32 |
|
| 33 |
return 0; |
| 34 |
} |
| 35 |
|
| 36 |
|