Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / array-bounds-strict-flex-arrays.cpp
blob35bc558d3f5b4668a88902c9e4b6c4ff91d3af7b
1 // RUN: %clang_cc1 -verify=relaxed -fstrict-flex-arrays=1 %s
2 // RUN: %clang_cc1 -verify=relaxed,strict -fstrict-flex-arrays=2 %s
3 // RUN: %clang_cc1 -verify=relaxed,strict,very-strict -fstrict-flex-arrays=3 %s
5 // We cannot know for sure the size of a flexible array.
6 struct t {
7 int f;
8 int a[];
9 };
10 void test(t *s2) {
11 s2->a[2] = 0; // no-warning
14 // Under -fstrict-flex-arrays={1,2,3} `a` is not a flexible array
15 struct t0 {
16 int f;
17 int a[10]; // relaxed-note {{array 'a' declared here}}
19 void test0(t0 *s2) {
20 s2->a[12] = 0; // relaxed-warning {{array index 12 is past the end of the array (that has type 'int[10]')}}
24 // Under -fstrict-flex-arrays=2 `a` is not a flexible array, but it is under -fstrict-flex-arrays=1
25 struct t1 {
26 int f;
27 int a[1]; // strict-note {{array 'a' declared here}}
29 void test1(t1 *s2) {
30 s2->a[2] = 0; // strict-warning {{array index 2 is past the end of the array (that has type 'int[1]')}}
33 // Under -fstrict-flex-arrays={1,2} `a` is a flexible array, but not under -fstrict-flex-arrays=3.
34 struct t2 {
35 int f;
36 int a[0]; // very-strict-note {{array 'a' declared here}}
38 void test1(t2 *s2) {
39 s2->a[2] = 0; // very-strict-warning {{array index 2 is past the end of the array (that has type 'int[0]')}}