From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/ada/acats/tests/c3/c340a01.a | 165 +++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 gcc/testsuite/ada/acats/tests/c3/c340a01.a (limited to 'gcc/testsuite/ada/acats/tests/c3/c340a01.a') diff --git a/gcc/testsuite/ada/acats/tests/c3/c340a01.a b/gcc/testsuite/ada/acats/tests/c3/c340a01.a new file mode 100644 index 000000000..108a30b5f --- /dev/null +++ b/gcc/testsuite/ada/acats/tests/c3/c340a01.a @@ -0,0 +1,165 @@ +-- C340A01.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 a tagged type declared in a package specification +-- may be passed as a generic formal (tagged) private type to a generic +-- package declaration. Check that the formal type may be extended with +-- a record extension in the generic package. +-- +-- Check that, in the instance, the record extension inherits the +-- user-defined primitive subprograms of the tagged actual. +-- +-- TEST DESCRIPTION: +-- Declare a tagged type and an associated primitive subprogram in a +-- package specification (foundation code). Declare a generic package +-- which takes a tagged type as a formal parameter, and then extends +-- it with a record extension (foundation code). +-- +-- Instantiate the generic package with the tagged type from the first +-- package (the "generic" extension should now have inherited +-- the primitive subprogram of the tagged type from the first +-- package). +-- +-- In the main program, call the primitive subprogram inherited by the +-- "generic" extension, and verify the correctness of the components. +-- +-- TEST FILES: +-- This test consists of the following files: +-- +-- F340A000.A +-- F340A001.A +-- => C340A01.A +-- +-- +-- CHANGE HISTORY: +-- 06 Dec 94 SAIC ACVC 2.0 +-- 12 Jun 96 SAIC ACVC 2.1: Modified prologue. Removed extraneous +-- comments. +-- +--! + +with F340A001; -- Book definitions. +package C340A01_0 is -- Raw data to be used in creating book elements. + + + Book_Count : constant := 3; + + subtype Number_Of_Books is Integer range 1 .. Book_Count; + + type Data_List is array (Number_Of_Books) of F340A001.Text_Ptr; + + Title_List : Data_List := (new String'("Wuthering Heights"), + new String'("Heart of Darkness"), + new String'("Ulysses")); + + Author_List : Data_List := (new String'("Bronte, Emily"), + new String'("Conrad, Joseph"), + new String'("Joyce, James")); + +end C340A01_0; + + + --==================================================================-- + + +-- Library-level instantiation. Actual parameter is tagged record. + +with F340A001; -- Book definitions. +with F340A000; -- Singly-linked list abstraction. +package C340A01_1 is new F340A000 (Parent_Type => F340A001.Book_Type); + + + --==================================================================-- + + +with Report; + +with F340A001; -- Book definitions. +with C340A01_0; -- Raw book data. +with C340A01_1; -- Instance. + +use F340A001; -- Primitive operations of Book_Type directly visible. +use C340A01_1; -- Operations inherited by Node_Type directly visible. + +procedure C340A01 is + + + List_Of_Books : Node_Ptr := null; -- Head of linked list of books. + + + --========================================================-- + + + procedure Create_List (Title, Author : in C340A01_0.Data_List; + Head : in out Node_Ptr) is + + Book : Node_Type; -- Object of extended type. + Book_Ptr : Node_Ptr; + + begin + for I in C340A01_0.Number_Of_Books loop + Create_Book (Title (I), Author (I), Book); -- Call inherited + -- operation. + Book_Ptr := new Node_Type'(Book); + Add (Book_Ptr, Head); + end loop; + end Create_List; + + + --========================================================-- + + + function Bad_List_Contents return Boolean is + begin + return (List_Of_Books.Title.all /= "Ulysses" or + List_Of_Books.Author.all /= "Joyce, James" or + List_Of_Books.Next.Title.all /= "Heart of Darkness" or + List_Of_Books.Next.Author.all /= "Conrad, Joseph" or + List_Of_Books.Next.Next.Title.all /= "Wuthering Heights" or + List_Of_Books.Next.Next.Author.all /= "Bronte, Emily"); + end Bad_List_Contents; + + + --========================================================-- + + +begin -- Main program. + + Report.Test ("C340A01", "Inheritance of primitive operations: record " & + "extension of formal tagged private type; actual is " & + "an ultimate ancestor type"); + + -- Create linked list using inherited operation: + Create_List (C340A01_0.Title_List, C340A01_0.Author_List, List_Of_Books); + + -- Verify results: + if Bad_List_Contents then + Report.Failed ("Wrong values after call to inherited operation"); + end if; + + Report.Result; + +end C340A01; -- cgit v1.2.3