зеркало из https://github.com/microsoft/clang-1.git
-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
This commit is contained in:
Родитель
1282029f3d
Коммит
0f9a5b5be5
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче