Merged trunk at revision 161680 into branch.
[official-gcc.git] / gcc / testsuite / gcc.dg / c99-array-lval-8.c
blobc4e202ef3018a08af87d6d1e49f714ec8d5ab20c
1 /* Test for non-lvalue arrays: test that qualifiers on non-lvalues
2 containing arrays do not remain when those arrays decay to
3 pointers. PR 35235. */
4 /* { dg-do compile } */
5 /* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
7 int a;
9 void
10 f (void)
12 const struct {
13 int a[1];
14 } s;
15 int *p1 = s.a; /* { dg-error "qualifier" } */
16 int *p2 = (a ? s : s).a;
17 /* In this case, the qualifier is properly on the array element type
18 not on the rvalue structure and so is not discarded. */
19 struct {
20 const int a[1];
21 } t;
22 int *p3 = t.a; /* { dg-error "qualifier" } */
23 int *p4 = (a ? t : t).a; /* { dg-error "qualifier" } */
24 /* The issue could also lead to code being wrongly accepted. */
25 const struct {
26 int a[1][1];
27 } u;
28 const int (*p5)[1] = u.a;
29 const int (*p6)[1] = (a ? u : u).a; /* { dg-error "pointer" } */