1 /* Test for scanf formats. Formats using C99 features should be rejected
4 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
5 /* { dg-do compile } */
6 /* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
8 typedef __SIZE_TYPE__ size_t;
9 typedef __PTRDIFF_TYPE__ ptrdiff_t;
11 __extension__ typedef long long int llong;
13 /* This next definition is a kludge. When GCC has a <stdint.h> it
16 /* (T *) if E is zero, (void *) otherwise. */
17 #define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E))
19 /* (T *) if E is nonzero, (void *) otherwise. */
20 #define type_if(T, E) type_if_not(T, !(E))
22 /* Combine pointer types, all but one (void *). */
23 #define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0)
24 #define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3))
26 #define maybe_int_ptr type_if(int, sizeof(int) == sizeof(llong))
27 #define maybe_long_ptr type_if(long, sizeof(long) == sizeof(llong) && sizeof(long) > sizeof(int))
28 #define maybe_long_long_ptr type_if(llong, sizeof(llong) > sizeof(long))
30 #define intmax_type_ptr type_comb3(maybe_int_ptr, maybe_long_ptr, maybe_long_long_ptr)
32 typedef __typeof__(*((intmax_type_ptr)0)) intmax_t;
34 extern int scanf (const char *, ...);
37 foo (signed char *hhp, float *fp, llong *llp, intmax_t *jp,
38 size_t *zp, ptrdiff_t *tp)
40 /* Some tests already in c90-scanf-1.c. */
41 /* The widths hh, ll, j, z, t are new. */
42 scanf ("%hhd", hhp); /* { dg-warning "length|C" "%hh in C90" } */
43 scanf ("%lld", llp); /* { dg-warning "length|C" "%ll in C90" } */
44 scanf ("%jd", jp); /* { dg-warning "length|C" "%j in C90" } */
45 scanf ("%zu", zp); /* { dg-warning "length|C" "%z in C90" } */
46 scanf ("%td", tp); /* { dg-warning "length|C" "%t in C90" } */
47 /* The formats F, a, A are new. */
48 scanf ("%F", fp); /* { dg-warning "C" "%F in C90" } */
49 scanf ("%a", fp); /* { dg-warning "C" "%a in C90" } */
50 scanf ("%A", fp); /* { dg-warning "C" "%A in C90" } */