Skip to content

Commit 90ecfa2

Browse files
committed
Revert "[Sema] Suppress -Wchar-subscripts if the index is a literal char"
This reverts commit 7adab77.
1 parent 08b5b55 commit 90ecfa2

File tree

2 files changed

+1
-15
lines changed

2 files changed

+1
-15
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4741,8 +4741,7 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
47414741

47424742
if ((IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_S) ||
47434743
IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_U))
4744-
&& !IndexExpr->isTypeDependent()
4745-
&& !isa<CharacterLiteral>(IndexExpr))
4744+
&& !IndexExpr->isTypeDependent())
47464745
Diag(LLoc, diag::warn_subscript_is_char) << IndexExpr->getSourceRange();
47474746

47484747
// C99 6.5.2.1p1: "shall have type "pointer to *object* type". Similarly,

clang/test/SemaCXX/warn-char-subscripts.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,6 @@ void t2() {
1414
int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}}
1515
}
1616

17-
void t3() {
18-
int array[50] = { 0 };
19-
int val = array[' ']; // no warning, subscript is a literal
20-
}
21-
void t4() {
22-
int array[50] = { 0 };
23-
int val = '('[array]; // no warning, subscript is a literal
24-
}
25-
void t5() {
26-
int array[50] = { 0 };
27-
int val = array['\x11']; // no warning, subscript is a literal
28-
}
29-
3017
void test() {
3118
t1<char>(); // expected-note {{in instantiation of function template specialization 't1<char>' requested here}}
3219
t2<char>(); // expected-note {{in instantiation of function template specialization 't2<char>' requested here}}

0 commit comments

Comments
 (0)