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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [dfp/] [union-init.c] - Blame information for rev 689

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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