summaryrefslogtreecommitdiff
path: root/gcc/testsuite/ada/acats/tests/cd/cd30004.a
blob: 1a1bcff1f5d852adf2c7929dbf16dde929b7ba54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
-- CD30004.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 the unspecified Size of static discrete
--      subtypes is the number of bits needed to represent each value
--      belonging to the subtype using an unbiased representation, where
--      space for a sign bit is provided only in the event the subtype
--      contains negative values.  Check that for first subtypes specified
--      Sizes are supported reflecting this representation. [ARM 95 13.3(55)].
--
-- TEST DESCRIPTION:
--      This test defines a few types that should have distinctly recognizable
--      sizes.  A packed record which should result in very specific bits
--      sizes for it's components is used to check the first part of the
--      objective. The second part of the objective is checked by giving
--	sizes for a similar set of types.
--
-- APPLICABILITY CRITERIA:
--      All implementations must attempt to compile this test.
--
--      For implementations validating against Systems Programming Annex (C):
--        this test must execute and report PASSED.
--
--      For implementations not validating against Annex C:
--        this test may report compile time errors at one or more points
--        indicated by "-- ANX-C RQMT", in which case it may be graded as inapplicable.
--        Otherwise, the test must execute and report PASSED.
--
-- CHANGE HISTORY:
--      22 JUL 95   SAIC   Initial version
--      06 MAY 96   SAIC   Revised for 2.1
--      26 FEB 97   PWB.CTA Added pragma Pack for type Check_Record
--      16 FEB 98   EDS    Modified Documentation.
--      06 JUL 99   RLB    Repaired comments, removed junk test cases.
--                         Added test cases to test that appropriate Size
--                         clauses are allowed.

--!
----------------------------------------------------------------- CD30004_0

package CD30004_0 is

--      Check that the unspecified Size of static discrete and fixed point
--      subtypes are the number of bits needed to represent each value
--      belonging to the subtype using an unbiased representation, where
--      space for a sign bit is provided only in the event the subtype
--      contains negative values.  Check that for first subtypes specified
--      Sizes are supported reflecting this representation.

  type Bits_2 is ( Zeroth_Bit, Fiercest_Bit, Secants_Bit, Threadless_Bit );

  type Bits_3 is range 0..2**3-1;

  type Bits_5 is range -2**4+1..2**4-1;  -- allow for 1's comp

  type Bits_14 is mod 2**14;

  type Check_Record is
  record
    B14 : Bits_14;
    B2  : Bits_2;
    B3  : Bits_3;
    B5  : Bits_5;
    C   : Character;
  end record;
  pragma Pack ( Check_Record );

  procedure TC_Check_Values;
  procedure TC_Check_Specified_Sizes;

end CD30004_0;

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
with Report;
with Impdef;
package body CD30004_0 is

  procedure TC_Check_Values is
  begin

    if Bits_2'Size /= 2 then
      if Impdef.Validating_Annex_C then
         Report.Failed("Bits_2'Size not 2 bits");
      else -- Recommended levels of support are not binding.
         Report.Comment("Bits_2'Size not 2 bits");
      end if;
    end if;

    if Bits_14'Size /= 14 then
      if Impdef.Validating_Annex_C then
         Report.Failed("Bits_14'Size not 14 bits");
      else
         Report.Comment("Bits_14'Size not 14 bits");
      end if;
    end if;

    if Bits_3'Size /= 3 then
      if Impdef.Validating_Annex_C then
         Report.Failed("Bits_3'Size not 3 bits");
      else
         Report.Comment("Bits_3'Size not 3 bits");
      end if;
    end if;

    if Bits_5'Size /= 5 then
      if Impdef.Validating_Annex_C then
         Report.Failed("Bits_5'Size not 5 bits");
      else
         Report.Comment("Bits_5'Size not 5 bits");
      end if;
    end if;

    if Character'Size /= 8 then
      Report.Failed("Character'Size not 8 bits");
    end if;

    if Wide_Character'Size /= 16 then
      Report.Failed("Wide_Character'Size not 16 bits");
    end if;

  end TC_Check_Values;

  type Spec_Bits_2 is ( Zeroth_Bit, Fiercest_Bit, Secants_Bit, Threadless_Bit );
  for Spec_Bits_2'Size use 2;                            -- ANX-C RQMT.

  type Spec_Bits_3 is range 0..2**3-1;
  for Spec_Bits_3'Size use 3;                            -- ANX-C RQMT.

  type Spec_Bits_5 is range -2**4+1..2**4-1;  -- allow for 1's comp
  for Spec_Bits_5'Size use 5;                            -- ANX-C RQMT.

  type Spec_Bits_14 is mod 2**14;
  for Spec_Bits_14'Size use 14;                          -- ANX-C RQMT.

  type Spec_Record is new Check_Record;
  for Spec_Record'Size use 64;                           -- ANX-C RQMT.

  procedure TC_Check_Specified_Sizes is

  begin

    if Spec_Record'Size /= 64 then
      Report.Failed("Spec_Record'Size not 64 bits");
    end if;

    if Spec_Bits_2'Size /= 2 then
      Report.Failed("Spec_Bits_2'Size not 2 bits");
    end if;

    if Spec_Bits_14'Size /= 14 then
      Report.Failed("Spec_Bits_14'Size not 14 bits");
    end if;

    if Spec_Bits_3'Size /= 3 then
      Report.Failed("Spec_Bits_3'Size not 3 bits");
    end if;

    if Spec_Bits_5'Size /= 5 then
      Report.Failed("Spec_Bits_5'Size not 5 bits");
    end if;

  end TC_Check_Specified_Sizes;

end CD30004_0;

------------------------------------------------------------------- CD30004

with Report;
with CD30004_0;

procedure CD30004 is

begin  -- Main test procedure.

  Report.Test ("CD30004", "Check that the unspecified Size of static " &
               "discrete and fixed point subtypes is the number of bits " &
               "needed to represent each value belonging to the subtype " &
               "using an unbiased representation, where space for a sign " &
               "bit is provided only in the event the subtype contains " &
               "negative values.  Check that for first subtypes " &
               "specified Sizes are supported reflecting this " &
               "representation.");

  CD30004_0.TC_Check_Values;

  CD30004_0.TC_Check_Specified_Sizes;

  Report.Result;

end CD30004;