Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / warn-char-subscripts.c
blob2e72d90fa612aeddb532756a13a02e5cc25bb5a0
1 // RUN: %clang_cc1 -Wchar-subscripts -fsyntax-only -verify %s
3 void t1(void) {
4 int array[1] = { 0 };
5 char subscript = 0;
6 int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
9 void t2(void) {
10 int array[1] = { 0 };
11 char subscript = 0;
12 int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}}
15 void t3(void) {
16 int *array = 0;
17 char subscript = 0;
18 int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
21 void t4(void) {
22 int *array = 0;
23 char subscript = 0;
24 int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}}
27 char returnsChar(void);
28 void t5(void) {
29 int *array = 0;
30 int val = array[returnsChar()]; // expected-warning{{array subscript is of type 'char'}}
33 void t6(void) {
34 int array[1] = { 0 };
35 signed char subscript = 0;
36 int val = array[subscript]; // no warning for explicit signed char
39 void t7(void) {
40 int array[1] = { 0 };
41 unsigned char subscript = 0;
42 int val = array[subscript]; // no warning for unsigned char
45 typedef char CharTy;
46 void t8(void) {
47 int array[1] = { 0 };
48 CharTy subscript = 0;
49 int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
52 typedef signed char SignedCharTy;
53 void t9(void) {
54 int array[1] = { 0 };
55 SignedCharTy subscript = 0;
56 int val = array[subscript]; // no warning for explicit signed char
59 typedef unsigned char UnsignedCharTy;
60 void t10(void) {
61 int array[1] = { 0 };
62 UnsignedCharTy subscript = 0;
63 int val = array[subscript]; // no warning for unsigned char