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" } */
5 /* { dg-require-effective-target int32plus } */
12 unsigned int u15
: 15;
14 unsigned int u16
: 16;
16 unsigned long u31
: 31;
18 unsigned long u32
: 32;
20 unsigned long long u48
: 48;
26 printf ("%d%u", x
.u1
, x
.u1
);
27 printf ("%d%u", x
.s1
, x
.s1
);
28 printf ("%d%u", x
.u15
, x
.u15
);
29 printf ("%d%u", x
.s15
, x
.s15
);
30 printf ("%d%u", x
.u16
, x
.u16
);
31 printf ("%d%u", x
.s16
, x
.s16
);
32 #if __INT_MAX__ > 32767
33 /* If integers are 16 bits, there doesn't seem to be a way of
34 printing these without getting an error. */
35 printf ("%d%u", x
.u31
, x
.u31
);
36 printf ("%d%u", x
.s31
, x
.s31
);
38 #if __LONG_MAX__ > 2147483647 && __INT_MAX__ >= 2147483647
39 /* If long is wider than 32 bits, the 32-bit bit-fields are int or
40 unsigned int or promote to those types. Otherwise, long is 32
41 bits and the bit-fields are of type plain long or unsigned
43 printf ("%d%u", x
.u32
, x
.u32
);
44 printf ("%d%u", x
.s32
, x
.s32
);
46 printf ("%ld%lu", x
.u32
, x
.u32
);
47 printf ("%ld%lu", x
.s32
, x
.s32
);
49 printf ("%llu", x
.u48
); /* { dg-warning "15:has type '.*unsigned int:48'" } */
50 printf ("%llu", (unsigned long long)x
.u48
);