annotate gcc/testsuite/ada/acats/tests/c8/c854002.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 -- C854002.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 and
kono
parents:
diff changeset
6 -- F08630-91-C-0015, the U.S. Government obtained unlimited rights in the
kono
parents:
diff changeset
7 -- software and documentation contained herein. Unlimited rights are
kono
parents:
diff changeset
8 -- defined in DFAR 252.227-7013(a)(19). By making this public release,
kono
parents:
diff changeset
9 -- the Government intends to confer upon all recipients unlimited rights
kono
parents:
diff changeset
10 -- equal to those held by the Government. These rights include rights to
kono
parents:
diff changeset
11 -- use, duplicate, release or disclose the released technical data and
kono
parents:
diff changeset
12 -- computer software in whole or in part, in any manner and for any purpose
kono
parents:
diff changeset
13 -- whatsoever, and to have or permit others to do so.
kono
parents:
diff changeset
14 --
kono
parents:
diff changeset
15 -- DISCLAIMER
kono
parents:
diff changeset
16 --
kono
parents:
diff changeset
17 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
18 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
19 -- WARRANTY AS TO ANY MATTER WHATSOVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
20 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
21 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
22 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
23 --*
kono
parents:
diff changeset
24 --
kono
parents:
diff changeset
25 -- OBJECTIVE
kono
parents:
diff changeset
26 -- Check the requirements of the new 8.5.4(8.A) from Technical
kono
parents:
diff changeset
27 -- Corrigendum 1 (originally discussed as AI95-00064).
kono
parents:
diff changeset
28 -- This paragraph requires an elaboration check on renamings-as-body:
kono
parents:
diff changeset
29 -- even if the body of the ultimately-called subprogram has been
kono
parents:
diff changeset
30 -- elaborated, the check should fail if the renaming-as-body
kono
parents:
diff changeset
31 -- itself has not yet been elaborated.
kono
parents:
diff changeset
32 --
kono
parents:
diff changeset
33 -- TEST DESCRIPTION
kono
parents:
diff changeset
34 -- We declare two functions F and G, and ensure that they are
kono
parents:
diff changeset
35 -- elaborated before anything else, by using pragma Pure. Then we
kono
parents:
diff changeset
36 -- declare two renamings-as-body: the renaming of F is direct, and
kono
parents:
diff changeset
37 -- the renaming of G is via an access-to-function object. We call
kono
parents:
diff changeset
38 -- the renamings during elaboration, and check that they raise
kono
parents:
diff changeset
39 -- Program_Error. We then call them again after elaboration; this
kono
parents:
diff changeset
40 -- time, they should work.
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 -- CHANGE HISTORY:
kono
parents:
diff changeset
43 -- 29 JUN 1999 RAD Initial Version
kono
parents:
diff changeset
44 -- 23 SEP 1999 RLB Improved comments, renamed, issued.
kono
parents:
diff changeset
45 -- 28 JUN 2002 RLB Added pragma Elaborate_All for Report.
kono
parents:
diff changeset
46 --!
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 package C854002_1 is
kono
parents:
diff changeset
49 pragma Pure;
kono
parents:
diff changeset
50 -- Empty.
kono
parents:
diff changeset
51 end C854002_1;
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 package C854002_1.Pure is
kono
parents:
diff changeset
54 pragma Pure;
kono
parents:
diff changeset
55 function F return String;
kono
parents:
diff changeset
56 function G return String;
kono
parents:
diff changeset
57 end C854002_1.Pure;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 with C854002_1.Pure;
kono
parents:
diff changeset
60 package C854002_1.Renamings is
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 F_Result: constant String := C854002_1.Pure.F; -- Make sure we can call F.
kono
parents:
diff changeset
63 function Renamed_F return String;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 G_Result: constant String := C854002_1.Pure.G;
kono
parents:
diff changeset
66 type String_Function is access function return String;
kono
parents:
diff changeset
67 G_Pointer: String_Function := null;
kono
parents:
diff changeset
68 -- Will be set to C854002_1.Pure.G'Access in the body.
kono
parents:
diff changeset
69 function Renamed_G return String;
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 end C854002_1.Renamings;
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 package C854002_1.Caller is
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 -- These procedures call the renamings; when called during elaboration,
kono
parents:
diff changeset
76 -- we pass Should_Fail => True, which checks that Program_Error is
kono
parents:
diff changeset
77 -- raised. Later, we use Should_Fail => False.
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 procedure Call_Renamed_F(Should_Fail: Boolean);
kono
parents:
diff changeset
80 procedure Call_Renamed_G(Should_Fail: Boolean);
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 end C854002_1.Caller;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 with Report; use Report; pragma Elaborate_All (Report);
kono
parents:
diff changeset
85 with C854002_1.Renamings;
kono
parents:
diff changeset
86 package body C854002_1.Caller is
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 Some_Error: exception;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 procedure Call_Renamed_F(Should_Fail: Boolean) is
kono
parents:
diff changeset
91 begin
kono
parents:
diff changeset
92 if Should_Fail then
kono
parents:
diff changeset
93 begin
kono
parents:
diff changeset
94 Failed(C854002_1.Renamings.Renamed_F);
kono
parents:
diff changeset
95 raise Some_Error;
kono
parents:
diff changeset
96 -- This raise statement is necessary, because the
kono
parents:
diff changeset
97 -- Report package has a bug -- if Failed is called
kono
parents:
diff changeset
98 -- before Test, then the failure is ignored, and the
kono
parents:
diff changeset
99 -- test prints "PASSED".
kono
parents:
diff changeset
100 -- Presumably, this raise statement will cause the
kono
parents:
diff changeset
101 -- program to crash, thus avoiding the PASSED message.
kono
parents:
diff changeset
102 exception
kono
parents:
diff changeset
103 when Program_Error =>
kono
parents:
diff changeset
104 Comment("Program_Error -- OK");
kono
parents:
diff changeset
105 end;
kono
parents:
diff changeset
106 else
kono
parents:
diff changeset
107 if C854002_1.Renamings.F_Result /= C854002_1.Renamings.Renamed_F then
kono
parents:
diff changeset
108 Failed("Bad result from renamed F");
kono
parents:
diff changeset
109 end if;
kono
parents:
diff changeset
110 end if;
kono
parents:
diff changeset
111 end Call_Renamed_F;
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 procedure Call_Renamed_G(Should_Fail: Boolean) is
kono
parents:
diff changeset
114 begin
kono
parents:
diff changeset
115 if Should_Fail then
kono
parents:
diff changeset
116 begin
kono
parents:
diff changeset
117 Failed(C854002_1.Renamings.Renamed_G);
kono
parents:
diff changeset
118 raise Some_Error;
kono
parents:
diff changeset
119 exception
kono
parents:
diff changeset
120 when Program_Error =>
kono
parents:
diff changeset
121 Comment("Program_Error -- OK");
kono
parents:
diff changeset
122 end;
kono
parents:
diff changeset
123 else
kono
parents:
diff changeset
124 if C854002_1.Renamings.G_Result /= C854002_1.Renamings.Renamed_G then
kono
parents:
diff changeset
125 Failed("Bad result from renamed G");
kono
parents:
diff changeset
126 end if;
kono
parents:
diff changeset
127 end if;
kono
parents:
diff changeset
128 end Call_Renamed_G;
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 begin
kono
parents:
diff changeset
131 -- At this point, the bodies of Renamed_F and Renamed_G have not yet
kono
parents:
diff changeset
132 -- been elaborated, so calling them should raise Program_Error:
kono
parents:
diff changeset
133 Call_Renamed_F(Should_Fail => True);
kono
parents:
diff changeset
134 Call_Renamed_G(Should_Fail => True);
kono
parents:
diff changeset
135 end C854002_1.Caller;
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 package body C854002_1.Pure is
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 function F return String is
kono
parents:
diff changeset
140 begin
kono
parents:
diff changeset
141 return "This is function F";
kono
parents:
diff changeset
142 end F;
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 function G return String is
kono
parents:
diff changeset
145 begin
kono
parents:
diff changeset
146 return "This is function G";
kono
parents:
diff changeset
147 end G;
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 end C854002_1.Pure;
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 with C854002_1.Pure;
kono
parents:
diff changeset
152 with C854002_1.Caller; pragma Elaborate(C854002_1.Caller);
kono
parents:
diff changeset
153 -- This pragma ensures that this package body (Renamings)
kono
parents:
diff changeset
154 -- will be elaborated after Caller, so that when Caller calls
kono
parents:
diff changeset
155 -- the renamings during its elaboration, the renamings will
kono
parents:
diff changeset
156 -- not have been elaborated (although what the rename have been).
kono
parents:
diff changeset
157 package body C854002_1.Renamings is
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 function Renamed_F return String renames C854002_1.Pure.F;
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 package Dummy is end; -- So we can insert statements here.
kono
parents:
diff changeset
162 package body Dummy is
kono
parents:
diff changeset
163 begin
kono
parents:
diff changeset
164 G_Pointer := C854002_1.Pure.G'Access;
kono
parents:
diff changeset
165 end Dummy;
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 function Renamed_G return String renames G_Pointer.all;
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 end C854002_1.Renamings;
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 with Report; use Report;
kono
parents:
diff changeset
172 with C854002_1.Caller;
kono
parents:
diff changeset
173 procedure C854002 is
kono
parents:
diff changeset
174 begin
kono
parents:
diff changeset
175 Test("C854002",
kono
parents:
diff changeset
176 "An elaboration check is performed for a call to a subprogram"
kono
parents:
diff changeset
177 & " whose body is given as a renaming-as-body");
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 -- By the time we get here, all library units have been elaborated,
kono
parents:
diff changeset
180 -- so the following calls should not raise Program_Error:
kono
parents:
diff changeset
181 C854002_1.Caller.Call_Renamed_F(Should_Fail => False);
kono
parents:
diff changeset
182 C854002_1.Caller.Call_Renamed_G(Should_Fail => False);
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 Result;
kono
parents:
diff changeset
185 end C854002;