1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Warray-bounds" } */
6 static inline int n(void) {
7 __SIZE_TYPE__
strlen(const char *s
);
8 return strlen("12345");
21 a
[-1] = 0; /* { dg-warning "6:array subscript" } */
27 a
[10] = 0; /* { dg-warning "6:array subscript" } */
28 a
[11] = 0; /* { dg-warning "6:array subscript" } */
29 a
[2 * n() - 11] = 1; /* { dg-warning "6:array subscript" } */
32 a
[2 * n() - 0] = 1; /* { dg-warning "6:array subscript" } */
34 b
[-1] = 0; /* { dg-warning "6:array subscript" } */
38 b
[10] = 0; /* { dg-warning "6:array subscript" } */
39 b
[11] = 0; /* { dg-warning "6:array subscript" } */
40 b
[2 * n() - 11] = 1; /* { dg-warning "6:array subscript" } */
43 b
[2 * n() - 0] = 1; /* { dg-warning "array subscript" } */
45 c
.c
[-1] = 0; /* { dg-warning "8:array subscript" } */
49 c
.c
[10] = 0; /* { dg-warning "8:array subscript" } */
50 c
.c
[11] = 0; /* { dg-warning "8:array subscript" } */
51 c
.c
[2 * n() - 11] = 1; /* { dg-warning "8:array subscript" } */
52 c
.c
[2 * n() - 10] = 1;
54 c
.c
[2 * n() - 0] = 1; /* { dg-warning "8:array subscript" } */
59 g(&a
[11]); /* { dg-warning "array subscript" "" { xfail *-*-* } } */
60 g(&a
[-30]+10); /* { dg-warning "array subscript" } */
65 g(&b
[11]); /* { dg-warning "array subscript" "" { xfail *-*-* } } */
66 g(&c
.c
[11]); /* { dg-warning "array subscript" } */
72 g(&a
[-1]); /* { dg-warning "array subscript" } */
73 g(&b
[-1]); /* { dg-warning "array subscript" } */
88 for (i
= 20; i
< 30; ++i
)
89 a
[i
] = 1; /* { dg-warning "15:array subscript" } */