Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / c2x-qual-2.c
blobf60a5b18faa35e936db3841fa93b07e2aa866357
1 /* Tests related to qualifiers and pointers to arrays in C2X, PR98397 */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c2x -Wc11-c2x-compat" } */
5 /* test that qualifiers are preserved in tertiary operator for pointers to arrays in C2X */
7 void f(void)
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" } */
15 /* test that assignment of unqualified to qualified pointers works as expected */
17 void g(void)
19 int (*x)[3];
20 const int (*p)[3] = x; /* { dg-warning "arrays with different qualifiers" } */
23 /* test that assignment of qualified void pointers works as expected */
25 void h(void)
27 const void* x;
28 const int (*p)[3] = x; /* { dg-warning "array with qualifier on the element is not qualified before C2X" } */