annotate gcc/testsuite/ada/acats/tests/cc/cc51001.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 -- CC51001.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 a formal parameter of a generic package may be a formal
kono
parents:
diff changeset
28 -- derived type. Check that the formal derived type may have an unknown
kono
parents:
diff changeset
29 -- discriminant part. Check that the ancestor type in a formal derived
kono
parents:
diff changeset
30 -- type definition may be a tagged type, and that the actual parameter
kono
parents:
diff changeset
31 -- may be a descendant of the ancestor type. Check that the formal derived
kono
parents:
diff changeset
32 -- type belongs to the derivation class rooted at the ancestor type;
kono
parents:
diff changeset
33 -- specifically, that components of the ancestor type may be referenced
kono
parents:
diff changeset
34 -- within the generic. Check that if a formal derived subtype is
kono
parents:
diff changeset
35 -- indefinite then the actual may be either definite or indefinite.
kono
parents:
diff changeset
36 --
kono
parents:
diff changeset
37 -- TEST DESCRIPTION:
kono
parents:
diff changeset
38 -- Define a class of tagged types with a definite root type. Extend the
kono
parents:
diff changeset
39 -- root type with a discriminated component. Since discriminants of
kono
parents:
diff changeset
40 -- tagged types may not have defaults, the type is indefinite.
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 -- Extend the extension with a second discriminated component, but with
kono
parents:
diff changeset
43 -- a new discriminant part. Declare a generic package with a formal
kono
parents:
diff changeset
44 -- derived type using the root type of the class as ancestor, and an
kono
parents:
diff changeset
45 -- unknown discriminant part. Declare an operation in the generic which
kono
parents:
diff changeset
46 -- accesses the common component of types in the class.
kono
parents:
diff changeset
47 --
kono
parents:
diff changeset
48 -- In the main program, instantiate the generic with each type in the
kono
parents:
diff changeset
49 -- class and verify that the operation correctly accesses the common
kono
parents:
diff changeset
50 -- component.
kono
parents:
diff changeset
51 --
kono
parents:
diff changeset
52 --
kono
parents:
diff changeset
53 -- CHANGE HISTORY:
kono
parents:
diff changeset
54 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
55 --
kono
parents:
diff changeset
56 --!
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 package CC51001_0 is -- Root type for message class.
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 subtype Msg_String is String (1 .. 20);
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 type Msg_Type is tagged record -- Root type of
kono
parents:
diff changeset
63 Text : Msg_String := (others => ' '); -- class (definite).
kono
parents:
diff changeset
64 end record;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 end CC51001_0;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 -- No body for CC51001_0.
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 --==================================================================--
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 with CC51001_0; -- Root type for message class.
kono
parents:
diff changeset
76 package CC51001_1 is -- Extensions to message class.
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 subtype Source_Length is Natural range 0 .. 10;
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 type From_Msg_Type (SLen : Source_Length) is -- Direct derivative
kono
parents:
diff changeset
81 new CC51001_0.Msg_Type with record -- of root type
kono
parents:
diff changeset
82 From : String (1 .. SLen); -- (indefinite).
kono
parents:
diff changeset
83 end record;
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 subtype Dest_Length is Natural range 0 .. 10;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 type To_From_Msg_Type (DLen : Dest_Length) is -- Indirect
kono
parents:
diff changeset
90 new From_Msg_Type (SLen => 10) with record -- derivative of
kono
parents:
diff changeset
91 To : String (1 .. DLen); -- root type
kono
parents:
diff changeset
92 end record; -- (indefinite).
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 end CC51001_1;
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 -- No body for CC51001_1.
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 --==================================================================--
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 with CC51001_0; -- Root type for message class.
kono
parents:
diff changeset
104 generic -- I/O operations for message class.
kono
parents:
diff changeset
105 type Message_Type (<>) is new CC51001_0.Msg_Type with private;
kono
parents:
diff changeset
106 package CC51001_2 is
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 -- This subprogram contains an artificial result for testing purposes:
kono
parents:
diff changeset
109 -- the function returns the text of the message to the caller as a string.
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 function Print_Message (M : in Message_Type) return String;
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 -- ... Other operations.
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 end CC51001_2;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 --==================================================================--
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 package body CC51001_2 is
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 -- The implementations of the operations below are purely artificial; the
kono
parents:
diff changeset
124 -- validity of their implementations in the context of the abstraction is
kono
parents:
diff changeset
125 -- irrelevant to the feature being tested.
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 function Print_Message (M : in Message_Type) return String is
kono
parents:
diff changeset
128 begin
kono
parents:
diff changeset
129 return M.Text;
kono
parents:
diff changeset
130 end Print_Message;
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 end CC51001_2;
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 --==================================================================--
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 with CC51001_0; -- Root type for message class.
kono
parents:
diff changeset
139 with CC51001_1; -- Extensions to message class.
kono
parents:
diff changeset
140 with CC51001_2; -- I/O operations for message class.
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 with Report;
kono
parents:
diff changeset
143 procedure CC51001 is
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 -- Instantiate for various types in the class:
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 package Msgs is new CC51001_2 (CC51001_0.Msg_Type); -- Definite.
kono
parents:
diff changeset
148 package FMsgs is new CC51001_2 (CC51001_1.From_Msg_Type); -- Indefinite.
kono
parents:
diff changeset
149 package TFMsgs is new CC51001_2 (CC51001_1.To_From_Msg_Type); -- Indefinite.
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 Msg : CC51001_0.Msg_Type := (Text => "This is message #001");
kono
parents:
diff changeset
154 FMsg : CC51001_1.From_Msg_Type := (Text => "This is message #002",
kono
parents:
diff changeset
155 SLen => 2,
kono
parents:
diff changeset
156 From => "Me");
kono
parents:
diff changeset
157 TFMsg : CC51001_1.To_From_Msg_Type := (Text => "This is message #003",
kono
parents:
diff changeset
158 From => "You ",
kono
parents:
diff changeset
159 DLen => 4,
kono
parents:
diff changeset
160 To => "Them");
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 Expected_Msg : constant String := "This is message #001";
kono
parents:
diff changeset
163 Expected_FMsg : constant String := "This is message #002";
kono
parents:
diff changeset
164 Expected_TFMsg : constant String := "This is message #003";
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 begin
kono
parents:
diff changeset
167 Report.Test ("CC51001", "Check that the formal derived type may have " &
kono
parents:
diff changeset
168 "an unknown discriminant part. Check that the ancestor " &
kono
parents:
diff changeset
169 "type in a formal derived type definition may be a " &
kono
parents:
diff changeset
170 "tagged type, and that the actual parameter may be any " &
kono
parents:
diff changeset
171 "definite or indefinite descendant of the ancestor type");
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 if (Msgs.Print_Message (Msg) /= Expected_Msg) then
kono
parents:
diff changeset
174 Report.Failed ("Wrong result for definite root type");
kono
parents:
diff changeset
175 end if;
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 if (FMsgs.Print_Message (FMsg) /= Expected_FMsg) then
kono
parents:
diff changeset
178 Report.Failed ("Wrong result for direct indefinite derivative");
kono
parents:
diff changeset
179 end if;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 if (TFMsgs.Print_Message (TFMsg) /= Expected_TFMsg) then
kono
parents:
diff changeset
182 Report.Failed ("Wrong result for Indirect indefinite derivative");
kono
parents:
diff changeset
183 end if;
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 Report.Result;
kono
parents:
diff changeset
186 end CC51001;