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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [fixed-point/] [union-init.c] - Blame information for rev 315

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

Line No. Rev Author Line
1 298 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-std=gnu99" } */
3
 
4
/* Cast to union is a GNU C extension.
5
   Based on the test from ../dfp/.  */
6
 
7
extern void abort (void);
8
 
9
union u
10
{
11
  long _Fract lf;
12
  double d;
13
};
14
 
15
union n
16
{
17
  double d;
18
  _Fract f;
19
};
20
 
21
int main ()
22
{
23
  static union u u1 = { 0.1lr };
24
  static union u u2 = { 0.2lr };
25
  static union u u4 = { 0.0 };
26
 
27
  static union n n1 = { 0.3r };
28
  static union n n2 = { 3.25 };
29
 
30
  long _Fract lf;
31
  _Fract f;
32
  double d;
33
 
34
  if (u1.lf != 0.1lr)
35
    abort ();
36
 
37
  if (u2.lf != 0.2lr)
38
    abort ();
39
 
40
  /* cast fixed-point to union type.  */
41
  lf = 0.4lr;
42
  f = 0.5r;
43
  d = 3.25;
44
 
45
  u4 = (union u) lf;
46
  if (u4.lf != 0.4lr)
47
    abort ();
48
 
49
  u4 = (union u) d;
50
  if (u4.d != 3.25)
51
    abort ();
52
 
53
  n1 = (union n) f;
54
  if (n1.f != 0.5r)
55
    abort ();
56
 
57
  n1 = (union n)d;
58
  if (n1.d != 3.25)
59
    abort ();
60
 
61
  return 0;
62
}

powered by: WebSVN 2.1.0

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