From 8ef8f431aaeed3d7418959c81dfaa677b44f05ed Mon Sep 17 00:00:00 2001 From: Matt Beaumont-Gay Date: Mon, 12 Dec 2011 22:35:02 +0000 Subject: Suppress -Warray-bounds in certain cases involving macros from system headers. The motivation here is a "clever" implementation of strncmp(), which peels the first few comparisons via chained conditional expressions which ensure that the input arrays are known at compile time to be sufficiently large. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146430 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/SemaCXX/array-bounds-system-header.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 test/SemaCXX/array-bounds-system-header.cpp (limited to 'test/SemaCXX/array-bounds-system-header.cpp') diff --git a/test/SemaCXX/array-bounds-system-header.cpp b/test/SemaCXX/array-bounds-system-header.cpp new file mode 100644 index 0000000000..34de5b5819 --- /dev/null +++ b/test/SemaCXX/array-bounds-system-header.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -isystem %S/Inputs -verify %s +#include +void test_system_header_macro() { + BAD_MACRO_1; // no-warning + char a[3]; // expected-note 2 {{declared here}} + BAD_MACRO_2(a, 3); // expected-warning {{array index 3}} + QUESTIONABLE_MACRO(a); + NOP(a[3] = 5); // expected-warning {{array index 3}} +} -- cgit v1.2.3-18-g5258