[cfe-commits] r140584 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/array-bounds.cpp
Ted Kremenek
kremenek at apple.com
Mon Sep 26 16:36:13 PDT 2011
Author: kremenek
Date: Mon Sep 26 18:36:13 2011
New Revision: 140584
URL: http://llvm.org/viewvc/llvm-project?rev=140584&view=rev
Log:
Fix regression of -Warray-bounds involving varargs functions [PR 11007].
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/array-bounds.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=140584&r1=140583&r2=140584&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Sep 26 18:36:13 2011
@@ -3398,6 +3398,10 @@
AllArgs.push_back(Arg.take());
}
}
+
+ // Check for array bounds violations.
+ for (unsigned i = ArgIx; i != NumArgs; ++i)
+ CheckArrayAccess(Args[i]);
}
return Invalid;
}
Modified: cfe/trunk/test/SemaCXX/array-bounds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/array-bounds.cpp?rev=140584&r1=140583&r2=140584&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/array-bounds.cpp (original)
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp Mon Sep 26 18:36:13 2011
@@ -226,3 +226,12 @@
// TODO: This should probably warn, too.
*(((char*)foo) + sizeof(foo)) = '\0'; // no-warning
}
+
+int test_pr11007_aux(const char * restrict, ...);
+
+// Test checking with varargs.
+void test_pr11007() {
+ double a[5]; // expected-note {{array 'a' declared here}}
+ test_pr11007_aux("foo", a[1000]); // expected-warning {{array index of '1000' indexes past the end of an array}}
+}
+
More information about the cfe-commits
mailing list