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.c] - Blame information for rev 853

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

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

powered by: WebSVN 2.1.0

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