3 -- Grant of Unlimited Rights
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
27 -- Check that X'Address produces a useful result when X is an aliased
29 -- Check that X'Address produces a useful result when X is an object of
30 -- a by-reference type.
31 -- Check that X'Address produces a useful result when X is an entity
32 -- whose Address has been specified.
34 -- Check that aliased objects and subcomponents are allocated on storage
35 -- element boundaries. Check that objects and subcomponents of by
36 -- reference types are allocated on storage element boundaries.
38 -- Check that for an array X, X'Address points at the first component
39 -- of the array, and not at the array bounds.
42 -- This test defines a data structure (an array of records) where each
43 -- aspect of the data structure is aliased. The test checks 'Address
44 -- for each "layer" of aliased objects.
46 -- APPLICABILITY CRITERIA:
47 -- All implementations must attempt to compile this test.
49 -- For implementations validating against Systems Programming Annex (C):
50 -- this test must execute and report PASSED.
52 -- For implementations not validating against Annex C:
53 -- this test may report compile time errors at one or more points
54 -- indicated by "-- ANX-C RQMT", in which case it may be graded as inapplicable.
55 -- Otherwise, the test must execute and report PASSED.
59 -- 22 JUL 95 SAIC Initial version
60 -- 08 MAY 96 SAIC Reinforced for 2.1
61 -- 16 FEB 98 EDS Modified documentation
64 ----------------------------------------------------------------- CD30001_0
69 -- Check that X'Address produces a useful result when X is an aliased
71 -- Check that X'Address produces a useful result when X is an object of
72 -- a by-reference type.
73 -- Check that X'Address produces a useful result when X is an entity
74 -- whose Address has been specified.
75 -- (using the new form of "for X'Address use ...")
77 -- Check that aliased objects and subcomponents are allocated on storage
78 -- element boundaries. Check that objects and subcomponents of by
79 -- reference types are allocated on storage element boundaries.
81 type Simple_Enum_Type
is (Just
, A
, Little
, Bit
);
84 Aliased_Comp_1
: aliased Simple_Enum_Type
;
85 Aliased_Comp_2
: aliased Simple_Enum_Type
;
88 type Array_W_Aliased_Comps
is array(1..2) of aliased Data
;
90 Aliased_Object
: aliased Array_W_Aliased_Comps
;
92 Specific_Object
: aliased Array_W_Aliased_Comps
;
93 for Specific_Object
'Address use SPPRT13
.Variable_Address2
; -- ANX-C RQMT.
95 procedure TC_Check_Aliased_Addresses
;
97 procedure TC_Check_Specific_Addresses
;
99 procedure TC_Check_By_Reference_Types
;
103 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
106 with System
.Storage_Elements
;
107 with System
.Address_To_Access_Conversions
;
108 package body CD30001_0
is
110 package Simple_Enum_Type_Ref_Conv
is
111 new System
.Address_To_Access_Conversions
(Simple_Enum_Type
);
113 package Data_Ref_Conv
is new System
.Address_To_Access_Conversions
(Data
);
115 package Array_W_Aliased_Comps_Ref_Conv
is
116 new System
.Address_To_Access_Conversions
(Array_W_Aliased_Comps
);
118 use type System
.Address
;
119 use type System
.Storage_Elements
.Integer_Address
;
120 use type System
.Storage_Elements
.Storage_Offset
;
122 procedure TC_Check_Aliased_Addresses
is
123 use type Simple_Enum_Type_Ref_Conv
.Object_Pointer
;
124 use type Data_Ref_Conv
.Object_Pointer
;
125 use type Array_W_Aliased_Comps_Ref_Conv
.Object_Pointer
;
129 -- Check the object Aliased_Object
131 if Aliased_Object
'Address not in System
.Address
then
132 Report
.Failed
("Aliased_Object'Address not an address");
135 if Array_W_Aliased_Comps_Ref_Conv
.To_Pointer
(Aliased_Object
'Address)
136 /= Aliased_Object
'Unchecked_Access then
138 ("'Unchecked_Access does not match expected address value");
141 -- Check the element Aliased_Object(1)
143 if Data_Ref_Conv
.To_Address
( Aliased_Object
(1)'Access )
144 /= Aliased_Object
(1)'Address then
146 ("Array element 'Access does not match expected address value");
149 -- Check that Array'Address points at the first component...
151 if Array_W_Aliased_Comps_Ref_Conv
.To_Address
( Aliased_Object
'Access )
152 /= Aliased_Object
(1)'Address then
154 ("Address of array object does not equal address of first component");
157 -- Check the components of Aliased_Object(2)
159 if Simple_Enum_Type_Ref_Conv
.To_Address
(
160 Aliased_Object
(2).Aliased_Comp_1
'Unchecked_Access)
161 not in System
.Address
then
162 Report
.Failed
("Component 2 'Unchecked_Access not a valid address");
165 if Aliased_Object
(2).Aliased_Comp_2
'Address not in System
.Address
then
166 Report
.Failed
("Component 2 not located at a valid address ");
169 end TC_Check_Aliased_Addresses
;
171 procedure TC_Check_Specific_Addresses
is
172 use type System
.Address
;
173 use type System
.Storage_Elements
.Integer_Address
;
174 use type Simple_Enum_Type_Ref_Conv
.Object_Pointer
;
175 use type Data_Ref_Conv
.Object_Pointer
;
176 use type Array_W_Aliased_Comps_Ref_Conv
.Object_Pointer
;
179 -- Check the object Specific_Object
181 if System
.Storage_Elements
.To_Integer
(Specific_Object
'Address)
182 /= System
.Storage_Elements
.To_Integer
(SPPRT13
.Variable_Address2
) then
184 ("Specific_Object not at address specified in representation clause");
187 if Array_W_Aliased_Comps_Ref_Conv
.To_Pointer
(SPPRT13
.Variable_Address2
)
188 /= Specific_Object
'Unchecked_Access then
189 Report
.Failed
("Specific_Object'Unchecked_Access not expected value");
192 -- Check the element Specific_Object(1)
194 if Data_Ref_Conv
.To_Address
( Specific_Object
(1)'Access )
195 /= Specific_Object
(1)'Address then
197 ("Specific Array element 'Access does not correspond to the "
198 & "elements 'Address");
201 -- Check that Array'Address points at the first component...
203 if Array_W_Aliased_Comps_Ref_Conv
.To_Address
( Specific_Object
'Access )
204 /= Specific_Object
(1)'Address then
206 ("Address of array object does not equal address of first component");
209 -- Check the components of Specific_Object(2)
211 if Simple_Enum_Type_Ref_Conv
.To_Address
(
212 Specific_Object
(1).Aliased_Comp_1
'Access)
213 not in System
.Address
then
214 Report
.Failed
("Access value of first record component for object at " &
215 "specific address not a valid address");
218 if Specific_Object
(2).Aliased_Comp_2
'Address not in System
.Address
then
219 Report
.Failed
("Second record component for object at specific " &
220 "address not located at a valid address");
223 end TC_Check_Specific_Addresses
;
225 -- Check that X'Address produces a useful result when X is an object of
226 -- a by-reference type.
228 type Tagged_But_Not_Exciting
is tagged record
229 A_Bit_Of_Data
: Boolean;
232 Tagged_Object
: Tagged_But_Not_Exciting
;
234 procedure Muck_With_Addresses
( It
: in out Tagged_But_Not_Exciting
;
235 Its_Address
: in System
.Address
) is
237 if It
'Address /= Its_Address
then
238 Report
.Failed
("Address of object passed by reference does not " &
239 "match address of object passed" );
241 end Muck_With_Addresses
;
243 procedure TC_Check_By_Reference_Types
is
245 Muck_With_Addresses
( Tagged_Object
, Tagged_Object
'Address );
246 end TC_Check_By_Reference_Types
;
250 ------------------------------------------------------------------- CD30001
256 begin -- Main test procedure.
258 Report
.Test
("CD30001",
259 "Check that X'Address produces a useful result when X is " &
260 "an aliased object, or an entity whose Address has been " &
263 -- Check that X'Address produces a useful result when X is an aliased
266 -- Check that aliased objects and subcomponents are allocated on storage
267 -- element boundaries. Check that objects and subcomponents of by
268 -- reference types are allocated on storage element boundaries.
270 CD30001_0
.TC_Check_Aliased_Addresses
;
272 -- Check that X'Address produces a useful result when X is an entity
273 -- whose Address has been specified.
275 CD30001_0
.TC_Check_Specific_Addresses
;
277 -- Check that X'Address produces a useful result when X is an object of
278 -- a by-reference type.
280 CD30001_0
.TC_Check_By_Reference_Types
;