URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [c3/] [c360002.a] - Rev 720
Compare with Previous | Blame | View Log
-- C360002.A---- Grant of Unlimited Rights---- 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-- unlimited rights in the software and documentation contained herein.-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making-- this public release, the Government intends to confer upon all-- recipients unlimited rights equal to those held by the Government.-- These rights include rights to use, duplicate, release or disclose the-- 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-- to do so.---- DISCLAIMER---- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A-- PARTICULAR PURPOSE OF SAID MATERIAL.--*---- OBJECTIVE:-- Check that modular types may be used as array indices.---- Check that if aliased appears in the component_definition of an-- array_type that each component of the array is aliased.---- Check that references to aliased array objects produce correct-- results, and that out-of-bounds indexing correctly produces-- Constraint_Error.---- TEST DESCRIPTION:-- This test defines several array types and subtypes indexed by modular-- types; some aliased some not, some with aliased components, some not.---- It then checks that assignments move the correct data.------ CHANGE HISTORY:-- 28 SEP 95 SAIC Initial version-- 23 APR 96 SAIC Doc fixes, fixed constrained/unconstrained conflict-- 13 FEB 97 PWB.CTA Removed illegal declarations and affected code--!------------------------------------------------------------------- C360002with Report;procedure C360002 isVerbose : Boolean := Report.Ident_Bool( False );type Mod_128 is mod 128;function Ident_128( I: Integer ) return Mod_128 isbeginreturn Mod_128( Report.Ident_Int( I ) );end Ident_128;type Unconstrained_Arrayis array( Mod_128 range <> ) of Integer;type Unconstrained_Array_Aliasedis array( Mod_128 range <> ) of aliased Integer;type Access_All_Unconstrained_Arrayis access all Unconstrained_Array;type Access_All_Unconstrained_Array_Aliasedis access all Unconstrained_Array_Aliased;subtype Array_01_10is Unconstrained_Array(01..10);subtype Array_11_20is Unconstrained_Array(11..20);subtype Array_Aliased_01_10is Unconstrained_Array_Aliased(01..10);subtype Array_Aliased_11_20is Unconstrained_Array_Aliased(11..20);subtype Access_All_01_10_Arrayis Access_All_Unconstrained_Array(01..10);subtype Access_All_01_10_Array_Aliasedis Access_All_Unconstrained_Array_Aliased(01..10);subtype Access_All_11_20_Arrayis Access_All_Unconstrained_Array(11..20);subtype Access_All_11_20_Array_Aliasedis Access_All_Unconstrained_Array_Aliased(11..20);-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ---- these 'filler' functions create unique values for every element that-- is used and/or tested in this test.Well_Bottom : Integer := 0;function Filler( Size : Mod_128 ) return Unconstrained_Array isIt : Unconstrained_Array( 0..Size-1 );beginfor Eyes in It'Range loopIt(Eyes) := Integer( Eyes ) + Well_Bottom;end loop;Well_Bottom := Well_Bottom + It'Length;return It;end Filler;function Filler( Size : Mod_128 ) return Unconstrained_Array_Aliased isIt : Unconstrained_Array_Aliased( 0..Size-1 );beginfor Ayes in It'Range loopIt(Ayes) := Integer( Ayes ) + Well_Bottom;end loop;Well_Bottom := Well_Bottom + It'Length;return It;end Filler;-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --An_Integer : Integer;type AAI is access all Integer;An_Integer_Access : AAI;Array_Item_01_10 : Array_01_10 := Filler(10); -- 0..9Array_Item_11_20 : Array_11_20 := Filler(10); -- 10..19 (sliding)Array_Aliased_Item_01_10 : Array_Aliased_01_10 := Filler(10); -- 20..29Array_Aliased_Item_11_20 : Array_Aliased_11_20 := Filler(10); -- 30..39Aliased_Array_Item_01_10 : aliased Array_01_10 := Filler(10); -- 40..49Aliased_Array_Item_11_20 : aliased Array_11_20 := Filler(10); -- 50..59Aliased_Array_Aliased_Item_01_10 : aliased Array_Aliased_01_10:= Filler(10); -- 60..69Aliased_Array_Aliased_Item_11_20 : aliased Array_Aliased_11_20:= Filler(10); -- 70..79Check_Item : Access_All_Unconstrained_Array;Check_Aliased_Item : Access_All_Unconstrained_Array_Aliased;-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --procedure Fail( Message : String; CI, SB : Integer ) isbeginReport.Failed("Wrong value passed " & Message);if Verbose thenReport.Comment("got" & Integer'Image(CI) &" should be" & Integer'Image(SB) );end if;end Fail;procedure Check_Array_01_10( Checked_Item : Array_01_10;Low_SB : Integer ) isbeginfor Index in Checked_Item'Range loopif (Checked_Item(Index) /= (Low_SB +Integer(Index)-1)) thenFail("unaliased 1..10", Checked_Item(Index),(Low_SB +Integer(Index)-1));end if;end loop;end Check_Array_01_10;procedure Check_Array_11_20( Checked_Item : Array_11_20;Low_SB : Integer ) isbeginfor Index in Checked_Item'Range loopif (Checked_Item(Index) /= (Low_SB +Integer(Index)-11)) thenFail("unaliased 11..20", Checked_Item(Index),(Low_SB +Integer(Index)-11));end if;end loop;end Check_Array_11_20;procedure Check_Single_Integer( The_Integer, SB : Integer;Message : String ) isbeginif The_Integer /= SB thenReport.Failed("Wrong integer value for " & Message );end if;end Check_Single_Integer;-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --begin -- Main test procedure.Report.Test ("C360002", "Check that modular types may be used as array " &"indices. Check that if aliased appears in " &"the component_definition of an array_type that " &"each component of the array is aliased. Check " &"that references to aliased array objects " &"produce correct results, and that out of bound " &"references to aliased objects correctly " &"produce Constraint_Error" );-- start with checks that the Filler assignments produced the expected-- result. This is a "case 0" test to check that nothing REALLY surprising-- is happeningCheck_Array_01_10( Array_Item_01_10, 0 );Check_Array_11_20( Array_Item_11_20, 10 );-- check that having the variable aliased makes no differenceCheck_Array_01_10( Aliased_Array_Item_01_10, 40 );Check_Array_11_20( Aliased_Array_Item_11_20, 50 );-- now check that conversion between array types where the only-- difference in the definitions is that the components are aliased worksCheck_Array_01_10( Unconstrained_Array( Array_Aliased_Item_01_10 ), 20 );Check_Array_11_20( Unconstrained_Array( Array_Aliased_Item_11_20 ), 30 );-- check that conversion of an aliased object with aliased components-- also worksCheck_Array_01_10( Unconstrained_Array( Aliased_Array_Aliased_Item_01_10 ),60 );Check_Array_11_20( Unconstrained_Array( Aliased_Array_Aliased_Item_11_20 ),70 );-- check that the bounds will slideCheck_Array_01_10( Array_01_10( Array_Item_11_20 ), 10 );Check_Array_11_20( Array_11_20( Array_Item_01_10 ), 0 );-- point at some of the components and check themAn_Integer_Access := Array_Aliased_Item_01_10(5)'Access;Check_Single_Integer( An_Integer_Access.all, 24,"Aliased component 'Access");An_Integer_Access := Aliased_Array_Aliased_Item_01_10(7)'Access;Check_Single_Integer( An_Integer_Access.all, 66,"Aliased Aliased component 'Access");-- check some assignmentsArray_Item_01_10 := Aliased_Array_Item_01_10;Check_Array_01_10( Array_Item_01_10, 40 );Aliased_Array_Item_01_10 := Aliased_Array_Item_11_20(11..20);Check_Array_01_10( Aliased_Array_Item_01_10, 50 );Aliased_Array_Aliased_Item_11_20(11..20):= Aliased_Array_Aliased_Item_01_10;Check_Array_11_20( Unconstrained_Array( Aliased_Array_Aliased_Item_11_20 ),60 );Report.Result;end C360002;
