1 /* Test for printf formats. Formats using extensions to the standard
2 should be rejected in strict pedantic mode.
4 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
5 /* { dg-do compile } */
6 /* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
8 typedef __SIZE_TYPE__ size_t;
9 typedef __WCHAR_TYPE__ wchar_t;
10 typedef __WINT_TYPE__ wint_t;
12 extern int printf (const char *, ...);
15 foo (int i, long long ll, size_t z, wint_t lc, wchar_t *ls)
17 /* The length modifiers q, Z and L as applied to integer formats are
20 printf ("%qd", ll); /* { dg-warning "C" "%q length" } */
21 printf ("%Ld", ll); /* { dg-warning "C" "%L length" } */
22 printf ("%Zd", z); /* { dg-warning "C" "%Z length" } */
23 /* The conversion specifiers C and S are X/Open extensions; the
24 conversion specifier m is a GNU extension.
26 printf ("%m"); /* { dg-warning "C" "printf %m" } */
27 printf ("%C", lc); /* { dg-warning "C" "printf %C" } */
28 printf ("%S", ls); /* { dg-warning "C" "printf %S" } */
29 /* The flag character ', and the use of operand number $ formats, are
32 printf ("%'d", i); /* { dg-warning "C" "printf ' flag" } */
33 printf ("%1$d", i); /* { dg-warning "C" "printf $ format" } */
34 /* The flag character I is a GNU extension. */
35 printf ("%Id", i); /* { dg-warning "C" "printf I flag" } */