aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaExpr.cpp6
-rw-r--r--test/Sema/warn-char-subscripts.c4
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 4967599da3..1c5d19748f 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1809,9 +1809,9 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
return ExprError(Diag(LLoc, diag::err_typecheck_subscript_not_integer)
<< IndexExpr->getSourceRange());
- QualType IndexTy = Context.getCanonicalType(IndexExpr->getType());
- if ((IndexTy == Context.CharTy || IndexTy == Context.SignedCharTy)
- && !IndexExpr->isTypeDependent())
+ if ((IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_S) ||
+ IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_U))
+ && !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/test/Sema/warn-char-subscripts.c b/test/Sema/warn-char-subscripts.c
index 972393cd6c..c6fd78cc1f 100644
--- a/test/Sema/warn-char-subscripts.c
+++ b/test/Sema/warn-char-subscripts.c
@@ -33,7 +33,7 @@ void t5() {
void t6() {
int array[1] = { 0 };
signed char subscript = 0;
- int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
+ int val = array[subscript]; // no warning for explicit signed char
}
void t7() {
@@ -53,7 +53,7 @@ typedef signed char SignedCharTy;
void t9() {
int array[1] = { 0 };
SignedCharTy subscript = 0;
- int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
+ int val = array[subscript]; // no warning for explicit signed char
}
typedef unsigned char UnsignedCharTy;