(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
Wvarargs.c
       1  /* { dg-do compile } */
       2  
       3  #include <stdarg.h>
       4  
       5  void
       6  err (int a)
       7  {
       8    va_list vp;
       9    va_start (vp, a); // { dg-error "used in function with fixed arguments" }
      10  }
      11  
      12  #pragma GCC diagnostic push
      13  #pragma GCC diagnostic ignored "-Wvarargs"
      14  
      15  void
      16  foo0 (int a, int b, ...)
      17  {
      18      va_list vp;
      19      /* 'a' is not the last argument of the enclosing function, but
      20         don't warn because we are ignoring -Wvarargs.  */
      21      va_start (vp, a);
      22      va_end (vp);
      23  }
      24  
      25  void
      26  foo1 (int a, register int b, ...)	// { dg-warning "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } }
      27  {
      28      va_list vp;
      29      /* 'b' is declared with register storage, but don't warn
      30         because we are ignoring -Wvarargs.  */
      31      va_start (vp, b);
      32      va_end (vp);
      33  }
      34  
      35  #pragma GCC diagnostic pop
      36  
      37  void
      38  foo2 (int a, int b, ...)
      39  {
      40      va_list vp;
      41      /* 'a' is not the last argument of the enclosing function, so
      42         warn.  */
      43      va_start (vp, a); /* { dg-warning "second parameter" } */
      44      va_end (vp);
      45  }
      46  
      47  void
      48  foo3 (int a, register int b, ...)	// { dg-warning "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } }
      49  {
      50      va_list vp;
      51      /* 'b' is declared with register storage, so warn.  */
      52      va_start (vp, b); /* { dg-warning "undefined behavior" } */
      53      va_end (vp);
      54  }