-- CDD2A03.A
|
-- CDD2A03.A
|
--
|
--
|
-- Grant of Unlimited Rights
|
-- Grant of Unlimited Rights
|
--
|
--
|
-- The Ada Conformity Assessment Authority (ACAA) holds unlimited
|
-- The Ada Conformity Assessment Authority (ACAA) holds unlimited
|
-- rights in the software and documentation contained herein. Unlimited
|
-- rights in the software and documentation contained herein. Unlimited
|
-- rights are the same as those granted by the U.S. Government for older
|
-- rights are the same as those granted by the U.S. Government for older
|
-- parts of the Ada Conformity Assessment Test Suite, and are defined
|
-- parts of the Ada Conformity Assessment Test Suite, and are defined
|
-- in DFAR 252.227-7013(a)(19). By making this public release, the ACAA
|
-- in DFAR 252.227-7013(a)(19). By making this public release, the ACAA
|
-- intends to confer upon all recipients unlimited rights equal to those
|
-- intends to confer upon all recipients unlimited rights equal to those
|
-- held by the ACAA. These rights include rights to use, duplicate,
|
-- held by the ACAA. These rights include rights to use, duplicate,
|
-- release or disclose the released technical data and computer software
|
-- release or disclose the released technical data and computer software
|
-- in whole or in part, in any manner and for any purpose whatsoever, and
|
-- in whole or in part, in any manner and for any purpose whatsoever, and
|
-- to have or permit others to do so.
|
-- to have or permit others 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 the default Read and Write attributes for a limited type
|
-- Check that the default Read and Write attributes for a limited type
|
-- extension are created from the parent type's attribute (which may be
|
-- extension are created from the parent type's attribute (which may be
|
-- user-defined) and those for the extension components, if the extension
|
-- user-defined) and those for the extension components, if the extension
|
-- components are non-limited or have user-defined attributes. Check that
|
-- components are non-limited or have user-defined attributes. Check that
|
-- such limited type extension attributes are callable (Defect Report
|
-- such limited type extension attributes are callable (Defect Report
|
-- 8652/0040, as reflected in Technical Corrigendum 1, penultimate sentence
|
-- 8652/0040, as reflected in Technical Corrigendum 1, penultimate sentence
|
-- of 13.13.2(9/1) and 13.13.2(36/1)).
|
-- of 13.13.2(9/1) and 13.13.2(36/1)).
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 1 AUG 2001 PHL Initial version.
|
-- 1 AUG 2001 PHL Initial version.
|
-- 3 DEC 2001 RLB Reformatted for ACATS.
|
-- 3 DEC 2001 RLB Reformatted for ACATS.
|
--
|
--
|
--!
|
--!
|
with Ada.Streams;
|
with Ada.Streams;
|
use Ada.Streams;
|
use Ada.Streams;
|
with FDD2A00;
|
with FDD2A00;
|
use FDD2A00;
|
use FDD2A00;
|
with Report;
|
with Report;
|
use Report;
|
use Report;
|
procedure CDD2A03 is
|
procedure CDD2A03 is
|
|
|
Input_Output_Error : exception;
|
Input_Output_Error : exception;
|
|
|
type Int is range 1 .. 1000;
|
type Int is range 1 .. 1000;
|
type Str is array (Int range <>) of Character;
|
type Str is array (Int range <>) of Character;
|
|
|
procedure Read (Stream : access Root_Stream_Type'Class;
|
procedure Read (Stream : access Root_Stream_Type'Class;
|
Item : out Int'Base);
|
Item : out Int'Base);
|
procedure Write (Stream : access Root_Stream_Type'Class; Item : Int'Base);
|
procedure Write (Stream : access Root_Stream_Type'Class; Item : Int'Base);
|
function Input (Stream : access Root_Stream_Type'Class) return Int'Base;
|
function Input (Stream : access Root_Stream_Type'Class) return Int'Base;
|
procedure Output (Stream : access Root_Stream_Type'Class; Item : Int'Base);
|
procedure Output (Stream : access Root_Stream_Type'Class; Item : Int'Base);
|
|
|
for Int'Read use Read;
|
for Int'Read use Read;
|
for Int'Write use Write;
|
for Int'Write use Write;
|
for Int'Input use Input;
|
for Int'Input use Input;
|
for Int'Output use Output;
|
for Int'Output use Output;
|
|
|
|
|
type Lim is limited
|
type Lim is limited
|
record
|
record
|
C : Int;
|
C : Int;
|
end record;
|
end record;
|
|
|
procedure Read (Stream : access Root_Stream_Type'Class; Item : out Lim);
|
procedure Read (Stream : access Root_Stream_Type'Class; Item : out Lim);
|
procedure Write (Stream : access Root_Stream_Type'Class; Item : Lim);
|
procedure Write (Stream : access Root_Stream_Type'Class; Item : Lim);
|
function Input (Stream : access Root_Stream_Type'Class) return Lim;
|
function Input (Stream : access Root_Stream_Type'Class) return Lim;
|
procedure Output (Stream : access Root_Stream_Type'Class; Item : Lim);
|
procedure Output (Stream : access Root_Stream_Type'Class; Item : Lim);
|
|
|
for Lim'Read use Read;
|
for Lim'Read use Read;
|
for Lim'Write use Write;
|
for Lim'Write use Write;
|
for Lim'Input use Input;
|
for Lim'Input use Input;
|
for Lim'Output use Output;
|
for Lim'Output use Output;
|
|
|
|
|
type Parent (D1, D2 : Int; B : Boolean) is tagged limited
|
type Parent (D1, D2 : Int; B : Boolean) is tagged limited
|
record
|
record
|
S : Str (D1 .. D2);
|
S : Str (D1 .. D2);
|
case B is
|
case B is
|
when False =>
|
when False =>
|
C1 : Integer;
|
C1 : Integer;
|
when True =>
|
when True =>
|
C2 : Float;
|
C2 : Float;
|
end case;
|
end case;
|
end record;
|
end record;
|
|
|
procedure Read (Stream : access Root_Stream_Type'Class; Item : out Parent);
|
procedure Read (Stream : access Root_Stream_Type'Class; Item : out Parent);
|
procedure Write (Stream : access Root_Stream_Type'Class; Item : Parent);
|
procedure Write (Stream : access Root_Stream_Type'Class; Item : Parent);
|
function Input (Stream : access Root_Stream_Type'Class) return Parent;
|
function Input (Stream : access Root_Stream_Type'Class) return Parent;
|
procedure Output (Stream : access Root_Stream_Type'Class; Item : Parent);
|
procedure Output (Stream : access Root_Stream_Type'Class; Item : Parent);
|
|
|
for Parent'Read use Read;
|
for Parent'Read use Read;
|
for Parent'Write use Write;
|
for Parent'Write use Write;
|
for Parent'Input use Input;
|
for Parent'Input use Input;
|
for Parent'Output use Output;
|
for Parent'Output use Output;
|
|
|
|
|
procedure Actual_Read
|
procedure Actual_Read
|
(Stream : access Root_Stream_Type'Class; Item : out Int) is
|
(Stream : access Root_Stream_Type'Class; Item : out Int) is
|
begin
|
begin
|
Integer'Read (Stream, Integer (Item));
|
Integer'Read (Stream, Integer (Item));
|
end Actual_Read;
|
end Actual_Read;
|
|
|
procedure Actual_Write
|
procedure Actual_Write
|
(Stream : access Root_Stream_Type'Class; Item : Int) is
|
(Stream : access Root_Stream_Type'Class; Item : Int) is
|
begin
|
begin
|
Integer'Write (Stream, Integer (Item));
|
Integer'Write (Stream, Integer (Item));
|
end Actual_Write;
|
end Actual_Write;
|
|
|
function Actual_Input (Stream : access Root_Stream_Type'Class) return Int is
|
function Actual_Input (Stream : access Root_Stream_Type'Class) return Int is
|
begin
|
begin
|
return Int (Integer'Input (Stream));
|
return Int (Integer'Input (Stream));
|
end Actual_Input;
|
end Actual_Input;
|
|
|
procedure Actual_Output
|
procedure Actual_Output
|
(Stream : access Root_Stream_Type'Class; Item : Int) is
|
(Stream : access Root_Stream_Type'Class; Item : Int) is
|
begin
|
begin
|
Integer'Output (Stream, Integer (Item));
|
Integer'Output (Stream, Integer (Item));
|
end Actual_Output;
|
end Actual_Output;
|
|
|
|
|
procedure Actual_Read
|
procedure Actual_Read
|
(Stream : access Root_Stream_Type'Class; Item : out Lim) is
|
(Stream : access Root_Stream_Type'Class; Item : out Lim) is
|
begin
|
begin
|
Integer'Read (Stream, Integer (Item.C));
|
Integer'Read (Stream, Integer (Item.C));
|
end Actual_Read;
|
end Actual_Read;
|
|
|
procedure Actual_Write
|
procedure Actual_Write
|
(Stream : access Root_Stream_Type'Class; Item : Lim) is
|
(Stream : access Root_Stream_Type'Class; Item : Lim) is
|
begin
|
begin
|
Integer'Write (Stream, Integer (Item.C));
|
Integer'Write (Stream, Integer (Item.C));
|
end Actual_Write;
|
end Actual_Write;
|
|
|
function Actual_Input (Stream : access Root_Stream_Type'Class) return Lim is
|
function Actual_Input (Stream : access Root_Stream_Type'Class) return Lim is
|
Result : Lim;
|
Result : Lim;
|
begin
|
begin
|
Result.C := Int (Integer'Input (Stream));
|
Result.C := Int (Integer'Input (Stream));
|
return Result;
|
return Result;
|
end Actual_Input;
|
end Actual_Input;
|
|
|
procedure Actual_Output
|
procedure Actual_Output
|
(Stream : access Root_Stream_Type'Class; Item : Lim) is
|
(Stream : access Root_Stream_Type'Class; Item : Lim) is
|
begin
|
begin
|
Integer'Output (Stream, Integer (Item.C));
|
Integer'Output (Stream, Integer (Item.C));
|
end Actual_Output;
|
end Actual_Output;
|
|
|
|
|
procedure Actual_Read
|
procedure Actual_Read
|
(Stream : access Root_Stream_Type'Class; Item : out Parent) is
|
(Stream : access Root_Stream_Type'Class; Item : out Parent) is
|
begin
|
begin
|
case Item.B is
|
case Item.B is
|
when False =>
|
when False =>
|
Item.C1 := 7;
|
Item.C1 := 7;
|
when True =>
|
when True =>
|
Float'Read (Stream, Item.C2);
|
Float'Read (Stream, Item.C2);
|
end case;
|
end case;
|
Str'Read (Stream, Item.S);
|
Str'Read (Stream, Item.S);
|
end Actual_Read;
|
end Actual_Read;
|
|
|
procedure Actual_Write
|
procedure Actual_Write
|
(Stream : access Root_Stream_Type'Class; Item : Parent) is
|
(Stream : access Root_Stream_Type'Class; Item : Parent) is
|
begin
|
begin
|
case Item.B is
|
case Item.B is
|
when False =>
|
when False =>
|
null; -- Don't write C1
|
null; -- Don't write C1
|
when True =>
|
when True =>
|
Float'Write (Stream, Item.C2);
|
Float'Write (Stream, Item.C2);
|
end case;
|
end case;
|
Str'Write (Stream, Item.S);
|
Str'Write (Stream, Item.S);
|
end Actual_Write;
|
end Actual_Write;
|
|
|
function Actual_Input
|
function Actual_Input
|
(Stream : access Root_Stream_Type'Class) return Parent is
|
(Stream : access Root_Stream_Type'Class) return Parent is
|
X : Parent (1, 1, True);
|
X : Parent (1, 1, True);
|
begin
|
begin
|
raise Input_Output_Error;
|
raise Input_Output_Error;
|
return X;
|
return X;
|
end Actual_Input;
|
end Actual_Input;
|
|
|
procedure Actual_Output
|
procedure Actual_Output
|
(Stream : access Root_Stream_Type'Class; Item : Parent) is
|
(Stream : access Root_Stream_Type'Class; Item : Parent) is
|
begin
|
begin
|
raise Input_Output_Error;
|
raise Input_Output_Error;
|
end Actual_Output;
|
end Actual_Output;
|
|
|
package Int_Ops is new Counting_Stream_Ops (T => Int'Base,
|
package Int_Ops is new Counting_Stream_Ops (T => Int'Base,
|
Actual_Write => Actual_Write,
|
Actual_Write => Actual_Write,
|
Actual_Input => Actual_Input,
|
Actual_Input => Actual_Input,
|
Actual_Read => Actual_Read,
|
Actual_Read => Actual_Read,
|
Actual_Output => Actual_Output);
|
Actual_Output => Actual_Output);
|
|
|
package Lim_Ops is new Counting_Stream_Ops (T => Lim,
|
package Lim_Ops is new Counting_Stream_Ops (T => Lim,
|
Actual_Write => Actual_Write,
|
Actual_Write => Actual_Write,
|
Actual_Input => Actual_Input,
|
Actual_Input => Actual_Input,
|
Actual_Read => Actual_Read,
|
Actual_Read => Actual_Read,
|
Actual_Output => Actual_Output);
|
Actual_Output => Actual_Output);
|
|
|
package Parent_Ops is
|
package Parent_Ops is
|
new Counting_Stream_Ops (T => Parent,
|
new Counting_Stream_Ops (T => Parent,
|
Actual_Write => Actual_Write,
|
Actual_Write => Actual_Write,
|
Actual_Input => Actual_Input,
|
Actual_Input => Actual_Input,
|
Actual_Read => Actual_Read,
|
Actual_Read => Actual_Read,
|
Actual_Output => Actual_Output);
|
Actual_Output => Actual_Output);
|
|
|
procedure Read (Stream : access Root_Stream_Type'Class; Item : out Int'Base)
|
procedure Read (Stream : access Root_Stream_Type'Class; Item : out Int'Base)
|
renames Int_Ops.Read;
|
renames Int_Ops.Read;
|
procedure Write (Stream : access Root_Stream_Type'Class; Item : Int'Base)
|
procedure Write (Stream : access Root_Stream_Type'Class; Item : Int'Base)
|
renames Int_Ops.Write;
|
renames Int_Ops.Write;
|
function Input (Stream : access Root_Stream_Type'Class) return Int'Base
|
function Input (Stream : access Root_Stream_Type'Class) return Int'Base
|
renames Int_Ops.Input;
|
renames Int_Ops.Input;
|
procedure Output (Stream : access Root_Stream_Type'Class; Item : Int'Base)
|
procedure Output (Stream : access Root_Stream_Type'Class; Item : Int'Base)
|
renames Int_Ops.Output;
|
renames Int_Ops.Output;
|
|
|
procedure Read (Stream : access Root_Stream_Type'Class; Item : out Lim)
|
procedure Read (Stream : access Root_Stream_Type'Class; Item : out Lim)
|
renames Lim_Ops.Read;
|
renames Lim_Ops.Read;
|
procedure Write (Stream : access Root_Stream_Type'Class; Item : Lim)
|
procedure Write (Stream : access Root_Stream_Type'Class; Item : Lim)
|
renames Lim_Ops.Write;
|
renames Lim_Ops.Write;
|
function Input (Stream : access Root_Stream_Type'Class) return Lim
|
function Input (Stream : access Root_Stream_Type'Class) return Lim
|
renames Lim_Ops.Input;
|
renames Lim_Ops.Input;
|
procedure Output (Stream : access Root_Stream_Type'Class; Item : Lim)
|
procedure Output (Stream : access Root_Stream_Type'Class; Item : Lim)
|
renames Lim_Ops.Output;
|
renames Lim_Ops.Output;
|
|
|
procedure Read (Stream : access Root_Stream_Type'Class; Item : out Parent)
|
procedure Read (Stream : access Root_Stream_Type'Class; Item : out Parent)
|
renames Parent_Ops.Read;
|
renames Parent_Ops.Read;
|
procedure Write (Stream : access Root_Stream_Type'Class; Item : Parent)
|
procedure Write (Stream : access Root_Stream_Type'Class; Item : Parent)
|
renames Parent_Ops.Write;
|
renames Parent_Ops.Write;
|
function Input (Stream : access Root_Stream_Type'Class) return Parent
|
function Input (Stream : access Root_Stream_Type'Class) return Parent
|
renames Parent_Ops.Input;
|
renames Parent_Ops.Input;
|
procedure Output (Stream : access Root_Stream_Type'Class; Item : Parent)
|
procedure Output (Stream : access Root_Stream_Type'Class; Item : Parent)
|
renames Parent_Ops.Output;
|
renames Parent_Ops.Output;
|
|
|
type Derived1 is new Parent with
|
type Derived1 is new Parent with
|
record
|
record
|
C3 : Int;
|
C3 : Int;
|
end record;
|
end record;
|
|
|
type Derived2 (D : Int) is new Parent (D1 => D,
|
type Derived2 (D : Int) is new Parent (D1 => D,
|
D2 => D,
|
D2 => D,
|
B => False) with
|
B => False) with
|
record
|
record
|
C3 : Lim;
|
C3 : Lim;
|
end record;
|
end record;
|
|
|
begin
|
begin
|
Test ("CDD2A03",
|
Test ("CDD2A03",
|
"Check that the default Read and Write attributes for a limited " &
|
"Check that the default Read and Write attributes for a limited " &
|
"type extension are created from the parent type's " &
|
"type extension are created from the parent type's " &
|
"attribute (which may be user-defined) and those for the " &
|
"attribute (which may be user-defined) and those for the " &
|
"extension components, if the extension components are " &
|
"extension components, if the extension components are " &
|
"non-limited or have user-defined attributes; check that such " &
|
"non-limited or have user-defined attributes; check that such " &
|
"limited type extension attributes are callable");
|
"limited type extension attributes are callable");
|
|
|
Test1:
|
Test1:
|
declare
|
declare
|
S : aliased My_Stream (1000);
|
S : aliased My_Stream (1000);
|
X1 : Derived1 (D1 => Int (Ident_Int (2)),
|
X1 : Derived1 (D1 => Int (Ident_Int (2)),
|
D2 => Int (Ident_Int (5)),
|
D2 => Int (Ident_Int (5)),
|
B => Ident_Bool (True));
|
B => Ident_Bool (True));
|
X2 : Derived1 (D1 => Int (Ident_Int (2)),
|
X2 : Derived1 (D1 => Int (Ident_Int (2)),
|
D2 => Int (Ident_Int (5)),
|
D2 => Int (Ident_Int (5)),
|
B => Ident_Bool (True));
|
B => Ident_Bool (True));
|
begin
|
begin
|
X1.S := Str (Ident_Str ("bcde"));
|
X1.S := Str (Ident_Str ("bcde"));
|
X1.C2 := Float (Ident_Int (4));
|
X1.C2 := Float (Ident_Int (4));
|
X1.C3 := Int (Ident_Int (99));
|
X1.C3 := Int (Ident_Int (99));
|
|
|
Derived1'Write (S'Access, X1);
|
Derived1'Write (S'Access, X1);
|
if Int_Ops.Get_Counts /=
|
if Int_Ops.Get_Counts /=
|
(Read => 0, Write => 1, Input => 0, Output => 0) then
|
(Read => 0, Write => 1, Input => 0, Output => 0) then
|
Failed ("Error writing extension components - 1");
|
Failed ("Error writing extension components - 1");
|
end if;
|
end if;
|
if Parent_Ops.Get_Counts /=
|
if Parent_Ops.Get_Counts /=
|
(Read => 0, Write => 1, Input => 0, Output => 0) then
|
(Read => 0, Write => 1, Input => 0, Output => 0) then
|
Failed ("Didn't call parent type's Write - 1");
|
Failed ("Didn't call parent type's Write - 1");
|
end if;
|
end if;
|
|
|
Derived1'Read (S'Access, X2);
|
Derived1'Read (S'Access, X2);
|
if Int_Ops.Get_Counts /=
|
if Int_Ops.Get_Counts /=
|
(Read => 1, Write => 1, Input => 0, Output => 0) then
|
(Read => 1, Write => 1, Input => 0, Output => 0) then
|
Failed ("Error reading extension components - 1");
|
Failed ("Error reading extension components - 1");
|
end if;
|
end if;
|
if Parent_Ops.Get_Counts /=
|
if Parent_Ops.Get_Counts /=
|
(Read => 1, Write => 1, Input => 0, Output => 0) then
|
(Read => 1, Write => 1, Input => 0, Output => 0) then
|
Failed ("Didn't call inherited Read - 1");
|
Failed ("Didn't call inherited Read - 1");
|
end if;
|
end if;
|
end Test1;
|
end Test1;
|
|
|
Test2:
|
Test2:
|
declare
|
declare
|
S : aliased My_Stream (1000);
|
S : aliased My_Stream (1000);
|
X1 : Derived2 (D => Int (Ident_Int (7)));
|
X1 : Derived2 (D => Int (Ident_Int (7)));
|
X2 : Derived2 (D => Int (Ident_Int (7)));
|
X2 : Derived2 (D => Int (Ident_Int (7)));
|
begin
|
begin
|
X1.S := Str (Ident_Str ("g"));
|
X1.S := Str (Ident_Str ("g"));
|
X1.C1 := Ident_Int (4);
|
X1.C1 := Ident_Int (4);
|
X1.C3.C := Int (Ident_Int (666));
|
X1.C3.C := Int (Ident_Int (666));
|
|
|
Derived2'Write (S'Access, X1);
|
Derived2'Write (S'Access, X1);
|
if Lim_Ops.Get_Counts /=
|
if Lim_Ops.Get_Counts /=
|
(Read => 0, Write => 1, Input => 0, Output => 0) then
|
(Read => 0, Write => 1, Input => 0, Output => 0) then
|
Failed ("Error writing extension components - 2");
|
Failed ("Error writing extension components - 2");
|
end if;
|
end if;
|
if Parent_Ops.Get_Counts /=
|
if Parent_Ops.Get_Counts /=
|
(Read => 1, Write => 2, Input => 0, Output => 0) then
|
(Read => 1, Write => 2, Input => 0, Output => 0) then
|
Failed ("Didn't call inherited Write - 2");
|
Failed ("Didn't call inherited Write - 2");
|
end if;
|
end if;
|
|
|
Derived2'Read (S'Access, X2);
|
Derived2'Read (S'Access, X2);
|
if Lim_Ops.Get_Counts /=
|
if Lim_Ops.Get_Counts /=
|
(Read => 1, Write => 1, Input => 0, Output => 0) then
|
(Read => 1, Write => 1, Input => 0, Output => 0) then
|
Failed ("Error reading extension components - 2");
|
Failed ("Error reading extension components - 2");
|
end if;
|
end if;
|
if Parent_Ops.Get_Counts /=
|
if Parent_Ops.Get_Counts /=
|
(Read => 2, Write => 2, Input => 0, Output => 0) then
|
(Read => 2, Write => 2, Input => 0, Output => 0) then
|
Failed ("Didn't call inherited Read - 2");
|
Failed ("Didn't call inherited Read - 2");
|
end if;
|
end if;
|
end Test2;
|
end Test2;
|
|
|
Result;
|
Result;
|
end CDD2A03;
|
end CDD2A03;
|
|
|