(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
Warray-bounds-flex-arrays-4.c
       1  /* Test -fstrict-flex-arrays + -Warray-bounds=2 + -Wstrict-flex-arrays.  */
       2  /* { dg-do compile } */
       3  /* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=1 -Warray-bounds=2" } */
       4  
       5  struct trailing_array_1 {
       6      int a;
       7      int b;
       8      int c[4]; 
       9  };
      10  
      11  struct trailing_array_2 {
      12      int a;
      13      int b;
      14      int c[1]; 
      15  };
      16  
      17  struct trailing_array_3 {
      18      int a;
      19      int b;
      20      int c[0];
      21  };
      22  struct trailing_array_4 {
      23      int a;
      24      int b;
      25      int c[];
      26  };
      27  
      28  void __attribute__((__noinline__)) stuff(
      29      struct trailing_array_1 *normal,
      30      struct trailing_array_2 *trailing_1,
      31      struct trailing_array_3 *trailing_0,
      32      struct trailing_array_4 *trailing_flex)
      33  {
      34      normal->c[5] = 5; 	/*{ dg-warning "array subscript 5 is above array bounds of" } */
      35      			/*{ dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */
      36      trailing_1->c[2] = 2; /* { dg-bogus "array subscript " } */
      37      trailing_0->c[1] = 1; /* { dg-bogus "array subscript " } */
      38      trailing_flex->c[10] = 10; /* { dg-bogus "array subscript " } */
      39  
      40  }