1 /* Test for printf formats and bit-fields: bug 22421. */
2 /* Origin: Joseph Myers <joseph@codesourcery.com> */
3 /* { dg-do compile { target { *-*-mingw* } } } */
4 /* { dg-options "-std=gnu99 -Wformat" } */
5 /* { dg-require-effective-target int32plus } */
7 #define USE_SYSTEM_FORMATS
13 unsigned int u15
: 15;
15 unsigned int u16
: 16;
17 unsigned long u31
: 31;
19 unsigned long u32
: 32;
21 unsigned long long u48
: 48;
27 printf ("%d%u", x
.u1
, x
.u1
);
28 printf ("%d%u", x
.s1
, x
.s1
);
29 printf ("%d%u", x
.u15
, x
.u15
);
30 printf ("%d%u", x
.s15
, x
.s15
);
31 printf ("%d%u", x
.u16
, x
.u16
);
32 printf ("%d%u", x
.s16
, x
.s16
);
33 #if __INT_MAX__ > 32767
34 /* If integers are 16 bits, there doesn't seem to be a way of
35 printing these without getting an error. */
36 printf ("%d%u", x
.u31
, x
.u31
);
37 printf ("%d%u", x
.s31
, x
.s31
);
39 #if __LONG_MAX__ > 2147483647 && __INT_MAX__ >= 2147483647
40 /* If long is wider than 32 bits, the 32-bit bit-fields are int or
41 unsigned int or promote to those types. Otherwise, long is 32
42 bits and the bit-fields are of type plain long or unsigned
44 printf ("%d%u", x
.u32
, x
.u32
);
45 printf ("%d%u", x
.s32
, x
.s32
);
47 printf ("%ld%lu", x
.u32
, x
.u32
);
48 printf ("%ld%lu", x
.s32
, x
.s32
);
50 printf ("%I64u", x
.u48
); /* { dg-warning "has type '.*unsigned int:48'" } */
51 printf ("%I64u", (unsigned long long)x
.u48
);