annotate gcc/testsuite/ada/acats/tests/c4/c490003.a @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- C490003.A
kono
parents:
diff changeset
2 --
kono
parents:
diff changeset
3 -- Grant of Unlimited Rights
kono
parents:
diff changeset
4 --
kono
parents:
diff changeset
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
7 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
9 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
10 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
11 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
12 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
13 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
14 -- to do so.
kono
parents:
diff changeset
15 --
kono
parents:
diff changeset
16 -- DISCLAIMER
kono
parents:
diff changeset
17 --
kono
parents:
diff changeset
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
24 --*
kono
parents:
diff changeset
25 --
kono
parents:
diff changeset
26 -- OBJECTIVE:
kono
parents:
diff changeset
27 -- Check that a static expression is legal if its evaluation fails
kono
parents:
diff changeset
28 -- no language-defined check other than Overflow_Check. Check that such
kono
parents:
diff changeset
29 -- a static expression is legal if it is part of a larger static
kono
parents:
diff changeset
30 -- expression, even if its value is outside the base range of the
kono
parents:
diff changeset
31 -- expected type.
kono
parents:
diff changeset
32 --
kono
parents:
diff changeset
33 -- Check that if a static expression is part of the right operand of a
kono
parents:
diff changeset
34 -- short circuit control form whose value is determined by its left
kono
parents:
diff changeset
35 -- operand, it is not evaluated.
kono
parents:
diff changeset
36 --
kono
parents:
diff changeset
37 -- Check that a static expression in a non-static context is evaluated
kono
parents:
diff changeset
38 -- exactly.
kono
parents:
diff changeset
39 --
kono
parents:
diff changeset
40 -- TEST DESCRIPTION:
kono
parents:
diff changeset
41 -- The first part of the objective is tested by constructing static
kono
parents:
diff changeset
42 -- expressions which involve predefined operations of integer, floating
kono
parents:
diff changeset
43 -- point, and fixed point subtypes. Intermediate expressions within the
kono
parents:
diff changeset
44 -- static expressions have values outside the base range of the expected
kono
parents:
diff changeset
45 -- type. In one case, the extended-range intermediates are compared as
kono
parents:
diff changeset
46 -- part of a boolean expression. In the remaining two cases, further
kono
parents:
diff changeset
47 -- predefined operations on the intermediates bring the final result
kono
parents:
diff changeset
48 -- within the base range. An implementation which compiles these static
kono
parents:
diff changeset
49 -- expressions satisfies this portion of the objective. A check is
kono
parents:
diff changeset
50 -- performed at run-time to ensure that the static expressions evaluate
kono
parents:
diff changeset
51 -- to values within the base range of their respective expected types.
kono
parents:
diff changeset
52 --
kono
parents:
diff changeset
53 -- The second part of the objective is tested by constructing
kono
parents:
diff changeset
54 -- short-circuit control forms whose left operands have the values
kono
parents:
diff changeset
55 -- shown below:
kono
parents:
diff changeset
56 --
kono
parents:
diff changeset
57 -- (TRUE) or else (...)
kono
parents:
diff changeset
58 -- (FALSE) and then (...)
kono
parents:
diff changeset
59 --
kono
parents:
diff changeset
60 -- In both cases the left operand determines the value of the condition.
kono
parents:
diff changeset
61 -- In the test each right operand involves a division by zero, which will
kono
parents:
diff changeset
62 -- raise Constraint_Error if evaluated. A check is made that no exception
kono
parents:
diff changeset
63 -- is raised when each short-circuit control form is evaluated, and that
kono
parents:
diff changeset
64 -- the value of the condition is that of the left operand.
kono
parents:
diff changeset
65 --
kono
parents:
diff changeset
66 -- The third part of the objective is tested by evaluating static
kono
parents:
diff changeset
67 -- expressions involving many operations in contexts which do not
kono
parents:
diff changeset
68 -- require a static expression, and verifying that the exact
kono
parents:
diff changeset
69 -- mathematical results are calculated.
kono
parents:
diff changeset
70 --
kono
parents:
diff changeset
71 --
kono
parents:
diff changeset
72 -- CHANGE HISTORY:
kono
parents:
diff changeset
73 -- 15 Sep 95 SAIC Initial prerelease version for ACVC 2.1.
kono
parents:
diff changeset
74 -- 20 Oct 96 SAIC Modified expressions in C490003_0 to avoid
kono
parents:
diff changeset
75 -- the use of universal operands.
kono
parents:
diff changeset
76 --
kono
parents:
diff changeset
77 --!
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 with System;
kono
parents:
diff changeset
80 package C490003_0 is
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 type My_Flt is digits System.Max_Digits;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 Flt_Range_Diff : My_Flt := (My_Flt'Base'Last - My_Flt'Base'First) -
kono
parents:
diff changeset
85 (My_Flt'Last - My_Flt'First); -- OK.
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 type My_Fix is delta 0.125 range -128.0 .. 128.0;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 Symmetric : Boolean := (My_Fix'Base'Last - My_Fix'Base'First) =
kono
parents:
diff changeset
91 (My_Fix'Base'Last + My_Fix'Base'Last); -- OK.
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 Center : constant Integer := Integer'Base'Last -
kono
parents:
diff changeset
95 (Integer'Base'Last -
kono
parents:
diff changeset
96 Integer'Base'First) / 2; -- OK.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 end C490003_0;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 --==================================================================--
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 with Ada.Numerics;
kono
parents:
diff changeset
105 package C490003_1 is
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 Zero : constant := 0.0;
kono
parents:
diff changeset
108 Pi : constant := Ada.Numerics.Pi;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 Two_Pi : constant := 2.0 * Pi;
kono
parents:
diff changeset
111 Half_Pi : constant := Pi/2.0;
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 Quarter : constant := 90.0;
kono
parents:
diff changeset
114 Half : constant := 180.0;
kono
parents:
diff changeset
115 Full : constant := 360.0;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 Deg_To_Rad : constant := Half_Pi/90;
kono
parents:
diff changeset
118 Rad_To_Deg : constant := 1.0/Deg_To_Rad;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 end C490003_1;
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 --==================================================================--
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 with C490003_0;
kono
parents:
diff changeset
127 with C490003_1;
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 with Report;
kono
parents:
diff changeset
130 procedure C490003 is
kono
parents:
diff changeset
131 begin
kono
parents:
diff changeset
132 Report.Test ("C490003", "Check that static expressions failing " &
kono
parents:
diff changeset
133 "Overflow_Check are legal if part of a larger static " &
kono
parents:
diff changeset
134 "expression. Check that static expressions as right " &
kono
parents:
diff changeset
135 "operands of short-circuit control forms are not " &
kono
parents:
diff changeset
136 "evaluated if value of control form is determined by " &
kono
parents:
diff changeset
137 "left operand. Check that static expressions in non-static " &
kono
parents:
diff changeset
138 "contexts are evaluated exactly");
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 --
kono
parents:
diff changeset
142 -- Static expressions within larger static expressions:
kono
parents:
diff changeset
143 --
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 if C490003_0.Flt_Range_Diff not in C490003_0.My_Flt'Base'Range then
kono
parents:
diff changeset
147 Report.Failed ("Error evaluating static expression: floating point");
kono
parents:
diff changeset
148 end if;
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 if C490003_0.Symmetric not in Boolean'Range then
kono
parents:
diff changeset
151 Report.Failed ("Error evaluating static expression: fixed point");
kono
parents:
diff changeset
152 end if;
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 if C490003_0.Center not in Integer'Base'Range then
kono
parents:
diff changeset
155 Report.Failed ("Error evaluating static expression: integer");
kono
parents:
diff changeset
156 end if;
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 --
kono
parents:
diff changeset
160 -- Short-circuit control forms:
kono
parents:
diff changeset
161 --
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 declare
kono
parents:
diff changeset
164 N : constant := 0.0;
kono
parents:
diff changeset
165 begin
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 begin
kono
parents:
diff changeset
168 if not ( (N = 0.0) or else (1.0/N > 0.5) ) then
kono
parents:
diff changeset
169 Report.Failed ("Error evaluating OR ELSE");
kono
parents:
diff changeset
170 end if;
kono
parents:
diff changeset
171 exception
kono
parents:
diff changeset
172 when Constraint_Error =>
kono
parents:
diff changeset
173 Report.Failed ("Right side of OR ELSE was evaluated");
kono
parents:
diff changeset
174 when others =>
kono
parents:
diff changeset
175 Report.Failed ("OR ELSE: unexpected exception raised");
kono
parents:
diff changeset
176 end;
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 begin
kono
parents:
diff changeset
179 if (N /= 0.0) and then (1.0/N <= 0.5) then
kono
parents:
diff changeset
180 Report.Failed ("Error evaluating AND THEN");
kono
parents:
diff changeset
181 end if;
kono
parents:
diff changeset
182 exception
kono
parents:
diff changeset
183 when Constraint_Error =>
kono
parents:
diff changeset
184 Report.Failed ("Right side of AND THEN was evaluated");
kono
parents:
diff changeset
185 when others =>
kono
parents:
diff changeset
186 Report.Failed ("AND THEN: unexpected exception raised");
kono
parents:
diff changeset
187 end;
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 end;
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 --
kono
parents:
diff changeset
193 -- Exact evaluation of static expressions:
kono
parents:
diff changeset
194 --
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 declare
kono
parents:
diff changeset
198 use C490003_1;
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 Left : constant := 6.0 + 0.3125*( (Full*0.375) + (Half/2.4) -
kono
parents:
diff changeset
201 ((Quarter + 36.0)/3.0) )/10.0; -- 11.25
kono
parents:
diff changeset
202 Right : constant := (Pi/3.0) * 1.2 * (15.0/96.0); -- Pi/16
kono
parents:
diff changeset
203 begin
kono
parents:
diff changeset
204 if Deg_To_Rad*Left /= Right then
kono
parents:
diff changeset
205 Report.Failed ("Static expressions not evaluated exactly: #1");
kono
parents:
diff changeset
206 end if;
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 if ((Pi*Rad_To_Deg)*2.0 + 4.0*Quarter)/16.0 /= Rad_To_Deg*(Pi/4.0) then
kono
parents:
diff changeset
209 Report.Failed ("Static expressions not evaluated exactly: #2");
kono
parents:
diff changeset
210 end if;
kono
parents:
diff changeset
211 end;
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 Report.Result;
kono
parents:
diff changeset
215 end C490003;