2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / format / multattr-2.c
blob1d78840aecb906a80e7085be24d2767313117d1c
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 } */
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, wherever they are placed on the declarations. */
12 extern __attribute__((__format__(__printf__, 1, 0))) void
13 my_vprintf_scanf (const char *, va_list, const char *, ...)
14 __attribute__((__format__(__scanf__, 3, 4)));
16 extern void (__attribute__((__format__(__printf__, 1, 0))) my_vprintf_scanf2)
17 (const char *, va_list, const char *, ...)
18 __attribute__((__format__(__scanf__, 3, 4)));
20 extern __attribute__((__format__(__scanf__, 3, 4))) void
21 (__attribute__((__format__(__printf__, 1, 0))) my_vprintf_scanf3)
22 (const char *, va_list, const char *, ...);
24 void
25 foo (va_list ap, int *ip, long *lp)
27 my_vprintf_scanf ("%d", ap, "%d", ip);
28 my_vprintf_scanf ("%d", ap, "%ld", lp);
29 my_vprintf_scanf ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
30 my_vprintf_scanf ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
31 my_vprintf_scanf2 ("%d", ap, "%d", ip);
32 my_vprintf_scanf2 ("%d", ap, "%ld", lp);
33 my_vprintf_scanf2 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
34 my_vprintf_scanf2 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */
35 my_vprintf_scanf3 ("%d", ap, "%d", ip);
36 my_vprintf_scanf3 ("%d", ap, "%ld", lp);
37 my_vprintf_scanf3 ("%", ap, "%d", ip); /* { dg-warning "format" "printf" } */
38 my_vprintf_scanf3 ("%d", ap, "%ld", ip); /* { dg-warning "format" "scanf" } */