Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gcc4 / gcc / testsuite / gcc.dg / format / bitfld-1.c
blob2cea5d220e5fe3df7e44356a5133d239d8d39e17
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" } */
6 #include "format.h"
8 struct s {
9 unsigned int u1 : 1;
10 signed int s1 : 1;
11 unsigned int u15 : 15;
12 signed int s15 : 15;
13 unsigned int u16 : 16;
14 signed int s16 : 16;
15 unsigned long u31 : 31;
16 signed long s31 : 31;
17 unsigned long u32 : 32;
18 signed long s32 : 32;
19 unsigned long long u48 : 48;
20 } x;
22 void
23 foo (void)
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
37 long. */
38 printf ("%d%u", x.u32, x.u32);
39 printf ("%d%u", x.s32, x.s32);
40 #else
41 printf ("%ld%lu", x.u32, x.u32);
42 printf ("%ld%lu", x.s32, x.s32);
43 #endif
44 printf ("%llu", x.u48); /* { dg-warning "has type '.*unsigned int:48'" } */
45 printf ("%llu", (unsigned long long)x.u48);