diff options
Diffstat (limited to 'test/SemaCXX/array-bounds.cpp')
| -rw-r--r-- | test/SemaCXX/array-bounds.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/SemaCXX/array-bounds.cpp b/test/SemaCXX/array-bounds.cpp index 8ae92e7613010..a97f8e312a05d 100644 --- a/test/SemaCXX/array-bounds.cpp +++ b/test/SemaCXX/array-bounds.cpp @@ -269,3 +269,18 @@ int test_operator_overload_struct_array_index() { struct P x[10] = {0}; // expected-note {{array 'x' declared here}} return x[1] + x[11]; // expected-warning {{array index 11 is past the end of the array (which contains 10 elements)}} } + +int multi[2][2][2]; // expected-note 3 {{array 'multi' declared here}} +int test_multiarray() { + return multi[2][0][0] + // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} + multi[0][2][0] + // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} + multi[0][0][2]; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} +} + +struct multi_s { + int arr[4]; +}; +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)}} +} |
