1 // RUN: %clang_cc1 -verify -fstrict-flex-arrays=2 %s
2
3 // We cannot know for sure the size of a flexible array.
4 struct t {
5 int f;
6 int a[];
7 };
test(t * s2)8 void test(t *s2) {
9 s2->a[2] = 0; // no-warning
10 }
11
12 // Under -fstrict-flex-arrays `a` is not a flexible array.
13 struct t1 {
14 int f;
15 int a[1]; // expected-note {{array 'a' declared here}}
16 };
test1(t1 * s2)17 void test1(t1 *s2) {
18 s2->a[2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
19 }
20
21 // Under -fstrict-flex-arrays `a` is a flexible array.
22 struct t2 {
23 int f;
24 int a[0];
25 };
test1(t2 * s2)26 void test1(t2 *s2) {
27 s2->a[2] = 0; // no-warning
28 }
29