OSDN Git Service

* gcc.dg/compare2.c (case 10): XFAIL.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / c99-printf-2.c
1 /* Test for printf formats.  Formats using extensions to the standard
2    should be rejected in strict pedantic mode.
3 */
4 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
5 /* { dg-do compile } */
6 /* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
7
8 typedef __SIZE_TYPE__ size_t;
9 typedef __WCHAR_TYPE__ wchar_t;
10 typedef __WINT_TYPE__ wint_t;
11
12 extern int printf (const char *, ...);
13
14 void
15 foo (int i, long long ll, size_t z, wint_t lc, wchar_t *ls)
16 {
17   /* The length modifiers q, Z and L as applied to integer formats are
18      extensions.
19   */
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.
25   */
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
30      X/Open extensions.
31   */
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" } */
36 }