aboutsummaryrefslogtreecommitdiff
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.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/SemaCXX/array-bounds.cpp b/test/SemaCXX/array-bounds.cpp
index 80646c7190..20451bf2f2 100644
--- a/test/SemaCXX/array-bounds.cpp
+++ b/test/SemaCXX/array-bounds.cpp
@@ -120,3 +120,11 @@ int test_pr9296() {
return array[true]; // no-warning
}
+int test_sizeof_as_condition(int flag) {
+ int arr[2] = { 0, 0 }; // expected-note {{array 'arr' declared here}}
+ if (flag)
+ return sizeof(char) != sizeof(char) ? arr[2] : arr[1];
+ return sizeof(char) == sizeof(char) ? arr[2] : arr[1]; // expected-warning {{array index of '2' indexes past the end of an array (that contains 2 elements)}}
+}
+
+