OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [format/] [bitfld-1.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* 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 } */
6
 
7
#include "format.h"
8
 
9
struct s {
10
  unsigned int u1 : 1;
11
  signed int s1 : 1;
12
  unsigned int u15 : 15;
13
  signed int s15 : 15;
14
  unsigned int u16 : 16;
15
  signed int s16 : 16;
16
  unsigned long u31 : 31;
17
  signed long s31 : 31;
18
  unsigned long u32 : 32;
19
  signed long s32 : 32;
20
  unsigned long long u48 : 48;
21
} x;
22
 
23
void
24
foo (void)
25
{
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);
37
#endif
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
42
     long.  */
43
  printf ("%d%u", x.u32, x.u32);
44
  printf ("%d%u", x.s32, x.s32);
45
#else
46
  printf ("%ld%lu", x.u32, x.u32);
47
  printf ("%ld%lu", x.s32, x.s32);
48
#endif
49
  printf ("%llu", x.u48); /* { dg-warning "has type '.*unsigned int:48'" } */
50
  printf ("%llu", (unsigned long long)x.u48);
51
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.