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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [dfp/] [union-init.c] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-options "-std=gnu99" } */
2
 
3
/* Cast to union is a GNU C extension.  */
4
 
5
extern void abort (void);
6
 
7
union u
8
{
9
  _Decimal128 d128;
10
  double d;
11
};
12
 
13
union n
14
{
15
  double d;
16
  _Decimal64 d64;
17
};
18
 
19
int main ()
20
{
21
  static union u u1 = { 0.0dl };
22
  static union u u2 = { 4.2dl };
23
  static union u u4 = { 0.0 };
24
 
25
  static union n n1 = { 2.2dd };
26
  static union n n2 = { 3.25 };
27
 
28
  _Decimal128 d128;
29
  _Decimal64 d64;
30
  double d;
31
 
32
  if (u1.d128 != 0.0dl)
33
    abort ();
34
 
35
  if (u2.d128 != 4.2dl)
36
    abort ();
37
 
38
  /* cast decimal floating point to union type.  */
39
  d128 = 1.23dl;
40
  d64 = 4.56dd;
41
  d = 3.25;
42
 
43
  u4 = (union u) d128;
44
  if (u4.d128 != 1.23dl)
45
    abort ();
46
 
47
  u4 = (union u) d;
48
  if (u4.d != 3.25)
49
    abort ();
50
 
51
  n1 = (union n) d64;
52
  if (n1.d64 != 4.56dd)
53
    abort ();
54
 
55
  n1 = (union n)d;
56
  if (n1.d != 3.25)
57
    abort ();
58
 
59
  return 0;
60
}

powered by: WebSVN 2.1.0

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