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