annotate gcc/testsuite/ada/acats/tests/cd/cd72a01.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 --
kono
parents:
diff changeset
2 -- CD72A01.A
kono
parents:
diff changeset
3 --
kono
parents:
diff changeset
4 -- Grant of Unlimited Rights
kono
parents:
diff changeset
5 --
kono
parents:
diff changeset
6 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
7 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
8 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
9 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
10 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
11 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
12 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
13 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
14 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
15 -- to do so.
kono
parents:
diff changeset
16 --
kono
parents:
diff changeset
17 -- DISCLAIMER
kono
parents:
diff changeset
18 --
kono
parents:
diff changeset
19 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
20 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
21 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
22 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
23 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
24 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
25 --*
kono
parents:
diff changeset
26 --
kono
parents:
diff changeset
27 -- OBJECTIVE:
kono
parents:
diff changeset
28 -- Check that the package System.Address_To_Access_Conversions may be
kono
parents:
diff changeset
29 -- instantiated for various simple types.
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- Check that To_Pointer and To_Address are inverse operations.
kono
parents:
diff changeset
32 --
kono
parents:
diff changeset
33 -- Check that To_Pointer(X'Address) equals X'Unchecked_Access for an
kono
parents:
diff changeset
34 -- X that allows Unchecked_Access.
kono
parents:
diff changeset
35 --
kono
parents:
diff changeset
36 -- Check that To_Pointer(Null_Address) returns null.
kono
parents:
diff changeset
37 --
kono
parents:
diff changeset
38 -- TEST DESCRIPTION:
kono
parents:
diff changeset
39 -- This test checks that the semantics provided in
kono
parents:
diff changeset
40 -- Address_To_Access_Conversions are present and operate
kono
parents:
diff changeset
41 -- within expectations (to the best extent possible in a portable
kono
parents:
diff changeset
42 -- implementation independent fashion).
kono
parents:
diff changeset
43 --
kono
parents:
diff changeset
44 -- The functions Address_To_Hex and Hex_To_Address test the invertability
kono
parents:
diff changeset
45 -- of the To_Integer and To_Address functions, along with a great deal
kono
parents:
diff changeset
46 -- of optimizer chaff and protection from the fact that type
kono
parents:
diff changeset
47 -- Storage_Elements.Integer_Address may be either a modular or a signed
kono
parents:
diff changeset
48 -- integer type.
kono
parents:
diff changeset
49 --
kono
parents:
diff changeset
50 -- This test has some interesting usage paradigms in that users
kono
parents:
diff changeset
51 -- occasionally want to store address information in a transportable
kono
parents:
diff changeset
52 -- fashion, and often resort to some textual representation of values.
kono
parents:
diff changeset
53 --
kono
parents:
diff changeset
54 -- APPLICABILITY CRITERIA:
kono
parents:
diff changeset
55 -- All implementations must attempt to compile this test.
kono
parents:
diff changeset
56 --
kono
parents:
diff changeset
57 -- For implementations validating against Systems Programming Annex (C):
kono
parents:
diff changeset
58 -- this test must execute and report PASSED.
kono
parents:
diff changeset
59 --
kono
parents:
diff changeset
60 -- For implementations not validating against Annex C:
kono
parents:
diff changeset
61 -- this test may report compile time errors at one or more points
kono
parents:
diff changeset
62 -- indicated by "-- ANX-C RQMT", in which case it may be graded as inapplicable.
kono
parents:
diff changeset
63 -- Otherwise, the test must execute and report PASSED.
kono
parents:
diff changeset
64 --
kono
parents:
diff changeset
65 -- CHANGE HISTORY:
kono
parents:
diff changeset
66 -- 13 JUL 95 SAIC Initial version (CD72001)
kono
parents:
diff changeset
67 -- 08 FEB 96 SAIC Revised (split) version for 2.1
kono
parents:
diff changeset
68 -- 07 MAY 96 SAIC Additional subtest added for 2.1
kono
parents:
diff changeset
69 -- 16 FEB 98 EDS Modified documentation.
kono
parents:
diff changeset
70 --!
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 with Report;
kono
parents:
diff changeset
73 with Impdef;
kono
parents:
diff changeset
74 with FD72A00;
kono
parents:
diff changeset
75 with System.Storage_Elements;
kono
parents:
diff changeset
76 with System.Address_To_Access_Conversions;
kono
parents:
diff changeset
77 procedure CD72A01 is
kono
parents:
diff changeset
78 use System;
kono
parents:
diff changeset
79 use FD72A00;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 package Number_ATAC is
kono
parents:
diff changeset
82 new System.Address_To_Access_Conversions(Number); -- ANX-C RQMT
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 use type Number_ATAC.Object_Pointer;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 type Data is record
kono
parents:
diff changeset
87 One, Two: aliased Number;
kono
parents:
diff changeset
88 end record;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 package Data_ATAC is
kono
parents:
diff changeset
91 new System.Address_To_Access_Conversions(Data); -- ANX-C RQMT
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 use type Data_ATAC.Object_Pointer;
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 type Test_Cases is ( Addr_Type, Record_Type );
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 type Naive_Dynamic_String is access String;
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 type String_Store is array(Test_Cases) of Naive_Dynamic_String;
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 The_Strings : String_Store;
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 -- create several aliased objects with distinct values
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 My_Number : aliased Number := Number'First;
kono
parents:
diff changeset
106 My_Data : aliased Data := (Number'First,Number'Last);
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 use type System.Storage_Elements.Integer_Address;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 begin -- Main test procedure.
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 Report.Test ("CD72A01", "Check package " &
kono
parents:
diff changeset
113 "System.Address_To_Access_Conversions " &
kono
parents:
diff changeset
114 "for simple types" );
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 -- take several pointer objects, convert them to addresses, and store
kono
parents:
diff changeset
117 -- the address as a hexadecimal representation for later reconversion
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 The_Strings(Addr_Type) := new String'(
kono
parents:
diff changeset
120 Address_To_Hex(Number_ATAC.To_Address(My_Number'Access)) );
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 The_Strings(Record_Type) := new String'(
kono
parents:
diff changeset
123 Address_To_Hex(Data_ATAC.To_Address(My_Data'Access)) );
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 -- now, reconvert the hexadecimal address values back to pointers,
kono
parents:
diff changeset
126 -- and check that the dereferenced pointer still designates the
kono
parents:
diff changeset
127 -- value placed at that location. The use of the intermediate
kono
parents:
diff changeset
128 -- string representation should foil even the cleverest of optimizers
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 if Number_ATAC.To_Pointer(
kono
parents:
diff changeset
131 Hex_To_Address(The_Strings(Addr_Type))).all
kono
parents:
diff changeset
132 /= Number'First then
kono
parents:
diff changeset
133 Report.Failed("Number reconversion");
kono
parents:
diff changeset
134 end if;
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 if Data_ATAC.To_Pointer(Hex_To_Address(The_Strings(Record_Type))).all
kono
parents:
diff changeset
137 /= (Number'First,Number'Last) then
kono
parents:
diff changeset
138 Report.Failed("Data reconversion");
kono
parents:
diff changeset
139 end if;
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 -- check that the resulting values are equal to the 'Unchecked_Access
kono
parents:
diff changeset
142 -- of the value
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 if Number_ATAC.To_Pointer(
kono
parents:
diff changeset
145 Hex_To_Address(The_Strings(Addr_Type)))
kono
parents:
diff changeset
146 /= My_Number'Unchecked_Access then
kono
parents:
diff changeset
147 Report.Failed("Number Unchecked_Access");
kono
parents:
diff changeset
148 end if;
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 if Data_ATAC.To_Pointer(Hex_To_Address(The_Strings(Record_Type)))
kono
parents:
diff changeset
151 /= My_Data'Unchecked_Access then
kono
parents:
diff changeset
152 Report.Failed("Data Unchecked_Access");
kono
parents:
diff changeset
153 end if;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 if Number_ATAC.To_Pointer(System.Null_Address) /= null then
kono
parents:
diff changeset
156 Report.Failed("To_Pointer(Null_Address) /= null");
kono
parents:
diff changeset
157 end if;
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 if Number_ATAC.To_Address(null) /= System.Null_Address then
kono
parents:
diff changeset
160 Report.Failed("To_Address(null) /= Null_Address");
kono
parents:
diff changeset
161 end if;
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 Report.Result;
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 end CD72A01;