annotate gcc/testsuite/ada/acats/tests/c3/c392004.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 -- C392004.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,
kono
parents:
diff changeset
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
7 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
9 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
10 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
11 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
12 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
13 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
14 -- to do so.
kono
parents:
diff changeset
15 --
kono
parents:
diff changeset
16 -- DISCLAIMER
kono
parents:
diff changeset
17 --
kono
parents:
diff changeset
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
24 --*
kono
parents:
diff changeset
25 --
kono
parents:
diff changeset
26 -- OBJECTIVE:
kono
parents:
diff changeset
27 -- Check that subprograms inherited from tagged derivations, which are
kono
parents:
diff changeset
28 -- subsequently redefined for the derived type, are available to the
kono
parents:
diff changeset
29 -- package defining the new class via view conversion. Check
kono
parents:
diff changeset
30 -- that operations performed on objects using view conversion do not
kono
parents:
diff changeset
31 -- affect the extended fields. Check that visible operations not masked
kono
parents:
diff changeset
32 -- by the deriving package remain available to the client, and do not
kono
parents:
diff changeset
33 -- affect the extended fields.
kono
parents:
diff changeset
34 --
kono
parents:
diff changeset
35 -- TEST DESCRIPTION:
kono
parents:
diff changeset
36 -- This test declares a tagged type, with a constructor operation,
kono
parents:
diff changeset
37 -- derives a type from that tagged type, and declares a constructor
kono
parents:
diff changeset
38 -- operation which masks the inherited operation. It then tests
kono
parents:
diff changeset
39 -- that the correct constructor is called, and that the extended
kono
parents:
diff changeset
40 -- part of the derived type remains untouched as appropriate.
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 --
kono
parents:
diff changeset
43 -- CHANGE HISTORY:
kono
parents:
diff changeset
44 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
45 -- 19 Dec 94 SAIC Removed RM references from objective text.
kono
parents:
diff changeset
46 -- 04 Jan 94 SAIC Fixed objective typo, removed dead code.
kono
parents:
diff changeset
47 --
kono
parents:
diff changeset
48 --!
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 with Report;
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 package C392004_1 is
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 type Vehicle is tagged private;
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 procedure Create ( The_Vehicle : out Vehicle; TC_Flag : Natural );
kono
parents:
diff changeset
57 procedure Start ( The_Vehicle : in out Vehicle );
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 private
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 type Vehicle is tagged record
kono
parents:
diff changeset
62 Engine_On : Boolean;
kono
parents:
diff changeset
63 end record;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 end C392004_1;
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 package body C392004_1 is
kono
parents:
diff changeset
68 procedure Create ( The_Vehicle : out Vehicle; TC_Flag : Natural ) is
kono
parents:
diff changeset
69 begin
kono
parents:
diff changeset
70 case TC_Flag is
kono
parents:
diff changeset
71 when 1 => null; -- expected flag for this subprogram
kono
parents:
diff changeset
72 when others =>
kono
parents:
diff changeset
73 Report.Failed ("Called Vehicle Create");
kono
parents:
diff changeset
74 end case;
kono
parents:
diff changeset
75 The_Vehicle := (Engine_On => False);
kono
parents:
diff changeset
76 end Create;
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 procedure Start ( The_Vehicle : in out Vehicle ) is
kono
parents:
diff changeset
79 begin
kono
parents:
diff changeset
80 The_Vehicle.Engine_On := True;
kono
parents:
diff changeset
81 end Start;
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 end C392004_1;
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 ----------------------------------------------------------------------------
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 with C392004_1;
kono
parents:
diff changeset
88 package C392004_2 is
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 type Car is new C392004_1.Vehicle with record
kono
parents:
diff changeset
91 Convertible : Boolean;
kono
parents:
diff changeset
92 end record;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 -- masking definition
kono
parents:
diff changeset
95 procedure Create( The_Car : out Car; TC_Flag : Natural );
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 type Limo is new Car with null record;
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 procedure Create( The_Limo : out Limo; TC_Flag : Natural );
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 end C392004_2;
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 ----------------------------------------------------------------------------
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 with Report;
kono
parents:
diff changeset
106 package body C392004_2 is
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 procedure Create( The_Car : out Car; TC_Flag : Natural ) is
kono
parents:
diff changeset
109 begin
kono
parents:
diff changeset
110 case TC_Flag is
kono
parents:
diff changeset
111 when 2 => null; -- expected flag for this subprogram
kono
parents:
diff changeset
112 when others => Report.Failed ("Called Car Create");
kono
parents:
diff changeset
113 end case;
kono
parents:
diff changeset
114 C392004_1.Create( C392004_1.Vehicle(The_Car), 1);
kono
parents:
diff changeset
115 The_Car.Convertible := False;
kono
parents:
diff changeset
116 end Create;
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 procedure Create( The_Limo : out Limo; TC_Flag : Natural ) is
kono
parents:
diff changeset
119 begin
kono
parents:
diff changeset
120 case TC_Flag is
kono
parents:
diff changeset
121 when 3 => null; -- expected flag for this subprogram
kono
parents:
diff changeset
122 when others => Report.Failed ("Called Limo Create");
kono
parents:
diff changeset
123 end case;
kono
parents:
diff changeset
124 C392004_1.Create( C392004_1.Vehicle(The_Limo), 1);
kono
parents:
diff changeset
125 The_Limo.Convertible := True;
kono
parents:
diff changeset
126 end Create;
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 end C392004_2;
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 ----------------------------------------------------------------------------
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 with Report;
kono
parents:
diff changeset
133 with C392004_1; use C392004_1;
kono
parents:
diff changeset
134 with C392004_2; use C392004_2;
kono
parents:
diff changeset
135 procedure C392004 is
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 My_Car : Car;
kono
parents:
diff changeset
138 Your_Car : Limo;
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 procedure TC_Assert( Is_True : Boolean; Message : String ) is
kono
parents:
diff changeset
141 begin
kono
parents:
diff changeset
142 if not Is_True then
kono
parents:
diff changeset
143 Report.Failed (Message);
kono
parents:
diff changeset
144 end if;
kono
parents:
diff changeset
145 end TC_Assert;
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 begin -- Main test procedure.
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 Report.Test ("C392004", "Check subprogram inheritance & visibility " &
kono
parents:
diff changeset
150 "for derived tagged types" );
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 My_Car.Convertible := False;
kono
parents:
diff changeset
153 Create( Vehicle( My_Car ), 1 );
kono
parents:
diff changeset
154 TC_Assert( not My_Car.Convertible, "Altered descendent component 1");
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 Create( Your_Car, 3 );
kono
parents:
diff changeset
157 TC_Assert( Your_Car.Convertible, "Did not set inherited component 2");
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 My_Car.Convertible := True;
kono
parents:
diff changeset
160 Create( Vehicle( My_Car ), 1 );
kono
parents:
diff changeset
161 TC_Assert( My_Car.Convertible, "Altered descendent component 3");
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 Create( My_Car, 2 );
kono
parents:
diff changeset
164 TC_Assert( not My_Car.Convertible, "Did not set extending component 4");
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 My_Car.Convertible := False;
kono
parents:
diff changeset
167 Start( Vehicle( My_Car ) );
kono
parents:
diff changeset
168 TC_Assert( not My_Car.Convertible , "Altered descendent component 5");
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 Start( My_Car );
kono
parents:
diff changeset
171 TC_Assert( not My_Car.Convertible, "Altered unreferenced component 6");
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 Your_Car.Convertible := False;
kono
parents:
diff changeset
174 Start( Vehicle( Your_Car ) );
kono
parents:
diff changeset
175 TC_Assert( not Your_Car.Convertible , "Altered descendent component 7");
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 Start( Your_Car );
kono
parents:
diff changeset
178 TC_Assert( not Your_Car.Convertible, "Altered unreferenced component 8");
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 My_Car.Convertible := True;
kono
parents:
diff changeset
181 Start( Vehicle( My_Car ) );
kono
parents:
diff changeset
182 TC_Assert( My_Car.Convertible, "Altered descendent component 9");
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 Start( My_Car );
kono
parents:
diff changeset
185 TC_Assert( My_Car.Convertible, "Altered unreferenced component 10");
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 Report.Result;
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 end C392004;