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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [format/] [ms_bitfld-1.c] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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