(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
attr-aligned-2.c
       1  /* PR c/88172 - attribute aligned of zero silently accepted but ignored
       2     Verify that valid alignment on functions is accepted for all targets
       3     and that alignment of zero is ignored with a warning.
       4     { dg-do compile }
       5     { dg-options "-Wno-pedantic" }  */
       6  
       7  #define ASSERT(expr)   _Static_assert (expr, #expr)
       8  #define ALIGN(n)       __attribute__ ((aligned (n)))
       9  #define alignof(expr)  __alignof__ (expr)
      10  
      11  ALIGN (0) void f0 (void) { }    /* { dg-warning "requested alignment .0. is not a positive power of 2" } */
      12  ALIGN (1) void f1 (void) { }
      13  ALIGN (2) void f2 (void) { }
      14  ALIGN (3) void f3 (void) { }    /* { dg-error "requested alignment '3' is not a positive power of 2" } */
      15  ALIGN (4) void f4 (void) { }
      16  
      17  ASSERT (alignof (f0) > 0);
      18  ASSERT (alignof (f1) >= 1);
      19  ASSERT (alignof (f2) >= 2);
      20  ASSERT (alignof (f3) >= 1);
      21  ASSERT (alignof (f4) >= 4);