OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cd/] [cd72a02.a] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
-- CD72A02.A
2
--
3
--                             Grant of Unlimited Rights
4
--
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
14
--     to do so.
15
--
16
--                                    DISCLAIMER
17
--
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.
24
--*
25
--
26
-- OBJECTIVE:
27
--      Check that the package System.Address_To_Access_Conversions may be
28
--      instantiated for various composite types.
29
--
30
--      Check that To_Pointer and To_Address are inverse operations.
31
--
32
--      Check that To_Pointer(X'Address) equals X'Unchecked_Access for an
33
--      X that allows Unchecked_Access.
34
--
35
--      Check that To_Pointer(Null_Address) returns null.
36
--
37
-- TEST DESCRIPTION:
38
--      This test is identical to CD72A01 with the exception that it tests
39
--      the composite types where CD72A01 tests "simple" types.
40
--
41
--      This test checks that the semantics provided in
42
--      Address_To_Access_Conversions are present and operate
43
--      within expectations (to the best extent possible in a portable
44
--      implementation independent fashion).
45
--
46
--      The functions Address_To_Hex and Hex_To_Address test the invertability
47
--      of the To_Integer and To_Address functions, along with a great deal
48
--      of optimizer chaff and protection from the fact that type
49
--      Storage_Elements.Integer_Address may be either a modular or a signed
50
--      integer type.
51
--
52
--      This test has some interesting usage paradigms in that users
53
--      occasionally want to store address information in a transportable
54
--      fashion, and often resort to some textual representation of values.
55
--
56
-- APPLICABILITY CRITERIA:
57
--      All implementations must attempt to compile this test.
58
--
59
--      For implementations validating against Systems Programming Annex (C):
60
--        this test must execute and report PASSED.
61
--
62
--      For implementations not validating against Annex C:
63
--        this test may report compile time errors at one or more points
64
--        indicated by "-- ANX-C RQMT", in which case it may be graded as inapplicable.
65
--        Otherwise, the test must execute and report PASSED.
66
--
67
--
68
-- CHANGE HISTORY:
69
--      13 JUL 95   SAIC   Initial version (CD72001)
70
--      08 FEB 96   SAIC   Split from CD72001 by reviewer request for 2.1
71
--      12 NOV 96   SAIC   Corrected typo in RM ref
72
--      16 FEB 98   EDS    Modified documentation.
73
--      22 JAN 02   RLB    Corrected test description.
74
--!
75
 
76
with Report;
77
with Impdef;
78
with FD72A00;
79
with System.Storage_Elements;
80
with System.Address_To_Access_Conversions;
81
procedure CD72A02 is
82
  use System;
83
  use FD72A00;
84
 
85
   type Tagged_Record is tagged record
86
      Value : Natural;
87
    end record;
88
 
89
    package Class_ATAC is
90
      new System.Address_To_Access_Conversions(Tagged_Record'Class);
91
                                                        -- ANX-C RQMT
92
 
93
  use type Class_ATAC.Object_Pointer;
94
 
95
    task type TC_Task_Type is
96
      entry E;
97
      entry F;
98
    end TC_Task_Type;
99
 
100
    package Task_ATAC is
101
            new System.Address_To_Access_Conversions(TC_Task_Type);
102
                                                        -- ANX-C RQMT
103
 
104
  use type Task_ATAC.Object_Pointer;
105
 
106
    task body TC_Task_Type is
107
    begin
108
      select
109
        accept E;
110
      or
111
        accept F;
112
          Report.Failed("Task rendezvoused on wrong path");
113
      end select;
114
    end TC_Task_Type;
115
 
116
    protected type TC_Protec is
117
      procedure E;
118
      procedure F;
119
    private
120
      Visited : Boolean := False;
121
    end TC_Protec;
122
 
123
    package Protected_ATAC is
124
            new System.Address_To_Access_Conversions(TC_Protec);
125
                                                        -- ANX-C RQMT
126
 
127
  use type Protected_ATAC.Object_Pointer;
128
 
129
    protected body TC_Protec is
130
      procedure E is
131
      begin
132
        Visited := True;
133
      end E;
134
      procedure F is
135
      begin
136
        if not Visited then
137
          Report.Failed("Protected Object took wrong path");
138
        end if;
139
      end F;
140
    end TC_Protec;
141
 
142
    type Test_Cases is ( Tagged_Type, Task_Type,  Protected_Type );
143
 
144
    type Naive_Dynamic_String is access String;
145
 
146
    type String_Store is array(Test_Cases) of Naive_Dynamic_String;
147
 
148
    The_Strings : String_Store;
149
 
150
    -- create several aliased objects with distinct values
151
 
152
    My_Rec  : aliased Tagged_Record := (Value => Natural'Last);
153
    My_Task : aliased TC_Task_Type;
154
    My_Prot : aliased TC_Protec;
155
 
156
    use type System.Storage_Elements.Integer_Address;
157
 
158
begin  -- Main test procedure.
159
 
160
   Report.Test ("CD72A02", "Check package " &
161
                            "System.Address_To_Access_Conversions " &
162
                            "for composite types" );
163
 
164
    -- take several pointer objects, convert them to addresses, and store
165
    -- the address as a hexadecimal representation for later reconversion
166
 
167
    The_Strings(Tagged_Type) := new String'(
168
      Address_To_Hex(Class_ATAC.To_Address(My_Rec'Access)) );
169
 
170
    The_Strings(Task_Type) := new String'(
171
      Address_To_Hex(Task_ATAC.To_Address(My_Task'Access)) );
172
 
173
    The_Strings(Protected_Type) := new String'(
174
      Address_To_Hex(Protected_ATAC.To_Address(My_Prot'Access)) );
175
 
176
    -- now, reconvert the hexadecimal address values back to pointers,
177
    -- and check that the dereferenced pointer still designates the
178
    -- value placed at that location.  The use of the intermediate
179
    -- string representation should foil even the cleverest of optimizers
180
 
181
    if Tagged_Record(Class_ATAC.To_Pointer(
182
                              Hex_To_Address(The_Strings(Tagged_Type))).all)
183
       /= Tagged_Record'(Value => Natural'Last) then
184
      Report.Failed("Tagged_Record reconversion");
185
    end if;
186
 
187
    Task_ATAC.To_Pointer(Hex_To_Address(The_Strings(Task_Type))).E;
188
 
189
    begin
190
      select        -- allow for task to have completed.
191
        My_Task.F;  -- should not happen, will call Report.Fail in task
192
      else
193
        null;       -- expected case, "Report.Pass;"
194
      end select;
195
    exception
196
      when Tasking_Error => null;  -- task terminated, which is OK
197
    end;
198
 
199
    Protected_ATAC.To_Pointer(
200
                           Hex_To_Address(The_Strings(Protected_Type))).E;
201
    My_Prot.F;    -- checks that call to E occurred
202
 
203
 
204
    -- check that the resulting values are equal to the 'Unchecked_Access
205
    -- of the value
206
 
207
    if Class_ATAC.To_Pointer(Hex_To_Address(The_Strings(Tagged_Type)))
208
       /= My_Rec'Unchecked_Access then
209
      Report.Failed("Tagged_Record Unchecked_Access");
210
    end if;
211
 
212
    if Task_ATAC.To_Pointer(Hex_To_Address(The_Strings(Task_Type)))
213
       /= My_Task'Unchecked_Access then
214
      Report.Failed("Task Unchecked_Access");
215
    end if;
216
 
217
    if Protected_ATAC.To_Pointer(
218
                           Hex_To_Address(The_Strings(Protected_Type)))
219
       /= My_Prot'Unchecked_Access then
220
      Report.Failed("Protected Unchecked_Access");
221
    end if;
222
 
223
  Report.Result;
224
 
225
end CD72A02;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.