annotate gcc/ada/sem_scil.adb @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S E M _ S C I L --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2009-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 with Einfo; use Einfo;
kono
parents:
diff changeset
27 with Nlists; use Nlists;
kono
parents:
diff changeset
28 with Rtsfind; use Rtsfind;
kono
parents:
diff changeset
29 with Sem_Aux; use Sem_Aux;
kono
parents:
diff changeset
30 with Sinfo; use Sinfo;
kono
parents:
diff changeset
31 with Stand; use Stand;
kono
parents:
diff changeset
32 with SCIL_LL; use SCIL_LL;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 package body Sem_SCIL is
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 ---------------------
kono
parents:
diff changeset
37 -- Check_SCIL_Node --
kono
parents:
diff changeset
38 ---------------------
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 function Check_SCIL_Node (N : Node_Id) return Traverse_Result is
kono
parents:
diff changeset
41 SCIL_Node : constant Node_Id := Get_SCIL_Node (N);
kono
parents:
diff changeset
42 Ctrl_Tag : Node_Id;
kono
parents:
diff changeset
43 Ctrl_Typ : Entity_Id;
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 begin
kono
parents:
diff changeset
46 -- For nodes that do not have SCIL node continue traversing the tree
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 if No (SCIL_Node) then
kono
parents:
diff changeset
49 return OK;
kono
parents:
diff changeset
50 end if;
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 case Nkind (SCIL_Node) is
kono
parents:
diff changeset
53 when N_SCIL_Dispatch_Table_Tag_Init =>
kono
parents:
diff changeset
54 pragma Assert (Nkind (N) = N_Object_Declaration);
kono
parents:
diff changeset
55 null;
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 when N_SCIL_Dispatching_Call =>
kono
parents:
diff changeset
58 Ctrl_Tag := SCIL_Controlling_Tag (SCIL_Node);
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 -- Parent of SCIL dispatching call nodes MUST be a subprogram call
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 if Nkind (N) not in N_Subprogram_Call then
kono
parents:
diff changeset
63 raise Program_Error;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 -- In simple cases the controlling tag is the tag of the
kono
parents:
diff changeset
66 -- controlling argument (i.e. Obj.Tag).
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 elsif Nkind (Ctrl_Tag) = N_Selected_Component then
kono
parents:
diff changeset
69 Ctrl_Typ := Etype (Ctrl_Tag);
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 -- Interface types are unsupported
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 if Is_Interface (Ctrl_Typ)
kono
parents:
diff changeset
74 or else (RTE_Available (RE_Interface_Tag)
kono
parents:
diff changeset
75 and then Ctrl_Typ = RTE (RE_Interface_Tag))
kono
parents:
diff changeset
76 then
kono
parents:
diff changeset
77 null;
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 else
kono
parents:
diff changeset
80 pragma Assert (Ctrl_Typ = RTE (RE_Tag));
kono
parents:
diff changeset
81 null;
kono
parents:
diff changeset
82 end if;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 -- When the controlling tag of a dispatching call is an identifier
kono
parents:
diff changeset
85 -- the SCIL_Controlling_Tag attribute references the corresponding
kono
parents:
diff changeset
86 -- object or parameter declaration. Interface types are still
kono
parents:
diff changeset
87 -- unsupported.
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 elsif Nkind_In (Ctrl_Tag, N_Object_Declaration,
kono
parents:
diff changeset
90 N_Parameter_Specification)
kono
parents:
diff changeset
91 then
kono
parents:
diff changeset
92 Ctrl_Typ := Etype (Defining_Identifier (Ctrl_Tag));
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 -- Interface types are unsupported.
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 if Is_Interface (Ctrl_Typ)
kono
parents:
diff changeset
97 or else (RTE_Available (RE_Interface_Tag)
kono
parents:
diff changeset
98 and then Ctrl_Typ = RTE (RE_Interface_Tag))
kono
parents:
diff changeset
99 or else (Is_Access_Type (Ctrl_Typ)
kono
parents:
diff changeset
100 and then
kono
parents:
diff changeset
101 Is_Interface
kono
parents:
diff changeset
102 (Available_View
kono
parents:
diff changeset
103 (Base_Type (Designated_Type (Ctrl_Typ)))))
kono
parents:
diff changeset
104 then
kono
parents:
diff changeset
105 null;
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 else
kono
parents:
diff changeset
108 pragma Assert
kono
parents:
diff changeset
109 (Ctrl_Typ = RTE (RE_Tag)
kono
parents:
diff changeset
110 or else
kono
parents:
diff changeset
111 (Is_Access_Type (Ctrl_Typ)
kono
parents:
diff changeset
112 and then Available_View
kono
parents:
diff changeset
113 (Base_Type (Designated_Type (Ctrl_Typ)))
kono
parents:
diff changeset
114 = RTE (RE_Tag)));
kono
parents:
diff changeset
115 null;
kono
parents:
diff changeset
116 end if;
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 -- Interface types are unsupported
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 elsif Is_Interface (Etype (Ctrl_Tag)) then
kono
parents:
diff changeset
121 null;
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 else
kono
parents:
diff changeset
124 pragma Assert (False);
kono
parents:
diff changeset
125 raise Program_Error;
kono
parents:
diff changeset
126 end if;
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 return Skip;
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 when N_SCIL_Membership_Test =>
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 -- Check contents of the boolean expression associated with the
kono
parents:
diff changeset
133 -- membership test.
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 pragma Assert (Nkind_In (N, N_Identifier,
kono
parents:
diff changeset
136 N_And_Then,
kono
parents:
diff changeset
137 N_Or_Else,
kono
parents:
diff changeset
138 N_Expression_With_Actions)
kono
parents:
diff changeset
139 and then Etype (N) = Standard_Boolean);
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 -- Check the entity identifier of the associated tagged type (that
kono
parents:
diff changeset
142 -- is, in testing for membership in T'Class, the entity id of the
kono
parents:
diff changeset
143 -- specific type T).
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 -- Note: When the SCIL node is generated the private and full-view
kono
parents:
diff changeset
146 -- of the tagged types may have been swapped and hence the node
kono
parents:
diff changeset
147 -- referenced by attribute SCIL_Entity may be the private view.
kono
parents:
diff changeset
148 -- Therefore, in order to uniformly locate the full-view we use
kono
parents:
diff changeset
149 -- attribute Underlying_Type.
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 pragma Assert
kono
parents:
diff changeset
152 (Is_Tagged_Type (Underlying_Type (SCIL_Entity (SCIL_Node))));
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 -- Interface types are unsupported
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 pragma Assert
kono
parents:
diff changeset
157 (not Is_Interface (Underlying_Type (SCIL_Entity (SCIL_Node))));
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 -- Check the decoration of the expression that denotes the tag
kono
parents:
diff changeset
160 -- value being tested
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 Ctrl_Tag := SCIL_Tag_Value (SCIL_Node);
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 case Nkind (Ctrl_Tag) is
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 -- For class-wide membership tests the SCIL tag value is the
kono
parents:
diff changeset
167 -- tag of the tested object (i.e. Obj.Tag).
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 when N_Selected_Component =>
kono
parents:
diff changeset
170 pragma Assert (Etype (Ctrl_Tag) = RTE (RE_Tag));
kono
parents:
diff changeset
171 null;
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 when others =>
kono
parents:
diff changeset
174 pragma Assert (False);
kono
parents:
diff changeset
175 null;
kono
parents:
diff changeset
176 end case;
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 return Skip;
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 when others =>
kono
parents:
diff changeset
181 pragma Assert (False);
kono
parents:
diff changeset
182 raise Program_Error;
kono
parents:
diff changeset
183 end case;
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 return Skip;
kono
parents:
diff changeset
186 end Check_SCIL_Node;
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 -------------------------
kono
parents:
diff changeset
189 -- First_Non_SCIL_Node --
kono
parents:
diff changeset
190 -------------------------
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 function First_Non_SCIL_Node (L : List_Id) return Node_Id is
kono
parents:
diff changeset
193 N : Node_Id;
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 begin
kono
parents:
diff changeset
196 N := First (L);
kono
parents:
diff changeset
197 while Nkind (N) in N_SCIL_Node loop
kono
parents:
diff changeset
198 Next (N);
kono
parents:
diff changeset
199 end loop;
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 return N;
kono
parents:
diff changeset
202 end First_Non_SCIL_Node;
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 ------------------------
kono
parents:
diff changeset
205 -- Next_Non_SCIL_Node --
kono
parents:
diff changeset
206 ------------------------
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 function Next_Non_SCIL_Node (N : Node_Id) return Node_Id is
kono
parents:
diff changeset
209 Aux_N : Node_Id;
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 begin
kono
parents:
diff changeset
212 Aux_N := Next (N);
kono
parents:
diff changeset
213 while Nkind (Aux_N) in N_SCIL_Node loop
kono
parents:
diff changeset
214 Next (Aux_N);
kono
parents:
diff changeset
215 end loop;
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 return Aux_N;
kono
parents:
diff changeset
218 end Next_Non_SCIL_Node;
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 end Sem_SCIL;