1 // RUN: %clang_cc1 -Wchar-subscripts -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -Wchar-subscripts -fsyntax-only -verify %s -fexperimental-new-constant-interpreter
7 int val
= array
[subscript
]; // expected-warning{{array subscript is of type 'char'}}
13 int val
= subscript
[array
]; // expected-warning{{array subscript is of type 'char'}}
19 int val
= array
[subscript
]; // expected-warning{{array subscript is of type 'char'}}
25 int val
= subscript
[array
]; // expected-warning{{array subscript is of type 'char'}}
28 char returnsChar(void);
31 int val
= array
[returnsChar()]; // expected-warning{{array subscript is of type 'char'}}
36 signed char subscript
= 0;
37 int val
= array
[subscript
]; // no warning for explicit signed char
42 unsigned char subscript
= 0;
43 int val
= array
[subscript
]; // no warning for unsigned char
50 int val
= array
[subscript
]; // expected-warning{{array subscript is of type 'char'}}
53 typedef signed char SignedCharTy
;
56 SignedCharTy subscript
= 0;
57 int val
= array
[subscript
]; // no warning for explicit signed char
60 typedef unsigned char UnsignedCharTy
;
63 UnsignedCharTy subscript
= 0;
64 int val
= array
[subscript
]; // no warning for unsigned char
68 int array
[256] = { 0 };
69 int val
= array
['a']; // no warning for char with known positive value
73 int array
[256] = { 0 };
75 int val
= array
[b
]; // expected-warning{{array subscript is of type 'char'}}
79 int array
[256] = { 0 };
81 int val
= array
[b
]; // expected-warning{{array subscript is of type 'char'}}
85 int array
[256] = { 0 }; // expected-note {{array 'array' declared here}}
87 // expected-warning@+2 {{array subscript is of type 'char'}}
88 // expected-warning@+1 {{array index -1 is before the beginning of the array}}