| 1 |
/* Test -Wchar-subscripts. */ |
| 2 |
/* Origin: Joseph Myers <[email protected]> */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-options "-Wchar-subscripts" } */ |
| 5 |
|
| 6 |
extern int a[]; |
| 7 |
int *p; |
| 8 |
char c; |
| 9 |
signed char sc; |
| 10 |
unsigned char uc; |
| 11 |
|
| 12 |
void |
| 13 |
f (void) |
| 14 |
{ |
| 15 |
a[sc]; |
| 16 |
a[uc]; |
| 17 |
sc[a]; |
| 18 |
uc[a]; |
| 19 |
p[sc]; |
| 20 |
p[uc]; |
| 21 |
sc[p]; |
| 22 |
uc[p]; |
| 23 |
a[c]; /* { dg-warning "array subscript has type 'char'" } */ |
| 24 |
p[c]; /* { dg-warning "array subscript has type 'char'" } */ |
| 25 |
/* -Wchar-subscripts does not warn if the char is not syntactically |
| 26 |
the subscript. */ |
| 27 |
c[a]; |
| 28 |
c[p]; |
| 29 |
} |