(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
analyzer/
stdarg-3.c
       1  typedef __builtin_va_list va_list;
       2  
       3  struct printf_spec {
       4    unsigned int type;
       5  };
       6  
       7  int
       8  format_decode(const char *fmt, struct printf_spec *spec);
       9  
      10  static int vbin_printf(const char *fmt, va_list args) {
      11    struct printf_spec spec;
      12    int width = 0;
      13  
      14    while (*fmt) {
      15      int read = format_decode(fmt, &spec);
      16  
      17      fmt += read;
      18  
      19      switch (spec.type) {
      20      case 0:
      21        break;
      22      case 1:
      23        width = __builtin_va_arg(args, int); /* { dg-bogus "-Wanalyzer-va-list-exhausted" } */
      24        break;
      25      }
      26    }
      27  
      28    return width;
      29  }
      30  
      31  int bprintf(const char *fmt, ...) {
      32    va_list args;
      33    int ret;
      34  
      35    __builtin_va_start(args, fmt);
      36    ret = vbin_printf(fmt, args);
      37    __builtin_va_end(args);
      38  
      39    return ret;
      40  }
      41  
      42  static int called_by_test_2 (va_list args)
      43  {
      44    return __builtin_va_arg(args, int); /* { dg-bogus "-Wanalyzer-va-list-exhausted" } */
      45  }
      46  
      47  int test_2 (const char *fmt, ...)
      48  {
      49    va_list args;
      50    int ret;
      51  
      52    __builtin_va_start (args, fmt);
      53    ret = called_by_test_2 (args);
      54    __builtin_va_end (args);
      55  
      56    return ret;
      57  }