111
|
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" } */
|
|
6
|
|
7 #define DONT_GNU_PROTOTYPE
|
|
8 #include "format.h"
|
|
9
|
|
10 /* If we specify multiple attributes for a single function, they should
|
|
11 all apply, wherever they are placed on the declarations. */
|
|
12
|
|
13 extern __attribute__((__format__(gnu_attr___printf__, 1, 0))) void
|
|
14 my_vprintf_scanf (const char *, va_list, const char *, ...)
|
|
15 __attribute__((__format__(gnu_attr___scanf__, 3, 4)));
|
|
16
|
|
17 extern void (__attribute__((__format__(gnu_attr___printf__, 1, 0))) my_vprintf_scanf2)
|
|
18 (const char *, va_list, const char *, ...)
|
|
19 __attribute__((__format__(gnu_attr___scanf__, 3, 4)));
|
|
20
|
|
21 extern __attribute__((__format__(gnu_attr___scanf__, 3, 4))) void
|
|
22 (__attribute__((__format__(gnu_attr___printf__, 1, 0))) my_vprintf_scanf3)
|
|
23 (const char *, va_list, const char *, ...);
|
|
24
|
|
25 void
|
|
26 foo (va_list ap, int *ip, long *lp)
|
|
27 {
|
|
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" } */
|
|
40 }
|