aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/array-bounds.cpp
diff options
context:
space:
mode:
authorMatt Beaumont-Gay <matthewbg@google.com>2011-11-29 22:43:53 +0000
committerMatt Beaumont-Gay <matthewbg@google.com>2011-11-29 22:43:53 +0000
commit381711c6e7911d762f81a65e9ef4339a6a3d6524 (patch)
treee85a24c8956386366ab00911d44ee5c2a38cac57 /test/SemaCXX/array-bounds.cpp
parent6649014b792f8a4b1bc1e8be8f844a72220af508 (diff)
Suppress -Warray-bounds for classes (not just structs) where the last field is
a 1-length character array. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145445 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/array-bounds.cpp')
-rw-r--r--test/SemaCXX/array-bounds.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/test/SemaCXX/array-bounds.cpp b/test/SemaCXX/array-bounds.cpp
index 48788f67d7..c1b3701172 100644
--- a/test/SemaCXX/array-bounds.cpp
+++ b/test/SemaCXX/array-bounds.cpp
@@ -190,10 +190,19 @@ namespace tailpad {
int x;
char c2[1];
};
-
- char bar(struct foo *F) {
- return F->c1[3]; // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
- return F->c2[3]; // no warning, foo could have tail padding allocated.
+
+ class baz {
+ public:
+ char c1[1]; // expected-note {{declared here}}
+ int x;
+ char c2[1];
+ };
+
+ char bar(struct foo *F, baz *B) {
+ return F->c1[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+ F->c2[3] + // no warning, foo could have tail padding allocated.
+ B->c1[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+ B->c2[3]; // no warning, baz could have tail padding allocated.
}
}