Emit vmov.i64 to load 0.0 into FP reg when neon enabled.
[official-gcc.git] / libstdc++-v3 / testsuite / decimal / incdec.cc
blob9196aa771b6b2ed2515a527fb49005f1d8b0e4f8
1 // Copyright (C) 2009-2016 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-require-effective-target dfp }
20 // ISO/IEC TR 24733 3.2.2.5 Increment and decrement operators (decimal32).
21 // ISO/IEC TR 24733 3.2.3.5 Increment and decrement operators (decimal64).
22 // ISO/IEC TR 24733 3.2.4.5 Increment and decrement operators (decimal128).
24 #include <decimal/decimal>
25 #include <testsuite_hooks.h>
27 // Use extension to replace implicit long long conversion with function call.
28 #define LONGLONG(X) decimal_to_long_long(X)
30 using namespace std::decimal;
32 void
33 incdec32 (void)
35 bool test __attribute__((unused)) = true;
36 int ival;
37 decimal32 a(11), b, c;
39 // Verify that we get the expected value of b after assignment.
40 b = a;
41 ival = LONGLONG (b); VERIFY (ival == 11);
43 // Check that the increment and decrement operators change the value
44 // of the original class.
45 b = a;
46 ++b;
47 ival = LONGLONG (b); VERIFY (ival == 12);
49 b = a;
50 b++;
51 ival = LONGLONG (b); VERIFY (ival == 12);
53 b = a;
54 --b;
55 ival = LONGLONG (b); VERIFY (ival == 10);
57 b = a;
58 b--;
59 ival = LONGLONG (b); VERIFY (ival == 10);
61 // Check that the increment and decrement operators return the
62 // correct value.
63 b = a;
64 c = ++b;
65 ival = LONGLONG (c); VERIFY (ival == 12);
67 b = a;
68 c = b++;
69 ival = LONGLONG (c); VERIFY (ival == 11);
71 b = a;
72 c = --b;
73 ival = LONGLONG (c); VERIFY (ival == 10);
75 b = a;
76 c = b--;
77 ival = LONGLONG (c); VERIFY (ival == 11);
80 void
81 incdec64 (void)
83 bool test __attribute__((unused)) = true;
84 int ival;
85 decimal64 a(11), b, c;
87 // Verify that we get the expected value of b after assignment.
88 b = a;
89 ival = LONGLONG (b); VERIFY (ival == 11);
91 // Check that the increment and decrement operators change the value
92 // of the original class.
93 b = a;
94 ++b;
95 ival = LONGLONG (b); VERIFY (ival == 12);
97 b = a;
98 b++;
99 ival = LONGLONG (b); VERIFY (ival == 12);
101 b = a;
102 --b;
103 ival = LONGLONG (b); VERIFY (ival == 10);
105 b = a;
106 b--;
107 ival = LONGLONG (b); VERIFY (ival == 10);
109 // Check that the increment and decrement operators return the
110 // correct value.
111 b = a;
112 c = ++b;
113 ival = LONGLONG (c); VERIFY (ival == 12);
115 b = a;
116 c = b++;
117 ival = LONGLONG (c); VERIFY (ival == 11);
119 b = a;
120 c = --b;
121 ival = LONGLONG (c); VERIFY (ival == 10);
123 b = a;
124 c = b--;
125 ival = LONGLONG (c); VERIFY (ival == 11);
128 void
129 incdec128 (void)
131 bool test __attribute__((unused)) = true;
132 int ival;
133 decimal128 a(11), b, c;
135 // Verify that we get the expected value of b after assignment.
136 b = a;
137 ival = LONGLONG (b); VERIFY (ival == 11);
139 // Check that the increment and decrement operators change the value
140 // of the original class.
141 b = a;
142 ++b;
143 ival = LONGLONG (b); VERIFY (ival == 12);
145 b = a;
146 b++;
147 ival = LONGLONG (b); VERIFY (ival == 12);
149 b = a;
150 --b;
151 ival = LONGLONG (b); VERIFY (ival == 10);
153 b = a;
154 b--;
155 ival = LONGLONG (b); VERIFY (ival == 10);
157 // Check that the increment and decrement operators return the
158 // correct value.
159 b = a;
160 c = ++b;
161 ival = LONGLONG (c); VERIFY (ival == 12);
163 b = a;
164 c = b++;
165 ival = LONGLONG (c); VERIFY (ival == 11);
167 b = a;
168 c = --b;
169 ival = LONGLONG (c); VERIFY (ival == 10);
171 b = a;
172 c = b--;
173 ival = LONGLONG (c); VERIFY (ival == 11);
177 main ()
179 incdec32 ();
180 incdec64 ();
181 incdec128 ();