| 1 |
/* Test for printf formats. Formats using extensions to the standard |
| 2 |
should be rejected in strict pedantic mode. |
| 3 |
*/ |
| 4 |
/* Origin: Joseph Myers <[email protected]> */ |
| 5 |
/* { dg-do compile { target { *-*-mingw* } } } */ |
| 6 |
/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */ |
| 7 |
|
| 8 |
#define USE_SYSTEM_FORMATS |
| 9 |
#include "format.h" |
| 10 |
|
| 11 |
void |
| 12 |
foo (int i, long long ll, size_t z, wint_t lc, wchar_t *ls) |
| 13 |
{ |
| 14 |
/* The length modifiers q, Z and L as applied to integer formats are |
| 15 |
extensions. |
| 16 |
*/ |
| 17 |
printf ("%qd", ll); /* { dg-warning "unknown|format" "%q length is unsupported" } */ |
| 18 |
printf ("%Ld", ll); /* { dg-warning "unknown|format" "%L length is unsupported" } */ |
| 19 |
printf ("%Zd", z); /* { dg-warning "unknown|format" "%Z length is unsupported" } */ |
| 20 |
/* The conversion specifiers C and S are X/Open extensions; the |
| 21 |
conversion specifier m is a GNU extension. |
| 22 |
*/ |
| 23 |
printf ("%m"); /* { dg-warning "unknown" "printf %m is unsupported" } */ |
| 24 |
printf ("%C", lc); /* { dg-warning "C" "printf %C" } */ |
| 25 |
printf ("%S", ls); /* { dg-warning "C" "printf %S" } */ |
| 26 |
/* The flag character ', and the use of operand number $ formats, are |
| 27 |
X/Open extensions. |
| 28 |
*/ |
| 29 |
printf ("%'d", i); /* { dg-warning "C" "printf ' flag" } */ |
| 30 |
printf ("%1$d", i); /* { dg-warning "C" "printf $ format" } */ |
| 31 |
printf ("%Ix", z); /* { dg-warning "C" "printf I format" } */ |
| 32 |
} |