Fix bogus -Warray-bounds warning involving 'array[true]' reported in PR 9296.

llvm-svn: 126341
This commit is contained in:
Ted Kremenek 2011-02-23 23:06:04 +00:00
parent 7b0f796c55
commit e4b316c15c
2 changed files with 6 additions and 1 deletions

View File

@ -3123,7 +3123,7 @@ void Sema::CheckArrayAccess(const clang::ArraySubscriptExpr *E) {
if (!IndexExpr->isIntegerConstantExpr(index, Context))
return;
if (!index.isNegative()) {
if (index.isUnsigned() || !index.isNegative()) {
llvm::APInt size = ArrayTy->getSize();
if (!size.isStrictlyPositive())
return;

View File

@ -115,3 +115,8 @@ void test_pr9284() {
pr9284b<false>(); // expected-note{{in instantiation of function template specialization 'pr9284b<false>' requested here}}
}
int test_pr9296() {
int array[2];
return array[true]; // no-warning
}