(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
attr-vector_size.c
       1  /* PR middle-end/89797 - ICE on a vector_size (1LU << 33) int variable
       2     PR c/89798 - excessive vector_size silently accepted and truncated
       3     { dg-do compile { target int32plus } }
       4     { dg-options "-Wall -Wno-unused" } */
       5  
       6  #define ASSERT(e)    _Static_assert (e, #e)
       7  #define VEC(N)       __attribute__ ((vector_size (N)))
       8  #define POW2(N)      (1LLU << N)
       9  #define CAT(a, b)    a ## b
      10  #define CONCAT(a, b) CAT (a, b)
      11  
      12  #define DEFVEC(storage, N)				\
      13    typedef VEC (POW2 (N)) char CONCAT (Vec, N);		\
      14    storage CONCAT (Vec, N) CONCAT (v, N);		\
      15    ASSERT (sizeof (CONCAT (Vec, N)) == POW2 (N));	\
      16    ASSERT (sizeof (CONCAT (v, N)) == POW2 (N))
      17  
      18  DEFVEC (extern, 27);
      19  DEFVEC (extern, 28);
      20  DEFVEC (extern, 29);
      21  DEFVEC (extern, 30);
      22  
      23  #if __SIZEOF_SIZE_T__ > 4
      24  
      25  VEC (POW2 (63)) char v63;     /* { dg-error  "'vector_size' attribute argument value '9223372036854775808' exceeds 9223372036854775807" "not-ILP32" { target { ! ilp32 } } } */
      26  
      27  #else
      28  
      29  VEC (POW2 (31)) char v31;     /* { dg-error  "'vector_size' attribute argument value '2147483648' exceeds 2147483647" "ILP32" { target ilp32 } } */
      30  
      31  VEC (POW2 (32)) char v32;     /* { dg-error  "'vector_size' attribute argument value '4294967296' exceeds 2147483647" "ILP32" { target ilp32 } } */
      32  
      33  #endif
      34  
      35  void test_local_scope (void)
      36  {
      37    DEFVEC (auto, 27);
      38    DEFVEC (auto, 28);
      39    DEFVEC (auto, 29);
      40    DEFVEC (auto, 30);
      41  
      42  #if __SIZEOF_SIZE_T__ > 4
      43  
      44    VEC (POW2 (63)) char v63;   /* { dg-error  "'vector_size' attribute argument value '9223372036854775808' exceeds 9223372036854775807" "not-ILP32" { target { ! ilp32 } } } */
      45  
      46  #else
      47  
      48    VEC (POW2 (31)) char v31;   /* { dg-error  "'vector_size' attribute argument value '2147483648' exceeds 2147483647" "ILP32" { target ilp32 } } */
      49  
      50    VEC (POW2 (32)) char v32;   /* { dg-error  "'vector_size' attribute argument value '4294967296' exceeds 2147483647" "ILP32" { target ilp32 } } */
      51  
      52  #endif
      53  }