1-- CD30011.A 2 3-- Grant of Unlimited Rights 4-- 5-- The Ada Conformity Assessment Authority (ACAA) holds unlimited 6-- rights in the software and documentation contained herein. Unlimited 7-- rights are the same as those granted by the U.S. Government for older 8-- parts of the Ada Conformity Assessment Test Suite, and are defined 9-- in DFAR 252.227-7013(a)(19). By making this public release, the ACAA 10-- intends to confer upon all recipients unlimited rights equal to those 11-- held by the ACAA. These rights include rights to use, duplicate, 12-- release or disclose the released technical data and computer software 13-- in whole or in part, in any manner and for any purpose whatsoever, and 14-- to have or permit others to do so. 15-- 16-- DISCLAIMER 17-- 18-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR 19-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED 20-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE 21-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE 22-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A 23-- PARTICULAR PURPOSE OF SAID MATERIAL. 24-- 25-- Notice 26-- 27-- The ACAA has created and maintains the Ada Conformity Assessment Test 28-- Suite for the purpose of conformity assessments conducted in accordance 29-- with the International Standard ISO/IEC 18009 - Ada: Conformity 30-- assessment of a language processor. This test suite should not be used 31-- to make claims of conformance unless used in accordance with 32-- ISO/IEC 18009 and any applicable ACAA procedures. 33-- 34--* 35-- OBJECTIVE: 36-- Check that a size specification can be given by an attribute definition 37-- clause for an enumeration type: 38-- * in the visible or private part of a package for a type declared 39-- in the visible part; 40-- * for a derived enumeration type; 41-- * for a derived private type whose full declaration is an 42-- enumeration type. 43-- 44-- TEST DESCRIPTION: 45-- This test was created from legacy tests CD1009B and CD2A31C. The 46-- objective of CD1009B was also an objective of CD2A31C; the tests 47-- were merged to eliminate duplication and add appropriate applicability 48-- criteria. 49-- 50-- APPLICABILITY CRITERIA: 51-- All implementations must attempt to compile this test. 52-- 53-- For implementations validating against Systems Programming Annex (C): 54-- this test must execute and report PASSED. 55-- 56-- or implementations not validating against Annex C: 57-- this test may report compile time errors at one or more points 58-- indicated by "-- ANX-C RQMT", in which case it may be graded as 59-- inapplicable. Otherwise, the test must execute and report PASSED. 60-- 61-- CHANGE HISTORY: 62-- 17 Jun 87 PWB Created original test CD2A21C. 63-- 07 Oct 87 VCL Created original test CD1009B. 64-- 17 Apr 89 DHH Changed extension from '.DEP' TO '.ADA', changed 65-- operators on 'Size tests, and added check on 66-- representation clause. 67-- 26 Mar 92 JRL Removed testing of nonobjective types. 68-- 29 Mar 17 RLB Created test from CD2A21C and CD1009B; reformatted 69-- to "modern" standards, added applicability criteria. 70 71with Report; use Report; 72with Length_Check; -- CONTAINS A CALL TO 'Failed'. 73procedure CD30011 is 74 75 type Basic_Enum is (A, B, C, D, E); 76 Specified_Size : constant := Basic_Enum'Size; 77 78 Minimum_Size : Integer := Report.Ident_Int (Specified_Size); 79 80 type Derived_Enum is new Basic_Enum; 81 for Derived_Enum'Size use Specified_Size; -- ANX-C RQMT. 82 83 package P is 84 type Enum_in_P is (A1, B1, C1, D1, E1, F1, G1); 85 for Enum_in_P'Size use Specified_Size; -- ANX-C RQMT. 86 type private_Enum is private; 87 type Alt_Enum_in_P is (A2, B2, C2, D2, E2, F2, G2); 88 private 89 type private_Enum is (A3, B3, C3, D3, E3, F3, G3); 90 for Alt_Enum_in_P'Size use Specified_Size; -- ANX-C RQMT. 91 end P; 92 93 type Derived_Private_Enum is new P.Private_Enum; 94 for Derived_Private_Enum'Size use Specified_Size; -- ANX-C RQMT. 95 96 use P; 97 98 procedure Check_1 is new Length_Check (Derived_Enum); 99 procedure Check_2 is new Length_Check (Enum_in_P); 100 procedure Check_3 is new Length_Check (Alt_Enum_in_P); 101 102 X : Enum_in_P := A1; 103 Y : Alt_Enum_in_P := A2; 104 105begin 106 107 Report.Test ("CD30011", "Check that 'Size attribute definition clauses " & 108 "can be given in the visible or private part " & 109 "of a package for enumeration types declared " & 110 "declared in the visible part, and for derived " & 111 "enumeration types and derived private types " & 112 "whose full declarations are as enumeration types"); 113 114 Check_1 (C, Specified_Size, "Derived_Enum"); 115 Check_2 (C1, Specified_Size, "Enum_in_P"); 116 Check_3 (C2, Specified_Size, "Alt_Enum_in_P"); 117 118 if Derived_Enum'Size /= Minimum_Size then 119 Failed ("Derived_Enum'Size should not be greater than" & 120 Integer'Image (Minimum_Size) & ". Actual Size is" & 121 Integer'Image (Derived_Enum'Size)); 122 end if; 123 124 if Enum_in_P'Size /= Minimum_Size then 125 Failed ("Enum_in_P'Size should not be greater than" & 126 Integer'Image (Minimum_Size) & ". Actual Size is" & 127 Integer'Image (Enum_in_P'Size)); 128 end if; 129 130 if Alt_Enum_in_P'Size /= Minimum_Size then 131 Failed ("Alt_Enum_in_P'Size should not be greater than" & 132 Integer'Image (Minimum_Size) & ". Actual Size is" & 133 Integer'Image (Alt_Enum_in_P'Size)); 134 end if; 135 136 if Derived_Private_Enum'Size /= Minimum_Size then 137 138 Failed ("Derived_Private_Enum'Size should not be greater " & 139 "than " & Integer'Image (Minimum_Size) & ". Actual Size is" & 140 Integer'Image (Derived_Private_Enum'Size)); 141 end if; 142 143 if X'Size < Specified_Size then 144 Failed ("Object'Size is too small --" & 145 Enum_in_P'Image (X)); 146 end if; 147 148 if Y'Size < Specified_Size then 149 Failed ("Object'Size is too small --" & 150 Alt_Enum_in_P'Image (Y)); 151 end if; 152 153 Report.Result; 154 155end CD30011; 156