Merge reload-branch up to revision 101000
[official-gcc.git] / gcc / testsuite / gcc.dg / format / multattr-1.c
blob7691aba5bd8780ffe0901ee3d288964486024bbc
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 } */
5 /* { dg-options "-std=gnu99 -Wformat" } */
7 #include "format.h"
9 /* If we specify multiple attributes for a single function, they should
10 all apply. This should apply whether they are on the same declaration
11 or on different declarations. */
13 extern void my_vprintf_scanf (const char *, va_list, const char *, ...)
14 __attribute__((__format__(__printf__, 1, 0)))
15 __attribute__((__format__(__scanf__, 3, 4)));
17 extern void my_vprintf_scanf2 (const char *, va_list, const char *, ...)
18 __attribute__((__format__(__scanf__, 3, 4)))
19 __attribute__((__format__(__printf__, 1, 0)));
21 extern void my_vprintf_scanf3 (const char *, va_list, const char *, ...)
22 __attribute__((__format__(__printf__, 1, 0)));
23 extern void my_vprintf_scanf3 (const char *, va_list, const char *, ...)
24 __attribute__((__format__(__scanf__, 3, 4)));
26 extern void my_vprintf_scanf4 (const char *, va_list, const char *, ...)
27 __attribute__((__format__(__scanf__, 3, 4)));
28 extern void my_vprintf_scanf4 (const char *, va_list, const char *, ...)
29 __attribute__((__format__(__printf__, 1, 0)));
31 void
32 foo (va_list ap, int *ip, long *lp)
34 my_vprintf_scanf ("%d", ap, "%d", ip);
35 my_vprintf_scanf ("%d", ap, "%ld", lp);
36 my_vprintf_scanf ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
37 my_vprintf_scanf ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
38 my_vprintf_scanf2 ("%d", ap, "%d", ip);
39 my_vprintf_scanf2 ("%d", ap, "%ld", lp);
40 my_vprintf_scanf2 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
41 my_vprintf_scanf2 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
42 my_vprintf_scanf3 ("%d", ap, "%d", ip);
43 my_vprintf_scanf3 ("%d", ap, "%ld", lp);
44 my_vprintf_scanf3 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
45 my_vprintf_scanf3 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
46 my_vprintf_scanf4 ("%d", ap, "%d", ip);
47 my_vprintf_scanf4 ("%d", ap, "%ld", lp);
48 my_vprintf_scanf4 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
49 my_vprintf_scanf4 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */