summaryrefslogtreecommitdiff
path: root/test/SemaCXX/array-bounds.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/array-bounds.cpp')
-rw-r--r--test/SemaCXX/array-bounds.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/SemaCXX/array-bounds.cpp b/test/SemaCXX/array-bounds.cpp
index a97f8e312a05d..6ebff8c992068 100644
--- a/test/SemaCXX/array-bounds.cpp
+++ b/test/SemaCXX/array-bounds.cpp
@@ -284,3 +284,15 @@ struct multi_s multi2[4]; // expected-note {{array 'multi2' declared here}}
int test_struct_multiarray() {
return multi2[4].arr[0]; // expected-warning {{array index 4 is past the end of the array (which contains 4 elements)}}
}
+
+namespace PR39746 {
+ struct S;
+ extern S xxx[2]; // expected-note {{array 'xxx' declared here}}
+ class C {};
+
+ C &f() { return reinterpret_cast<C *>(xxx)[1]; } // no-warning
+ // We have no info on whether this is out-of-bounds.
+ C &g() { return reinterpret_cast<C *>(xxx)[2]; } // no-warning
+ // We can still diagnose this.
+ C &h() { return reinterpret_cast<C *>(xxx)[-1]; } // expected-warning {{array index -1 is before the beginning of the array}}
+}