aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-09-26 23:36:13 +0000
committerTed Kremenek <kremenek@apple.com>2011-09-26 23:36:13 +0000
commit615eb7c477eb0523bfc1d238c57cee9497c874e3 (patch)
tree4733e9a7722a293df981e43441d1313f62847782
parenteabdd6716dfe777a28435276fe6c89af77608b11 (diff)
Fix regression of -Warray-bounds involving varargs functions [PR 11007].
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140584 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp4
-rw-r--r--test/SemaCXX/array-bounds.cpp9
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index d30620b816..3397680ee1 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -3398,6 +3398,10 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc,
AllArgs.push_back(Arg.take());
}
}
+
+ // Check for array bounds violations.
+ for (unsigned i = ArgIx; i != NumArgs; ++i)
+ CheckArrayAccess(Args[i]);
}
return Invalid;
}
diff --git a/test/SemaCXX/array-bounds.cpp b/test/SemaCXX/array-bounds.cpp
index e071bc7b5b..555ac33af5 100644
--- a/test/SemaCXX/array-bounds.cpp
+++ b/test/SemaCXX/array-bounds.cpp
@@ -226,3 +226,12 @@ void test_pr10771() {
// 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}}
+}
+