xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/warn-char-subscripts.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -Wchar-subscripts -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc template<typename T>
t1()4*f4a2713aSLionel Sambuc void t1() {
5*f4a2713aSLionel Sambuc   int array[1] = { 0 };
6*f4a2713aSLionel Sambuc   T subscript = 0;
7*f4a2713aSLionel Sambuc   int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
8*f4a2713aSLionel Sambuc }
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc template<typename T>
t2()11*f4a2713aSLionel Sambuc void t2() {
12*f4a2713aSLionel Sambuc   int array[1] = { 0 };
13*f4a2713aSLionel Sambuc   T subscript = 0;
14*f4a2713aSLionel Sambuc   int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}}
15*f4a2713aSLionel Sambuc }
16*f4a2713aSLionel Sambuc 
test()17*f4a2713aSLionel Sambuc void test() {
18*f4a2713aSLionel Sambuc   t1<char>(); // expected-note {{in instantiation of function template specialization 't1<char>' requested here}}
19*f4a2713aSLionel Sambuc   t2<char>(); // expected-note {{in instantiation of function template specialization 't2<char>' requested here}}
20*f4a2713aSLionel Sambuc }
21*f4a2713aSLionel Sambuc 
22