* testsuite/libgomp.fortran/vla7.f90: Add -w to options.
[official-gcc.git] / gcc / testsuite / gcc.dg / array-8.c
blob44b757b70dfb04ec156e9eb30d5e04365dfd9e42
1 /* Test diagnostics for array references. */
2 /* Origin: Joseph Myers <joseph@codesourcery.com> */
3 /* { dg-do compile } */
4 /* { dg-options "-std=gnu89" } */
6 struct s { char c[1]; };
7 struct s f (void);
8 _Bool b;
9 char c;
10 enum e { E } e;
11 extern int a[];
12 int *p;
13 void *pv;
14 void (*fp)(void);
15 struct si *sip;
17 void
18 g (void)
20 a[b];
21 a[c];
22 a[e];
23 p[b];
24 p[c];
25 p[e];
26 b[a];
27 c[a];
28 e[a];
29 b[p];
30 c[p];
31 e[p];
32 /* These two should be treated the same. In particular, a "neither
33 array nor pointer" bogus warning used to be given for the
34 second. */
35 f().c[0];
36 0[f().c];
37 /* Various invalid cases. */
38 c[c]; /* { dg-error "error: subscripted value is neither array nor pointer" } */
39 p[1.0]; /* { dg-error "error: array subscript is not an integer" } */
40 1.0[a]; /* { dg-error "error: array subscript is not an integer" } */
41 fp[0]; /* { dg-error "error: subscripted value is pointer to function" } */
42 0[fp]; /* { dg-error "error: subscripted value is pointer to function" } */
43 pv[0]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */
44 0[pv]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */
45 sip[0]; /* { dg-error "error: invalid use of undefined type 'struct si'" } */
46 /* { dg-error "error: dereferencing pointer to incomplete type" "incomplete" { target *-*-* } 45 } */
47 0[sip]; /* { dg-error "error: invalid use of undefined type 'struct si'" } */
48 /* { dg-error "error: dereferencing pointer to incomplete type" "incomplete" { target *-*-* } 47 } */