(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
format/
ms_multattr-1.c
       1  /* Test for multiple format attributes.  Test for printf and scanf attributes
       2     together.  */
       3  /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
       4  /* { dg-do compile { target { *-*-mingw* } } } */
       5  /* { dg-options "-std=gnu99 -Wformat" } */
       6  
       7  #define USE_SYSTEM_FORMATS
       8  #include "format.h"
       9  
      10  /* If we specify multiple attributes for a single function, they should
      11     all apply.  This should apply whether they are on the same declaration
      12     or on different declarations.  */
      13  
      14  extern void my_vprintf_scanf (const char *, va_list, const char *, ...)
      15       __attribute__((__format__(__ms_printf__, 1, 0)))
      16       __attribute__((__format__(__ms_scanf__, 3, 4)));
      17  
      18  extern void my_vprintf_scanf2 (const char *, va_list, const char *, ...)
      19       __attribute__((__format__(__ms_scanf__, 3, 4)))
      20       __attribute__((__format__(__ms_printf__, 1, 0)));
      21  
      22  extern void my_vprintf_scanf3 (const char *, va_list, const char *, ...)
      23       __attribute__((__format__(__ms_printf__, 1, 0)));
      24  extern void my_vprintf_scanf3 (const char *, va_list, const char *, ...)
      25       __attribute__((__format__(__ms_scanf__, 3, 4)));
      26  
      27  extern void my_vprintf_scanf4 (const char *, va_list, const char *, ...)
      28       __attribute__((__format__(__ms_scanf__, 3, 4)));
      29  extern void my_vprintf_scanf4 (const char *, va_list, const char *, ...)
      30       __attribute__((__format__(__ms_printf__, 1, 0)));
      31  
      32  void
      33  foo (va_list ap, int *ip, long *lp)
      34  {
      35    my_vprintf_scanf ("%d", ap, "%d", ip);
      36    my_vprintf_scanf ("%d", ap, "%ld", lp);
      37    my_vprintf_scanf ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
      38    my_vprintf_scanf ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
      39    my_vprintf_scanf2 ("%d", ap, "%d", ip);
      40    my_vprintf_scanf2 ("%d", ap, "%ld", lp);
      41    my_vprintf_scanf2 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
      42    my_vprintf_scanf2 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
      43    my_vprintf_scanf3 ("%d", ap, "%d", ip);
      44    my_vprintf_scanf3 ("%d", ap, "%ld", lp);
      45    my_vprintf_scanf3 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
      46    my_vprintf_scanf3 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
      47    my_vprintf_scanf4 ("%d", ap, "%d", ip);
      48    my_vprintf_scanf4 ("%d", ap, "%ld", lp);
      49    my_vprintf_scanf4 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
      50    my_vprintf_scanf4 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
      51  }