1 /* Test for multiple format attributes. Test for printf and scanf attributes
3 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
4 /* { dg-do compile { target { *-*-mingw* } } } */
5 /* { dg-options "-std=gnu99 -Wformat" } */
7 #define USE_SYSTEM_FORMATS
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. */
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)));
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)));
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)));
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)));
33 foo (va_list ap
, int *ip
, long *lp
)
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" } */