-- C761006.A
|
-- C761006.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 Program_Error is raised when:
|
-- Check that Program_Error is raised when:
|
-- * an exception is raised if Finalize invoked as part of an
|
-- * an exception is raised if Finalize invoked as part of an
|
-- assignment operation; or
|
-- assignment operation; or
|
-- * an exception is raised if Adjust invoked as part of an assignment
|
-- * an exception is raised if Adjust invoked as part of an assignment
|
-- operation, after any other adjustment due to be performed are
|
-- operation, after any other adjustment due to be performed are
|
-- performed; or
|
-- performed; or
|
-- * an exception is raised if Finalize invoked as part of a call on
|
-- * an exception is raised if Finalize invoked as part of a call on
|
-- Unchecked_Deallocation, after any other finalizations to be
|
-- Unchecked_Deallocation, after any other finalizations to be
|
-- performed are performed.
|
-- performed are performed.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- This test defines these four controlled types:
|
-- This test defines these four controlled types:
|
-- Good
|
-- Good
|
-- Bad_Initialize
|
-- Bad_Initialize
|
-- Bad_Adjust
|
-- Bad_Adjust
|
-- Bad_Finalize
|
-- Bad_Finalize
|
-- The type name conveys the associated failure. The operations in type
|
-- The type name conveys the associated failure. The operations in type
|
-- good will "touch" the boolean array indicating correct path
|
-- good will "touch" the boolean array indicating correct path
|
-- utilization for the purposes of checking "other are
|
-- utilization for the purposes of checking "other are
|
-- performed", where ::= initialization, adjusting, and
|
-- performed", where ::= initialization, adjusting, and
|
-- finalization
|
-- finalization
|
--
|
--
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 12 APR 94 SAIC Initial version
|
-- 12 APR 94 SAIC Initial version
|
-- 02 MAY 96 SAIC Visibility fixed for 2.1
|
-- 02 MAY 96 SAIC Visibility fixed for 2.1
|
-- 13 FEB 97 PWB.CTA Corrected value of Events_Occurring at line 286
|
-- 13 FEB 97 PWB.CTA Corrected value of Events_Occurring at line 286
|
-- 01 DEC 97 EDS Made correction wrt RM 7.6(21)
|
-- 01 DEC 97 EDS Made correction wrt RM 7.6(21)
|
-- 16 MAR 01 RLB Corrected Adjust cases to avoid problems with
|
-- 16 MAR 01 RLB Corrected Adjust cases to avoid problems with
|
-- RM 7.6.1(16/1) from Technical Corrigendum 1.
|
-- RM 7.6.1(16/1) from Technical Corrigendum 1.
|
--
|
--
|
--!
|
--!
|
|
|
------------------------------------------------------------- C761006_Support
|
------------------------------------------------------------- C761006_Support
|
|
|
package C761006_Support is
|
package C761006_Support is
|
|
|
type Events is ( Good_Initialize, Good_Adjust, Good_Finalize );
|
type Events is ( Good_Initialize, Good_Adjust, Good_Finalize );
|
|
|
type Event_Array is array(Events) of Boolean;
|
type Event_Array is array(Events) of Boolean;
|
|
|
Events_Occurring : Event_Array := (others => False);
|
Events_Occurring : Event_Array := (others => False);
|
|
|
Propagating_Exception : exception;
|
Propagating_Exception : exception;
|
|
|
procedure Raise_Propagating_Exception(Do_It: Boolean);
|
procedure Raise_Propagating_Exception(Do_It: Boolean);
|
|
|
function Unique_Value return Natural;
|
function Unique_Value return Natural;
|
|
|
end C761006_Support;
|
end C761006_Support;
|
|
|
------------------------------------------------------------- C761006_Support
|
------------------------------------------------------------- C761006_Support
|
|
|
with Report;
|
with Report;
|
package body C761006_Support is
|
package body C761006_Support is
|
|
|
procedure Raise_Propagating_Exception(Do_It: Boolean) is
|
procedure Raise_Propagating_Exception(Do_It: Boolean) is
|
begin
|
begin
|
if Report.Ident_Bool(Do_It) then
|
if Report.Ident_Bool(Do_It) then
|
raise Propagating_Exception;
|
raise Propagating_Exception;
|
end if;
|
end if;
|
end Raise_Propagating_Exception;
|
end Raise_Propagating_Exception;
|
|
|
Seed : Natural := 0;
|
Seed : Natural := 0;
|
|
|
function Unique_Value return Natural is
|
function Unique_Value return Natural is
|
begin
|
begin
|
Seed := Seed +1;
|
Seed := Seed +1;
|
return Seed;
|
return Seed;
|
end Unique_Value;
|
end Unique_Value;
|
|
|
end C761006_Support;
|
end C761006_Support;
|
|
|
------------------------------------------------------------------- C761006_0
|
------------------------------------------------------------------- C761006_0
|
|
|
with Ada.Finalization;
|
with Ada.Finalization;
|
with C761006_Support;
|
with C761006_Support;
|
package C761006_0 is
|
package C761006_0 is
|
|
|
type Good is new Ada.Finalization.Controlled
|
type Good is new Ada.Finalization.Controlled
|
with record
|
with record
|
Initialized : Boolean := False;
|
Initialized : Boolean := False;
|
Adjusted : Boolean := False;
|
Adjusted : Boolean := False;
|
Unique : Natural := C761006_Support.Unique_Value;
|
Unique : Natural := C761006_Support.Unique_Value;
|
end record;
|
end record;
|
|
|
procedure Initialize( It: in out Good );
|
procedure Initialize( It: in out Good );
|
procedure Adjust ( It: in out Good );
|
procedure Adjust ( It: in out Good );
|
procedure Finalize ( It: in out Good );
|
procedure Finalize ( It: in out Good );
|
|
|
type Bad_Initialize is private;
|
type Bad_Initialize is private;
|
|
|
type Bad_Adjust is private;
|
type Bad_Adjust is private;
|
|
|
type Bad_Finalize is private;
|
type Bad_Finalize is private;
|
|
|
Inits_Order : String(1..255);
|
Inits_Order : String(1..255);
|
Inits_Called : Natural := 0;
|
Inits_Called : Natural := 0;
|
private
|
private
|
type Bad_Initialize is new Ada.Finalization.Controlled
|
type Bad_Initialize is new Ada.Finalization.Controlled
|
with null record;
|
with null record;
|
procedure Initialize( It: in out Bad_Initialize );
|
procedure Initialize( It: in out Bad_Initialize );
|
|
|
type Bad_Adjust is new Ada.Finalization.Controlled
|
type Bad_Adjust is new Ada.Finalization.Controlled
|
with null record;
|
with null record;
|
procedure Adjust ( It: in out Bad_Adjust );
|
procedure Adjust ( It: in out Bad_Adjust );
|
|
|
type Bad_Finalize is
|
type Bad_Finalize is
|
new Ada.Finalization.Controlled with null record;
|
new Ada.Finalization.Controlled with null record;
|
procedure Finalize ( It: in out Bad_Finalize );
|
procedure Finalize ( It: in out Bad_Finalize );
|
end C761006_0;
|
end C761006_0;
|
|
|
------------------------------------------------------------------- C761006_1
|
------------------------------------------------------------------- C761006_1
|
|
|
with Ada.Finalization;
|
with Ada.Finalization;
|
with C761006_0;
|
with C761006_0;
|
package C761006_1 is
|
package C761006_1 is
|
|
|
type Init_Check_Root is new Ada.Finalization.Controlled with record
|
type Init_Check_Root is new Ada.Finalization.Controlled with record
|
Good_Component : C761006_0.Good;
|
Good_Component : C761006_0.Good;
|
Init_Fails : C761006_0.Bad_Initialize;
|
Init_Fails : C761006_0.Bad_Initialize;
|
end record;
|
end record;
|
|
|
type Adj_Check_Root is new Ada.Finalization.Controlled with record
|
type Adj_Check_Root is new Ada.Finalization.Controlled with record
|
Good_Component : C761006_0.Good;
|
Good_Component : C761006_0.Good;
|
Adj_Fails : C761006_0.Bad_Adjust;
|
Adj_Fails : C761006_0.Bad_Adjust;
|
end record;
|
end record;
|
|
|
type Fin_Check_Root is new Ada.Finalization.Controlled with record
|
type Fin_Check_Root is new Ada.Finalization.Controlled with record
|
Good_Component : C761006_0.Good;
|
Good_Component : C761006_0.Good;
|
Fin_Fails : C761006_0.Bad_Finalize;
|
Fin_Fails : C761006_0.Bad_Finalize;
|
end record;
|
end record;
|
|
|
end C761006_1;
|
end C761006_1;
|
|
|
------------------------------------------------------------------- C761006_2
|
------------------------------------------------------------------- C761006_2
|
|
|
with C761006_1;
|
with C761006_1;
|
package C761006_2 is
|
package C761006_2 is
|
|
|
type Init_Check is new C761006_1.Init_Check_Root with null record;
|
type Init_Check is new C761006_1.Init_Check_Root with null record;
|
type Adj_Check is new C761006_1.Adj_Check_Root with null record;
|
type Adj_Check is new C761006_1.Adj_Check_Root with null record;
|
type Fin_Check is new C761006_1.Fin_Check_Root with null record;
|
type Fin_Check is new C761006_1.Fin_Check_Root with null record;
|
|
|
end C761006_2;
|
end C761006_2;
|
|
|
------------------------------------------------------------------- C761006_0
|
------------------------------------------------------------------- C761006_0
|
|
|
with Report;
|
with Report;
|
with C761006_Support;
|
with C761006_Support;
|
package body C761006_0 is
|
package body C761006_0 is
|
|
|
package Sup renames C761006_Support;
|
package Sup renames C761006_Support;
|
|
|
procedure Initialize( It: in out Good ) is
|
procedure Initialize( It: in out Good ) is
|
begin
|
begin
|
Sup.Events_Occurring( Sup.Good_Initialize ) := True;
|
Sup.Events_Occurring( Sup.Good_Initialize ) := True;
|
It.Initialized := True;
|
It.Initialized := True;
|
end Initialize;
|
end Initialize;
|
|
|
procedure Adjust ( It: in out Good ) is
|
procedure Adjust ( It: in out Good ) is
|
begin
|
begin
|
Sup.Events_Occurring( Sup.Good_Adjust ) := True;
|
Sup.Events_Occurring( Sup.Good_Adjust ) := True;
|
It.Adjusted := True;
|
It.Adjusted := True;
|
It.Unique := C761006_Support.Unique_Value;
|
It.Unique := C761006_Support.Unique_Value;
|
end Adjust;
|
end Adjust;
|
|
|
procedure Finalize ( It: in out Good ) is
|
procedure Finalize ( It: in out Good ) is
|
begin
|
begin
|
Sup.Events_Occurring( Sup.Good_Finalize ) := True;
|
Sup.Events_Occurring( Sup.Good_Finalize ) := True;
|
end Finalize;
|
end Finalize;
|
|
|
procedure Initialize( It: in out Bad_Initialize ) is
|
procedure Initialize( It: in out Bad_Initialize ) is
|
begin
|
begin
|
Sup.Raise_Propagating_Exception(Report.Ident_Bool(True));
|
Sup.Raise_Propagating_Exception(Report.Ident_Bool(True));
|
end Initialize;
|
end Initialize;
|
|
|
procedure Adjust( It: in out Bad_Adjust ) is
|
procedure Adjust( It: in out Bad_Adjust ) is
|
begin
|
begin
|
Sup.Raise_Propagating_Exception(Report.Ident_Bool(True));
|
Sup.Raise_Propagating_Exception(Report.Ident_Bool(True));
|
end Adjust;
|
end Adjust;
|
|
|
procedure Finalize( It: in out Bad_Finalize ) is
|
procedure Finalize( It: in out Bad_Finalize ) is
|
begin
|
begin
|
Sup.Raise_Propagating_Exception(Report.Ident_Bool(True));
|
Sup.Raise_Propagating_Exception(Report.Ident_Bool(True));
|
end Finalize;
|
end Finalize;
|
|
|
end C761006_0;
|
end C761006_0;
|
|
|
--------------------------------------------------------------------- C761006
|
--------------------------------------------------------------------- C761006
|
|
|
with Report;
|
with Report;
|
with C761006_0;
|
with C761006_0;
|
with C761006_2;
|
with C761006_2;
|
with C761006_Support;
|
with C761006_Support;
|
with Ada.Exceptions;
|
with Ada.Exceptions;
|
with Ada.Finalization;
|
with Ada.Finalization;
|
with Unchecked_Deallocation;
|
with Unchecked_Deallocation;
|
procedure C761006 is
|
procedure C761006 is
|
|
|
package Sup renames C761006_Support;
|
package Sup renames C761006_Support;
|
use type Sup.Event_Array;
|
use type Sup.Event_Array;
|
|
|
type Procedure_Handle is access procedure;
|
type Procedure_Handle is access procedure;
|
|
|
type Test_ID is ( Simple, Initialize, Adjust, Finalize );
|
type Test_ID is ( Simple, Initialize, Adjust, Finalize );
|
|
|
Sub_Tests : array(Test_ID) of Procedure_Handle;
|
Sub_Tests : array(Test_ID) of Procedure_Handle;
|
|
|
procedure Simple_Test is
|
procedure Simple_Test is
|
A_Good_Object : C761006_0.Good; -- should call Initialize
|
A_Good_Object : C761006_0.Good; -- should call Initialize
|
begin
|
begin
|
if not A_Good_Object.Initialized then
|
if not A_Good_Object.Initialized then
|
Report.Failed("Good object not initialized");
|
Report.Failed("Good object not initialized");
|
end if;
|
end if;
|
|
|
-- should call Adjust
|
-- should call Adjust
|
A_Good_Object := ( Ada.Finalization.Controlled
|
A_Good_Object := ( Ada.Finalization.Controlled
|
with Unique => 0, others => False );
|
with Unique => 0, others => False );
|
if not A_Good_Object.Adjusted then
|
if not A_Good_Object.Adjusted then
|
Report.Failed("Good object not adjusted");
|
Report.Failed("Good object not adjusted");
|
end if;
|
end if;
|
|
|
-- should call Finalize before end of scope
|
-- should call Finalize before end of scope
|
end Simple_Test;
|
end Simple_Test;
|
|
|
procedure Initialize_Test is
|
procedure Initialize_Test is
|
begin
|
begin
|
declare
|
declare
|
This_Object_Fails_In_Initialize : C761006_2.Init_Check;
|
This_Object_Fails_In_Initialize : C761006_2.Init_Check;
|
begin
|
begin
|
Report.Failed("Exception in Initialize did not occur");
|
Report.Failed("Exception in Initialize did not occur");
|
exception
|
exception
|
when others =>
|
when others =>
|
Report.Failed("Initialize caused exception at wrong lex");
|
Report.Failed("Initialize caused exception at wrong lex");
|
end;
|
end;
|
|
|
Report.Failed("Error in execution sequence");
|
Report.Failed("Error in execution sequence");
|
|
|
exception
|
exception
|
when Sup.Propagating_Exception => -- this is correct
|
when Sup.Propagating_Exception => -- this is correct
|
if not Sup.Events_Occurring(Sup.Good_Initialize) then
|
if not Sup.Events_Occurring(Sup.Good_Initialize) then
|
Report.Failed("Initialization of Good Component did not occur");
|
Report.Failed("Initialization of Good Component did not occur");
|
end if;
|
end if;
|
end Initialize_Test;
|
end Initialize_Test;
|
|
|
procedure Adjust_Test is
|
procedure Adjust_Test is
|
This_Object_OK : C761006_2.Adj_Check;
|
This_Object_OK : C761006_2.Adj_Check;
|
This_Object_Target : C761006_2.Adj_Check;
|
This_Object_Target : C761006_2.Adj_Check;
|
begin
|
begin
|
|
|
Check_Adjust_Due_To_Assignment: begin
|
Check_Adjust_Due_To_Assignment: begin
|
This_Object_Target := This_Object_OK;
|
This_Object_Target := This_Object_OK;
|
Report.Failed("Adjust did not propagate any exception");
|
Report.Failed("Adjust did not propagate any exception");
|
exception
|
exception
|
when Program_Error => -- expected case
|
when Program_Error => -- expected case
|
if not This_Object_Target.Good_Component.Adjusted then
|
if not This_Object_Target.Good_Component.Adjusted then
|
Report.Failed("other adjustment not performed");
|
Report.Failed("other adjustment not performed");
|
end if;
|
end if;
|
when others =>
|
when others =>
|
Report.Failed("Adjust propagated wrong exception");
|
Report.Failed("Adjust propagated wrong exception");
|
end Check_Adjust_Due_To_Assignment;
|
end Check_Adjust_Due_To_Assignment;
|
|
|
C761006_Support.Events_Occurring := (True, False, False);
|
C761006_Support.Events_Occurring := (True, False, False);
|
|
|
Check_Adjust_Due_To_Initial_Assignment: declare
|
Check_Adjust_Due_To_Initial_Assignment: declare
|
Another_Target : C761006_2.Adj_Check := This_Object_OK;
|
Another_Target : C761006_2.Adj_Check := This_Object_OK;
|
begin
|
begin
|
Report.Failed("Adjust did not propagate any exception");
|
Report.Failed("Adjust did not propagate any exception");
|
exception
|
exception
|
when others => Report.Failed("Adjust caused exception at wrong lex");
|
when others => Report.Failed("Adjust caused exception at wrong lex");
|
end Check_Adjust_Due_To_Initial_Assignment;
|
end Check_Adjust_Due_To_Initial_Assignment;
|
|
|
exception
|
exception
|
when Program_Error => -- expected case
|
when Program_Error => -- expected case
|
if Sup.Events_Occurring(Sup.Good_Finalize) /=
|
if Sup.Events_Occurring(Sup.Good_Finalize) /=
|
Sup.Events_Occurring(Sup.Good_Adjust) then
|
Sup.Events_Occurring(Sup.Good_Adjust) then
|
-- RM 7.6.1(16/1) says that the good Adjust may or may not
|
-- RM 7.6.1(16/1) says that the good Adjust may or may not
|
-- be performed; but if it is, then the Finalize must be
|
-- be performed; but if it is, then the Finalize must be
|
-- performed; and if it is not, then the Finalize must not
|
-- performed; and if it is not, then the Finalize must not
|
-- performed.
|
-- performed.
|
if Sup.Events_Occurring(Sup.Good_Finalize) then
|
if Sup.Events_Occurring(Sup.Good_Finalize) then
|
Report.Failed("Good adjust not performed with bad adjust, " &
|
Report.Failed("Good adjust not performed with bad adjust, " &
|
"but good finalize was");
|
"but good finalize was");
|
else
|
else
|
Report.Failed("Good adjust performed with bad adjust, " &
|
Report.Failed("Good adjust performed with bad adjust, " &
|
"but good finalize was not");
|
"but good finalize was not");
|
end if;
|
end if;
|
end if;
|
end if;
|
when others =>
|
when others =>
|
Report.Failed("Adjust propagated wrong exception");
|
Report.Failed("Adjust propagated wrong exception");
|
end Adjust_Test;
|
end Adjust_Test;
|
|
|
procedure Finalize_Test is
|
procedure Finalize_Test is
|
|
|
Fin_Not_Perf : constant String := "other finalizations not performed";
|
Fin_Not_Perf : constant String := "other finalizations not performed";
|
|
|
procedure Finalize_15 is
|
procedure Finalize_15 is
|
Item : C761006_2.Fin_Check;
|
Item : C761006_2.Fin_Check;
|
Target : C761006_2.Fin_Check;
|
Target : C761006_2.Fin_Check;
|
begin
|
begin
|
|
|
Item := Target;
|
Item := Target;
|
-- finalization of Item should cause PE
|
-- finalization of Item should cause PE
|
-- ARM7.6:21 allows the implementation to omit the assignment of the
|
-- ARM7.6:21 allows the implementation to omit the assignment of the
|
-- value into an anonymous object, which is the point at which Adjust
|
-- value into an anonymous object, which is the point at which Adjust
|
-- is normally called. However, this would result in Program_Error's
|
-- is normally called. However, this would result in Program_Error's
|
-- being raised before the call to Adjust, with the consequence that
|
-- being raised before the call to Adjust, with the consequence that
|
-- Adjust is never called.
|
-- Adjust is never called.
|
|
|
exception
|
exception
|
when Program_Error => -- expected case
|
when Program_Error => -- expected case
|
if not Sup.Events_Occurring(Sup.Good_Finalize) then
|
if not Sup.Events_Occurring(Sup.Good_Finalize) then
|
Report.Failed("Assignment: " & Fin_Not_Perf);
|
Report.Failed("Assignment: " & Fin_Not_Perf);
|
end if;
|
end if;
|
when others =>
|
when others =>
|
Report.Failed("Other exception in Finalize_15");
|
Report.Failed("Other exception in Finalize_15");
|
|
|
-- finalization of Item/Target should cause PE
|
-- finalization of Item/Target should cause PE
|
end Finalize_15;
|
end Finalize_15;
|
|
|
-- check failure in finalize due to Unchecked_Deallocation
|
-- check failure in finalize due to Unchecked_Deallocation
|
|
|
type Shark is access C761006_2.Fin_Check;
|
type Shark is access C761006_2.Fin_Check;
|
|
|
procedure Catch is
|
procedure Catch is
|
new Unchecked_Deallocation( C761006_2.Fin_Check, Shark );
|
new Unchecked_Deallocation( C761006_2.Fin_Check, Shark );
|
|
|
procedure Finalize_17 is
|
procedure Finalize_17 is
|
White : Shark := new C761006_2.Fin_Check;
|
White : Shark := new C761006_2.Fin_Check;
|
begin
|
begin
|
Catch( White );
|
Catch( White );
|
exception
|
exception
|
when Program_Error =>
|
when Program_Error =>
|
if not Sup.Events_Occurring(Sup.Good_Finalize) then
|
if not Sup.Events_Occurring(Sup.Good_Finalize) then
|
Report.Failed("Unchecked_Deallocation: " & Fin_Not_Perf);
|
Report.Failed("Unchecked_Deallocation: " & Fin_Not_Perf);
|
end if;
|
end if;
|
end Finalize_17;
|
end Finalize_17;
|
|
|
begin
|
begin
|
|
|
Exception_In_Finalization: begin
|
Exception_In_Finalization: begin
|
Finalize_15;
|
Finalize_15;
|
exception
|
exception
|
when Program_Error => null; -- anticipated
|
when Program_Error => null; -- anticipated
|
end Exception_In_Finalization;
|
end Exception_In_Finalization;
|
|
|
Use_Of_Unchecked_Deallocation: begin
|
Use_Of_Unchecked_Deallocation: begin
|
Finalize_17;
|
Finalize_17;
|
exception
|
exception
|
when others =>
|
when others =>
|
Report.Failed("Unchecked_Deallocation check, unwanted exception");
|
Report.Failed("Unchecked_Deallocation check, unwanted exception");
|
end Use_Of_Unchecked_Deallocation;
|
end Use_Of_Unchecked_Deallocation;
|
|
|
end Finalize_Test;
|
end Finalize_Test;
|
|
|
begin -- Main test procedure.
|
begin -- Main test procedure.
|
|
|
Report.Test ("C761006", "Check that exceptions raised in Initialize, " &
|
Report.Test ("C761006", "Check that exceptions raised in Initialize, " &
|
"Adjust and Finalize are processed correctly" );
|
"Adjust and Finalize are processed correctly" );
|
|
|
Sub_Tests := (Simple_Test'Access, Initialize_Test'Access,
|
Sub_Tests := (Simple_Test'Access, Initialize_Test'Access,
|
Adjust_Test'Access, Finalize_Test'Access);
|
Adjust_Test'Access, Finalize_Test'Access);
|
|
|
for Test in Sub_Tests'Range loop
|
for Test in Sub_Tests'Range loop
|
begin
|
begin
|
|
|
Sup.Events_Occurring := (others => False);
|
Sup.Events_Occurring := (others => False);
|
|
|
Sub_Tests(Test).all;
|
Sub_Tests(Test).all;
|
|
|
case Test is
|
case Test is
|
when Simple | Adjust =>
|
when Simple | Adjust =>
|
if Sup.Events_Occurring /= Sup.Event_Array ' ( others => True ) then
|
if Sup.Events_Occurring /= Sup.Event_Array ' ( others => True ) then
|
Report.Failed ( "Other operation missing in " &
|
Report.Failed ( "Other operation missing in " &
|
Test_ID'Image ( Test ) );
|
Test_ID'Image ( Test ) );
|
end if;
|
end if;
|
when Initialize =>
|
when Initialize =>
|
null;
|
null;
|
when Finalize =>
|
when Finalize =>
|
-- Note that for Good_Adjust, we may get either True or False
|
-- Note that for Good_Adjust, we may get either True or False
|
if Sup.Events_Occurring ( Sup.Good_Initialize ) = False or
|
if Sup.Events_Occurring ( Sup.Good_Initialize ) = False or
|
Sup.Events_Occurring ( Sup.Good_Finalize ) = False
|
Sup.Events_Occurring ( Sup.Good_Finalize ) = False
|
then
|
then
|
Report.Failed ( "Other operation missing in " &
|
Report.Failed ( "Other operation missing in " &
|
Test_ID'Image ( Test ) );
|
Test_ID'Image ( Test ) );
|
end if;
|
end if;
|
end case;
|
end case;
|
|
|
exception
|
exception
|
when How: others => Report.Failed( Ada.Exceptions.Exception_Name( How )
|
when How: others => Report.Failed( Ada.Exceptions.Exception_Name( How )
|
& " from " & Test_ID'Image( Test ) );
|
& " from " & Test_ID'Image( Test ) );
|
end;
|
end;
|
end loop;
|
end loop;
|
|
|
Report.Result;
|
Report.Result;
|
|
|
end C761006;
|
end C761006;
|
|
|