aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Weinig <sam.weinig@gmail.com>2009-09-14 20:14:57 +0000
committerSam Weinig <sam.weinig@gmail.com>2009-09-14 20:14:57 +0000
commit0f9a5b5be561c2ec42399c1b466d1f3e792de191 (patch)
tree472c0d6aad5540cbeeba930b90c4128112e7bf7e
parent1282029f3d37f482bbba3c38ea9da17a78d11d40 (diff)
-Wchar-subscripts should not warn for explicit signed char subscripts either. Another fix for PR4978.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81780 91177308-0d34-0410-b5e6-96231b3b80d8
-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;