| 1 |
/* Tests related to qualifiers and pointers to arrays in C23, PR98397 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-std=c23 -pedantic-errors" } */ |
| 4 |
|
| 5 |
/* test that qualifiers are preserved in tertiary operator for pointers to arrays in C23 */ |
| 6 |
|
| 7 |
void f(void) |
| 8 |
{ |
| 9 |
const int (*u)[1]; |
| 10 |
void *v; |
| 11 |
_Static_assert(_Generic(1 ? u : v, const void*: 1, void*: 0), "lost qualifier"); |
| 12 |
_Static_assert(_Generic(1 ? v : u, const void*: 1, void*: 0), "lost qualifier"); |
| 13 |
} |
| 14 |
|
| 15 |
/* test that assignment of unqualified to qualified pointers works as expected */ |
| 16 |
|
| 17 |
void g(void) |
| 18 |
{ |
| 19 |
int (*x)[3]; |
| 20 |
const int (*p)[3] = x; |
| 21 |
} |
| 22 |
|
| 23 |
/* test that assignment of qualified void pointers works as expected */ |
| 24 |
|
| 25 |
void h(void) |
| 26 |
{ |
| 27 |
const void* x; |
| 28 |
const int (*p)[3] = x; |
| 29 |
} |
| 30 |
|