1 |
149 |
jeremybenn |
/* 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 |
|
|
#include "format.h"
|
9 |
|
|
|
10 |
|
|
void
|
11 |
|
|
foo (quad_t *qp, u_quad_t *uqp, quad_t *qn, long long int *llp,
|
12 |
|
|
unsigned long long int *ullp, float *fp, char *s, void **pp, wchar_t *ls,
|
13 |
|
|
int *ip, unsigned int *up)
|
14 |
|
|
{
|
15 |
|
|
/* As an extension, GCC allows the BSD length "q" for integer formats.
|
16 |
|
|
This is largely obsoleted in C99 by %j, %ll and SCNd64.
|
17 |
|
|
*/
|
18 |
|
|
scanf ("%qd%qi%qo%qu%qx%qX%qn", qp, qp, uqp, uqp, uqp, uqp, qn);
|
19 |
|
|
scanf ("%qf", fp); /* { dg-warning "length" "bad use of %q" } */
|
20 |
|
|
scanf ("%qF", fp); /* { dg-warning "length" "bad use of %q" } */
|
21 |
|
|
scanf ("%qe", fp); /* { dg-warning "length" "bad use of %q" } */
|
22 |
|
|
scanf ("%qE", fp); /* { dg-warning "length" "bad use of %q" } */
|
23 |
|
|
scanf ("%qg", fp); /* { dg-warning "length" "bad use of %q" } */
|
24 |
|
|
scanf ("%qG", fp); /* { dg-warning "length" "bad use of %q" } */
|
25 |
|
|
scanf ("%qa", fp); /* { dg-warning "length" "bad use of %q" } */
|
26 |
|
|
scanf ("%qA", fp); /* { dg-warning "length" "bad use of %q" } */
|
27 |
|
|
scanf ("%qs", s); /* { dg-warning "length" "bad use of %q" } */
|
28 |
|
|
scanf ("%q[abc]", s); /* { dg-warning "length" "bad use of %q" } */
|
29 |
|
|
scanf ("%qc", s); /* { dg-warning "length" "bad use of %q" } */
|
30 |
|
|
scanf ("%qp", pp); /* { dg-warning "length" "bad use of %q" } */
|
31 |
|
|
scanf ("%qC", ls); /* { dg-warning "length" "bad use of %q" } */
|
32 |
|
|
scanf ("%qS", ls); /* { dg-warning "length" "bad use of %q" } */
|
33 |
|
|
/* As an extension, GCC allows the length "L" on integer formats
|
34 |
|
|
(but not %n) as a synonym for "ll".
|
35 |
|
|
This should be considered deprecated.
|
36 |
|
|
*/
|
37 |
|
|
scanf ("%Ld%Li%Lo%Lu%Lx%LX", llp, llp, ullp, ullp, ullp, ullp);
|
38 |
|
|
/* glibc also supports flags ' and I on scanf formats. The ' flag applies
|
39 |
|
|
to all formats scanning decimal values; the I flag only to decimal integer
|
40 |
|
|
formats.
|
41 |
|
|
*/
|
42 |
|
|
scanf ("%'d%'i%'u%'a%'A%'e%'E%'f%'F%'g%'G", ip, ip, up, fp, fp, fp, fp,
|
43 |
|
|
fp, fp, fp, fp);
|
44 |
|
|
scanf ("%'o", up); /* { dg-warning "flag" "bad use of ' flag" } */
|
45 |
|
|
scanf ("%'x", up); /* { dg-warning "flag" "bad use of ' flag" } */
|
46 |
|
|
scanf ("%'X", up); /* { dg-warning "flag" "bad use of ' flag" } */
|
47 |
|
|
scanf ("%'n", ip); /* { dg-warning "flag" "bad use of ' flag" } */
|
48 |
|
|
scanf ("%'s", s); /* { dg-warning "flag" "bad use of ' flag" } */
|
49 |
|
|
scanf ("%'[abc]", s); /* { dg-warning "flag" "bad use of ' flag" } */
|
50 |
|
|
scanf ("%'c", s); /* { dg-warning "flag" "bad use of ' flag" } */
|
51 |
|
|
scanf ("%'p", pp); /* { dg-warning "flag" "bad use of ' flag" } */
|
52 |
|
|
scanf ("%'C", ls); /* { dg-warning "flag" "bad use of ' flag" } */
|
53 |
|
|
scanf ("%'S", ls); /* { dg-warning "flag" "bad use of ' flag" } */
|
54 |
|
|
scanf ("%Id%Ii%Iu", ip, ip, up);
|
55 |
|
|
scanf ("%Ia", fp); /* { dg-warning "flag" "bad use of I flag" } */
|
56 |
|
|
scanf ("%IA", fp); /* { dg-warning "flag" "bad use of I flag" } */
|
57 |
|
|
scanf ("%Ie", fp); /* { dg-warning "flag" "bad use of I flag" } */
|
58 |
|
|
scanf ("%IE", fp); /* { dg-warning "flag" "bad use of I flag" } */
|
59 |
|
|
scanf ("%If", fp); /* { dg-warning "flag" "bad use of I flag" } */
|
60 |
|
|
scanf ("%IF", fp); /* { dg-warning "flag" "bad use of I flag" } */
|
61 |
|
|
scanf ("%Ig", fp); /* { dg-warning "flag" "bad use of I flag" } */
|
62 |
|
|
scanf ("%IG", fp); /* { dg-warning "flag" "bad use of I flag" } */
|
63 |
|
|
scanf ("%Io", up); /* { dg-warning "flag" "bad use of I flag" } */
|
64 |
|
|
scanf ("%Ix", up); /* { dg-warning "flag" "bad use of I flag" } */
|
65 |
|
|
scanf ("%IX", up); /* { dg-warning "flag" "bad use of I flag" } */
|
66 |
|
|
scanf ("%In", ip); /* { dg-warning "flag" "bad use of I flag" } */
|
67 |
|
|
scanf ("%Is", s); /* { dg-warning "flag" "bad use of I flag" } */
|
68 |
|
|
scanf ("%I[abc]", s); /* { dg-warning "flag" "bad use of I flag" } */
|
69 |
|
|
scanf ("%Ic", s); /* { dg-warning "flag" "bad use of I flag" } */
|
70 |
|
|
scanf ("%Ip", pp); /* { dg-warning "flag" "bad use of I flag" } */
|
71 |
|
|
scanf ("%IC", ls); /* { dg-warning "flag" "bad use of I flag" } */
|
72 |
|
|
scanf ("%IS", ls); /* { dg-warning "flag" "bad use of I flag" } */
|
73 |
|
|
}
|