| 1 |
/* { dg-do run } |
| 2 |
* { dg-options "-std=c23 -O2" } |
| 3 |
*/ |
| 4 |
|
| 5 |
|
| 6 |
/* These tests check that redefinitions of tagged |
| 7 |
types can alias the original definitions. */ |
| 8 |
|
| 9 |
struct foo { int x; }; |
| 10 |
|
| 11 |
int test_foo(struct foo* a, void* b) |
| 12 |
{ |
| 13 |
a->x = 1; |
| 14 |
|
| 15 |
struct foo { int x; }* p = b; |
| 16 |
p->x = 2; |
| 17 |
|
| 18 |
return a->x; |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
enum bar { A = 1, B = 3 }; |
| 23 |
|
| 24 |
int test_bar(enum bar* a, void* b) |
| 25 |
{ |
| 26 |
*a = A; |
| 27 |
|
| 28 |
enum bar { A = 1, B = 3 }* p = b; |
| 29 |
*p = B; |
| 30 |
|
| 31 |
return *a; |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
int main() |
| 36 |
{ |
| 37 |
struct foo y; |
| 38 |
|
| 39 |
if (2 != test_foo(&y, &y)) |
| 40 |
__builtin_abort(); |
| 41 |
|
| 42 |
enum bar z; |
| 43 |
|
| 44 |
if (B != test_bar(&z, &z)) |
| 45 |
__builtin_abort(); |
| 46 |
|
| 47 |
return 0; |
| 48 |
} |
| 49 |
|