1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2002, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Atree
; use Atree
;
28 with Checks
; use Checks
;
29 with Einfo
; use Einfo
;
30 with Errout
; use Errout
;
32 with Elists
; use Elists
;
33 with Itypes
; use Itypes
;
34 with Lib
.Xref
; use Lib
.Xref
;
35 with Nlists
; use Nlists
;
36 with Nmake
; use Nmake
;
38 with Restrict
; use Restrict
;
39 with Rtsfind
; use Rtsfind
;
41 with Sem_Ch3
; use Sem_Ch3
;
42 with Sem_Ch5
; use Sem_Ch5
;
43 with Sem_Ch6
; use Sem_Ch6
;
44 with Sem_Ch8
; use Sem_Ch8
;
45 with Sem_Eval
; use Sem_Eval
;
46 with Sem_Res
; use Sem_Res
;
47 with Sem_Type
; use Sem_Type
;
48 with Sem_Util
; use Sem_Util
;
49 with Sem_Warn
; use Sem_Warn
;
50 with Snames
; use Snames
;
51 with Stand
; use Stand
;
52 with Sinfo
; use Sinfo
;
54 with Tbuild
; use Tbuild
;
55 with Uintp
; use Uintp
;
57 package body Sem_Ch9
is
59 -----------------------
60 -- Local Subprograms --
61 -----------------------
63 procedure Check_Max_Entries
(Def
: Node_Id
; R
: Restriction_Parameter_Id
);
64 -- Given either a protected definition or a task definition in Def, check
65 -- the corresponding restriction parameter identifier R, and if it is set,
66 -- count the entries (checking the static requirement), and compare with
69 function Find_Concurrent_Spec
(Body_Id
: Entity_Id
) return Entity_Id
;
70 -- Find entity in corresponding task or protected declaration. Use full
71 -- view if first declaration was for an incomplete type.
73 procedure Install_Declarations
(Spec
: Entity_Id
);
74 -- Utility to make visible in corresponding body the entities defined
75 -- in task, protected type declaration, or entry declaration.
77 -----------------------------
78 -- Analyze_Abort_Statement --
79 -----------------------------
81 procedure Analyze_Abort_Statement
(N
: Node_Id
) is
86 T_Name
:= First
(Names
(N
));
87 while Present
(T_Name
) loop
90 if not Is_Task_Type
(Etype
(T_Name
)) then
91 Error_Msg_N
("expect task name for ABORT", T_Name
);
94 Resolve
(T_Name
, Etype
(T_Name
));
100 Check_Restriction
(No_Abort_Statements
, N
);
101 Check_Potentially_Blocking_Operation
(N
);
102 end Analyze_Abort_Statement
;
104 --------------------------------
105 -- Analyze_Accept_Alternative --
106 --------------------------------
108 procedure Analyze_Accept_Alternative
(N
: Node_Id
) is
110 Tasking_Used
:= True;
112 if Present
(Pragmas_Before
(N
)) then
113 Analyze_List
(Pragmas_Before
(N
));
116 Analyze
(Accept_Statement
(N
));
118 if Present
(Condition
(N
)) then
119 Analyze_And_Resolve
(Condition
(N
), Any_Boolean
);
122 if Is_Non_Empty_List
(Statements
(N
)) then
123 Analyze_Statements
(Statements
(N
));
125 end Analyze_Accept_Alternative
;
127 ------------------------------
128 -- Analyze_Accept_Statement --
129 ------------------------------
131 procedure Analyze_Accept_Statement
(N
: Node_Id
) is
132 Nam
: constant Entity_Id
:= Entry_Direct_Name
(N
);
133 Formals
: constant List_Id
:= Parameter_Specifications
(N
);
134 Index
: constant Node_Id
:= Entry_Index
(N
);
135 Stats
: constant Node_Id
:= Handled_Statement_Sequence
(N
);
137 Entry_Nam
: Entity_Id
;
140 Task_Nam
: Entity_Id
;
142 -----------------------
143 -- Actual_Index_Type --
144 -----------------------
146 function Actual_Index_Type
(E
: Entity_Id
) return Entity_Id
;
147 -- If the bounds of an entry family depend on task discriminants,
148 -- create a new index type where a discriminant is replaced by the
149 -- local variable that renames it in the task body.
151 function Actual_Index_Type
(E
: Entity_Id
) return Entity_Id
is
152 Typ
: Entity_Id
:= Entry_Index_Type
(E
);
153 Lo
: Node_Id
:= Type_Low_Bound
(Typ
);
154 Hi
: Node_Id
:= Type_High_Bound
(Typ
);
157 function Actual_Discriminant_Ref
(Bound
: Node_Id
) return Node_Id
;
158 -- If bound is discriminant reference, replace with corresponding
159 -- local variable of the same name.
161 function Actual_Discriminant_Ref
(Bound
: Node_Id
) return Node_Id
is
162 Typ
: Entity_Id
:= Etype
(Bound
);
166 if not Is_Entity_Name
(Bound
)
167 or else Ekind
(Entity
(Bound
)) /= E_Discriminant
172 Ref
:= Make_Identifier
(Sloc
(N
), Chars
(Entity
(Bound
)));
177 end Actual_Discriminant_Ref
;
179 -- Start of processing for Actual_Index_Type
182 if not Has_Discriminants
(Task_Nam
)
183 or else (not Is_Entity_Name
(Lo
)
184 and then not Is_Entity_Name
(Hi
))
186 return Entry_Index_Type
(E
);
188 New_T
:= Create_Itype
(Ekind
(Typ
), N
);
189 Set_Etype
(New_T
, Base_Type
(Typ
));
190 Set_Size_Info
(New_T
, Typ
);
191 Set_RM_Size
(New_T
, RM_Size
(Typ
));
192 Set_Scalar_Range
(New_T
,
193 Make_Range
(Sloc
(N
),
194 Low_Bound
=> Actual_Discriminant_Ref
(Lo
),
195 High_Bound
=> Actual_Discriminant_Ref
(Hi
)));
199 end Actual_Index_Type
;
201 -- Start of processing for Analyze_Accept_Statement
204 Tasking_Used
:= True;
206 -- Entry name is initialized to Any_Id. It should get reset to the
207 -- matching entry entity. An error is signalled if it is not reset.
211 for J
in reverse 0 .. Scope_Stack
.Last
loop
212 Task_Nam
:= Scope_Stack
.Table
(J
).Entity
;
213 exit when Ekind
(Etype
(Task_Nam
)) = E_Task_Type
;
214 Kind
:= Ekind
(Task_Nam
);
216 if Kind
/= E_Block
and then Kind
/= E_Loop
217 and then not Is_Entry
(Task_Nam
)
219 Error_Msg_N
("enclosing body of accept must be a task", N
);
224 if Ekind
(Etype
(Task_Nam
)) /= E_Task_Type
then
225 Error_Msg_N
("invalid context for accept statement", N
);
229 -- In order to process the parameters, we create a defining
230 -- identifier that can be used as the name of the scope. The
231 -- name of the accept statement itself is not a defining identifier.
233 if Present
(Index
) then
234 Ityp
:= New_Internal_Entity
235 (E_Entry_Family
, Current_Scope
, Sloc
(N
), 'E');
237 Ityp
:= New_Internal_Entity
238 (E_Entry
, Current_Scope
, Sloc
(N
), 'E');
241 Set_Etype
(Ityp
, Standard_Void_Type
);
242 Set_Accept_Address
(Ityp
, New_Elmt_List
);
244 if Present
(Formals
) then
246 Process_Formals
(Formals
, N
);
247 Create_Extra_Formals
(Ityp
);
251 -- We set the default expressions processed flag because we don't
252 -- need default expression functions. This is really more like a
253 -- body entity than a spec entity anyway.
255 Set_Default_Expressions_Processed
(Ityp
);
257 E
:= First_Entity
(Etype
(Task_Nam
));
259 while Present
(E
) loop
260 if Chars
(E
) = Chars
(Nam
)
261 and then (Ekind
(E
) = Ekind
(Ityp
))
262 and then Type_Conformant
(Ityp
, E
)
271 if Entry_Nam
= Any_Id
then
272 Error_Msg_N
("no entry declaration matches accept statement", N
);
275 Set_Entity
(Nam
, Entry_Nam
);
276 Generate_Reference
(Entry_Nam
, Nam
, 'b', Set_Ref
=> False);
277 Style
.Check_Identifier
(Nam
, Entry_Nam
);
280 -- Verify that the entry is not hidden by a procedure declared in
281 -- the current block (pathological but possible).
283 if Current_Scope
/= Task_Nam
then
288 E1
:= First_Entity
(Current_Scope
);
290 while Present
(E1
) loop
292 if Ekind
(E1
) = E_Procedure
293 and then Type_Conformant
(E1
, Entry_Nam
)
295 Error_Msg_N
("entry name is not visible", N
);
303 Set_Convention
(Ityp
, Convention
(Entry_Nam
));
304 Check_Fully_Conformant
(Ityp
, Entry_Nam
, N
);
306 for J
in reverse 0 .. Scope_Stack
.Last
loop
307 exit when Task_Nam
= Scope_Stack
.Table
(J
).Entity
;
309 if Entry_Nam
= Scope_Stack
.Table
(J
).Entity
then
310 Error_Msg_N
("duplicate accept statement for same entry", N
);
321 when N_Task_Body | N_Compilation_Unit
=>
323 when N_Asynchronous_Select
=>
324 Error_Msg_N
("accept statements are not allowed within" &
325 " an asynchronous select inner" &
326 " to the enclosing task body", N
);
334 if Ekind
(E
) = E_Entry_Family
then
336 Error_Msg_N
("missing entry index in accept for entry family", N
);
338 Analyze_And_Resolve
(Index
, Entry_Index_Type
(E
));
339 Apply_Range_Check
(Index
, Actual_Index_Type
(E
));
342 elsif Present
(Index
) then
343 Error_Msg_N
("invalid entry index in accept for simple entry", N
);
346 -- If statements are present, they must be analyzed in the context
347 -- of the entry, so that references to formals are correctly resolved.
348 -- We also have to add the declarations that are required by the
349 -- expansion of the accept statement in this case if expansion active.
351 -- In the case of a select alternative of a selective accept,
352 -- the expander references the address declaration even if there
353 -- is no statement list.
355 Exp_Ch9
.Expand_Accept_Declarations
(N
, Entry_Nam
);
357 -- If label declarations present, analyze them. They are declared
358 -- in the enclosing task, but their enclosing scope is the entry itself,
359 -- so that goto's to the label are recognized as local to the accept.
361 if Present
(Declarations
(N
)) then
368 Decl
:= First
(Declarations
(N
));
370 while Present
(Decl
) loop
374 (Nkind
(Decl
) = N_Implicit_Label_Declaration
);
376 Id
:= Defining_Identifier
(Decl
);
377 Set_Enclosing_Scope
(Id
, Entry_Nam
);
383 -- Set Not_Source_Assigned flag on all entry formals
385 E
:= First_Entity
(Entry_Nam
);
387 while Present
(E
) loop
388 Set_Not_Source_Assigned
(E
, True);
392 -- Analyze statements if present
394 if Present
(Stats
) then
395 New_Scope
(Entry_Nam
);
396 Install_Declarations
(Entry_Nam
);
398 Set_Actual_Subtypes
(N
, Current_Scope
);
400 Process_End_Label
(Handled_Statement_Sequence
(N
), 't', Entry_Nam
);
404 -- Some warning checks
406 Check_Potentially_Blocking_Operation
(N
);
407 Check_References
(Entry_Nam
, N
);
408 Set_Entry_Accepted
(Entry_Nam
);
409 end Analyze_Accept_Statement
;
411 ---------------------------------
412 -- Analyze_Asynchronous_Select --
413 ---------------------------------
415 procedure Analyze_Asynchronous_Select
(N
: Node_Id
) is
417 Tasking_Used
:= True;
418 Check_Restriction
(Max_Asynchronous_Select_Nesting
, N
);
419 Check_Restriction
(No_Select_Statements
, N
);
421 Analyze
(Triggering_Alternative
(N
));
423 Analyze_Statements
(Statements
(Abortable_Part
(N
)));
424 end Analyze_Asynchronous_Select
;
426 ------------------------------------
427 -- Analyze_Conditional_Entry_Call --
428 ------------------------------------
430 procedure Analyze_Conditional_Entry_Call
(N
: Node_Id
) is
432 Check_Restriction
(No_Select_Statements
, N
);
433 Tasking_Used
:= True;
434 Analyze
(Entry_Call_Alternative
(N
));
435 Analyze_Statements
(Else_Statements
(N
));
436 end Analyze_Conditional_Entry_Call
;
438 --------------------------------
439 -- Analyze_Delay_Alternative --
440 --------------------------------
442 procedure Analyze_Delay_Alternative
(N
: Node_Id
) is
446 Tasking_Used
:= True;
447 Check_Restriction
(No_Delay
, N
);
449 if Present
(Pragmas_Before
(N
)) then
450 Analyze_List
(Pragmas_Before
(N
));
453 if Nkind
(Parent
(N
)) = N_Selective_Accept
454 or else Nkind
(Parent
(N
)) = N_Timed_Entry_Call
456 Expr
:= Expression
(Delay_Statement
(N
));
458 -- defer full analysis until the statement is expanded, to insure
459 -- that generated code does not move past the guard. The delay
460 -- expression is only evaluated if the guard is open.
462 if Nkind
(Delay_Statement
(N
)) = N_Delay_Relative_Statement
then
463 Pre_Analyze_And_Resolve
(Expr
, Standard_Duration
);
466 Pre_Analyze_And_Resolve
(Expr
);
469 Check_Restriction
(No_Fixed_Point
, Expr
);
471 Analyze
(Delay_Statement
(N
));
474 if Present
(Condition
(N
)) then
475 Analyze_And_Resolve
(Condition
(N
), Any_Boolean
);
478 if Is_Non_Empty_List
(Statements
(N
)) then
479 Analyze_Statements
(Statements
(N
));
481 end Analyze_Delay_Alternative
;
483 ----------------------------
484 -- Analyze_Delay_Relative --
485 ----------------------------
487 procedure Analyze_Delay_Relative
(N
: Node_Id
) is
488 E
: constant Node_Id
:= Expression
(N
);
491 Check_Restriction
(No_Relative_Delay
, N
);
492 Tasking_Used
:= True;
493 Check_Restriction
(No_Delay
, N
);
494 Check_Potentially_Blocking_Operation
(N
);
495 Analyze_And_Resolve
(E
, Standard_Duration
);
496 Check_Restriction
(No_Fixed_Point
, E
);
497 end Analyze_Delay_Relative
;
499 -------------------------
500 -- Analyze_Delay_Until --
501 -------------------------
503 procedure Analyze_Delay_Until
(N
: Node_Id
) is
504 E
: constant Node_Id
:= Expression
(N
);
507 Tasking_Used
:= True;
508 Check_Restriction
(No_Delay
, N
);
509 Check_Potentially_Blocking_Operation
(N
);
512 if not Is_RTE
(Base_Type
(Etype
(E
)), RO_CA_Time
) and then
513 not Is_RTE
(Base_Type
(Etype
(E
)), RO_RT_Time
)
515 Error_Msg_N
("expect Time types for `DELAY UNTIL`", E
);
517 end Analyze_Delay_Until
;
519 ------------------------
520 -- Analyze_Entry_Body --
521 ------------------------
523 procedure Analyze_Entry_Body
(N
: Node_Id
) is
524 Id
: constant Entity_Id
:= Defining_Identifier
(N
);
525 Decls
: constant List_Id
:= Declarations
(N
);
526 Stats
: constant Node_Id
:= Handled_Statement_Sequence
(N
);
527 Formals
: constant Node_Id
:= Entry_Body_Formal_Part
(N
);
528 P_Type
: constant Entity_Id
:= Current_Scope
;
529 Entry_Name
: Entity_Id
;
533 Tasking_Used
:= True;
535 -- Entry_Name is initialized to Any_Id. It should get reset to the
536 -- matching entry entity. An error is signalled if it is not reset
538 Entry_Name
:= Any_Id
;
542 if Present
(Entry_Index_Specification
(Formals
)) then
543 Set_Ekind
(Id
, E_Entry_Family
);
545 Set_Ekind
(Id
, E_Entry
);
548 Set_Scope
(Id
, Current_Scope
);
549 Set_Etype
(Id
, Standard_Void_Type
);
550 Set_Accept_Address
(Id
, New_Elmt_List
);
552 E
:= First_Entity
(P_Type
);
553 while Present
(E
) loop
554 if Chars
(E
) = Chars
(Id
)
555 and then (Ekind
(E
) = Ekind
(Id
))
556 and then Type_Conformant
(Id
, E
)
559 Set_Convention
(Id
, Convention
(E
));
560 Check_Fully_Conformant
(Id
, E
, N
);
567 if Entry_Name
= Any_Id
then
568 Error_Msg_N
("no entry declaration matches entry body", N
);
571 elsif Has_Completion
(Entry_Name
) then
572 Error_Msg_N
("duplicate entry body", N
);
576 Set_Has_Completion
(Entry_Name
);
577 Generate_Reference
(Entry_Name
, Id
, 'b', Set_Ref
=> False);
578 Style
.Check_Identifier
(Id
, Entry_Name
);
581 Exp_Ch9
.Expand_Entry_Barrier
(N
, Entry_Name
);
582 New_Scope
(Entry_Name
);
584 Exp_Ch9
.Expand_Entry_Body_Declarations
(N
);
585 Install_Declarations
(Entry_Name
);
586 Set_Actual_Subtypes
(N
, Current_Scope
);
588 -- The entity for the protected subprogram corresponding to the entry
589 -- has been created. We retain the name of this entity in the entry
590 -- body, for use when the corresponding subprogram body is created.
591 -- Note that entry bodies have to corresponding_spec, and there is no
592 -- easy link back in the tree between the entry body and the entity for
595 Set_Protected_Body_Subprogram
(Id
,
596 Protected_Body_Subprogram
(Entry_Name
));
598 if Present
(Decls
) then
599 Analyze_Declarations
(Decls
);
602 if Present
(Stats
) then
606 Check_References
(Entry_Name
);
607 Process_End_Label
(Handled_Statement_Sequence
(N
), 't', Entry_Name
);
610 -- If this is an entry family, remove the loop created to provide
611 -- a scope for the entry index.
613 if Ekind
(Id
) = E_Entry_Family
614 and then Present
(Entry_Index_Specification
(Formals
))
619 end Analyze_Entry_Body
;
621 ------------------------------------
622 -- Analyze_Entry_Body_Formal_Part --
623 ------------------------------------
625 procedure Analyze_Entry_Body_Formal_Part
(N
: Node_Id
) is
626 Id
: constant Entity_Id
:= Defining_Identifier
(Parent
(N
));
627 Index
: constant Node_Id
:= Entry_Index_Specification
(N
);
628 Formals
: constant List_Id
:= Parameter_Specifications
(N
);
631 Tasking_Used
:= True;
633 if Present
(Index
) then
637 if Present
(Formals
) then
638 Set_Scope
(Id
, Current_Scope
);
640 Process_Formals
(Formals
, Parent
(N
));
644 end Analyze_Entry_Body_Formal_Part
;
646 ------------------------------------
647 -- Analyze_Entry_Call_Alternative --
648 ------------------------------------
650 procedure Analyze_Entry_Call_Alternative
(N
: Node_Id
) is
652 Tasking_Used
:= True;
654 if Present
(Pragmas_Before
(N
)) then
655 Analyze_List
(Pragmas_Before
(N
));
658 Analyze
(Entry_Call_Statement
(N
));
660 if Is_Non_Empty_List
(Statements
(N
)) then
661 Analyze_Statements
(Statements
(N
));
663 end Analyze_Entry_Call_Alternative
;
665 -------------------------------
666 -- Analyze_Entry_Declaration --
667 -------------------------------
669 procedure Analyze_Entry_Declaration
(N
: Node_Id
) is
670 Id
: Entity_Id
:= Defining_Identifier
(N
);
671 D_Sdef
: Node_Id
:= Discrete_Subtype_Definition
(N
);
672 Formals
: List_Id
:= Parameter_Specifications
(N
);
675 Generate_Definition
(Id
);
676 Tasking_Used
:= True;
679 Set_Ekind
(Id
, E_Entry
);
682 Set_Ekind
(Id
, E_Entry_Family
);
684 Make_Index
(D_Sdef
, N
, Id
);
687 Set_Etype
(Id
, Standard_Void_Type
);
688 Set_Convention
(Id
, Convention_Entry
);
689 Set_Accept_Address
(Id
, New_Elmt_List
);
691 if Present
(Formals
) then
692 Set_Scope
(Id
, Current_Scope
);
694 Process_Formals
(Formals
, N
);
695 Create_Extra_Formals
(Id
);
699 if Ekind
(Id
) = E_Entry
then
700 New_Overloaded_Entity
(Id
);
703 end Analyze_Entry_Declaration
;
705 ---------------------------------------
706 -- Analyze_Entry_Index_Specification --
707 ---------------------------------------
709 -- The defining_Identifier of the entry index specification is local
710 -- to the entry body, but must be available in the entry barrier,
711 -- which is evaluated outside of the entry body. The index is eventually
712 -- renamed as a run-time object, so is visibility is strictly a front-end
713 -- concern. In order to make it available to the barrier, we create
714 -- an additional scope, as for a loop, whose only declaration is the
715 -- index name. This loop is not attached to the tree and does not appear
716 -- as an entity local to the protected type, so its existence need only
717 -- be knwown to routines that process entry families.
719 procedure Analyze_Entry_Index_Specification
(N
: Node_Id
) is
720 Iden
: constant Node_Id
:= Defining_Identifier
(N
);
721 Def
: constant Node_Id
:= Discrete_Subtype_Definition
(N
);
722 Loop_Id
: Entity_Id
:=
723 Make_Defining_Identifier
(Sloc
(N
),
724 Chars
=> New_Internal_Name
('L'));
727 Tasking_Used
:= True;
730 Set_Ekind
(Loop_Id
, E_Loop
);
731 Set_Scope
(Loop_Id
, Current_Scope
);
734 Set_Ekind
(Iden
, E_Entry_Index_Parameter
);
735 Set_Etype
(Iden
, Etype
(Def
));
736 end Analyze_Entry_Index_Specification
;
738 ----------------------------
739 -- Analyze_Protected_Body --
740 ----------------------------
742 procedure Analyze_Protected_Body
(N
: Node_Id
) is
743 Body_Id
: constant Entity_Id
:= Defining_Identifier
(N
);
747 -- This is initially the entity of the protected object or protected
748 -- type involved, but is replaced by the protected type always in the
749 -- case of a single protected declaration, since this is the proper
753 -- This is the entity of the protected object or protected type
754 -- involved, and is the entity used for cross-reference purposes
755 -- (it differs from Spec_Id in the case of a single protected
756 -- object, since Spec_Id is set to the protected type in this case).
759 Tasking_Used
:= True;
760 Set_Ekind
(Body_Id
, E_Protected_Body
);
761 Spec_Id
:= Find_Concurrent_Spec
(Body_Id
);
764 and then Ekind
(Spec_Id
) = E_Protected_Type
768 elsif Present
(Spec_Id
)
769 and then Ekind
(Etype
(Spec_Id
)) = E_Protected_Type
770 and then not Comes_From_Source
(Etype
(Spec_Id
))
775 Error_Msg_N
("missing specification for protected body", Body_Id
);
780 Generate_Reference
(Ref_Id
, Body_Id
, 'b', Set_Ref
=> False);
781 Style
.Check_Identifier
(Body_Id
, Spec_Id
);
783 -- The declarations are always attached to the type
785 if Ekind
(Spec_Id
) /= E_Protected_Type
then
786 Spec_Id
:= Etype
(Spec_Id
);
790 Set_Corresponding_Spec
(N
, Spec_Id
);
791 Set_Corresponding_Body
(Parent
(Spec_Id
), Body_Id
);
792 Set_Has_Completion
(Spec_Id
);
793 Install_Declarations
(Spec_Id
);
795 Exp_Ch9
.Expand_Protected_Body_Declarations
(N
, Spec_Id
);
797 Last_E
:= Last_Entity
(Spec_Id
);
799 Analyze_Declarations
(Declarations
(N
));
801 -- For visibility purposes, all entities in the body are private.
802 -- Set First_Private_Entity accordingly, if there was no private
803 -- part in the protected declaration.
805 if No
(First_Private_Entity
(Spec_Id
)) then
806 if Present
(Last_E
) then
807 Set_First_Private_Entity
(Spec_Id
, Next_Entity
(Last_E
));
809 Set_First_Private_Entity
(Spec_Id
, First_Entity
(Spec_Id
));
813 Check_Completion
(Body_Id
);
814 Check_References
(Spec_Id
);
815 Process_End_Label
(N
, 't', Ref_Id
);
817 end Analyze_Protected_Body
;
819 ----------------------------------
820 -- Analyze_Protected_Definition --
821 ----------------------------------
823 procedure Analyze_Protected_Definition
(N
: Node_Id
) is
828 Tasking_Used
:= True;
829 Analyze_Declarations
(Visible_Declarations
(N
));
831 if Present
(Private_Declarations
(N
))
832 and then not Is_Empty_List
(Private_Declarations
(N
))
834 L
:= Last_Entity
(Current_Scope
);
835 Analyze_Declarations
(Private_Declarations
(N
));
838 Set_First_Private_Entity
(Current_Scope
, Next_Entity
(L
));
841 Set_First_Private_Entity
(Current_Scope
,
842 First_Entity
(Current_Scope
));
846 E
:= First_Entity
(Current_Scope
);
848 while Present
(E
) loop
850 if Ekind
(E
) = E_Function
851 or else Ekind
(E
) = E_Procedure
853 Set_Convention
(E
, Convention_Protected
);
855 elsif Is_Task_Type
(Etype
(E
))
856 or else Has_Task
(Etype
(E
))
858 Set_Has_Task
(Current_Scope
);
864 Check_Max_Entries
(N
, Max_Protected_Entries
);
865 Process_End_Label
(N
, 'e', Current_Scope
);
866 end Analyze_Protected_Definition
;
868 ----------------------------
869 -- Analyze_Protected_Type --
870 ----------------------------
872 procedure Analyze_Protected_Type
(N
: Node_Id
) is
875 Def_Id
: constant Entity_Id
:= Defining_Identifier
(N
);
878 Tasking_Used
:= True;
879 Check_Restriction
(No_Protected_Types
, N
);
881 T
:= Find_Type_Name
(N
);
883 if Ekind
(T
) = E_Incomplete_Type
then
885 Set_Completion_Referenced
(T
);
888 Set_Ekind
(T
, E_Protected_Type
);
891 Set_Is_First_Subtype
(T
, True);
892 Set_Has_Delayed_Freeze
(T
, True);
893 Set_Girder_Constraint
(T
, No_Elist
);
896 if Present
(Discriminant_Specifications
(N
)) then
897 if Has_Discriminants
(T
) then
899 -- Install discriminants. Also, verify conformance of
900 -- discriminants of previous and current view. ???
902 Install_Declarations
(T
);
904 Process_Discriminants
(N
);
908 Analyze
(Protected_Definition
(N
));
910 -- Protected types with entries are controlled (because of the
911 -- Protection component if nothing else), same for any protected type
912 -- with interrupt handlers. Note that we need to analyze the protected
913 -- definition to set Has_Entries and such.
915 if (Abort_Allowed
or else Restrictions
(No_Entry_Queue
) = False
916 or else Number_Entries
(T
) > 1)
919 or else Has_Interrupt_Handler
(T
)
920 or else Has_Attach_Handler
(T
))
922 Set_Has_Controlled_Component
(T
, True);
925 -- The Ekind of components is E_Void during analysis to detect
926 -- illegal uses. Now it can be set correctly.
928 E
:= First_Entity
(Current_Scope
);
930 while Present
(E
) loop
931 if Ekind
(E
) = E_Void
then
932 Set_Ekind
(E
, E_Component
);
933 Init_Component_Location
(E
);
942 and then Is_Private_Type
(Def_Id
)
943 and then Has_Discriminants
(Def_Id
)
944 and then Expander_Active
946 Exp_Ch9
.Expand_N_Protected_Type_Declaration
(N
);
947 Process_Full_View
(N
, T
, Def_Id
);
950 end Analyze_Protected_Type
;
952 ---------------------
953 -- Analyze_Requeue --
954 ---------------------
956 procedure Analyze_Requeue
(N
: Node_Id
) is
957 Entry_Name
: Node_Id
:= Name
(N
);
958 Entry_Id
: Entity_Id
;
962 Enclosing
: Entity_Id
;
963 Target_Obj
: Node_Id
:= Empty
;
964 Req_Scope
: Entity_Id
;
965 Outer_Ent
: Entity_Id
;
968 Check_Restriction
(No_Requeue
, N
);
969 Check_Unreachable_Code
(N
);
970 Tasking_Used
:= True;
973 for J
in reverse 0 .. Scope_Stack
.Last
loop
974 Enclosing
:= Scope_Stack
.Table
(J
).Entity
;
975 exit when Is_Entry
(Enclosing
);
977 if Ekind
(Enclosing
) /= E_Block
978 and then Ekind
(Enclosing
) /= E_Loop
980 Error_Msg_N
("requeue must appear within accept or entry body", N
);
985 Analyze
(Entry_Name
);
987 if Etype
(Entry_Name
) = Any_Type
then
991 if Nkind
(Entry_Name
) = N_Selected_Component
then
992 Target_Obj
:= Prefix
(Entry_Name
);
993 Entry_Name
:= Selector_Name
(Entry_Name
);
996 -- If an explicit target object is given then we have to check
997 -- the restrictions of 9.5.4(6).
999 if Present
(Target_Obj
) then
1000 -- Locate containing concurrent unit and determine
1001 -- enclosing entry body or outermost enclosing accept
1002 -- statement within the unit.
1005 for S
in reverse 0 .. Scope_Stack
.Last
loop
1006 Req_Scope
:= Scope_Stack
.Table
(S
).Entity
;
1008 exit when Ekind
(Req_Scope
) in Task_Kind
1009 or else Ekind
(Req_Scope
) in Protected_Kind
;
1011 if Is_Entry
(Req_Scope
) then
1012 Outer_Ent
:= Req_Scope
;
1016 pragma Assert
(Present
(Outer_Ent
));
1018 -- Check that the accessibility level of the target object
1019 -- is not greater or equal to the outermost enclosing accept
1020 -- statement (or entry body) unless it is a parameter of the
1021 -- innermost enclosing accept statement (or entry body).
1023 if Object_Access_Level
(Target_Obj
) >= Scope_Depth
(Outer_Ent
)
1025 (not Is_Entity_Name
(Target_Obj
)
1026 or else Ekind
(Entity
(Target_Obj
)) not in Formal_Kind
1027 or else Enclosing
/= Scope
(Entity
(Target_Obj
)))
1030 ("target object has invalid level for requeue", Target_Obj
);
1034 -- Overloaded case, find right interpretation
1036 if Is_Overloaded
(Entry_Name
) then
1037 Get_First_Interp
(Entry_Name
, I
, It
);
1041 while Present
(It
.Nam
) loop
1043 if No
(First_Formal
(It
.Nam
))
1044 or else Subtype_Conformant
(Enclosing
, It
.Nam
)
1050 Error_Msg_N
("ambiguous entry name in requeue", N
);
1055 Get_Next_Interp
(I
, It
);
1059 Error_Msg_N
("no entry matches context", N
);
1062 Set_Entity
(Entry_Name
, Entry_Id
);
1065 -- Non-overloaded cases
1067 -- For the case of a reference to an element of an entry family,
1068 -- the Entry_Name is an indexed component.
1070 elsif Nkind
(Entry_Name
) = N_Indexed_Component
then
1072 -- Requeue to an entry out of the body
1074 if Nkind
(Prefix
(Entry_Name
)) = N_Selected_Component
then
1075 Entry_Id
:= Entity
(Selector_Name
(Prefix
(Entry_Name
)));
1077 -- Requeue from within the body itself
1079 elsif Nkind
(Prefix
(Entry_Name
)) = N_Identifier
then
1080 Entry_Id
:= Entity
(Prefix
(Entry_Name
));
1083 Error_Msg_N
("invalid entry_name specified", N
);
1087 -- If we had a requeue of the form REQUEUE A (B), then the parser
1088 -- accepted it (because it could have been a requeue on an entry
1089 -- index. If A turns out not to be an entry family, then the analysis
1090 -- of A (B) turned it into a function call.
1092 elsif Nkind
(Entry_Name
) = N_Function_Call
then
1094 ("arguments not allowed in requeue statement",
1095 First
(Parameter_Associations
(Entry_Name
)));
1098 -- Normal case of no entry family, no argument
1101 Entry_Id
:= Entity
(Entry_Name
);
1104 -- Resolve entry, and check that it is subtype conformant with the
1105 -- enclosing construct if this construct has formals (RM 9.5.4(5)).
1107 if not Is_Entry
(Entry_Id
) then
1108 Error_Msg_N
("expect entry name in requeue statement", Name
(N
));
1109 elsif Ekind
(Entry_Id
) = E_Entry_Family
1111 and then Nkind
(Entry_Name
) /= N_Indexed_Component
1113 Error_Msg_N
("missing index for entry family component", Name
(N
));
1116 Resolve_Entry
(Name
(N
));
1118 if Present
(First_Formal
(Entry_Id
)) then
1119 Check_Subtype_Conformant
(Enclosing
, Entry_Id
, Name
(N
));
1121 -- Mark any output parameters as assigned
1124 Ent
: Entity_Id
:= First_Formal
(Enclosing
);
1127 while Present
(Ent
) loop
1128 if Ekind
(Ent
) = E_Out_Parameter
then
1129 Set_Not_Source_Assigned
(Ent
, False);
1138 end Analyze_Requeue
;
1140 ------------------------------
1141 -- Analyze_Selective_Accept --
1142 ------------------------------
1144 procedure Analyze_Selective_Accept
(N
: Node_Id
) is
1145 Alts
: constant List_Id
:= Select_Alternatives
(N
);
1148 Accept_Present
: Boolean := False;
1149 Terminate_Present
: Boolean := False;
1150 Delay_Present
: Boolean := False;
1151 Relative_Present
: Boolean := False;
1152 Alt_Count
: Uint
:= Uint_0
;
1155 Check_Restriction
(No_Select_Statements
, N
);
1156 Tasking_Used
:= True;
1158 Alt
:= First
(Alts
);
1159 while Present
(Alt
) loop
1160 Alt_Count
:= Alt_Count
+ 1;
1163 if Nkind
(Alt
) = N_Delay_Alternative
then
1164 if Delay_Present
then
1166 if (Relative_Present
/=
1167 (Nkind
(Delay_Statement
(Alt
)) = N_Delay_Relative_Statement
))
1170 ("delay_until and delay_relative alternatives ", Alt
);
1172 ("\cannot appear in the same selective_wait", Alt
);
1176 Delay_Present
:= True;
1178 Nkind
(Delay_Statement
(Alt
)) = N_Delay_Relative_Statement
;
1181 elsif Nkind
(Alt
) = N_Terminate_Alternative
then
1182 if Terminate_Present
then
1183 Error_Msg_N
("Only one terminate alternative allowed", N
);
1185 Terminate_Present
:= True;
1186 Check_Restriction
(No_Terminate_Alternatives
, N
);
1189 elsif Nkind
(Alt
) = N_Accept_Alternative
then
1190 Accept_Present
:= True;
1192 -- Check for duplicate accept
1196 Stm
: constant Node_Id
:= Accept_Statement
(Alt
);
1197 EDN
: constant Node_Id
:= Entry_Direct_Name
(Stm
);
1201 if Nkind
(EDN
) = N_Identifier
1202 and then No
(Condition
(Alt
))
1203 and then Present
(Entity
(EDN
)) -- defend against junk
1204 and then Ekind
(Entity
(EDN
)) = E_Entry
1206 Ent
:= Entity
(EDN
);
1208 Alt1
:= First
(Alts
);
1209 while Alt1
/= Alt
loop
1210 if Nkind
(Alt1
) = N_Accept_Alternative
1211 and then No
(Condition
(Alt1
))
1214 Stm1
: constant Node_Id
:= Accept_Statement
(Alt1
);
1215 EDN1
: constant Node_Id
:= Entry_Direct_Name
(Stm1
);
1218 if Nkind
(EDN1
) = N_Identifier
then
1219 if Entity
(EDN1
) = Ent
then
1220 Error_Msg_Sloc
:= Sloc
(Stm1
);
1222 ("?accept duplicates one on line#", Stm
);
1238 Check_Restriction
(Max_Select_Alternatives
, Alt_Count
, N
);
1239 Check_Potentially_Blocking_Operation
(N
);
1241 if Terminate_Present
and Delay_Present
then
1242 Error_Msg_N
("at most one of terminate or delay alternative", N
);
1244 elsif not Accept_Present
then
1246 ("select must contain at least one accept alternative", N
);
1249 if Present
(Else_Statements
(N
)) then
1250 if Terminate_Present
or Delay_Present
then
1251 Error_Msg_N
("else part not allowed with other alternatives", N
);
1254 Analyze_Statements
(Else_Statements
(N
));
1256 end Analyze_Selective_Accept
;
1258 ------------------------------
1259 -- Analyze_Single_Protected --
1260 ------------------------------
1262 procedure Analyze_Single_Protected
(N
: Node_Id
) is
1263 Loc
: constant Source_Ptr
:= Sloc
(N
);
1264 Id
: constant Node_Id
:= Defining_Identifier
(N
);
1268 O_Name
: constant Entity_Id
:= New_Copy
(Id
);
1271 Generate_Definition
(Id
);
1272 Tasking_Used
:= True;
1274 -- The node is rewritten as a protected type declaration,
1275 -- in exact analogy with what is done with single tasks.
1278 Make_Defining_Identifier
(Sloc
(Id
),
1279 New_External_Name
(Chars
(Id
), 'T'));
1282 Make_Protected_Type_Declaration
(Loc
,
1283 Defining_Identifier
=> T
,
1284 Protected_Definition
=> Relocate_Node
(Protected_Definition
(N
)));
1287 Make_Object_Declaration
(Loc
,
1288 Defining_Identifier
=> O_Name
,
1289 Object_Definition
=> Make_Identifier
(Loc
, Chars
(T
)));
1291 Rewrite
(N
, T_Decl
);
1292 Insert_After
(N
, O_Decl
);
1293 Mark_Rewrite_Insertion
(O_Decl
);
1295 -- Enter names of type and object before analysis, because the name
1296 -- of the object may be used in its own body.
1299 Set_Ekind
(T
, E_Protected_Type
);
1302 Enter_Name
(O_Name
);
1303 Set_Ekind
(O_Name
, E_Variable
);
1304 Set_Etype
(O_Name
, T
);
1306 -- Instead of calling Analyze on the new node, call directly
1307 -- the proper analysis procedure. Otherwise the node would be
1308 -- expanded twice, with disastrous result.
1310 Analyze_Protected_Type
(N
);
1312 end Analyze_Single_Protected
;
1314 -------------------------
1315 -- Analyze_Single_Task --
1316 -------------------------
1318 procedure Analyze_Single_Task
(N
: Node_Id
) is
1319 Loc
: constant Source_Ptr
:= Sloc
(N
);
1320 Id
: constant Node_Id
:= Defining_Identifier
(N
);
1324 O_Name
: constant Entity_Id
:= New_Copy
(Id
);
1327 Generate_Definition
(Id
);
1328 Tasking_Used
:= True;
1330 -- The node is rewritten as a task type declaration, followed
1331 -- by an object declaration of that anonymous task type.
1334 Make_Defining_Identifier
(Sloc
(Id
),
1335 New_External_Name
(Chars
(Id
), Suffix
=> "TK"));
1338 Make_Task_Type_Declaration
(Loc
,
1339 Defining_Identifier
=> T
,
1340 Task_Definition
=> Relocate_Node
(Task_Definition
(N
)));
1343 Make_Object_Declaration
(Loc
,
1344 Defining_Identifier
=> O_Name
,
1345 Object_Definition
=> Make_Identifier
(Loc
, Chars
(T
)));
1347 Rewrite
(N
, T_Decl
);
1348 Insert_After
(N
, O_Decl
);
1349 Mark_Rewrite_Insertion
(O_Decl
);
1351 -- Enter names of type and object before analysis, because the name
1352 -- of the object may be used in its own body.
1355 Set_Ekind
(T
, E_Task_Type
);
1358 Enter_Name
(O_Name
);
1359 Set_Ekind
(O_Name
, E_Variable
);
1360 Set_Etype
(O_Name
, T
);
1362 -- Instead of calling Analyze on the new node, call directly
1363 -- the proper analysis procedure. Otherwise the node would be
1364 -- expanded twice, with disastrous result.
1366 Analyze_Task_Type
(N
);
1368 end Analyze_Single_Task
;
1370 -----------------------
1371 -- Analyze_Task_Body --
1372 -----------------------
1374 procedure Analyze_Task_Body
(N
: Node_Id
) is
1375 Body_Id
: constant Entity_Id
:= Defining_Identifier
(N
);
1378 Spec_Id
: Entity_Id
;
1379 -- This is initially the entity of the task or task type involved,
1380 -- but is replaced by the task type always in the case of a single
1381 -- task declaration, since this is the proper scope to be used.
1384 -- This is the entity of the task or task type, and is the entity
1385 -- used for cross-reference purposes (it differs from Spec_Id in
1386 -- the case of a single task, since Spec_Id is set to the task type)
1389 Tasking_Used
:= True;
1390 Set_Ekind
(Body_Id
, E_Task_Body
);
1391 Set_Scope
(Body_Id
, Current_Scope
);
1392 Spec_Id
:= Find_Concurrent_Spec
(Body_Id
);
1394 -- The spec is either a task type declaration, or a single task
1395 -- declaration for which we have created an anonymous type.
1397 if Present
(Spec_Id
)
1398 and then Ekind
(Spec_Id
) = E_Task_Type
1402 elsif Present
(Spec_Id
)
1403 and then Ekind
(Etype
(Spec_Id
)) = E_Task_Type
1404 and then not Comes_From_Source
(Etype
(Spec_Id
))
1409 Error_Msg_N
("missing specification for task body", Body_Id
);
1414 Generate_Reference
(Ref_Id
, Body_Id
, 'b', Set_Ref
=> False);
1415 Style
.Check_Identifier
(Body_Id
, Spec_Id
);
1417 -- Deal with case of body of single task (anonymous type was created)
1419 if Ekind
(Spec_Id
) = E_Variable
then
1420 Spec_Id
:= Etype
(Spec_Id
);
1423 New_Scope
(Spec_Id
);
1424 Set_Corresponding_Spec
(N
, Spec_Id
);
1425 Set_Corresponding_Body
(Parent
(Spec_Id
), Body_Id
);
1426 Set_Has_Completion
(Spec_Id
);
1427 Install_Declarations
(Spec_Id
);
1428 Last_E
:= Last_Entity
(Spec_Id
);
1430 Analyze_Declarations
(Declarations
(N
));
1432 -- For visibility purposes, all entities in the body are private.
1433 -- Set First_Private_Entity accordingly, if there was no private
1434 -- part in the protected declaration.
1436 if No
(First_Private_Entity
(Spec_Id
)) then
1437 if Present
(Last_E
) then
1438 Set_First_Private_Entity
(Spec_Id
, Next_Entity
(Last_E
));
1440 Set_First_Private_Entity
(Spec_Id
, First_Entity
(Spec_Id
));
1444 Analyze
(Handled_Statement_Sequence
(N
));
1445 Check_Completion
(Body_Id
);
1446 Check_References
(Body_Id
);
1448 -- Check for entries with no corresponding accept
1454 Ent
:= First_Entity
(Spec_Id
);
1456 while Present
(Ent
) loop
1458 and then not Entry_Accepted
(Ent
)
1459 and then Comes_From_Source
(Ent
)
1461 Error_Msg_NE
("no accept for entry &?", N
, Ent
);
1468 Process_End_Label
(Handled_Statement_Sequence
(N
), 't', Ref_Id
);
1470 end Analyze_Task_Body
;
1472 -----------------------------
1473 -- Analyze_Task_Definition --
1474 -----------------------------
1476 procedure Analyze_Task_Definition
(N
: Node_Id
) is
1480 Tasking_Used
:= True;
1482 if Present
(Visible_Declarations
(N
)) then
1483 Analyze_Declarations
(Visible_Declarations
(N
));
1486 if Present
(Private_Declarations
(N
)) then
1487 L
:= Last_Entity
(Current_Scope
);
1488 Analyze_Declarations
(Private_Declarations
(N
));
1491 Set_First_Private_Entity
1492 (Current_Scope
, Next_Entity
(L
));
1494 Set_First_Private_Entity
1495 (Current_Scope
, First_Entity
(Current_Scope
));
1499 Check_Max_Entries
(N
, Max_Task_Entries
);
1500 Process_End_Label
(N
, 'e', Current_Scope
);
1501 end Analyze_Task_Definition
;
1503 -----------------------
1504 -- Analyze_Task_Type --
1505 -----------------------
1507 procedure Analyze_Task_Type
(N
: Node_Id
) is
1509 Def_Id
: constant Entity_Id
:= Defining_Identifier
(N
);
1512 Tasking_Used
:= True;
1513 Check_Restriction
(Max_Tasks
, N
);
1514 Check_Restriction
(No_Tasking
, N
);
1515 T
:= Find_Type_Name
(N
);
1516 Generate_Definition
(T
);
1518 if Ekind
(T
) = E_Incomplete_Type
then
1520 Set_Completion_Referenced
(T
);
1523 Set_Ekind
(T
, E_Task_Type
);
1524 Set_Is_First_Subtype
(T
, True);
1525 Set_Has_Task
(T
, True);
1526 Init_Size_Align
(T
);
1528 Set_Has_Delayed_Freeze
(T
, True);
1529 Set_Girder_Constraint
(T
, No_Elist
);
1532 if Present
(Discriminant_Specifications
(N
)) then
1533 if Ada_83
and then Comes_From_Source
(N
) then
1534 Error_Msg_N
("(Ada 83) task discriminant not allowed!", N
);
1537 if Has_Discriminants
(T
) then
1539 -- Install discriminants. Also, verify conformance of
1540 -- discriminants of previous and current view. ???
1542 Install_Declarations
(T
);
1544 Process_Discriminants
(N
);
1548 if Present
(Task_Definition
(N
)) then
1549 Analyze_Task_Definition
(Task_Definition
(N
));
1552 if not Is_Library_Level_Entity
(T
) then
1553 Check_Restriction
(No_Task_Hierarchy
, N
);
1559 and then Is_Private_Type
(Def_Id
)
1560 and then Has_Discriminants
(Def_Id
)
1561 and then Expander_Active
1563 Exp_Ch9
.Expand_N_Task_Type_Declaration
(N
);
1564 Process_Full_View
(N
, T
, Def_Id
);
1566 end Analyze_Task_Type
;
1568 -----------------------------------
1569 -- Analyze_Terminate_Alternative --
1570 -----------------------------------
1572 procedure Analyze_Terminate_Alternative
(N
: Node_Id
) is
1574 Tasking_Used
:= True;
1576 if Present
(Pragmas_Before
(N
)) then
1577 Analyze_List
(Pragmas_Before
(N
));
1580 if Present
(Condition
(N
)) then
1581 Analyze_And_Resolve
(Condition
(N
), Any_Boolean
);
1583 end Analyze_Terminate_Alternative
;
1585 ------------------------------
1586 -- Analyze_Timed_Entry_Call --
1587 ------------------------------
1589 procedure Analyze_Timed_Entry_Call
(N
: Node_Id
) is
1591 Check_Restriction
(No_Select_Statements
, N
);
1592 Tasking_Used
:= True;
1593 Analyze
(Entry_Call_Alternative
(N
));
1594 Analyze
(Delay_Alternative
(N
));
1595 end Analyze_Timed_Entry_Call
;
1597 ------------------------------------
1598 -- Analyze_Triggering_Alternative --
1599 ------------------------------------
1601 procedure Analyze_Triggering_Alternative
(N
: Node_Id
) is
1602 Trigger
: Node_Id
:= Triggering_Statement
(N
);
1604 Tasking_Used
:= True;
1606 if Present
(Pragmas_Before
(N
)) then
1607 Analyze_List
(Pragmas_Before
(N
));
1611 if Comes_From_Source
(Trigger
)
1612 and then Nkind
(Trigger
) /= N_Delay_Until_Statement
1613 and then Nkind
(Trigger
) /= N_Delay_Relative_Statement
1614 and then Nkind
(Trigger
) /= N_Entry_Call_Statement
1617 ("triggering statement must be delay or entry call", Trigger
);
1620 if Is_Non_Empty_List
(Statements
(N
)) then
1621 Analyze_Statements
(Statements
(N
));
1623 end Analyze_Triggering_Alternative
;
1625 -----------------------
1626 -- Check_Max_Entries --
1627 -----------------------
1629 procedure Check_Max_Entries
(Def
: Node_Id
; R
: Restriction_Parameter_Id
) is
1632 procedure Count
(L
: List_Id
);
1633 -- Count entries in given declaration list
1635 procedure Count
(L
: List_Id
) is
1644 while Present
(D
) loop
1645 if Nkind
(D
) = N_Entry_Declaration
then
1647 DSD
: constant Node_Id
:=
1648 Discrete_Subtype_Definition
(D
);
1652 Ecount
:= Ecount
+ 1;
1654 elsif Is_OK_Static_Subtype
(Etype
(DSD
)) then
1656 Lo
: constant Uint
:=
1658 (Type_Low_Bound
(Etype
(DSD
)));
1659 Hi
: constant Uint
:=
1661 (Type_High_Bound
(Etype
(DSD
)));
1665 Ecount
:= Ecount
+ Hi
- Lo
+ 1;
1671 ("static subtype required by Restriction pragma", DSD
);
1680 -- Start of processing for Check_Max_Entries
1683 if Restriction_Parameters
(R
) >= 0 then
1685 Count
(Visible_Declarations
(Def
));
1686 Count
(Private_Declarations
(Def
));
1687 Check_Restriction
(R
, Ecount
, Def
);
1689 end Check_Max_Entries
;
1691 --------------------------
1692 -- Find_Concurrent_Spec --
1693 --------------------------
1695 function Find_Concurrent_Spec
(Body_Id
: Entity_Id
) return Entity_Id
is
1696 Spec_Id
: Entity_Id
:= Current_Entity_In_Scope
(Body_Id
);
1699 -- The type may have been given by an incomplete type declaration.
1700 -- Find full view now.
1702 if Present
(Spec_Id
) and then Ekind
(Spec_Id
) = E_Incomplete_Type
then
1703 Spec_Id
:= Full_View
(Spec_Id
);
1707 end Find_Concurrent_Spec
;
1709 --------------------------
1710 -- Install_Declarations --
1711 --------------------------
1713 procedure Install_Declarations
(Spec
: Entity_Id
) is
1718 E
:= First_Entity
(Spec
);
1720 while Present
(E
) loop
1721 Prev
:= Current_Entity
(E
);
1722 Set_Current_Entity
(E
);
1723 Set_Is_Immediately_Visible
(E
);
1724 Set_Homonym
(E
, Prev
);
1727 end Install_Declarations
;