1 /* Test for printf formats and bit-fields: bug 22421. */
2 /* Origin: Joseph Myers <joseph@codesourcery.com> */
3 /* { dg-do compile } */
4 /* { dg-options "-std=gnu99 -Wformat" } */
11 unsigned int u15
: 15;
13 unsigned int u16
: 16;
15 unsigned long u31
: 31;
17 unsigned long u32
: 32;
19 unsigned long long u48
: 48;
25 printf ("%d%u", x
.u1
, x
.u1
);
26 printf ("%d%u", x
.s1
, x
.s1
);
27 printf ("%d%u", x
.u15
, x
.u15
);
28 printf ("%d%u", x
.s15
, x
.s15
);
29 printf ("%d%u", x
.u16
, x
.u16
);
30 printf ("%d%u", x
.s16
, x
.s16
);
31 printf ("%d%u", x
.u31
, x
.u31
);
32 printf ("%d%u", x
.s31
, x
.s31
);
33 #if __LONG_MAX__ > 2147483647 && __INT_MAX__ >= 2147483647
34 /* If long is wider than 32 bits, the 32-bit bit-fields are int or
35 unsigned int or promote to those types. Otherwise, long is 32
36 bits and the bit-fields are of type plain long or unsigned
38 printf ("%d%u", x
.u32
, x
.u32
);
39 printf ("%d%u", x
.s32
, x
.s32
);
41 printf ("%ld%lu", x
.u32
, x
.u32
);
42 printf ("%ld%lu", x
.s32
, x
.s32
);
44 printf ("%llu", x
.u48
); /* { dg-warning "has type '.*unsigned int:48'" } */
45 printf ("%llu", (unsigned long long)x
.u48
);