[cfe-commits] r126341 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/SemaCXX/array-bounds.cpp
Ted Kremenek
kremenek at apple.com
Wed Feb 23 15:06:05 PST 2011
Author: kremenek
Date: Wed Feb 23 17:06:04 2011
New Revision: 126341
URL: http://llvm.org/viewvc/llvm-project?rev=126341&view=rev
Log:
Fix bogus -Warray-bounds warning involving 'array[true]' reported in PR 9296.
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/array-bounds.cpp
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=126341&r1=126340&r2=126341&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Feb 23 17:06:04 2011
@@ -3123,7 +3123,7 @@
if (!IndexExpr->isIntegerConstantExpr(index, Context))
return;
- if (!index.isNegative()) {
+ if (index.isUnsigned() || !index.isNegative()) {
llvm::APInt size = ArrayTy->getSize();
if (!size.isStrictlyPositive())
return;
Modified: cfe/trunk/test/SemaCXX/array-bounds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/array-bounds.cpp?rev=126341&r1=126340&r2=126341&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/array-bounds.cpp (original)
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp Wed Feb 23 17:06:04 2011
@@ -115,3 +115,8 @@
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
+}
+
More information about the cfe-commits
mailing list