150
|
1 // RUN: %clang_cc1 -Wchar-subscripts -fsyntax-only -verify %s
|
|
2
|
236
|
3 void t1(void) {
|
150
|
4 int array[1] = { 0 };
|
|
5 char subscript = 0;
|
|
6 int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
|
|
7 }
|
|
8
|
236
|
9 void t2(void) {
|
150
|
10 int array[1] = { 0 };
|
|
11 char subscript = 0;
|
|
12 int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}}
|
|
13 }
|
|
14
|
236
|
15 void t3(void) {
|
150
|
16 int *array = 0;
|
|
17 char subscript = 0;
|
|
18 int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
|
|
19 }
|
|
20
|
236
|
21 void t4(void) {
|
150
|
22 int *array = 0;
|
|
23 char subscript = 0;
|
|
24 int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}}
|
|
25 }
|
|
26
|
236
|
27 char returnsChar(void);
|
|
28 void t5(void) {
|
150
|
29 int *array = 0;
|
|
30 int val = array[returnsChar()]; // expected-warning{{array subscript is of type 'char'}}
|
|
31 }
|
|
32
|
236
|
33 void t6(void) {
|
150
|
34 int array[1] = { 0 };
|
|
35 signed char subscript = 0;
|
|
36 int val = array[subscript]; // no warning for explicit signed char
|
|
37 }
|
|
38
|
236
|
39 void t7(void) {
|
150
|
40 int array[1] = { 0 };
|
|
41 unsigned char subscript = 0;
|
|
42 int val = array[subscript]; // no warning for unsigned char
|
|
43 }
|
|
44
|
|
45 typedef char CharTy;
|
236
|
46 void t8(void) {
|
150
|
47 int array[1] = { 0 };
|
|
48 CharTy subscript = 0;
|
|
49 int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
|
|
50 }
|
|
51
|
|
52 typedef signed char SignedCharTy;
|
236
|
53 void t9(void) {
|
150
|
54 int array[1] = { 0 };
|
|
55 SignedCharTy subscript = 0;
|
|
56 int val = array[subscript]; // no warning for explicit signed char
|
|
57 }
|
|
58
|
|
59 typedef unsigned char UnsignedCharTy;
|
236
|
60 void t10(void) {
|
150
|
61 int array[1] = { 0 };
|
|
62 UnsignedCharTy subscript = 0;
|
|
63 int val = array[subscript]; // no warning for unsigned char
|
|
64 }
|