| 1 |
/* { dg-do compile } |
| 2 |
* { dg-options "-std=c23" } |
| 3 |
*/ |
| 4 |
|
| 5 |
// packed structs |
| 6 |
|
| 7 |
struct foo { |
| 8 |
char a; |
| 9 |
int b [[gnu::packed]]; |
| 10 |
char d; |
| 11 |
int c [[gnu::packed]]; |
| 12 |
}; |
| 13 |
|
| 14 |
struct foo { |
| 15 |
char a; |
| 16 |
int b [[gnu::packed]]; |
| 17 |
char d; |
| 18 |
int c [[gnu::packed]]; |
| 19 |
}; |
| 20 |
|
| 21 |
extern struct foo x; |
| 22 |
|
| 23 |
void g() |
| 24 |
{ |
| 25 |
struct foo { |
| 26 |
char a; |
| 27 |
int b [[gnu::packed]]; |
| 28 |
char d; |
| 29 |
int c [[gnu::packed]]; |
| 30 |
}; |
| 31 |
|
| 32 |
extern struct foo y; |
| 33 |
extern typeof(*(1 ? &x : &y)) x; |
| 34 |
} |
| 35 |
|
| 36 |
void h() |
| 37 |
{ |
| 38 |
struct foo { |
| 39 |
char a; |
| 40 |
int b; |
| 41 |
char d; |
| 42 |
int c; |
| 43 |
}* z = &x; /* { dg-error "incompatible" } */ |
| 44 |
} |
| 45 |
|