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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [dfp/] [convert-int-fold.c] - Blame information for rev 867

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

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-options "-std=gnu99 -O" } */
2
 
3
/* N1150 5.1 Conversion between decimal floating integer.
4
   C99 6.3.1.4(1a) New.
5
   These should all be folded at compile time.  */
6
 
7
extern void link_error (void);
8
 
9
int
10
main ()
11
{
12
  _Decimal32 d32;
13
  _Decimal64 d64;
14
  _Decimal128 d128;
15
  unsigned int ui;
16
  unsigned long ul;
17
  unsigned long long ull;
18
  int si;
19
  long sl;
20
  long long sll;
21
  _Bool b;
22
 
23
  /* C99 Section 6.7.2 Type specifiers.  Type _Bool is
24
     mentioned in this section.  Conversions between
25
     _Bool and DFP types.  */
26
 
27
  /* Decimal float to unsigned integer.  */
28
  d32 = 456.789df;
29
  d64 = 23.456789dd;
30
  d128 = 1234.5678dl;
31
 
32
  ui = d32;
33
  if (ui != 456U)
34
    link_error ();
35
  ul = d32;
36
  if (ul != 456UL)
37
    link_error ();
38
  ull = d32;
39
  if (ull != 456ULL)
40
    link_error ();
41
 
42
  ui = d64;
43
  if (ui != 23U)
44
    link_error ();
45
  ul = d64;
46
  if (ul != 23UL)
47
    link_error ();
48
  ull = d64;
49
  if (ull != 23ULL)
50
    link_error ();
51
 
52
  ui = d128;
53
  if (ui != 1234U)
54
    link_error ();
55
  ul = d128;
56
  if (ul != 1234UL)
57
    link_error ();
58
  ull = d128;
59
  if (ull != 1234ULL)
60
    link_error ();
61
 
62
  /* Decimal float to signed integer.  */
63
 
64
  /* Decimal float to _Bool.  */
65
  d32 = 1.23df;
66
  d64 = -3.4dd;
67
  d128 = 0.00003dl;
68
 
69
  b = d32;
70
  if (!b)
71
    link_error ();
72
  b = d64;
73
  if (!b)
74
    link_error ();
75
  b = d128;
76
  if (!b)
77
    link_error ();
78
 
79
  /* Unsigned integer to decimal float.  */
80
  ui = 987U;
81
  ul = 345678UL;
82
  ull = 1234567ULL;
83
 
84
  d32 = ui;
85
  if (d32 != 987.0df)
86
    link_error ();
87
  d32 = ul;
88
  if (d32 != 345678.0df)
89
    link_error ();
90
  d32 = ull;
91
  if (d32 != 1234567.df)
92
    link_error ();
93
 
94
  d64 = ui;
95
  if (d64 != 987.0dd)
96
    link_error ();
97
  d64 = ul;
98
  if (d64 != 345678.0dd)
99
    link_error ();
100
  d64 = ull;
101
  if (d64 != 1234567.dd)
102
    link_error ();
103
 
104
  d128 = ui;
105
  if (d128 != 987.0dl)
106
    link_error ();
107
  d128 = ul;
108
  if (d128 != 345678.0dl)
109
    link_error ();
110
  d128 = ull;
111
  if (d128 != 1234567.dl)
112
    link_error ();
113
 
114
  /* Signed integer to decimal float.  */
115
  si = -987;
116
  sl = -345678;
117
  sll = -1234567;
118
 
119
  d32 = si;
120
  if (d32 != -987.0df)
121
    link_error ();
122
  d32 = sl;
123
  if (d32 != -345678.0df)
124
    link_error ();
125
  d32 = sll;
126
  if (d32 != -1234567.df)
127
    link_error ();
128
 
129
  d64 = si;
130
  if (d64 != -987.0dd)
131
    link_error ();
132
  d64 = sl;
133
  if (d64 != -345678.0dd)
134
    link_error ();
135
  d64 = sll;
136
  if (d64 != -1234567.dd)
137
    link_error ();
138
 
139
  d128 = si;
140
  if (d128 != -987.0dl)
141
    link_error ();
142
  d128 = sl;
143
  if (d128 != -345678.0dl)
144
    link_error ();
145
  d128 = sll;
146
  if (d128 != -1234567.dl)
147
    link_error ();
148
 
149
  /* _Bool to decimal float.  */
150
  d32 = 0.0DF;
151
  d64 = 0.0DD;
152
  d128 = 0.0DL;
153
 
154
  b = d32;
155
  if (b)
156
    link_error ();
157
  b = d64;
158
  if (b)
159
    link_error ();
160
  b = d128;
161
  if (b)
162
    link_error ();
163
 
164
  return 0;
165
}

powered by: WebSVN 2.1.0

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