annotate gcc/testsuite/ada/acats/tests/cc/cc51004.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 -- CC51004.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 if the ancestor type of a formal derived type is a composite
kono
parents:
diff changeset
28 -- type that is not an array type, the formal type inherits components,
kono
parents:
diff changeset
29 -- including discriminants, from the ancestor type.
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- Check for the case where the ancestor type is a tagged type, and the
kono
parents:
diff changeset
32 -- formal derived type is declared in a generic subprogram.
kono
parents:
diff changeset
33 --
kono
parents:
diff changeset
34 -- TEST DESCRIPTION:
kono
parents:
diff changeset
35 -- Define a discriminated tagged type in a package. Declare a
kono
parents:
diff changeset
36 -- library-level generic subprogram with a formal derived type using the
kono
parents:
diff changeset
37 -- tagged type as ancestor. Give the generic subprogram an in out
kono
parents:
diff changeset
38 -- parameter of the formal derived type. Inside the generic, use the
kono
parents:
diff changeset
39 -- discriminant component and modify the remaining components of the
kono
parents:
diff changeset
40 -- tagged parameter. In the main program, declare tagged record objects
kono
parents:
diff changeset
41 -- with two different discriminant values. Derive an indefinite type from
kono
parents:
diff changeset
42 -- the tagged type with a new discriminant part. Instantiate the
kono
parents:
diff changeset
43 -- generic subprogram for the root tagged subtype and the derived subtype.
kono
parents:
diff changeset
44 -- Call the root subtype instance with actual parameters having the two
kono
parents:
diff changeset
45 -- discriminant values. Also call the derived subtype instance with an
kono
parents:
diff changeset
46 -- appropriate actual.
kono
parents:
diff changeset
47 --
kono
parents:
diff changeset
48 --
kono
parents:
diff changeset
49 -- CHANGE HISTORY:
kono
parents:
diff changeset
50 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
51 -- 05 Jan 94 SAIC Removed unknown discriminant part from formal
kono
parents:
diff changeset
52 -- derived type. Moved declaration of type
kono
parents:
diff changeset
53 -- New_Dbl_Sq from main subprogram to CC51004_0.
kono
parents:
diff changeset
54 -- 05 Nov 95 SAIC ACVC 2.0.1 fixes: Removed constrained subtype
kono
parents:
diff changeset
55 -- instantiation and associated declarations.
kono
parents:
diff changeset
56 -- Modified commentary.
kono
parents:
diff changeset
57 --
kono
parents:
diff changeset
58 --!
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 -- Simulate a fragment of a matrix manipulation application.
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 package CC51004_0 is -- Matrix types.
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 type Matrix is array (Natural range <>, Natural range <>) of Integer;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 type Square (Side : Natural) is record
kono
parents:
diff changeset
67 Mat : Matrix (1 .. Side, 1 .. Side);
kono
parents:
diff changeset
68 end record;
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 type Sq_Type (Num1 : Natural) is tagged record
kono
parents:
diff changeset
71 One : Square (Num1);
kono
parents:
diff changeset
72 end record;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 -- Extended type with new discriminant part (which constrains parent):
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 type New_Dbl_Sq (Num2 : Natural) is new Sq_Type(Num2) with record
kono
parents:
diff changeset
77 Two : Square (Num2);
kono
parents:
diff changeset
78 end record;
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 end CC51004_0;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 -- No body for CC51004_0;
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 --==================================================================--
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 with CC51004_0; -- Matrix types.
kono
parents:
diff changeset
90 generic -- Generic matrix "clear" operation.
kono
parents:
diff changeset
91 type Squares is new CC51004_0.Sq_Type with private; -- Indefinite
kono
parents:
diff changeset
92 procedure CC51004_1 (Sq : in out Squares); -- formal.
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 --==================================================================--
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 procedure CC51004_1 (Sq : in out Squares) is
kono
parents:
diff changeset
99 begin
kono
parents:
diff changeset
100 for I in 1 .. Sq.Num1 loop -- Discriminants inherited from ancestor
kono
parents:
diff changeset
101 for J in 1 .. Sq.Num1 loop -- type (should work even for derived type
kono
parents:
diff changeset
102 -- declaring new discriminant part).
kono
parents:
diff changeset
103 Sq.One.Mat (I, J) := 0; -- Other components inherited from
kono
parents:
diff changeset
104 -- ancestor type.
kono
parents:
diff changeset
105 end loop;
kono
parents:
diff changeset
106 end loop;
kono
parents:
diff changeset
107 end CC51004_1;
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 --==================================================================--
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 with CC51004_0; -- Matrix types.
kono
parents:
diff changeset
114 with CC51004_1; -- Generic double-matrix "clear" operation.
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 with Report;
kono
parents:
diff changeset
117 procedure CC51004 is
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 use CC51004_0; -- "/=" operator directly visible for Sq_Type.
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 -- Matrices of root type:
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 Mat_2x2 : Square(Side => 2) := (Side => 2, Mat => ( (1, 2), (3, 4) ));
kono
parents:
diff changeset
124 One_Mat_2x2 : Sq_Type(Num1 => 2) := (2, Mat_2x2);
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 Zero_2x2 : constant Square(2) := (2, Mat => ( (0, 0), (0, 0) ));
kono
parents:
diff changeset
127 Expected_2x2 : constant Sq_Type(2) := (Num1 => 2, One => Zero_2x2);
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 Mat_3x3 : Square(Side => 3) := (Side => 3,
kono
parents:
diff changeset
131 Mat => (1 => (5, 2, 7),
kono
parents:
diff changeset
132 others => (1 => 4,
kono
parents:
diff changeset
133 others => 9)));
kono
parents:
diff changeset
134 One_Mat_3x3 : Sq_Type(3) := (Num1 => 3, One => Mat_3x3);
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 Zero_3x3 : constant Square(3) := (3, Mat => (others => (0,0,0)));
kono
parents:
diff changeset
137 Expected_3x3 : constant Sq_Type(Num1 => 3) := (3, Zero_3x3);
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 New_Dbl_2x2 : New_Dbl_Sq(Num2 => 2) := (2, others => Mat_2x2);
kono
parents:
diff changeset
141 Expected_New_2x2 : constant New_Dbl_Sq := (2, Zero_2x2, Mat_2x2);
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 -- Instantiations:
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 procedure Clr_Mat is new CC51004_1 (Sq_Type);
kono
parents:
diff changeset
148 procedure Clr_New_Dbl is new CC51004_1 (New_Dbl_Sq);
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 begin
kono
parents:
diff changeset
152 Report.Test ("CC51004", "Check that a formal derived tagged type " &
kono
parents:
diff changeset
153 "inherits components, including discriminants, " &
kono
parents:
diff changeset
154 "from its ancestor type");
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 -- Simulate use of matrix manipulation operations.
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 Clr_Mat (One_Mat_2x2);
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 if (One_Mat_2x2 /= Expected_2x2) then
kono
parents:
diff changeset
162 Report.Failed ("Wrong result root type (2x2 matrix)");
kono
parents:
diff changeset
163 end if;
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 Clr_Mat (One_Mat_3x3);
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 if (One_Mat_3x3 /= Expected_3x3) then
kono
parents:
diff changeset
169 Report.Failed ("Wrong result root type (3x3 matrix)");
kono
parents:
diff changeset
170 end if;
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 Clr_New_Dbl (New_Dbl_2x2);
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 if (New_Dbl_2x2 /= Expected_New_2x2) then
kono
parents:
diff changeset
176 Report.Failed ("Wrong result extended type (2x2 matrix)");
kono
parents:
diff changeset
177 end if;
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 Report.Result;
kono
parents:
diff changeset
181 end CC51004;