1 // RUN: %clang_cc1 -Wchar-subscripts -fsyntax-only -verify %s
6 int val
= array
[subscript
]; // expected-warning{{array subscript is of type 'char'}}
12 int val
= subscript
[array
]; // expected-warning{{array subscript is of type 'char'}}
18 int val
= array
[subscript
]; // expected-warning{{array subscript is of type 'char'}}
24 int val
= subscript
[array
]; // expected-warning{{array subscript is of type 'char'}}
27 char returnsChar(void);
30 int val
= array
[returnsChar()]; // expected-warning{{array subscript is of type 'char'}}
35 signed char subscript
= 0;
36 int val
= array
[subscript
]; // no warning for explicit signed char
41 unsigned char subscript
= 0;
42 int val
= array
[subscript
]; // no warning for unsigned char
49 int val
= array
[subscript
]; // expected-warning{{array subscript is of type 'char'}}
52 typedef signed char SignedCharTy
;
55 SignedCharTy subscript
= 0;
56 int val
= array
[subscript
]; // no warning for explicit signed char
59 typedef unsigned char UnsignedCharTy
;
62 UnsignedCharTy subscript
= 0;
63 int val
= array
[subscript
]; // no warning for unsigned char
67 int array
[256] = { 0 };
68 int val
= array
['a']; // no warning for char with known positive value
72 int array
[256] = { 0 };
74 int val
= array
[b
]; // expected-warning{{array subscript is of type 'char'}}
78 int array
[256] = { 0 };
80 int val
= array
[b
]; // no warning for char with known positive value
84 int array
[256] = { 0 };
85 constexpr char b
= 'a';
86 int val
= array
[b
]; // no warning for char with known positive value
90 int array
[256] = { 0 }; // expected-note {{array 'array' declared here}}
92 // expected-warning@+2 {{array subscript is of type 'char'}}
93 // expected-warning@+1 {{array index -1 is before the beginning of the array}}
98 int array
[256] = { 0 }; // expected-note {{array 'array' declared here}}
99 constexpr char b
= -1;
100 // expected-warning@+2 {{array subscript is of type 'char'}}
101 // expected-warning@+1 {{array index -1 is before the beginning of the array}}