OSDN Git Service

* gcc.dg/testsuite/c++98.c,c++98-pedantic.c,c89.c,c89-pedantic.c,
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / c99-scanf-2.c
1 /* Test for scanf 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 __WCHAR_TYPE__ wchar_t;
9
10 extern int scanf (const char *, ...);
11
12 void
13 foo (int *ip, long long int *llp, wchar_t *ls)
14 {
15   /* The length modifiers q and L as applied to integer formats are
16      extensions.
17   */
18   scanf ("%qd", llp); /* { dg-warning "C" "%q length" } */
19   scanf ("%Ld", llp); /* { dg-warning "C" "%L length" } */
20   /* The conversion specifiers C and S are X/Open extensions.  */
21   scanf ("%C", ls); /* { dg-warning "C" "scanf %C" } */
22   scanf ("%S", ls); /* { dg-warning "C" "scanf %S" } */
23   /* The use of operand number $ formats is an X/Open extension.  */
24   scanf ("%1$d", ip); /* { dg-warning "C" "scanf $ format" } */
25   /* glibc also supports flags ' and I on scanf formats as an extension.  */
26   scanf ("%'d", ip); /* { dg-warning "C" "scanf ' flag" } */
27   scanf ("%Id", ip); /* { dg-warning "C" "scanf I flag" } */
28 }