Debian Codegraph @

gcc/testsuite/gnat.dg/aggr33.adb

raw
1 -- { dg-do compile }
2 -- { dg-options "-gnat2022" }
3
4 with Ada.Containers.Vectors;
5
6 procedure Aggr33 is
7 type Light_Count is new Natural;
8 subtype Light_Position is Light_Count;
9
10 generic
11 Lights : Light_Position;
12
13 package Generic_Machine
14 is
15
16 subtype Light_State is Character
17 with Static_Predicate => Light_State in '.' | '#';
18
19 Off : constant Light_State := '.';
20 Lit : constant Light_State := '#';
21
22 type Panel_Type is
23 array (Light_Position range 0 .. Lights - 1) of Light_State;
24
25 Off_Panel : constant Panel_Type := [others => Off];
26
27 -----------------
28 -- Toggle_List --
29 -----------------
30
31 type Button_Index is new Positive;
32
33 package Toggle_Lists is new
34 Ada.Containers.Vectors (Index_Type => Button_Index,
35 Element_Type => Light_Position);
36
37 subtype Toggle_List is Toggle_Lists.Vector;
38
39 ----------------
40 -- Press_List --
41 ----------------
42
43 package Press_Lists is new
44 Ada.Containers.Vectors (Index_Type => Positive,
45 Element_Type => Toggle_Lists.Vector,
46 "=" => Toggle_Lists."=");
47
48 subtype Press_List is Press_Lists.Vector;
49
50 --------------------
51 -- Press_Sequence --
52 --------------------
53
54 subtype Press_Number is Natural;
55
56 type Press_Outcome is
57 record
58 Press : Toggle_List;
59 Panel : Panel_Type;
60 end record;
61
62 package Outcome_Lists is new
63 Ada.Containers.Vectors (Index_Type => Press_Number,
64 Element_Type => Press_Outcome);
65
66 subtype Outcome_List is Outcome_Lists.Vector;
67
68 --------------
69 -- Sequence --
70 --------------
71
72 subtype Sequence_Id is Positive;
73
74 package Sequence_Lists is new
75 Ada.Containers.Vectors (Index_Type => Sequence_Id,
76 Element_Type => Outcome_Lists.Vector,
77 "=" => Outcome_Lists."=");
78
79 subtype Sequence_List is Sequence_Lists.Vector;
80
81 end Generic_Machine;
82
83 package body Generic_Machine
84 is
85
86 procedure Add_Press
87 is
88 New_Sequence : Sequence_List;
89 Toggle : Toggle_List;
90 New_Panel : Panel_Type;
91 begin
92 New_Sequence.Append (Outcome_List'(Toggle, New_Panel)); -- { dg-error "too many components" }
93 end Add_Press;
94
95 end Generic_Machine;
96
97 begin
98 null;
99 end;