annotate gcc/testsuite/ada/acats/tests/c3/c390002.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 -- C390002.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 tagged base type may be declared, and derived
kono
parents:
diff changeset
28 -- from in simple, private and extended forms. (Overlaps with C390B04)
kono
parents:
diff changeset
29 -- Check that the package Ada.Tags is present and correctly implemented.
kono
parents:
diff changeset
30 -- Check for the correct operation of Expanded_Name, External_Tag and
kono
parents:
diff changeset
31 -- Internal_Tag within that package. Check that the exception Tag_Error
kono
parents:
diff changeset
32 -- is correctly raised on calling Internal_Tag with bad input.
kono
parents:
diff changeset
33 --
kono
parents:
diff changeset
34 -- TEST DESCRIPTION:
kono
parents:
diff changeset
35 -- This test declares a tagged type, and derives three types from it.
kono
parents:
diff changeset
36 -- These types are then used to test the presence and function of the
kono
parents:
diff changeset
37 -- package Ada.Tags.
kono
parents:
diff changeset
38 --
kono
parents:
diff changeset
39 --
kono
parents:
diff changeset
40 -- CHANGE HISTORY:
kono
parents:
diff changeset
41 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
42 -- 19 Dec 94 SAIC Removed RM references from objective text.
kono
parents:
diff changeset
43 -- 27 Jan 96 SAIC Update RM references for 2.1
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 --!
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 with Report;
kono
parents:
diff changeset
48 with Ada.Tags;
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 procedure C390002 is
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 package Vehicle is
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 type Object is tagged limited private; -- ancestor type
kono
parents:
diff changeset
55 procedure Create( The_Vehicle : in out Object; Wheels : in Natural );
kono
parents:
diff changeset
56 function Wheels( The_Vehicle : Object ) return Natural;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 private
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 type Object is tagged limited record
kono
parents:
diff changeset
61 Wheel_Count : Natural := 0;
kono
parents:
diff changeset
62 end record;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 end Vehicle;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 package Motivators is
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 type Bicycle is new Vehicle.Object with null record; -- simple
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 type Car is new Vehicle.Object with record -- extended
kono
parents:
diff changeset
71 Convertible : Boolean;
kono
parents:
diff changeset
72 end record;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 type Truck is new Vehicle.Object with private; -- private
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 private
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 type Truck is new Vehicle.Object with record
kono
parents:
diff changeset
79 Air_Horn : Boolean;
kono
parents:
diff changeset
80 end record;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 end Motivators;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 package body Vehicle is
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 procedure Create( The_Vehicle : in out Object; Wheels : in Natural ) is
kono
parents:
diff changeset
87 begin
kono
parents:
diff changeset
88 The_Vehicle.Wheel_Count := Wheels;
kono
parents:
diff changeset
89 end Create;
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 function Wheels( The_Vehicle : Object ) return Natural is
kono
parents:
diff changeset
92 begin
kono
parents:
diff changeset
93 return The_Vehicle.Wheel_Count;
kono
parents:
diff changeset
94 end Wheels;
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 end Vehicle;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 function TC_ID_Tag( Tag : in Ada.Tags.Tag ) return Ada.Tags.Tag is
kono
parents:
diff changeset
99 begin
kono
parents:
diff changeset
100 return Ada.Tags.Internal_Tag( Ada.Tags.External_Tag( Tag ) );
kono
parents:
diff changeset
101 Report.Comment("This message intentionally blank.");
kono
parents:
diff changeset
102 end TC_ID_Tag;
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 procedure Check_Tags( Machine : in Vehicle.Object'Class;
kono
parents:
diff changeset
105 Expected_Name : in String;
kono
parents:
diff changeset
106 External_Tag : in String ) is
kono
parents:
diff changeset
107 The_Tag : constant Ada.Tags.Tag := Machine'Tag;
kono
parents:
diff changeset
108 use type Ada.Tags.Tag;
kono
parents:
diff changeset
109 begin
kono
parents:
diff changeset
110 if Ada.Tags.Expanded_Name(The_Tag) /= Expected_Name then
kono
parents:
diff changeset
111 Report.Failed ("Failed in Check_Tags, Expanded_Name "
kono
parents:
diff changeset
112 & Expected_Name);
kono
parents:
diff changeset
113 end if;
kono
parents:
diff changeset
114 if Ada.Tags.External_Tag(The_Tag) /= External_Tag then
kono
parents:
diff changeset
115 Report.Failed ("Failed in Check_Tags, External_Tag "
kono
parents:
diff changeset
116 & Expected_Name);
kono
parents:
diff changeset
117 end if;
kono
parents:
diff changeset
118 if Ada.Tags.Internal_Tag(External_Tag) /= The_Tag then
kono
parents:
diff changeset
119 Report.Failed ("Failed in Check_Tags, Internal_Tag "
kono
parents:
diff changeset
120 & Expected_Name);
kono
parents:
diff changeset
121 end if;
kono
parents:
diff changeset
122 end Check_Tags;
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 procedure Check_Exception is
kono
parents:
diff changeset
125 Boeing_777_Id : Ada.Tags.Tag;
kono
parents:
diff changeset
126 begin
kono
parents:
diff changeset
127 Boeing_777_Id := Ada.Tags.Internal_Tag("!@#$%^:*\/?"" not a tag!");
kono
parents:
diff changeset
128 Report.Failed ("Failed in Check_Exception, no exception");
kono
parents:
diff changeset
129 Boeing_777_Id := TC_ID_Tag( Boeing_777_Id );
kono
parents:
diff changeset
130 exception
kono
parents:
diff changeset
131 when Ada.Tags.Tag_Error => null;
kono
parents:
diff changeset
132 when others =>
kono
parents:
diff changeset
133 Report.Failed ("Failed in Check_Exception, wrong exception");
kono
parents:
diff changeset
134 end Check_Exception;
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 use Motivators;
kono
parents:
diff changeset
137 Two_Wheeler : Bicycle;
kono
parents:
diff changeset
138 Four_Wheeler : Car;
kono
parents:
diff changeset
139 Eighteen_Wheeler : Truck;
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 begin -- Main test procedure.
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 Report.Test ("C390002", "Check that a tagged type may be declared and " &
kono
parents:
diff changeset
144 "derived from in simple, private and extended forms. " &
kono
parents:
diff changeset
145 "Check package Ada.Tags" );
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 Create( Two_Wheeler, 2 );
kono
parents:
diff changeset
148 Create( Four_Wheeler, 4 );
kono
parents:
diff changeset
149 Create( Eighteen_Wheeler, 18 );
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 Check_Tags( Machine => Two_Wheeler,
kono
parents:
diff changeset
152 Expected_Name => "C390002.MOTIVATORS.BICYCLE",
kono
parents:
diff changeset
153 External_Tag => Bicycle'External_Tag );
kono
parents:
diff changeset
154 Check_Tags( Machine => Four_Wheeler,
kono
parents:
diff changeset
155 Expected_Name => "C390002.MOTIVATORS.CAR",
kono
parents:
diff changeset
156 External_Tag => Car'External_Tag );
kono
parents:
diff changeset
157 Check_Tags( Machine => Eighteen_Wheeler,
kono
parents:
diff changeset
158 Expected_Name => "C390002.MOTIVATORS.TRUCK",
kono
parents:
diff changeset
159 External_Tag => Truck'External_Tag );
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 Check_Exception;
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 Report.Result;
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 end C390002;