| 1 |
/* { dg-do run { target lto } } |
| 2 |
* { dg-options "-std=c23 -O2" } |
| 3 |
*/ |
| 4 |
|
| 5 |
/* These tests check that definitions of enums with |
| 6 |
* the same underlying type can alias, even when |
| 7 |
* they are not compatible. */ |
| 8 |
|
| 9 |
enum bar : long { A = 1, B = 3 }; |
| 10 |
|
| 11 |
int test_bar(enum bar* a, void* b) |
| 12 |
{ |
| 13 |
*a = A; |
| 14 |
|
| 15 |
enum foo : long { C = 2, D = 4 }* p = b; |
| 16 |
*p = B; |
| 17 |
|
| 18 |
return *a; |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
int main() |
| 23 |
{ |
| 24 |
enum bar z; |
| 25 |
|
| 26 |
if (B != test_bar(&z, &z)) |
| 27 |
__builtin_abort(); |
| 28 |
|
| 29 |
return 0; |
| 30 |
} |
| 31 |
|
| 32 |
|