brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 35bc558 Raw
41 lines · cpp
1// RUN: %clang_cc1 -verify=relaxed                    -fstrict-flex-arrays=1 %s2// RUN: %clang_cc1 -verify=relaxed,strict             -fstrict-flex-arrays=2 %s3// RUN: %clang_cc1 -verify=relaxed,strict,very-strict -fstrict-flex-arrays=3 %s4 5// We cannot know for sure the size of a flexible array.6struct t {7  int f;8  int a[];9};10void test(t *s2) {11  s2->a[2] = 0; // no-warning12}13 14// Under -fstrict-flex-arrays={1,2,3} `a` is not a flexible array15struct t0 {16  int f;17  int a[10]; // relaxed-note {{array 'a' declared here}}18};19void 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]')}}21}22 23 24// Under -fstrict-flex-arrays=2 `a` is not a flexible array, but it is under -fstrict-flex-arrays=125struct t1 {26  int f;27  int a[1]; // strict-note {{array 'a' declared here}}28};29void 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]')}}31}32 33// Under -fstrict-flex-arrays={1,2} `a` is a flexible array, but not under -fstrict-flex-arrays=3.34struct t2 {35  int f;36  int a[0]; // very-strict-note {{array 'a' declared here}}37};38void 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]')}}40}41