2 /* { dg-do compile } */
3 /* { dg-options "-Wformat" } */
5 char *foo (const char *) __attribute__((format_arg(1)));
6 void bar (const char *, ...) __attribute__((format(printf
, 1, 2)));
11 bar ("%ld", x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
12 bar (x
? "%ld" : "%ld", x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
13 bar (x
? "%ld" : "%lld", x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
14 /* { dg-warning "format '%lld' expects argument of type 'long long int', but argument 2 has type 'int'" "" { target *-*-* } .-1 } */
15 bar (foo ("%ld"), x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
16 bar (x
? foo ("%ld") : "%ld", x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
17 bar (x
? foo ("%ld") : "%lld", x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
18 /* { dg-warning "format '%lld' expects argument of type 'long long int', but argument 2 has type 'int'" "" { target *-*-* } .-1 } */
19 bar (foo (x
? "%ld" : "%ld"), x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
20 bar (foo (x
? "%ld" : "%lld"), x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
21 /* { dg-warning "format '%lld' expects argument of type 'long long int', but argument 2 has type 'int'" "" { target *-*-* } .-1 } */
22 bar (("%ld"), x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
23 bar ((x
? "%ld" : "%ld"), x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
24 bar ((x
? "%ld" : "%lld"), x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
25 /* { dg-warning "format '%lld' expects argument of type 'long long int', but argument 2 has type 'int'" "" { target *-*-* } .-1 } */
26 bar ((foo ("%ld")), x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
27 bar ((x
? foo ("%ld") : "%ld"), x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
28 bar ((x
? foo ("%ld") : "%lld"), x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
29 /* { dg-warning "format '%lld' expects argument of type 'long long int', but argument 2 has type 'int'" "" { target *-*-* } .-1 } */
30 bar ((foo (x
? "%ld" : "%ld")), x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
31 bar ((foo (x
? "%ld" : "%lld")), x
); /* { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" } */
32 /* { dg-warning "format '%lld' expects argument of type 'long long int', but argument 2 has type 'int'" "" { target *-*-* } .-1 } */