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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [c6/] [c650001.a] - Blame information for rev 720

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- C650001.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, for a function result type that is a return-by-reference
28
--      type, Program_Error is raised if the return expression is a name that
29
--      denotes an object view whose accessibility level is deeper than that
30
--      of the master that elaborated the function body.
31
--
32
--      Check for cases where the result type is:
33
--         (a) A tagged limited type.
34
--         (b) A task type.
35
--         (c) A protected type.
36
--         (d) A composite type with a subcomponent of a
37
--             return-by-reference type (task type).
38
--
39
-- TEST DESCRIPTION:
40
--      The accessibility level of the master that elaborates the body of a
41
--      return-by-reference function will always be less deep than that of
42
--      the function (which is itself a master).
43
--
44
--      Thus, the return object may not be any of the following, since each
45
--      has an accessibility level at least as deep as that of the function:
46
--
47
--         (1) An object declared local to the function.
48
--         (2) The result of a local function.
49
--         (3) A parameter of the function.
50
--
51
--      Verify that Program_Error is raised within the return-by-reference
52
--      function if the return object is any of (1)-(3) above, for various
53
--      subsets of the return types (a)-(d) above. Include cases where (1)-(3)
54
--      are operands of parenthesized expressions.
55
--
56
--      Verify that no exception is raised if the return object is any of the
57
--      following:
58
--
59
--         (4) An object declared at a less deep level than that of the
60
--             master that elaborated the function body.
61
--         (5) The result of a function declared at the same level as the
62
--             original function (assuming the new function is also legal).
63
--         (6) A parameter of the master that elaborated the function body.
64
--
65
--      For (5), pass the new function as an actual via an access-to-
66
--      subprogram parameter of the original function. Check for cases where
67
--      the new function does and does not raise an exception.
68
--
69
--      Since the functions to be tested cannot be part of an assignment
70
--      statement (since they return values of a limited type), pass each
71
--      function result as an actual parameter to a dummy procedure, e.g.,
72
--
73
--         Dummy_Proc ( Function_Call );
74
--
75
--
76
-- CHANGE HISTORY:
77
--      03 May 95   SAIC    Initial prerelease version.
78
--      08 Feb 99   RLB     Removed subcase with two errors.
79
--
80
--!
81
 
82
package C650001_0 is
83
 
84
   type Tagged_Limited is tagged limited record
85
      C: String (1 .. 10);
86
   end record;
87
 
88
   task type Task_Type;
89
 
90
   protected type Protected_Type is
91
      procedure Op;
92
   end Protected_Type;
93
 
94
   type Task_Array is array (1 .. 10) of Task_Type;
95
 
96
   type Variant_Record (Toggle: Boolean) is record
97
      case Toggle is
98
         when True  =>
99
            T: Task_Type;  -- Return-by-reference component.
100
         when False =>
101
            I: Integer;    -- Non-return-by-reference component.
102
      end case;
103
   end record;
104
 
105
   -- Limited type even though variant contains no limited components:
106
   type Non_Task_Variant is new Variant_Record (Toggle => False);
107
 
108
end C650001_0;
109
 
110
 
111
     --==================================================================--
112
 
113
 
114
package body C650001_0 is
115
 
116
   task body Task_Type is
117
   begin
118
      null;
119
   end Task_Type;
120
 
121
   protected body Protected_Type is
122
      procedure Op is
123
      begin
124
         null;
125
      end Op;
126
   end Protected_Type;
127
 
128
end C650001_0;
129
 
130
 
131
     --==================================================================--
132
 
133
 
134
with C650001_0;
135
package C650001_1 is
136
 
137
   type TC_Result_Kind is (OK, P_E, O_E);
138
 
139
   procedure TC_Display_Results (Actual  : in TC_Result_Kind;
140
                                 Expected: in TC_Result_Kind;
141
                                 Message : in String);
142
 
143
   -- Dummy procedures:
144
 
145
   procedure Check_Tagged    (P: C650001_0.Tagged_Limited);
146
   procedure Check_Task      (P: C650001_0.Task_Type);
147
   procedure Check_Protected (P: C650001_0.Protected_Type);
148
   procedure Check_Composite (P: C650001_0.Non_Task_Variant);
149
 
150
end C650001_1;
151
 
152
 
153
     --==================================================================--
154
 
155
 
156
with Report;
157
package body C650001_1 is
158
 
159
   procedure TC_Display_Results (Actual  : in TC_Result_Kind;
160
                                 Expected: in TC_Result_Kind;
161
                                 Message : in String) is
162
   begin
163
      if Actual /= Expected then
164
         case Actual is
165
            when OK  =>
166
               Report.Failed ("No exception raised: "         & Message);
167
            when P_E =>
168
               Report.Failed ("Program_Error raised: "        & Message);
169
            when O_E =>
170
               Report.Failed ("Unexpected exception raised: " & Message);
171
         end case;
172
      end if;
173
   end TC_Display_Results;
174
 
175
 
176
   procedure Check_Tagged (P: C650001_0.Tagged_Limited) is
177
   begin
178
      null;
179
   end;
180
 
181
   procedure Check_Task (P: C650001_0.Task_Type) is
182
   begin
183
      null;
184
   end;
185
 
186
   procedure Check_Protected (P: C650001_0.Protected_Type) is
187
   begin
188
      null;
189
   end;
190
 
191
   procedure Check_Composite (P: C650001_0.Non_Task_Variant) is
192
   begin
193
      null;
194
   end;
195
 
196
end C650001_1;
197
 
198
 
199
 
200
     --==================================================================--
201
 
202
 
203
with C650001_0;
204
with C650001_1;
205
 
206
with Report;
207
procedure C650001 is
208
begin
209
 
210
   Report.Test ("C650001", "Check that, for a function result type that " &
211
                "is a return-by-reference type, Program_Error is raised " &
212
                "if the return expression is a name that denotes an "     &
213
                "object view whose accessibility level is deeper than "   &
214
                "that of the master that elaborated the function body");
215
 
216
 
217
 
218
   SUBTEST1:
219
   declare
220
 
221
      Result: C650001_1.TC_Result_Kind;
222
      PO    : C650001_0.Protected_Type;
223
 
224
      function Return_Prot (P: C650001_0.Protected_Type)
225
        return C650001_0.Protected_Type is
226
      begin
227
         Result := C650001_1.OK;
228
         return P;                                     -- Formal parameter (3).
229
      exception
230
         when Program_Error =>
231
            Result := C650001_1.P_E;                        -- Expected result.
232
            return PO;
233
         when others        =>
234
            Result := C650001_1.O_E;
235
            return PO;
236
      end Return_Prot;
237
 
238
   begin  -- SUBTEST1.
239
      C650001_1.Check_Protected ( Return_Prot(PO) );
240
      C650001_1.TC_Display_Results (Result, C650001_1.P_E, "SUBTEST #1");
241
   exception
242
      when others =>
243
         Report.Failed ("SUBTEST #1: Unexpected exception in outer block");
244
   end SUBTEST1;
245
 
246
 
247
 
248
   SUBTEST2:
249
   declare
250
 
251
      Result: C650001_1.TC_Result_Kind;
252
      Comp  : C650001_0.Non_Task_Variant;
253
 
254
      function Return_Composite return C650001_0.Non_Task_Variant is
255
         Local: C650001_0.Non_Task_Variant;
256
      begin
257
         Result := C650001_1.OK;
258
         return (Local);                     -- Parenthesized local object (1).
259
      exception
260
         when Program_Error =>
261
            Result := C650001_1.P_E;                        -- Expected result.
262
            return Comp;
263
         when others        =>
264
            Result := C650001_1.O_E;
265
            return Comp;
266
      end Return_Composite;
267
 
268
   begin -- SUBTEST2.
269
      C650001_1.Check_Composite ( Return_Composite );
270
      C650001_1.TC_Display_Results (Result, C650001_1.P_E, "SUBTEST #2");
271
   exception
272
      when others =>
273
         Report.Failed ("SUBTEST #2: Unexpected exception in outer block");
274
   end SUBTEST2;
275
 
276
 
277
 
278
   SUBTEST3:
279
   declare
280
 
281
      Result: C650001_1.TC_Result_Kind;
282
      Tsk   : C650001_0.Task_Type;
283
      TskArr: C650001_0.Task_Array;
284
 
285
      function Return_Task (P: C650001_0.Task_Array)
286
        return C650001_0.Task_Type is
287
 
288
         function Inner return C650001_0.Task_Type is
289
         begin
290
            return P(P'First);           -- OK: should not raise exception (6).
291
         exception
292
            when Program_Error =>
293
               Report.Failed ("SUBTEST #3: Program_Error incorrectly " &
294
                              "raised within function Inner");
295
               return Tsk;
296
            when others        =>
297
               Report.Failed ("SUBTEST #3: Unexpected exception " &
298
                              "raised within function Inner");
299
               return Tsk;
300
         end Inner;
301
 
302
      begin -- Return_Task.
303
         Result := C650001_1.OK;
304
         return Inner;                           -- Call to local function (2).
305
      exception
306
         when Program_Error =>
307
            Result := C650001_1.P_E;                        -- Expected result.
308
            return Tsk;
309
         when others        =>
310
            Result := C650001_1.O_E;
311
            return Tsk;
312
      end Return_Task;
313
 
314
   begin -- SUBTEST3.
315
      C650001_1.Check_Task ( Return_Task(TskArr) );
316
      C650001_1.TC_Display_Results (Result, C650001_1.P_E, "SUBTEST #3");
317
   exception
318
      when others =>
319
         Report.Failed ("SUBTEST #3: Unexpected exception in outer block");
320
   end SUBTEST3;
321
 
322
 
323
 
324
   SUBTEST4:
325
   declare
326
 
327
      Result: C650001_1.TC_Result_Kind;
328
      TagLim: C650001_0.Tagged_Limited;
329
 
330
      function Return_TagLim (P: C650001_0.Tagged_Limited'Class)
331
        return C650001_0.Tagged_Limited is
332
      begin
333
         Result := C650001_1.OK;
334
         return C650001_0.Tagged_Limited(P); -- Conversion of formal param (3).
335
      exception
336
         when Program_Error =>
337
            Result := C650001_1.P_E;                        -- Expected result.
338
            return TagLim;
339
         when others        =>
340
            Result := C650001_1.O_E;
341
            return TagLim;
342
      end Return_TagLim;
343
 
344
   begin -- SUBTEST4.
345
      C650001_1.Check_Tagged ( Return_TagLim(TagLim) );
346
      C650001_1.TC_Display_Results (Result, C650001_1.P_E,
347
                                    "SUBTEST #4 (root type)");
348
   exception
349
      when others =>
350
         Report.Failed ("SUBTEST #4: Unexpected exception in outer block");
351
   end SUBTEST4;
352
 
353
 
354
 
355
   SUBTEST5:
356
   declare
357
      Tsk : C650001_0.Task_Type;
358
   begin  -- SUBTEST5.
359
 
360
      declare
361
         Result: C650001_1.TC_Result_Kind;
362
 
363
         type AccToFunc is access function return C650001_0.Task_Type;
364
 
365
         function Return_Global return C650001_0.Task_Type is
366
         begin
367
            return Tsk;                  -- OK: should not raise exception (4).
368
         end Return_Global;
369
 
370
         function Return_Local return C650001_0.Task_Type is
371
            Local : C650001_0.Task_Type;
372
         begin
373
            return Local;                           -- Propagate Program_Error.
374
         end Return_Local;
375
 
376
 
377
         function Return_Func (P: AccToFunc) return C650001_0.Task_Type is
378
         begin
379
            Result := C650001_1.OK;
380
            return P.all;                                 -- Function call (5).
381
         exception
382
            when Program_Error =>
383
               Result := C650001_1.P_E;
384
               return Tsk;
385
            when others        =>
386
               Result := C650001_1.O_E;
387
               return Tsk;
388
         end Return_Func;
389
 
390
         RG : AccToFunc := Return_Global'Access;
391
         RL : AccToFunc := Return_Local'Access;
392
 
393
      begin
394
         C650001_1.Check_Task ( Return_Func(RG) );
395
         C650001_1.TC_Display_Results (Result, C650001_1.OK,
396
                                       "SUBTEST #5 (global task)");
397
 
398
         C650001_1.Check_Task ( Return_Func(RL) );
399
         C650001_1.TC_Display_Results (Result, C650001_1.P_E,
400
                                       "SUBTEST #5 (local task)");
401
      exception
402
         when others =>
403
            Report.Failed ("SUBTEST #5: Unexpected exception in outer block");
404
      end;
405
 
406
   end SUBTEST5;
407
 
408
 
409
 
410
   Report.Result;
411
 
412
end C650001;

powered by: WebSVN 2.1.0

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