Author: Edward Jones Date: 2019-11-07T18:45:40Z New Revision: 90ecfa2f5f7feea6e3676d59fe6126e08c52d00e
URL: https://github.com/llvm/llvm-project/commit/90ecfa2f5f7feea6e3676d59fe6126e08c52d00e DIFF: https://github.com/llvm/llvm-project/commit/90ecfa2f5f7feea6e3676d59fe6126e08c52d00e.diff LOG: Revert "[Sema] Suppress -Wchar-subscripts if the index is a literal char" This reverts commit 7adab7719e55e1b29bfd521dcc73f202139e8f41. Added: Modified: clang/lib/Sema/SemaExpr.cpp clang/test/SemaCXX/warn-char-subscripts.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 2842e7199b1d..e41cd5b6653a 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4741,8 +4741,7 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, if ((IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_S) || IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_U)) - && !IndexExpr->isTypeDependent() - && !isa<CharacterLiteral>(IndexExpr)) + && !IndexExpr->isTypeDependent()) Diag(LLoc, diag::warn_subscript_is_char) << IndexExpr->getSourceRange(); // C99 6.5.2.1p1: "shall have type "pointer to *object* type". Similarly, diff --git a/clang/test/SemaCXX/warn-char-subscripts.cpp b/clang/test/SemaCXX/warn-char-subscripts.cpp index 7760ed0e5eba..84ea536b979e 100644 --- a/clang/test/SemaCXX/warn-char-subscripts.cpp +++ b/clang/test/SemaCXX/warn-char-subscripts.cpp @@ -14,19 +14,6 @@ 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}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits