diff options
author | Edward Jones <ed.jones@embecosm.com> | 2019-11-07 15:44:38 +0000 |
---|---|---|
committer | Edward Jones <ed.jones@embecosm.com> | 2019-11-07 15:45:44 +0000 |
commit | 7adab7719e55e1b29bfd521dcc73f202139e8f41 (patch) | |
tree | 064a97407b61d7908722dfa6276f22258d0c41c8 /clang/test/SemaCXX/warn-char-subscripts.cpp | |
parent | 343597789eba1e6482e130b0c1b0818b1432d311 (diff) | |
download | bcm5719-llvm-7adab7719e55e1b29bfd521dcc73f202139e8f41.tar.gz bcm5719-llvm-7adab7719e55e1b29bfd521dcc73f202139e8f41.zip |
[Sema] Suppress -Wchar-subscripts if the index is a literal char
Assume that the user knows what they're doing if they provide a char
literal as an array index. This more closely matches the behavior of
GCC.
Differential Revision: https://reviews.llvm.org/D58896
Diffstat (limited to 'clang/test/SemaCXX/warn-char-subscripts.cpp')
-rw-r--r-- | clang/test/SemaCXX/warn-char-subscripts.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/warn-char-subscripts.cpp b/clang/test/SemaCXX/warn-char-subscripts.cpp index 84ea536b979..7760ed0e5eb 100644 --- a/clang/test/SemaCXX/warn-char-subscripts.cpp +++ b/clang/test/SemaCXX/warn-char-subscripts.cpp @@ -14,6 +14,19 @@ void t2() { int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}} } +void t3() { + int array[50] = { 0 }; + int val = array[' ']; // no warning, subscript is a literal +} +void t4() { + int array[50] = { 0 }; + int val = '('[array]; // no warning, subscript is a literal +} +void t5() { + int array[50] = { 0 }; + int val = array['\x11']; // no warning, subscript is a literal +} + void test() { t1<char>(); // expected-note {{in instantiation of function template specialization 't1<char>' requested here}} t2<char>(); // expected-note {{in instantiation of function template specialization 't2<char>' requested here}} |