annotate gcc/testsuite/ada/acats/tests/c4/c420001.a @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- C420001.A
kono
parents:
diff changeset
2 --
kono
parents:
diff changeset
3 -- Grant of Unlimited Rights
kono
parents:
diff changeset
4 --
kono
parents:
diff changeset
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687 and
kono
parents:
diff changeset
6 -- F08630-91-C-0015, the U.S. Government obtained unlimited rights in the
kono
parents:
diff changeset
7 -- software and documentation contained herein. Unlimited rights are
kono
parents:
diff changeset
8 -- defined in DFAR 252.227-7013(a)(19). By making this public release,
kono
parents:
diff changeset
9 -- the Government intends to confer upon all recipients unlimited rights
kono
parents:
diff changeset
10 -- equal to those held by the Government. These rights include rights to
kono
parents:
diff changeset
11 -- use, duplicate, release or disclose the released technical data and
kono
parents:
diff changeset
12 -- computer software in whole or in part, in any manner and for any purpose
kono
parents:
diff changeset
13 -- whatsoever, and to have or permit others to do so.
kono
parents:
diff changeset
14 --
kono
parents:
diff changeset
15 -- DISCLAIMER
kono
parents:
diff changeset
16 --
kono
parents:
diff changeset
17 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
18 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
19 -- WARRANTY AS TO ANY MATTER WHATSOVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
20 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
21 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
22 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
23 --*
kono
parents:
diff changeset
24 --
kono
parents:
diff changeset
25 -- OBJECTIVE
kono
parents:
diff changeset
26 -- Check that if the index subtype of a string type is a modular subtype
kono
parents:
diff changeset
27 -- whose lower bound is zero, then the evaluation of a null string_literal
kono
parents:
diff changeset
28 -- raises Constraint_Error. This was confirmed by AI95-00138.
kono
parents:
diff changeset
29 --
kono
parents:
diff changeset
30 -- TEST DESCRIPTION
kono
parents:
diff changeset
31 -- In this test, we have a generic formal modular type, and we have
kono
parents:
diff changeset
32 -- several null string literals of that type. Because the type is
kono
parents:
diff changeset
33 -- generic formal, the string literals are not static, and therefore
kono
parents:
diff changeset
34 -- the Constraint_Error should be detected at run time.
kono
parents:
diff changeset
35 --
kono
parents:
diff changeset
36 -- CHANGE HISTORY:
kono
parents:
diff changeset
37 -- 29 JUN 1999 RAD Initial Version
kono
parents:
diff changeset
38 -- 23 SEP 1999 RLB Improved comments and messages, renamed, issued.
kono
parents:
diff changeset
39 --
kono
parents:
diff changeset
40 --!
kono
parents:
diff changeset
41 with Report; use Report; pragma Elaborate_All(Report);
kono
parents:
diff changeset
42 with System;
kono
parents:
diff changeset
43 procedure C420001 is
kono
parents:
diff changeset
44 generic
kono
parents:
diff changeset
45 type Modular is mod <>;
kono
parents:
diff changeset
46 package Mod_Test is
kono
parents:
diff changeset
47 type Str is array(Modular range <>) of Character;
kono
parents:
diff changeset
48 procedure Test_String_Literal;
kono
parents:
diff changeset
49 end Mod_Test;
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 package body Mod_Test is
kono
parents:
diff changeset
52 procedure Test_String_Literal is
kono
parents:
diff changeset
53 begin
kono
parents:
diff changeset
54 begin
kono
parents:
diff changeset
55 declare
kono
parents:
diff changeset
56 Null_String: Str := ""; -- Should raise C_E.
kono
parents:
diff changeset
57 begin
kono
parents:
diff changeset
58 Comment(String(Null_String)); -- Avoid 11.6 issues.
kono
parents:
diff changeset
59 end;
kono
parents:
diff changeset
60 Failed("Null string didn't raise Constraint_Error");
kono
parents:
diff changeset
61 exception
kono
parents:
diff changeset
62 when Exc: Constraint_Error =>
kono
parents:
diff changeset
63 null; -- Comment("Constraint_Error -- OK");
kono
parents:
diff changeset
64 when Exc2: others =>
kono
parents:
diff changeset
65 Failed("Null string raised wrong exception");
kono
parents:
diff changeset
66 end;
kono
parents:
diff changeset
67 begin
kono
parents:
diff changeset
68 Failed(String(Str'(""))); -- Should raise C_E, not do Failed.
kono
parents:
diff changeset
69 Failed("Null string didn't raise Constraint_Error");
kono
parents:
diff changeset
70 exception
kono
parents:
diff changeset
71 when Exc: Constraint_Error =>
kono
parents:
diff changeset
72 null; -- Comment("Constraint_Error -- OK");
kono
parents:
diff changeset
73 when Exc2: others =>
kono
parents:
diff changeset
74 Failed("Null string raised wrong exception");
kono
parents:
diff changeset
75 end;
kono
parents:
diff changeset
76 end Test_String_Literal;
kono
parents:
diff changeset
77 begin
kono
parents:
diff changeset
78 Test_String_Literal;
kono
parents:
diff changeset
79 end Mod_Test;
kono
parents:
diff changeset
80 begin
kono
parents:
diff changeset
81 Test("C420001", "Check that if the index subtype of a string type is a " &
kono
parents:
diff changeset
82 "modular subtype whose lower bound is zero, then the " &
kono
parents:
diff changeset
83 "evaluation of a null string_literal raises " &
kono
parents:
diff changeset
84 "Constraint_Error. ");
kono
parents:
diff changeset
85 declare
kono
parents:
diff changeset
86 type M1 is mod 1;
kono
parents:
diff changeset
87 package Test_M1 is new Mod_Test(M1);
kono
parents:
diff changeset
88 type M2 is mod 2;
kono
parents:
diff changeset
89 package Test_M2 is new Mod_Test(M2);
kono
parents:
diff changeset
90 type M3 is mod 3;
kono
parents:
diff changeset
91 package Test_M3 is new Mod_Test(M3);
kono
parents:
diff changeset
92 type M4 is mod 4;
kono
parents:
diff changeset
93 package Test_M4 is new Mod_Test(M4);
kono
parents:
diff changeset
94 type M5 is mod 5;
kono
parents:
diff changeset
95 package Test_M5 is new Mod_Test(M5);
kono
parents:
diff changeset
96 type M6 is mod 6;
kono
parents:
diff changeset
97 package Test_M6 is new Mod_Test(M6);
kono
parents:
diff changeset
98 type M7 is mod 7;
kono
parents:
diff changeset
99 package Test_M7 is new Mod_Test(M7);
kono
parents:
diff changeset
100 type M8 is mod 8;
kono
parents:
diff changeset
101 package Test_M8 is new Mod_Test(M8);
kono
parents:
diff changeset
102 type M_Max_Binary_Modulus is mod System.Max_Binary_Modulus;
kono
parents:
diff changeset
103 package Test_M_Max_Binary_Modulus is new Mod_Test(M_Max_Binary_Modulus);
kono
parents:
diff changeset
104 type M_Max_Nonbinary_Modulus is mod System.Max_Nonbinary_Modulus;
kono
parents:
diff changeset
105 package Test_M_Max_Nonbinary_Modulus is new Mod_Test(M_Max_Nonbinary_Modulus);
kono
parents:
diff changeset
106 begin
kono
parents:
diff changeset
107 null;
kono
parents:
diff changeset
108 end;
kono
parents:
diff changeset
109 Result;
kono
parents:
diff changeset
110 end C420001;