aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c2x-qual-2.c
blob: f60a5b18faa35e936db3841fa93b07e2aa866357 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Tests related to qualifiers and pointers to arrays in C2X, PR98397 */
/* { dg-do compile } */
/* { dg-options "-std=c2x -Wc11-c2x-compat" } */

/* test that qualifiers are preserved in tertiary operator for pointers to arrays in C2X */

void f(void)
{
	const int (*u)[1];
	void *v;
	_Static_assert(_Generic(1 ? u : v, const void*: 1, void*: 0), "lost qualifier");	/* { dg-warning "pointer to array loses qualifier in conditional" } */
	_Static_assert(_Generic(1 ? v : u, const void*: 1, void*: 0), "lost qualifier");	/* { dg-warning "pointer to array loses qualifier in conditional" } */
}

/* test that assignment of unqualified to qualified pointers works as expected */

void g(void)
{
	int (*x)[3];
	const int (*p)[3] = x; /* { dg-warning "arrays with different qualifiers"  } */
}

/* test that assignment of qualified void pointers works as expected */

void h(void)
{
	const void* x;
	const int (*p)[3] = x; /* { dg-warning "array with qualifier on the element is not qualified before C2X" } */
}