]>
Commit | Line | Data |
---|---|---|
4894ecce JM |
1 | /* Test for format extensions beyond the C standard and X/Open standard. |
2 | Test for scanf formats. | |
3 | */ | |
4 | /* Origin: Joseph Myers <jsm28@cam.ac.uk> */ | |
5 | /* { dg-do compile } */ | |
6 | /* { dg-options "-std=gnu99 -Wformat" } */ | |
7 | ||
8 | /* %q formats want a "quad"; GCC considers this to be a long long. */ | |
9 | typedef long long int quad_t; | |
10 | typedef unsigned long long int u_quad_t; | |
11 | ||
12 | typedef __WCHAR_TYPE__ wchar_t; | |
13 | ||
14 | extern int scanf (const char *, ...); | |
15 | ||
16 | void | |
17 | foo (quad_t *qp, u_quad_t *uqp, quad_t *qn, long long int *llp, | |
4831bc84 JM |
18 | unsigned long long int *ullp, float *fp, char *s, void **pp, wchar_t *ls, |
19 | int *ip, unsigned int *up) | |
4894ecce JM |
20 | { |
21 | /* As an extension, GCC allows the BSD length "q" for integer formats. | |
22 | This is largely obsoleted in C99 by %j, %ll and SCNd64. | |
23 | */ | |
24 | scanf ("%qd%qi%qo%qu%qx%qX%qn", qp, qp, uqp, uqp, uqp, uqp, qn); | |
f798660e JM |
25 | scanf ("%qf", fp); /* { dg-warning "length" "bad use of %q" } */ |
26 | scanf ("%qF", fp); /* { dg-warning "length" "bad use of %q" } */ | |
27 | scanf ("%qe", fp); /* { dg-warning "length" "bad use of %q" } */ | |
28 | scanf ("%qE", fp); /* { dg-warning "length" "bad use of %q" } */ | |
29 | scanf ("%qg", fp); /* { dg-warning "length" "bad use of %q" } */ | |
30 | scanf ("%qG", fp); /* { dg-warning "length" "bad use of %q" } */ | |
31 | scanf ("%qa", fp); /* { dg-warning "length" "bad use of %q" } */ | |
32 | scanf ("%qA", fp); /* { dg-warning "length" "bad use of %q" } */ | |
33 | scanf ("%qs", s); /* { dg-warning "length" "bad use of %q" } */ | |
34 | scanf ("%q[abc]", s); /* { dg-warning "length" "bad use of %q" } */ | |
35 | scanf ("%qc", s); /* { dg-warning "length" "bad use of %q" } */ | |
36 | scanf ("%qp", pp); /* { dg-warning "length" "bad use of %q" } */ | |
37 | scanf ("%qC", ls); /* { dg-warning "length" "bad use of %q" } */ | |
38 | scanf ("%qS", ls); /* { dg-warning "length" "bad use of %q" } */ | |
4894ecce JM |
39 | /* As an extension, GCC allows the length "L" on integer formats |
40 | (but not %n) as a synonym for "ll". | |
41 | This should be considered deprecated. | |
42 | */ | |
43 | scanf ("%Ld%Li%Lo%Lu%Lx%LX", llp, llp, ullp, ullp, ullp, ullp); | |
4831bc84 JM |
44 | /* glibc also supports flags ' and I on scanf formats. The ' flag applies |
45 | to all formats scanning decimal values; the I flag only to decimal integer | |
46 | formats. | |
47 | */ | |
48 | scanf ("%'d%'i%'u%'a%'A%'e%'E%'f%'F%'g%'G", ip, ip, up, fp, fp, fp, fp, | |
49 | fp, fp, fp, fp); | |
50 | scanf ("%'o", up); /* { dg-warning "flag" "bad use of ' flag" } */ | |
51 | scanf ("%'x", up); /* { dg-warning "flag" "bad use of ' flag" } */ | |
52 | scanf ("%'X", up); /* { dg-warning "flag" "bad use of ' flag" } */ | |
53 | scanf ("%'n", ip); /* { dg-warning "flag" "bad use of ' flag" } */ | |
54 | scanf ("%'s", s); /* { dg-warning "flag" "bad use of ' flag" } */ | |
55 | scanf ("%'[abc]", s); /* { dg-warning "flag" "bad use of ' flag" } */ | |
56 | scanf ("%'c", s); /* { dg-warning "flag" "bad use of ' flag" } */ | |
57 | scanf ("%'p", pp); /* { dg-warning "flag" "bad use of ' flag" } */ | |
58 | scanf ("%'C", ls); /* { dg-warning "flag" "bad use of ' flag" } */ | |
59 | scanf ("%'S", ls); /* { dg-warning "flag" "bad use of ' flag" } */ | |
60 | scanf ("%Id%Ii%Iu", ip, ip, up); | |
61 | scanf ("%Ia", fp); /* { dg-warning "flag" "bad use of I flag" } */ | |
62 | scanf ("%IA", fp); /* { dg-warning "flag" "bad use of I flag" } */ | |
63 | scanf ("%Ie", fp); /* { dg-warning "flag" "bad use of I flag" } */ | |
64 | scanf ("%IE", fp); /* { dg-warning "flag" "bad use of I flag" } */ | |
65 | scanf ("%If", fp); /* { dg-warning "flag" "bad use of I flag" } */ | |
66 | scanf ("%IF", fp); /* { dg-warning "flag" "bad use of I flag" } */ | |
67 | scanf ("%Ig", fp); /* { dg-warning "flag" "bad use of I flag" } */ | |
68 | scanf ("%IG", fp); /* { dg-warning "flag" "bad use of I flag" } */ | |
69 | scanf ("%Io", up); /* { dg-warning "flag" "bad use of I flag" } */ | |
70 | scanf ("%Ix", up); /* { dg-warning "flag" "bad use of I flag" } */ | |
71 | scanf ("%IX", up); /* { dg-warning "flag" "bad use of I flag" } */ | |
72 | scanf ("%In", ip); /* { dg-warning "flag" "bad use of I flag" } */ | |
73 | scanf ("%Is", s); /* { dg-warning "flag" "bad use of I flag" } */ | |
74 | scanf ("%I[abc]", s); /* { dg-warning "flag" "bad use of I flag" } */ | |
75 | scanf ("%Ic", s); /* { dg-warning "flag" "bad use of I flag" } */ | |
76 | scanf ("%Ip", pp); /* { dg-warning "flag" "bad use of I flag" } */ | |
77 | scanf ("%IC", ls); /* { dg-warning "flag" "bad use of I flag" } */ | |
78 | scanf ("%IS", ls); /* { dg-warning "flag" "bad use of I flag" } */ | |
4894ecce | 79 | } |