Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / ada / acats / tests / c3 / c3a0001.a
blobf8a0681e78f868bb58a8321f6655fe8e12482f37
1 -- C3A0001.A
2 --
3 -- Grant of Unlimited Rights
4 --
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
14 -- to do so.
16 -- DISCLAIMER
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
24 --*
26 -- OBJECTIVE:
27 -- Check that access to subprogram type can be used to select and
28 -- invoke functions with appropriate arguments dynamically.
30 -- TEST DESCRIPTION:
31 -- Declare an access to function type in a package specification.
32 -- Declare three different sine functions that can be referred to by
33 -- the access to function type.
34 --
35 -- In the main program, call each function indirectly by dereferencing
36 -- the access value.
39 -- CHANGE HISTORY:
40 -- 06 Dec 94 SAIC ACVC 2.0
42 --!
44 package C3A0001_0 is
46 TC_Call_Tag : Natural := 0;
48 -- Type accesses to any sine function
49 type Sine_Function_Ptr is access function
50 (Angle : in Float) return Float;
52 -- Three 'Sine' functions that model an application situation in which
53 -- one function might be chosen when speed is important, another (using
54 -- a different algorithm) might be chosen when accuracy is important,
55 -- and so on.
57 function Sine_Calc_Fast (Angle : in Float) return Float;
59 function Sine_Calc_Acc (Angle : in Float) return Float;
61 function Sine_Calc_Table (Angle : in Float) return Float;
63 end C3A0001_0;
66 -----------------------------------------------------------------------------
69 package body C3A0001_0 is
71 function Sine_Calc_Fast (Angle : in Float) return Float is
72 begin
73 TC_Call_Tag := 1;
74 return 1.0;
75 end Sine_Calc_Fast;
78 function Sine_Calc_Acc (Angle : in Float) return Float is
79 begin
80 TC_Call_Tag := 2;
81 return 0.0;
82 end Sine_Calc_Acc;
85 function Sine_Calc_Table (Angle : in Float) return Float is
86 begin
87 TC_Call_Tag := 3;
88 return -1.0;
89 end Sine_Calc_Table;
91 end C3A0001_0;
93 -----------------------------------------------------------------------------
95 with Report;
96 with C3A0001_0;
98 procedure C3A0001 is
100 Sine_Access : C3A0001_0.Sine_Function_Ptr;
101 X, Theta : Float := 0.0;
103 begin
105 Report.Test ("C3A0001", "Check that access to subprogram can be " &
106 "used to select and invoke an operation with " &
107 "appropriate arguments dynamically");
109 Sine_Access := C3A0001_0.Sine_Calc_Fast'Access;
111 -- Invoking Sine function designated by access value
112 X := Sine_Access(Theta);
114 If C3A0001_0.TC_Call_Tag /= 1 then
115 Report.Failed ("Incorrect Sine_Calc_Fast result");
116 end if;
118 Sine_Access := C3A0001_0.Sine_Calc_Acc'Access;
120 -- Invoking Sine function designated by access value
121 X := Sine_Access(Theta);
123 If C3A0001_0.TC_Call_Tag /= 2 then
124 Report.Failed ("Incorrect Sine_Calc_Acc result");
125 end if;
127 Sine_Access := C3A0001_0.Sine_Calc_Table'Access;
129 -- Invoking Sine function designated by access value
130 X := Sine_Access(Theta);
132 If C3A0001_0.TC_Call_Tag /= 3 then
133 Report.Failed ("Incorrect Sine_Calc_Table result");
134 end if;
136 Report.Result;
138 end C3A0001;