summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wchar-subscripts-1.c
blob: 3f5adeb31d175116d5884acd4fce2f56265b09ac (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
/* Test -Wchar-subscripts.  */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-Wchar-subscripts" } */

extern int a[];
int *p;
char c;
signed char sc;
unsigned char uc;

void
f (void)
{
  a[sc];
  a[uc];
  sc[a];
  uc[a];
  p[sc];
  p[uc];
  sc[p];
  uc[p];
  a[c]; /* { dg-warning "array subscript has type 'char'" } */
  p[c]; /* { dg-warning "array subscript has type 'char'" } */
  /* -Wchar-subscripts does not warn if the char is not syntactically
      the subscript.  */
  c[a];
  c[p];
}