annotate gcc/testsuite/ada/acats/tests/c3/c332001.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 -- C332001.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 the static expression given for a number declaration may be
kono
parents:
diff changeset
28 -- of any numeric type. Check that the type of a named number is
kono
parents:
diff changeset
29 -- universal_integer or universal_real regardless of the type of the
kono
parents:
diff changeset
30 -- static expression that provides its value.
kono
parents:
diff changeset
31 --
kono
parents:
diff changeset
32 -- TEST DESCRIPTION:
kono
parents:
diff changeset
33 -- This test defines a large cross section of mixed type named numbers.
kono
parents:
diff changeset
34 -- Well, obviously the named numbers don't have types (other than
kono
parents:
diff changeset
35 -- universal_integer and universal_real) associated with them.
kono
parents:
diff changeset
36 -- This test uses typed static values in the definition of several named
kono
parents:
diff changeset
37 -- numbers, and then mixes the named numbers to ensure that their typed
kono
parents:
diff changeset
38 -- origins do not interfere with the use of their values.
kono
parents:
diff changeset
39 --
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 -- CHANGE HISTORY:
kono
parents:
diff changeset
42 -- 10 OCT 95 SAIC Initial version
kono
parents:
diff changeset
43 -- 11 APR 96 SAIC Fixed a few arithmetic errors for 2.1
kono
parents:
diff changeset
44 -- 24 NOV 98 RLB Removed decimal types to insure that this
kono
parents:
diff changeset
45 -- test is applicable to all implementations.
kono
parents:
diff changeset
46 --
kono
parents:
diff changeset
47 --!
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 ----------------------------------------------------------------- C332001_0
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 package C332001_0 is
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 type Enumeration_Type is ( Ah, Gnome, Er, Ay, Shun );
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 type Integer_Type is range 0..1023;
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 type Modular_Type is mod 256;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 type Floating_Type is digits 4;
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 type Fixed_Type is delta 0.125 range -10.0 .. 10.0;
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 type Mod_Array is array(Modular_Type) of Floating_Type;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 type Int_Array is array(Integer_Type) of Fixed_Type;
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 type Record_Type is record
kono
parents:
diff changeset
68 Pinkie : Integer_Type;
kono
parents:
diff changeset
69 Ring : Modular_Type;
kono
parents:
diff changeset
70 Middle : Floating_Type;
kono
parents:
diff changeset
71 Index : Fixed_Type;
kono
parents:
diff changeset
72 end record;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 Mod_Array_Object : Mod_Array;
kono
parents:
diff changeset
75 Int_Array_Object : Int_Array;
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 Record_Object : Record_Type;
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 -- numeric_literals
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 Nothing_New_Integer : constant := 1;
kono
parents:
diff changeset
82 Nothing_New_Real : constant := 1.0;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 -- static constants
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 Integ : constant Integer_Type := 2;
kono
parents:
diff changeset
87 Modul : constant Modular_Type := 2;
kono
parents:
diff changeset
88 Float : constant Floating_Type := 2.0; -- bad practice, good test
kono
parents:
diff changeset
89 Fixed : constant Fixed_Type := 2.0;
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 Named_Integer : constant := Integ; -- 2
kono
parents:
diff changeset
92 Named_Modular : constant := Modul; -- 2
kono
parents:
diff changeset
93 Named_Float : constant := Float; -- 2.0
kono
parents:
diff changeset
94 Named_Fixed : constant := Fixed; -- 2.0
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 -- function calls
kono
parents:
diff changeset
97 -- parenthetical expressions
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 Fn_Integer : constant := Integer_Type'Min(Integ * 2, 8); -- 4
kono
parents:
diff changeset
100 Fn_Modular : constant := Modular_Type'Max(Modul + 2, Modular_Type'First);--4
kono
parents:
diff changeset
101 Fn_Float : constant := (Float ** 2); -- 4.0
kono
parents:
diff changeset
102 Fn_Fixed : constant := - Fixed; -- -2.0
kono
parents:
diff changeset
103 -- attributes
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 ITF : constant := Integer_Type'First; -- 0
kono
parents:
diff changeset
106 MTL : constant := Modular_Type'Last; -- 255
kono
parents:
diff changeset
107 MTM : constant := Modular_Type'Modulus; -- 256
kono
parents:
diff changeset
108 ENP : constant := Enumeration_Type'Pos(Ay); -- 3
kono
parents:
diff changeset
109 MTP : constant := Modular_Type'Pred(Modul); -- 1
kono
parents:
diff changeset
110 FTS : constant := Fixed_Type'Size; -- # impdef
kono
parents:
diff changeset
111 ITS : constant := Integer_Type'Succ(Integ); -- 3
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 -- array attributes 'First, 'Last, 'Length
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 MAFirst : constant := Mod_Array_Object'First; -- 0
kono
parents:
diff changeset
116 IALast : constant := Int_Array_Object'Last; -- 1023
kono
parents:
diff changeset
117 MAL : constant := Mod_Array_Object'Length; -- 255
kono
parents:
diff changeset
118 IAL : constant := Int_Array_Object'Length; -- 1024
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 -- type conversions
kono
parents:
diff changeset
121 --
kono
parents:
diff changeset
122 -- F\T Int Mod Flt Fix
kono
parents:
diff changeset
123 -- Int . X O X
kono
parents:
diff changeset
124 -- Mod O . X O
kono
parents:
diff changeset
125 -- Flt X O . X
kono
parents:
diff changeset
126 -- Fix O X O .
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 Int2Mod : constant := Modular_Type (Integ); -- 2
kono
parents:
diff changeset
129 Int2Fix : constant := Fixed_Type (Integ); -- 2.0
kono
parents:
diff changeset
130 Mod2Flt : constant := Floating_Type (Modul); -- 2.0
kono
parents:
diff changeset
131 Flt2Int : constant := Integer_Type(Float); -- 2
kono
parents:
diff changeset
132 Flt2Fix : constant := Fixed_Type (Float); -- 2.0
kono
parents:
diff changeset
133 Fix2Mod : constant := Modular_Type (Fixed); -- 2
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 procedure Check_Values;
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 -- TRANSITION CHECKS
kono
parents:
diff changeset
138 --
kono
parents:
diff changeset
139 -- The following were illegal in Ada83; they are now legal in Ada95
kono
parents:
diff changeset
140 --
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 Int_Base_First : constant := Integer'Base'First; -- # impdef
kono
parents:
diff changeset
143 Int_First : constant := Integer'First; -- # impdef
kono
parents:
diff changeset
144 Int_Last : constant := Integer'Last; -- # impdef
kono
parents:
diff changeset
145 Int_Val : constant := Integer'Val(17); -- 17
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 -- END OF TRANSITION CHECKS
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 end C332001_0;
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 with Report;
kono
parents:
diff changeset
154 package body C332001_0 is
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 procedure Assert( Truth : Boolean; Message: String ) is
kono
parents:
diff changeset
157 begin
kono
parents:
diff changeset
158 if not Truth then
kono
parents:
diff changeset
159 Report.Failed("Assertion " & Message & " not true" );
kono
parents:
diff changeset
160 end if;
kono
parents:
diff changeset
161 end Assert;
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 procedure Check_Values is
kono
parents:
diff changeset
164 begin
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 Assert( Nothing_New_Integer * Named_Integer = Named_Modular,
kono
parents:
diff changeset
167 "Nothing_New_Integer * Named_Integer = Named_Modular" ); -- 1*2 = 2
kono
parents:
diff changeset
168 Assert( Nothing_New_Real * Named_Float = Named_Fixed,
kono
parents:
diff changeset
169 "Nothing_New_Real * Named_Float = Named_Fixed" );-- 1.0*2.0 = 2.0
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 Assert( Fn_Integer = Int2Mod + Flt2Int,
kono
parents:
diff changeset
172 "Fn_Integer = Int2Mod + Flt2Int" ); -- 4 = 2+2
kono
parents:
diff changeset
173 Assert( Fn_Modular = Flt2Int * 2,
kono
parents:
diff changeset
174 "Fn_Modular = Flt2Int * 2" ); -- 4 = 2*2
kono
parents:
diff changeset
175 Assert( Fn_Float = Mod2Flt ** Fix2Mod,
kono
parents:
diff changeset
176 "Fn_Float = Mod2Flt ** Fix2Mod" ); -- 4.0 = 2.0**2
kono
parents:
diff changeset
177 Assert( Fn_Fixed = (- Mod2Flt),
kono
parents:
diff changeset
178 "Fn_Fixed = (- Mod2Flt)" ); -- -2.0 = (-2.0)
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 Assert( ITF = Modular_Type'First,
kono
parents:
diff changeset
181 "ITF = Modular_Type'First" ); -- 0 = 0
kono
parents:
diff changeset
182 Assert( MTL < Integer_Type'Last,
kono
parents:
diff changeset
183 "MTL < Integer_Type'Last" ); -- 255 < 1023
kono
parents:
diff changeset
184 Assert( MTM < Integer_Type'Last,
kono
parents:
diff changeset
185 "MTM < Integer_Type'Last" ); -- 256 < 1023
kono
parents:
diff changeset
186 Assert( ENP > MTP,
kono
parents:
diff changeset
187 "ENP > MTP" ); -- 3 > 1
kono
parents:
diff changeset
188 Assert( (FTS < MTL) or (FTS >= MTL), -- given FTS is impdef...
kono
parents:
diff changeset
189 "(FTS < MTL) or (FTS >= MTL)" ); -- True
kono
parents:
diff changeset
190 Assert( FTS > ITS,
kono
parents:
diff changeset
191 "FTS > ITS" ); -- impdef > 3
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 Assert( MAFirst = Int_Array_Object'First,
kono
parents:
diff changeset
194 "MAFirst = Int_Array_Object'First" ); -- 0 = 0
kono
parents:
diff changeset
195 Assert( IALast > MAFirst,
kono
parents:
diff changeset
196 "IALast > MAFirst" ); -- 1023 > 0
kono
parents:
diff changeset
197 Assert( MAL < IAL,
kono
parents:
diff changeset
198 "MAL < IAL" ); -- 255 < 1024
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 Assert( Mod2Flt = Flt2Fix,
kono
parents:
diff changeset
201 "Mod2Flt = Flt2Fix" ); -- 2.0 = 2.0
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 end Check_Values;
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 end C332001_0;
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 ------------------------------------------------------------------- C332001
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 with Report;
kono
parents:
diff changeset
210 with C332001_0;
kono
parents:
diff changeset
211 procedure C332001 is
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 begin -- Main test procedure.
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 Report.Test ("C332001", "Check that the static expression given for a " &
kono
parents:
diff changeset
216 "number declaration may be of any numeric type. " &
kono
parents:
diff changeset
217 "Check that the type of the named number is " &
kono
parents:
diff changeset
218 "universal_integer of universal_real regardless " &
kono
parents:
diff changeset
219 "of the type of the static expression that " &
kono
parents:
diff changeset
220 "provides its value" );
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 C332001_0.Check_Values;
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 Report.Result;
kono
parents:
diff changeset
225
kono
parents:
diff changeset
226 end C332001;