-- B431008.A -- -- Grant of Unlimited Rights -- -- The Ada Conformity Assessment Authority (ACAA) holds unlimited -- rights in the software and documentation contained herein. Unlimited -- 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 -- 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 -- held by the ACAA. 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 ACAA 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. -- -- Notice -- -- The ACAA has created and maintains the Ada Conformity Assessment Test -- Suite for the purpose of conformity assessments conducted in accordance -- with the International Standard ISO/IEC 18009 - Ada: Conformity -- assessment of a language processor. This test suite should not be used -- to make claims of conformance unless used in accordance with -- ISO/IEC 18009 and any applicable ACAA procedures. -- --* -- OBJECTIVE: -- Check that the association in a record aggregate for a discriminant -- without a default cannot be given by <>. -- -- TEST DESCRIPTION: -- Record aggregate cases for paragraph 4.3.1(17.1/2). Note that this rule -- applies to all Ada versions since Amendment 1 for Ada 95. -- -- CHANGE HISTORY: -- 2022-03-28 RLB Created test using new test C431003 as a template. -- --! with Ada.Calendar; procedure B431008 is -- Example where a discriminant of a numeric type determines the bounds of a -- 1-D array type Integer_Vector is array (Integer range <>) of Integer; Max : constant := 100; subtype Index is Integer range 0 .. Max; type Poly_Type (N : Index) is record A : Integer_Vector (0 .. N); end record; -- Discriminant explicitly initialised to default Poly_1 : Poly_Type := (N => <>, A => <>); -- ERROR: {26;1} -- Discriminant explicitly initialised to a specific value Poly_2 : Poly_Type := (N => 2, A => <>); -- OK. {26;1} -- Example where discriminants of a numeric type determine the bounds of a -- matrix subtype Bounds_Type is Integer range 0 .. 100; type Matrix_Type is array (Bounds_Type range <>, Bounds_Type range <>) of Float; type Matrix_Rec_Type (Rows : Integer; Columns : Integer) is record Mat : Matrix_Type (1 .. Rows, 1 .. Columns); end record; Matrix_Rec : Matrix_Rec_Type (2, 3) := (Rows => <>, Columns => <>, Mat => (others => (others => 0.0))); -- ERROR: {2:13;1} -- Example where a discriminant of a numeric type selects a variant subtype Account_Number_Type is Integer range 1 .. 9_999; type Account_Type (Account_Number : Account_Number_Type) is record case Account_Number is when 1 .. 4_999 => -- Savings Account Savings_Rate : Float; when 5_000 .. 9_999 => -- Loan Account Loan_Rate : Float; end case; end record; Account : Account_Type(1); -- Example where multiple discriminants selects variants, one of a numeric -- type, one of an enumeration type type Extended_Account_Type (Account_Number : Account_Number_Type; Term_Account : Boolean ) is record case Account_Number is when 1 .. 4_999 => -- Savings Account Savings_Rate : Float; case Term_Account is when False => null; when True => Maturity_Date : Ada.Calendar.Time; end case; when 5_000 .. 9_999 => -- Loan Account Loan_Rate : Float; case Term_Account is when False => null; when True => Repayment_Date : Ada.Calendar.Time; end case; end case; end record; Extended_Account : Extended_Account_Type(1, False); begin -- Discriminant returned to default by assignment Poly_2 := (N => <>, A => <>); -- ERROR: {14;1} Matrix_Rec := (Rows => <>, Columns => <>, Mat => (others => (others => 0.0))); -- ERROR: {2:18;1} Matrix_Rec := (Rows => 2, Columns => <>, Mat => (others => (others => 0.0))); -- ERROR: {2:18;1} Matrix_Rec := (Rows => <>, Columns => 3, Mat => (others => (others => 0.0))); -- ERROR: {2:18;1} Matrix_Rec := (Rows => 2, Columns => 3, Mat => (others => (others => 0.0))); -- OK. {2:18;1} Matrix_Rec := (others => <>); -- ERROR: {18;1} Account := (Account_Number => <>, Savings_Rate => <>); -- ERROR: {15;1} Extended_Account := (Account_Number => <>, Savings_Rate => <>, Term_Account => <>); -- ERROR: {2:24;1} Extended_Account := (Account_Number => 1, Savings_Rate => <>, Term_Account => <>); -- ERROR: {2:24;1} Extended_Account := (Account_Number => <>, Savings_Rate => <>, Term_Account => False); -- ERROR: {2:24;1} Extended_Account := (Account_Number => 1, Savings_Rate => <>, Term_Account => False); -- OK. {2:24;1} Extended_Account := (others => <>); -- ERROR: {24;1} Extended_Account := (Account_Number => 1, others => <>); -- ERROR: {1:24;1} Extended_Account := (Account_Number => 1, Term_Account => False, others => <>); -- OK. {2:24;1} end B431008;