]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/c2x-qual-3.c
testsuite: Refer more consistently to C23 not C2X
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / c2x-qual-3.c
CommitLineData
094a609c 1/* Tests related to qualifiers and pointers to arrays in C23, PR98397 */
972eab51 2/* { dg-do compile } */
54bac0ce 3/* { dg-options "-std=c23 -Wc11-c23-compat -pedantic-errors" } */
972eab51 4
094a609c 5/* test that qualifiers are preserved in tertiary operator for pointers to arrays in C23 */
972eab51
MU
6
7void 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"); /* { dg-warning "pointer to array loses qualifier in conditional" } */
12 _Static_assert(_Generic(1 ? v : u, const void*: 1, void*: 0), "lost qualifier"); /* { dg-warning "pointer to array loses qualifier in conditional" } */
13}
14
15/* test that assignment of unqualified to qualified pointers works as expected */
16
17void g(void)
18{
19 int (*x)[3];
20 const int (*p)[3] = x; /* { dg-warning "arrays with different qualifiers" } */
21}
22
23/* test that assignment of qualified void pointers works as expected */
24
25void h(void)
26{
27 const void* x;
094a609c 28 const int (*p)[3] = x; /* { dg-warning "array with qualifier on the element is not qualified before C23" } */
972eab51
MU
29}
30