-- C490003.A
|
-- C490003.A
|
--
|
--
|
-- Grant of Unlimited Rights
|
-- Grant of Unlimited Rights
|
--
|
--
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- unlimited rights in the software and documentation contained herein.
|
-- unlimited rights in the software and documentation contained herein.
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- this public release, the Government intends to confer upon all
|
-- this public release, the Government intends to confer upon all
|
-- recipients unlimited rights equal to those held by the Government.
|
-- recipients unlimited rights equal to those held by the Government.
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- released technical data and computer software in whole or in part, in
|
-- released technical data and computer software in whole or in part, in
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- to do so.
|
-- to do so.
|
--
|
--
|
-- DISCLAIMER
|
-- DISCLAIMER
|
--
|
--
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
--*
|
--*
|
--
|
--
|
-- OBJECTIVE:
|
-- OBJECTIVE:
|
-- Check that a static expression is legal if its evaluation fails
|
-- Check that a static expression is legal if its evaluation fails
|
-- no language-defined check other than Overflow_Check. Check that such
|
-- no language-defined check other than Overflow_Check. Check that such
|
-- a static expression is legal if it is part of a larger static
|
-- a static expression is legal if it is part of a larger static
|
-- expression, even if its value is outside the base range of the
|
-- expression, even if its value is outside the base range of the
|
-- expected type.
|
-- expected type.
|
--
|
--
|
-- Check that if a static expression is part of the right operand of a
|
-- Check that if a static expression is part of the right operand of a
|
-- short circuit control form whose value is determined by its left
|
-- short circuit control form whose value is determined by its left
|
-- operand, it is not evaluated.
|
-- operand, it is not evaluated.
|
--
|
--
|
-- Check that a static expression in a non-static context is evaluated
|
-- Check that a static expression in a non-static context is evaluated
|
-- exactly.
|
-- exactly.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- The first part of the objective is tested by constructing static
|
-- The first part of the objective is tested by constructing static
|
-- expressions which involve predefined operations of integer, floating
|
-- expressions which involve predefined operations of integer, floating
|
-- point, and fixed point subtypes. Intermediate expressions within the
|
-- point, and fixed point subtypes. Intermediate expressions within the
|
-- static expressions have values outside the base range of the expected
|
-- static expressions have values outside the base range of the expected
|
-- type. In one case, the extended-range intermediates are compared as
|
-- type. In one case, the extended-range intermediates are compared as
|
-- part of a boolean expression. In the remaining two cases, further
|
-- part of a boolean expression. In the remaining two cases, further
|
-- predefined operations on the intermediates bring the final result
|
-- predefined operations on the intermediates bring the final result
|
-- within the base range. An implementation which compiles these static
|
-- within the base range. An implementation which compiles these static
|
-- expressions satisfies this portion of the objective. A check is
|
-- expressions satisfies this portion of the objective. A check is
|
-- performed at run-time to ensure that the static expressions evaluate
|
-- performed at run-time to ensure that the static expressions evaluate
|
-- to values within the base range of their respective expected types.
|
-- to values within the base range of their respective expected types.
|
--
|
--
|
-- The second part of the objective is tested by constructing
|
-- The second part of the objective is tested by constructing
|
-- short-circuit control forms whose left operands have the values
|
-- short-circuit control forms whose left operands have the values
|
-- shown below:
|
-- shown below:
|
--
|
--
|
-- (TRUE) or else (...)
|
-- (TRUE) or else (...)
|
-- (FALSE) and then (...)
|
-- (FALSE) and then (...)
|
--
|
--
|
-- In both cases the left operand determines the value of the condition.
|
-- In both cases the left operand determines the value of the condition.
|
-- In the test each right operand involves a division by zero, which will
|
-- In the test each right operand involves a division by zero, which will
|
-- raise Constraint_Error if evaluated. A check is made that no exception
|
-- raise Constraint_Error if evaluated. A check is made that no exception
|
-- is raised when each short-circuit control form is evaluated, and that
|
-- is raised when each short-circuit control form is evaluated, and that
|
-- the value of the condition is that of the left operand.
|
-- the value of the condition is that of the left operand.
|
--
|
--
|
-- The third part of the objective is tested by evaluating static
|
-- The third part of the objective is tested by evaluating static
|
-- expressions involving many operations in contexts which do not
|
-- expressions involving many operations in contexts which do not
|
-- require a static expression, and verifying that the exact
|
-- require a static expression, and verifying that the exact
|
-- mathematical results are calculated.
|
-- mathematical results are calculated.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 15 Sep 95 SAIC Initial prerelease version for ACVC 2.1.
|
-- 15 Sep 95 SAIC Initial prerelease version for ACVC 2.1.
|
-- 20 Oct 96 SAIC Modified expressions in C490003_0 to avoid
|
-- 20 Oct 96 SAIC Modified expressions in C490003_0 to avoid
|
-- the use of universal operands.
|
-- the use of universal operands.
|
--
|
--
|
--!
|
--!
|
|
|
with System;
|
with System;
|
package C490003_0 is
|
package C490003_0 is
|
|
|
type My_Flt is digits System.Max_Digits;
|
type My_Flt is digits System.Max_Digits;
|
|
|
Flt_Range_Diff : My_Flt := (My_Flt'Base'Last - My_Flt'Base'First) -
|
Flt_Range_Diff : My_Flt := (My_Flt'Base'Last - My_Flt'Base'First) -
|
(My_Flt'Last - My_Flt'First); -- OK.
|
(My_Flt'Last - My_Flt'First); -- OK.
|
|
|
|
|
type My_Fix is delta 0.125 range -128.0 .. 128.0;
|
type My_Fix is delta 0.125 range -128.0 .. 128.0;
|
|
|
Symmetric : Boolean := (My_Fix'Base'Last - My_Fix'Base'First) =
|
Symmetric : Boolean := (My_Fix'Base'Last - My_Fix'Base'First) =
|
(My_Fix'Base'Last + My_Fix'Base'Last); -- OK.
|
(My_Fix'Base'Last + My_Fix'Base'Last); -- OK.
|
|
|
|
|
Center : constant Integer := Integer'Base'Last -
|
Center : constant Integer := Integer'Base'Last -
|
(Integer'Base'Last -
|
(Integer'Base'Last -
|
Integer'Base'First) / 2; -- OK.
|
Integer'Base'First) / 2; -- OK.
|
|
|
end C490003_0;
|
end C490003_0;
|
|
|
|
|
--==================================================================--
|
--==================================================================--
|
|
|
|
|
with Ada.Numerics;
|
with Ada.Numerics;
|
package C490003_1 is
|
package C490003_1 is
|
|
|
Zero : constant := 0.0;
|
Zero : constant := 0.0;
|
Pi : constant := Ada.Numerics.Pi;
|
Pi : constant := Ada.Numerics.Pi;
|
|
|
Two_Pi : constant := 2.0 * Pi;
|
Two_Pi : constant := 2.0 * Pi;
|
Half_Pi : constant := Pi/2.0;
|
Half_Pi : constant := Pi/2.0;
|
|
|
Quarter : constant := 90.0;
|
Quarter : constant := 90.0;
|
Half : constant := 180.0;
|
Half : constant := 180.0;
|
Full : constant := 360.0;
|
Full : constant := 360.0;
|
|
|
Deg_To_Rad : constant := Half_Pi/90;
|
Deg_To_Rad : constant := Half_Pi/90;
|
Rad_To_Deg : constant := 1.0/Deg_To_Rad;
|
Rad_To_Deg : constant := 1.0/Deg_To_Rad;
|
|
|
end C490003_1;
|
end C490003_1;
|
|
|
|
|
--==================================================================--
|
--==================================================================--
|
|
|
|
|
with C490003_0;
|
with C490003_0;
|
with C490003_1;
|
with C490003_1;
|
|
|
with Report;
|
with Report;
|
procedure C490003 is
|
procedure C490003 is
|
begin
|
begin
|
Report.Test ("C490003", "Check that static expressions failing " &
|
Report.Test ("C490003", "Check that static expressions failing " &
|
"Overflow_Check are legal if part of a larger static " &
|
"Overflow_Check are legal if part of a larger static " &
|
"expression. Check that static expressions as right " &
|
"expression. Check that static expressions as right " &
|
"operands of short-circuit control forms are not " &
|
"operands of short-circuit control forms are not " &
|
"evaluated if value of control form is determined by " &
|
"evaluated if value of control form is determined by " &
|
"left operand. Check that static expressions in non-static " &
|
"left operand. Check that static expressions in non-static " &
|
"contexts are evaluated exactly");
|
"contexts are evaluated exactly");
|
|
|
|
|
--
|
--
|
-- Static expressions within larger static expressions:
|
-- Static expressions within larger static expressions:
|
--
|
--
|
|
|
|
|
if C490003_0.Flt_Range_Diff not in C490003_0.My_Flt'Base'Range then
|
if C490003_0.Flt_Range_Diff not in C490003_0.My_Flt'Base'Range then
|
Report.Failed ("Error evaluating static expression: floating point");
|
Report.Failed ("Error evaluating static expression: floating point");
|
end if;
|
end if;
|
|
|
if C490003_0.Symmetric not in Boolean'Range then
|
if C490003_0.Symmetric not in Boolean'Range then
|
Report.Failed ("Error evaluating static expression: fixed point");
|
Report.Failed ("Error evaluating static expression: fixed point");
|
end if;
|
end if;
|
|
|
if C490003_0.Center not in Integer'Base'Range then
|
if C490003_0.Center not in Integer'Base'Range then
|
Report.Failed ("Error evaluating static expression: integer");
|
Report.Failed ("Error evaluating static expression: integer");
|
end if;
|
end if;
|
|
|
|
|
--
|
--
|
-- Short-circuit control forms:
|
-- Short-circuit control forms:
|
--
|
--
|
|
|
declare
|
declare
|
N : constant := 0.0;
|
N : constant := 0.0;
|
begin
|
begin
|
|
|
begin
|
begin
|
if not ( (N = 0.0) or else (1.0/N > 0.5) ) then
|
if not ( (N = 0.0) or else (1.0/N > 0.5) ) then
|
Report.Failed ("Error evaluating OR ELSE");
|
Report.Failed ("Error evaluating OR ELSE");
|
end if;
|
end if;
|
exception
|
exception
|
when Constraint_Error =>
|
when Constraint_Error =>
|
Report.Failed ("Right side of OR ELSE was evaluated");
|
Report.Failed ("Right side of OR ELSE was evaluated");
|
when others =>
|
when others =>
|
Report.Failed ("OR ELSE: unexpected exception raised");
|
Report.Failed ("OR ELSE: unexpected exception raised");
|
end;
|
end;
|
|
|
begin
|
begin
|
if (N /= 0.0) and then (1.0/N <= 0.5) then
|
if (N /= 0.0) and then (1.0/N <= 0.5) then
|
Report.Failed ("Error evaluating AND THEN");
|
Report.Failed ("Error evaluating AND THEN");
|
end if;
|
end if;
|
exception
|
exception
|
when Constraint_Error =>
|
when Constraint_Error =>
|
Report.Failed ("Right side of AND THEN was evaluated");
|
Report.Failed ("Right side of AND THEN was evaluated");
|
when others =>
|
when others =>
|
Report.Failed ("AND THEN: unexpected exception raised");
|
Report.Failed ("AND THEN: unexpected exception raised");
|
end;
|
end;
|
|
|
end;
|
end;
|
|
|
|
|
--
|
--
|
-- Exact evaluation of static expressions:
|
-- Exact evaluation of static expressions:
|
--
|
--
|
|
|
|
|
declare
|
declare
|
use C490003_1;
|
use C490003_1;
|
|
|
Left : constant := 6.0 + 0.3125*( (Full*0.375) + (Half/2.4) -
|
Left : constant := 6.0 + 0.3125*( (Full*0.375) + (Half/2.4) -
|
((Quarter + 36.0)/3.0) )/10.0; -- 11.25
|
((Quarter + 36.0)/3.0) )/10.0; -- 11.25
|
Right : constant := (Pi/3.0) * 1.2 * (15.0/96.0); -- Pi/16
|
Right : constant := (Pi/3.0) * 1.2 * (15.0/96.0); -- Pi/16
|
begin
|
begin
|
if Deg_To_Rad*Left /= Right then
|
if Deg_To_Rad*Left /= Right then
|
Report.Failed ("Static expressions not evaluated exactly: #1");
|
Report.Failed ("Static expressions not evaluated exactly: #1");
|
end if;
|
end if;
|
|
|
if ((Pi*Rad_To_Deg)*2.0 + 4.0*Quarter)/16.0 /= Rad_To_Deg*(Pi/4.0) then
|
if ((Pi*Rad_To_Deg)*2.0 + 4.0*Quarter)/16.0 /= Rad_To_Deg*(Pi/4.0) then
|
Report.Failed ("Static expressions not evaluated exactly: #2");
|
Report.Failed ("Static expressions not evaluated exactly: #2");
|
end if;
|
end if;
|
end;
|
end;
|
|
|
|
|
Report.Result;
|
Report.Result;
|
end C490003;
|
end C490003;
|
|
|