Update concepts branch to revision 131834
[official-gcc.git] / gcc / testsuite / gcc.dg / format / ms_multattr-2.c
blob47e20e4d461fb71d332b063b4b4dfa3e7b6cfd1b
1 /* Test for multiple format attributes. Test for printf and scanf attributes
2 together, in different places on the declarations. */
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
8 #include "format.h"
10 /* If we specify multiple attributes for a single function, they should
11 all apply, wherever they are placed on the declarations. */
13 extern __attribute__((__format__(__ms_printf__, 1, 0))) void
14 my_vprintf_scanf (const char *, va_list, const char *, ...)
15 __attribute__((__format__(__ms_scanf__, 3, 4)));
17 extern void (__attribute__((__format__(__ms_printf__, 1, 0))) my_vprintf_scanf2)
18 (const char *, va_list, const char *, ...)
19 __attribute__((__format__(__ms_scanf__, 3, 4)));
21 extern __attribute__((__format__(__ms_scanf__, 3, 4))) void
22 (__attribute__((__format__(__ms_printf__, 1, 0))) my_vprintf_scanf3)
23 (const char *, va_list, const char *, ...);
25 void
26 foo (va_list ap, int *ip, long *lp)
28 my_vprintf_scanf ("%d", ap, "%d", ip);
29 my_vprintf_scanf ("%d", ap, "%ld", lp);
30 my_vprintf_scanf ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
31 my_vprintf_scanf ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
32 my_vprintf_scanf2 ("%d", ap, "%d", ip);
33 my_vprintf_scanf2 ("%d", ap, "%ld", lp);
34 my_vprintf_scanf2 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
35 my_vprintf_scanf2 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
36 my_vprintf_scanf3 ("%d", ap, "%d", ip);
37 my_vprintf_scanf3 ("%d", ap, "%ld", lp);
38 my_vprintf_scanf3 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
39 my_vprintf_scanf3 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */