annotate gcc/testsuite/ada/acats/tests/c3/c392c07.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 -- C392C07.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 for a call to a dispatching subprogram the subprogram
kono
parents:
diff changeset
28 -- body which is executed is determined by the controlling tag for
kono
parents:
diff changeset
29 -- the case where the call has dynamic tagged controlling operands
kono
parents:
diff changeset
30 -- of the type T. Check for calls to these same subprograms where
kono
parents:
diff changeset
31 -- the operands are of specific statically tagged types:
kono
parents:
diff changeset
32 -- objects (declared or allocated), formal parameters, view
kono
parents:
diff changeset
33 -- conversions, and function calls (both primitive and non-primitive).
kono
parents:
diff changeset
34 --
kono
parents:
diff changeset
35 -- TEST DESCRIPTION:
kono
parents:
diff changeset
36 -- This test uses foundation F392C00 to test the usages of statically
kono
parents:
diff changeset
37 -- tagged objects and values. This test is derived in part from
kono
parents:
diff changeset
38 -- C392C05.
kono
parents:
diff changeset
39 --
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 -- CHANGE HISTORY:
kono
parents:
diff changeset
42 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
43 -- 24 Oct 95 SAIC Updated for ACVC 2.0.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 TCTouch;
kono
parents:
diff changeset
49 with F392C00_1;
kono
parents:
diff changeset
50 procedure C392C07 is -- Hardware_Store
kono
parents:
diff changeset
51 package Switch renames F392C00_1;
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 subtype Switch_Class is Switch.Toggle'Class;
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 type Reference is access all Switch_Class;
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 A_Switch : aliased Switch.Toggle;
kono
parents:
diff changeset
58 A_Dimmer : aliased Switch.Dimmer;
kono
parents:
diff changeset
59 An_Autodim : aliased Switch.Auto_Dimmer;
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 type Light_Bank is array(Positive range <>) of Reference;
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 Lamps : Light_Bank(1..3);
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 -- dynamically tagged controlling operands : class wide formal parameters
kono
parents:
diff changeset
66 procedure Clamp( Device : in out Switch_Class; On : Boolean := False ) is
kono
parents:
diff changeset
67 begin
kono
parents:
diff changeset
68 if Switch.On( Device ) /= On then
kono
parents:
diff changeset
69 Switch.Flip( Device );
kono
parents:
diff changeset
70 end if;
kono
parents:
diff changeset
71 end Clamp;
kono
parents:
diff changeset
72 function Class_Item(Bank_Pos: Positive) return Switch_Class is
kono
parents:
diff changeset
73 begin
kono
parents:
diff changeset
74 return Lamps(Bank_Pos).all;
kono
parents:
diff changeset
75 end Class_Item;
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 begin -- Main test procedure.
kono
parents:
diff changeset
78 Report.Test ("C392C07", "Check that a dispatching subprogram call is "
kono
parents:
diff changeset
79 & "determined by the controlling tag for "
kono
parents:
diff changeset
80 & "dynamically tagged controlling operands" );
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 Lamps := ( A_Switch'Access, A_Dimmer'Access, An_Autodim'Access );
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 -- dynamically tagged operands referring to
kono
parents:
diff changeset
85 -- statically tagged declared objects
kono
parents:
diff changeset
86 for Knob in Lamps'Range loop
kono
parents:
diff changeset
87 Clamp( Lamps(Knob).all, On => True );
kono
parents:
diff changeset
88 end loop;
kono
parents:
diff changeset
89 TCTouch.Validate( "BABGBABKGBA", "Clamping On Lamps" );
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 Lamps(1) := new Switch.Toggle;
kono
parents:
diff changeset
92 Lamps(2) := new Switch.Dimmer;
kono
parents:
diff changeset
93 Lamps(3) := new Switch.Auto_Dimmer;
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 -- turn the full bank of switches ON
kono
parents:
diff changeset
96 -- dynamically tagged allocated objects
kono
parents:
diff changeset
97 for Knob in Lamps'Range loop
kono
parents:
diff changeset
98 Clamp( Lamps(Knob).all, On => True );
kono
parents:
diff changeset
99 end loop;
kono
parents:
diff changeset
100 TCTouch.Validate( "BABGBABKGBA", "Dynamic Allocated");
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 -- Double check execution correctness
kono
parents:
diff changeset
103 if Switch.Off( Lamps(1).all )
kono
parents:
diff changeset
104 or Switch.Off( Lamps(2).all )
kono
parents:
diff changeset
105 or Switch.Off( Lamps(3).all ) then
kono
parents:
diff changeset
106 Report.Failed( "Bad Value" );
kono
parents:
diff changeset
107 end if;
kono
parents:
diff changeset
108 TCTouch.Validate( "CCC", "Class-wide");
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 -- turn the full bank of switches OFF
kono
parents:
diff changeset
111 for Knob in Lamps'Range loop
kono
parents:
diff changeset
112 Switch.Flip( Lamps(Knob).all );
kono
parents:
diff changeset
113 end loop;
kono
parents:
diff changeset
114 TCTouch.Validate( "AGBAKGBA", "Dynamic Allocated, Primitive Ops");
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 -- check switches for OFF
kono
parents:
diff changeset
117 -- a few function calls as operands
kono
parents:
diff changeset
118 for Knob in Lamps'Range loop
kono
parents:
diff changeset
119 if not Switch.Off( Class_Item(Knob) ) then
kono
parents:
diff changeset
120 Report.Failed("At function tests, Switch not OFF");
kono
parents:
diff changeset
121 end if;
kono
parents:
diff changeset
122 end loop;
kono
parents:
diff changeset
123 TCTouch.Validate( "CCC",
kono
parents:
diff changeset
124 "Using function returning class-wide type");
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 -- Switches are all OFF now.
kono
parents:
diff changeset
127 -- dynamically tagged view conversion
kono
parents:
diff changeset
128 Clamp( Switch_Class( A_Switch ) );
kono
parents:
diff changeset
129 Clamp( Switch_Class( A_Dimmer ) );
kono
parents:
diff changeset
130 Clamp( Switch_Class( An_Autodim ) );
kono
parents:
diff changeset
131 TCTouch.Validate( "BABGBABKGBA", "View Conversions" );
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 -- dynamically tagged controlling operands : declared class wide objects
kono
parents:
diff changeset
134 -- calling primitive functions
kono
parents:
diff changeset
135 declare
kono
parents:
diff changeset
136 Dine_O_Might : Switch_Class := Switch.TC_CW_TI( 't' );
kono
parents:
diff changeset
137 begin
kono
parents:
diff changeset
138 Switch.Flip( Dine_O_Might );
kono
parents:
diff changeset
139 if Switch.On( Dine_O_Might ) then
kono
parents:
diff changeset
140 Report.Failed( "Exploded at Dine_O_Might" );
kono
parents:
diff changeset
141 end if;
kono
parents:
diff changeset
142 TCTouch.Validate( "WAB", "Dispatching function 1" );
kono
parents:
diff changeset
143 end;
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 declare
kono
parents:
diff changeset
146 Dyne_A_Mite : Switch_Class := Switch.TC_CW_TI( 'd' );
kono
parents:
diff changeset
147 begin
kono
parents:
diff changeset
148 Switch.Flip( Dyne_A_Mite );
kono
parents:
diff changeset
149 if Switch.On( Dyne_A_Mite ) then
kono
parents:
diff changeset
150 Report.Failed( "Exploded at Dyne_A_Mite" );
kono
parents:
diff changeset
151 end if;
kono
parents:
diff changeset
152 TCTouch.Validate( "WGBAB", "Dispatching function 2" );
kono
parents:
diff changeset
153 end;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 declare
kono
parents:
diff changeset
156 Din_Um_Out : Switch_Class := Switch.TC_CW_TI( 'a' );
kono
parents:
diff changeset
157 begin
kono
parents:
diff changeset
158 Switch.Flip( Din_Um_Out );
kono
parents:
diff changeset
159 if Switch.Off( Din_Um_Out ) then
kono
parents:
diff changeset
160 Report.Failed( "Exploded at Din_Um_Out" );
kono
parents:
diff changeset
161 end if;
kono
parents:
diff changeset
162 TCTouch.Validate( "WKCC", "Dispatching function 3" );
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 -- Non-dispatching function calls.
kono
parents:
diff changeset
165 if not Switch.TC_Non_Disp( Switch.Toggle( Din_Um_Out ) ) then
kono
parents:
diff changeset
166 Report.Failed( "Non primitive, via view conversion" );
kono
parents:
diff changeset
167 end if;
kono
parents:
diff changeset
168 TCTouch.Validate( "X", "View Conversion 1" );
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 if not Switch.TC_Non_Disp( Switch.Dimmer( Din_Um_Out ) ) then
kono
parents:
diff changeset
171 Report.Failed( "Non primitive, via view conversion" );
kono
parents:
diff changeset
172 end if;
kono
parents:
diff changeset
173 TCTouch.Validate( "Y", "View Conversion 2" );
kono
parents:
diff changeset
174 end;
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 -- a few more function calls as operands (oops)
kono
parents:
diff changeset
177 if not Switch.On( Switch.Toggle'( Switch.Create ) ) then
kono
parents:
diff changeset
178 Report.Failed("Toggle did not create ""On""");
kono
parents:
diff changeset
179 end if;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 if Switch.Off( Switch.Dimmer'( Switch.Create ) ) then
kono
parents:
diff changeset
182 Report.Failed("Dimmer created ""Off""");
kono
parents:
diff changeset
183 end if;
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 if Switch.Off( Switch.Auto_Dimmer'( Switch.Create ) ) then
kono
parents:
diff changeset
186 Report.Failed("Auto_Dimmer created ""Off""");
kono
parents:
diff changeset
187 end if;
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 Report.Result;
kono
parents:
diff changeset
190 end C392C07;