1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 1992-2002, Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 ------------------------------------------------------------------------------
28 with Atree
; use Atree
;
29 with Checks
; use Checks
;
30 with Einfo
; use Einfo
;
31 with Errout
; use Errout
;
33 with Elists
; use Elists
;
34 with Itypes
; use Itypes
;
35 with Lib
.Xref
; use Lib
.Xref
;
36 with Nlists
; use Nlists
;
37 with Nmake
; use Nmake
;
39 with Restrict
; use Restrict
;
40 with Rtsfind
; use Rtsfind
;
42 with Sem_Ch3
; use Sem_Ch3
;
43 with Sem_Ch5
; use Sem_Ch5
;
44 with Sem_Ch6
; use Sem_Ch6
;
45 with Sem_Ch8
; use Sem_Ch8
;
46 with Sem_Eval
; use Sem_Eval
;
47 with Sem_Res
; use Sem_Res
;
48 with Sem_Type
; use Sem_Type
;
49 with Sem_Util
; use Sem_Util
;
50 with Sem_Warn
; use Sem_Warn
;
51 with Snames
; use Snames
;
52 with Stand
; use Stand
;
53 with Sinfo
; use Sinfo
;
55 with Tbuild
; use Tbuild
;
56 with Uintp
; use Uintp
;
58 package body Sem_Ch9
is
60 -----------------------
61 -- Local Subprograms --
62 -----------------------
64 procedure Check_Max_Entries
(Def
: Node_Id
; R
: Restriction_Parameter_Id
);
65 -- Given either a protected definition or a task definition in Def, check
66 -- the corresponding restriction parameter identifier R, and if it is set,
67 -- count the entries (checking the static requirement), and compare with
70 function Find_Concurrent_Spec
(Body_Id
: Entity_Id
) return Entity_Id
;
71 -- Find entity in corresponding task or protected declaration. Use full
72 -- view if first declaration was for an incomplete type.
74 procedure Install_Declarations
(Spec
: Entity_Id
);
75 -- Utility to make visible in corresponding body the entities defined
76 -- in task, protected type declaration, or entry declaration.
78 -----------------------------
79 -- Analyze_Abort_Statement --
80 -----------------------------
82 procedure Analyze_Abort_Statement
(N
: Node_Id
) is
87 T_Name
:= First
(Names
(N
));
88 while Present
(T_Name
) loop
91 if not Is_Task_Type
(Etype
(T_Name
)) then
92 Error_Msg_N
("expect task name for ABORT", T_Name
);
95 Resolve
(T_Name
, Etype
(T_Name
));
101 Check_Restriction
(No_Abort_Statements
, N
);
102 Check_Potentially_Blocking_Operation
(N
);
103 end Analyze_Abort_Statement
;
105 --------------------------------
106 -- Analyze_Accept_Alternative --
107 --------------------------------
109 procedure Analyze_Accept_Alternative
(N
: Node_Id
) is
111 Tasking_Used
:= True;
113 if Present
(Pragmas_Before
(N
)) then
114 Analyze_List
(Pragmas_Before
(N
));
117 Analyze
(Accept_Statement
(N
));
119 if Present
(Condition
(N
)) then
120 Analyze_And_Resolve
(Condition
(N
), Any_Boolean
);
123 if Is_Non_Empty_List
(Statements
(N
)) then
124 Analyze_Statements
(Statements
(N
));
126 end Analyze_Accept_Alternative
;
128 ------------------------------
129 -- Analyze_Accept_Statement --
130 ------------------------------
132 procedure Analyze_Accept_Statement
(N
: Node_Id
) is
133 Nam
: constant Entity_Id
:= Entry_Direct_Name
(N
);
134 Formals
: constant List_Id
:= Parameter_Specifications
(N
);
135 Index
: constant Node_Id
:= Entry_Index
(N
);
136 Stats
: constant Node_Id
:= Handled_Statement_Sequence
(N
);
138 Entry_Nam
: Entity_Id
;
141 Task_Nam
: Entity_Id
;
143 -----------------------
144 -- Actual_Index_Type --
145 -----------------------
147 function Actual_Index_Type
(E
: Entity_Id
) return Entity_Id
;
148 -- If the bounds of an entry family depend on task discriminants,
149 -- create a new index type where a discriminant is replaced by the
150 -- local variable that renames it in the task body.
152 function Actual_Index_Type
(E
: Entity_Id
) return Entity_Id
is
153 Typ
: Entity_Id
:= Entry_Index_Type
(E
);
154 Lo
: Node_Id
:= Type_Low_Bound
(Typ
);
155 Hi
: Node_Id
:= Type_High_Bound
(Typ
);
158 function Actual_Discriminant_Ref
(Bound
: Node_Id
) return Node_Id
;
159 -- If bound is discriminant reference, replace with corresponding
160 -- local variable of the same name.
162 function Actual_Discriminant_Ref
(Bound
: Node_Id
) return Node_Id
is
163 Typ
: Entity_Id
:= Etype
(Bound
);
167 if not Is_Entity_Name
(Bound
)
168 or else Ekind
(Entity
(Bound
)) /= E_Discriminant
173 Ref
:= Make_Identifier
(Sloc
(N
), Chars
(Entity
(Bound
)));
178 end Actual_Discriminant_Ref
;
180 -- Start of processing for Actual_Index_Type
183 if not Has_Discriminants
(Task_Nam
)
184 or else (not Is_Entity_Name
(Lo
)
185 and then not Is_Entity_Name
(Hi
))
187 return Entry_Index_Type
(E
);
189 New_T
:= Create_Itype
(Ekind
(Typ
), N
);
190 Set_Etype
(New_T
, Base_Type
(Typ
));
191 Set_Size_Info
(New_T
, Typ
);
192 Set_RM_Size
(New_T
, RM_Size
(Typ
));
193 Set_Scalar_Range
(New_T
,
194 Make_Range
(Sloc
(N
),
195 Low_Bound
=> Actual_Discriminant_Ref
(Lo
),
196 High_Bound
=> Actual_Discriminant_Ref
(Hi
)));
200 end Actual_Index_Type
;
202 -- Start of processing for Analyze_Accept_Statement
205 Tasking_Used
:= True;
207 -- Entry name is initialized to Any_Id. It should get reset to the
208 -- matching entry entity. An error is signalled if it is not reset.
212 for J
in reverse 0 .. Scope_Stack
.Last
loop
213 Task_Nam
:= Scope_Stack
.Table
(J
).Entity
;
214 exit when Ekind
(Etype
(Task_Nam
)) = E_Task_Type
;
215 Kind
:= Ekind
(Task_Nam
);
217 if Kind
/= E_Block
and then Kind
/= E_Loop
218 and then not Is_Entry
(Task_Nam
)
220 Error_Msg_N
("enclosing body of accept must be a task", N
);
225 if Ekind
(Etype
(Task_Nam
)) /= E_Task_Type
then
226 Error_Msg_N
("invalid context for accept statement", N
);
230 -- In order to process the parameters, we create a defining
231 -- identifier that can be used as the name of the scope. The
232 -- name of the accept statement itself is not a defining identifier.
234 if Present
(Index
) then
235 Ityp
:= New_Internal_Entity
236 (E_Entry_Family
, Current_Scope
, Sloc
(N
), 'E');
238 Ityp
:= New_Internal_Entity
239 (E_Entry
, Current_Scope
, Sloc
(N
), 'E');
242 Set_Etype
(Ityp
, Standard_Void_Type
);
243 Set_Accept_Address
(Ityp
, New_Elmt_List
);
245 if Present
(Formals
) then
247 Process_Formals
(Formals
, N
);
248 Create_Extra_Formals
(Ityp
);
252 -- We set the default expressions processed flag because we don't
253 -- need default expression functions. This is really more like a
254 -- body entity than a spec entity anyway.
256 Set_Default_Expressions_Processed
(Ityp
);
258 E
:= First_Entity
(Etype
(Task_Nam
));
260 while Present
(E
) loop
261 if Chars
(E
) = Chars
(Nam
)
262 and then (Ekind
(E
) = Ekind
(Ityp
))
263 and then Type_Conformant
(Ityp
, E
)
272 if Entry_Nam
= Any_Id
then
273 Error_Msg_N
("no entry declaration matches accept statement", N
);
276 Set_Entity
(Nam
, Entry_Nam
);
277 Generate_Reference
(Entry_Nam
, Nam
, 'b', Set_Ref
=> False);
278 Style
.Check_Identifier
(Nam
, Entry_Nam
);
281 -- Verify that the entry is not hidden by a procedure declared in
282 -- the current block (pathological but possible).
284 if Current_Scope
/= Task_Nam
then
289 E1
:= First_Entity
(Current_Scope
);
291 while Present
(E1
) loop
293 if Ekind
(E1
) = E_Procedure
294 and then Type_Conformant
(E1
, Entry_Nam
)
296 Error_Msg_N
("entry name is not visible", N
);
304 Set_Convention
(Ityp
, Convention
(Entry_Nam
));
305 Check_Fully_Conformant
(Ityp
, Entry_Nam
, N
);
307 for J
in reverse 0 .. Scope_Stack
.Last
loop
308 exit when Task_Nam
= Scope_Stack
.Table
(J
).Entity
;
310 if Entry_Nam
= Scope_Stack
.Table
(J
).Entity
then
311 Error_Msg_N
("duplicate accept statement for same entry", N
);
322 when N_Task_Body | N_Compilation_Unit
=>
324 when N_Asynchronous_Select
=>
325 Error_Msg_N
("accept statements are not allowed within" &
326 " an asynchronous select inner" &
327 " to the enclosing task body", N
);
335 if Ekind
(E
) = E_Entry_Family
then
337 Error_Msg_N
("missing entry index in accept for entry family", N
);
339 Analyze_And_Resolve
(Index
, Entry_Index_Type
(E
));
340 Apply_Range_Check
(Index
, Actual_Index_Type
(E
));
343 elsif Present
(Index
) then
344 Error_Msg_N
("invalid entry index in accept for simple entry", N
);
347 -- If statements are present, they must be analyzed in the context
348 -- of the entry, so that references to formals are correctly resolved.
349 -- We also have to add the declarations that are required by the
350 -- expansion of the accept statement in this case if expansion active.
352 -- In the case of a select alternative of a selective accept,
353 -- the expander references the address declaration even if there
354 -- is no statement list.
356 Exp_Ch9
.Expand_Accept_Declarations
(N
, Entry_Nam
);
358 -- If label declarations present, analyze them. They are declared
359 -- in the enclosing task, but their enclosing scope is the entry itself,
360 -- so that goto's to the label are recognized as local to the accept.
362 if Present
(Declarations
(N
)) then
369 Decl
:= First
(Declarations
(N
));
371 while Present
(Decl
) loop
375 (Nkind
(Decl
) = N_Implicit_Label_Declaration
);
377 Id
:= Defining_Identifier
(Decl
);
378 Set_Enclosing_Scope
(Id
, Entry_Nam
);
384 -- Set Not_Source_Assigned flag on all entry formals
386 E
:= First_Entity
(Entry_Nam
);
388 while Present
(E
) loop
389 Set_Not_Source_Assigned
(E
, True);
393 -- Analyze statements if present
395 if Present
(Stats
) then
396 New_Scope
(Entry_Nam
);
397 Install_Declarations
(Entry_Nam
);
399 Set_Actual_Subtypes
(N
, Current_Scope
);
401 Process_End_Label
(Handled_Statement_Sequence
(N
), 't', Entry_Nam
);
405 -- Some warning checks
407 Check_Potentially_Blocking_Operation
(N
);
408 Check_References
(Entry_Nam
, N
);
409 Set_Entry_Accepted
(Entry_Nam
);
410 end Analyze_Accept_Statement
;
412 ---------------------------------
413 -- Analyze_Asynchronous_Select --
414 ---------------------------------
416 procedure Analyze_Asynchronous_Select
(N
: Node_Id
) is
418 Tasking_Used
:= True;
419 Check_Restriction
(Max_Asynchronous_Select_Nesting
, N
);
420 Check_Restriction
(No_Select_Statements
, N
);
422 Analyze
(Triggering_Alternative
(N
));
424 Analyze_Statements
(Statements
(Abortable_Part
(N
)));
425 end Analyze_Asynchronous_Select
;
427 ------------------------------------
428 -- Analyze_Conditional_Entry_Call --
429 ------------------------------------
431 procedure Analyze_Conditional_Entry_Call
(N
: Node_Id
) is
433 Check_Restriction
(No_Select_Statements
, N
);
434 Tasking_Used
:= True;
435 Analyze
(Entry_Call_Alternative
(N
));
436 Analyze_Statements
(Else_Statements
(N
));
437 end Analyze_Conditional_Entry_Call
;
439 --------------------------------
440 -- Analyze_Delay_Alternative --
441 --------------------------------
443 procedure Analyze_Delay_Alternative
(N
: Node_Id
) is
447 Tasking_Used
:= True;
448 Check_Restriction
(No_Delay
, N
);
450 if Present
(Pragmas_Before
(N
)) then
451 Analyze_List
(Pragmas_Before
(N
));
454 if Nkind
(Parent
(N
)) = N_Selective_Accept
455 or else Nkind
(Parent
(N
)) = N_Timed_Entry_Call
457 Expr
:= Expression
(Delay_Statement
(N
));
459 -- defer full analysis until the statement is expanded, to insure
460 -- that generated code does not move past the guard. The delay
461 -- expression is only evaluated if the guard is open.
463 if Nkind
(Delay_Statement
(N
)) = N_Delay_Relative_Statement
then
464 Pre_Analyze_And_Resolve
(Expr
, Standard_Duration
);
467 Pre_Analyze_And_Resolve
(Expr
);
470 Check_Restriction
(No_Fixed_Point
, Expr
);
472 Analyze
(Delay_Statement
(N
));
475 if Present
(Condition
(N
)) then
476 Analyze_And_Resolve
(Condition
(N
), Any_Boolean
);
479 if Is_Non_Empty_List
(Statements
(N
)) then
480 Analyze_Statements
(Statements
(N
));
482 end Analyze_Delay_Alternative
;
484 ----------------------------
485 -- Analyze_Delay_Relative --
486 ----------------------------
488 procedure Analyze_Delay_Relative
(N
: Node_Id
) is
489 E
: constant Node_Id
:= Expression
(N
);
492 Check_Restriction
(No_Relative_Delay
, N
);
493 Tasking_Used
:= True;
494 Check_Restriction
(No_Delay
, N
);
495 Check_Potentially_Blocking_Operation
(N
);
496 Analyze_And_Resolve
(E
, Standard_Duration
);
497 Check_Restriction
(No_Fixed_Point
, E
);
498 end Analyze_Delay_Relative
;
500 -------------------------
501 -- Analyze_Delay_Until --
502 -------------------------
504 procedure Analyze_Delay_Until
(N
: Node_Id
) is
505 E
: constant Node_Id
:= Expression
(N
);
508 Tasking_Used
:= True;
509 Check_Restriction
(No_Delay
, N
);
510 Check_Potentially_Blocking_Operation
(N
);
513 if not Is_RTE
(Base_Type
(Etype
(E
)), RO_CA_Time
) and then
514 not Is_RTE
(Base_Type
(Etype
(E
)), RO_RT_Time
)
516 Error_Msg_N
("expect Time types for `DELAY UNTIL`", E
);
518 end Analyze_Delay_Until
;
520 ------------------------
521 -- Analyze_Entry_Body --
522 ------------------------
524 procedure Analyze_Entry_Body
(N
: Node_Id
) is
525 Id
: constant Entity_Id
:= Defining_Identifier
(N
);
526 Decls
: constant List_Id
:= Declarations
(N
);
527 Stats
: constant Node_Id
:= Handled_Statement_Sequence
(N
);
528 Formals
: constant Node_Id
:= Entry_Body_Formal_Part
(N
);
529 P_Type
: constant Entity_Id
:= Current_Scope
;
530 Entry_Name
: Entity_Id
;
534 Tasking_Used
:= True;
536 -- Entry_Name is initialized to Any_Id. It should get reset to the
537 -- matching entry entity. An error is signalled if it is not reset
539 Entry_Name
:= Any_Id
;
543 if Present
(Entry_Index_Specification
(Formals
)) then
544 Set_Ekind
(Id
, E_Entry_Family
);
546 Set_Ekind
(Id
, E_Entry
);
549 Set_Scope
(Id
, Current_Scope
);
550 Set_Etype
(Id
, Standard_Void_Type
);
551 Set_Accept_Address
(Id
, New_Elmt_List
);
553 E
:= First_Entity
(P_Type
);
554 while Present
(E
) loop
555 if Chars
(E
) = Chars
(Id
)
556 and then (Ekind
(E
) = Ekind
(Id
))
557 and then Type_Conformant
(Id
, E
)
560 Set_Convention
(Id
, Convention
(E
));
561 Check_Fully_Conformant
(Id
, E
, N
);
568 if Entry_Name
= Any_Id
then
569 Error_Msg_N
("no entry declaration matches entry body", N
);
572 elsif Has_Completion
(Entry_Name
) then
573 Error_Msg_N
("duplicate entry body", N
);
577 Set_Has_Completion
(Entry_Name
);
578 Generate_Reference
(Entry_Name
, Id
, 'b', Set_Ref
=> False);
579 Style
.Check_Identifier
(Id
, Entry_Name
);
582 Exp_Ch9
.Expand_Entry_Barrier
(N
, Entry_Name
);
583 New_Scope
(Entry_Name
);
585 Exp_Ch9
.Expand_Entry_Body_Declarations
(N
);
586 Install_Declarations
(Entry_Name
);
587 Set_Actual_Subtypes
(N
, Current_Scope
);
589 -- The entity for the protected subprogram corresponding to the entry
590 -- has been created. We retain the name of this entity in the entry
591 -- body, for use when the corresponding subprogram body is created.
592 -- Note that entry bodies have to corresponding_spec, and there is no
593 -- easy link back in the tree between the entry body and the entity for
596 Set_Protected_Body_Subprogram
(Id
,
597 Protected_Body_Subprogram
(Entry_Name
));
599 if Present
(Decls
) then
600 Analyze_Declarations
(Decls
);
603 if Present
(Stats
) then
607 Check_References
(Entry_Name
);
608 Process_End_Label
(Handled_Statement_Sequence
(N
), 't', Entry_Name
);
611 -- If this is an entry family, remove the loop created to provide
612 -- a scope for the entry index.
614 if Ekind
(Id
) = E_Entry_Family
615 and then Present
(Entry_Index_Specification
(Formals
))
620 end Analyze_Entry_Body
;
622 ------------------------------------
623 -- Analyze_Entry_Body_Formal_Part --
624 ------------------------------------
626 procedure Analyze_Entry_Body_Formal_Part
(N
: Node_Id
) is
627 Id
: constant Entity_Id
:= Defining_Identifier
(Parent
(N
));
628 Index
: constant Node_Id
:= Entry_Index_Specification
(N
);
629 Formals
: constant List_Id
:= Parameter_Specifications
(N
);
632 Tasking_Used
:= True;
634 if Present
(Index
) then
638 if Present
(Formals
) then
639 Set_Scope
(Id
, Current_Scope
);
641 Process_Formals
(Formals
, Parent
(N
));
645 end Analyze_Entry_Body_Formal_Part
;
647 ------------------------------------
648 -- Analyze_Entry_Call_Alternative --
649 ------------------------------------
651 procedure Analyze_Entry_Call_Alternative
(N
: Node_Id
) is
653 Tasking_Used
:= True;
655 if Present
(Pragmas_Before
(N
)) then
656 Analyze_List
(Pragmas_Before
(N
));
659 Analyze
(Entry_Call_Statement
(N
));
661 if Is_Non_Empty_List
(Statements
(N
)) then
662 Analyze_Statements
(Statements
(N
));
664 end Analyze_Entry_Call_Alternative
;
666 -------------------------------
667 -- Analyze_Entry_Declaration --
668 -------------------------------
670 procedure Analyze_Entry_Declaration
(N
: Node_Id
) is
671 Id
: Entity_Id
:= Defining_Identifier
(N
);
672 D_Sdef
: Node_Id
:= Discrete_Subtype_Definition
(N
);
673 Formals
: List_Id
:= Parameter_Specifications
(N
);
676 Generate_Definition
(Id
);
677 Tasking_Used
:= True;
680 Set_Ekind
(Id
, E_Entry
);
683 Set_Ekind
(Id
, E_Entry_Family
);
685 Make_Index
(D_Sdef
, N
, Id
);
688 Set_Etype
(Id
, Standard_Void_Type
);
689 Set_Convention
(Id
, Convention_Entry
);
690 Set_Accept_Address
(Id
, New_Elmt_List
);
692 if Present
(Formals
) then
693 Set_Scope
(Id
, Current_Scope
);
695 Process_Formals
(Formals
, N
);
696 Create_Extra_Formals
(Id
);
700 if Ekind
(Id
) = E_Entry
then
701 New_Overloaded_Entity
(Id
);
704 end Analyze_Entry_Declaration
;
706 ---------------------------------------
707 -- Analyze_Entry_Index_Specification --
708 ---------------------------------------
710 -- The defining_Identifier of the entry index specification is local
711 -- to the entry body, but must be available in the entry barrier,
712 -- which is evaluated outside of the entry body. The index is eventually
713 -- renamed as a run-time object, so is visibility is strictly a front-end
714 -- concern. In order to make it available to the barrier, we create
715 -- an additional scope, as for a loop, whose only declaration is the
716 -- index name. This loop is not attached to the tree and does not appear
717 -- as an entity local to the protected type, so its existence need only
718 -- be knwown to routines that process entry families.
720 procedure Analyze_Entry_Index_Specification
(N
: Node_Id
) is
721 Iden
: constant Node_Id
:= Defining_Identifier
(N
);
722 Def
: constant Node_Id
:= Discrete_Subtype_Definition
(N
);
723 Loop_Id
: Entity_Id
:=
724 Make_Defining_Identifier
(Sloc
(N
),
725 Chars
=> New_Internal_Name
('L'));
728 Tasking_Used
:= True;
731 Set_Ekind
(Loop_Id
, E_Loop
);
732 Set_Scope
(Loop_Id
, Current_Scope
);
735 Set_Ekind
(Iden
, E_Entry_Index_Parameter
);
736 Set_Etype
(Iden
, Etype
(Def
));
737 end Analyze_Entry_Index_Specification
;
739 ----------------------------
740 -- Analyze_Protected_Body --
741 ----------------------------
743 procedure Analyze_Protected_Body
(N
: Node_Id
) is
744 Body_Id
: constant Entity_Id
:= Defining_Identifier
(N
);
748 -- This is initially the entity of the protected object or protected
749 -- type involved, but is replaced by the protected type always in the
750 -- case of a single protected declaration, since this is the proper
754 -- This is the entity of the protected object or protected type
755 -- involved, and is the entity used for cross-reference purposes
756 -- (it differs from Spec_Id in the case of a single protected
757 -- object, since Spec_Id is set to the protected type in this case).
760 Tasking_Used
:= True;
761 Set_Ekind
(Body_Id
, E_Protected_Body
);
762 Spec_Id
:= Find_Concurrent_Spec
(Body_Id
);
765 and then Ekind
(Spec_Id
) = E_Protected_Type
769 elsif Present
(Spec_Id
)
770 and then Ekind
(Etype
(Spec_Id
)) = E_Protected_Type
771 and then not Comes_From_Source
(Etype
(Spec_Id
))
776 Error_Msg_N
("missing specification for protected body", Body_Id
);
781 Generate_Reference
(Ref_Id
, Body_Id
, 'b', Set_Ref
=> False);
782 Style
.Check_Identifier
(Body_Id
, Spec_Id
);
784 -- The declarations are always attached to the type
786 if Ekind
(Spec_Id
) /= E_Protected_Type
then
787 Spec_Id
:= Etype
(Spec_Id
);
791 Set_Corresponding_Spec
(N
, Spec_Id
);
792 Set_Corresponding_Body
(Parent
(Spec_Id
), Body_Id
);
793 Set_Has_Completion
(Spec_Id
);
794 Install_Declarations
(Spec_Id
);
796 Exp_Ch9
.Expand_Protected_Body_Declarations
(N
, Spec_Id
);
798 Last_E
:= Last_Entity
(Spec_Id
);
800 Analyze_Declarations
(Declarations
(N
));
802 -- For visibility purposes, all entities in the body are private.
803 -- Set First_Private_Entity accordingly, if there was no private
804 -- part in the protected declaration.
806 if No
(First_Private_Entity
(Spec_Id
)) then
807 if Present
(Last_E
) then
808 Set_First_Private_Entity
(Spec_Id
, Next_Entity
(Last_E
));
810 Set_First_Private_Entity
(Spec_Id
, First_Entity
(Spec_Id
));
814 Check_Completion
(Body_Id
);
815 Check_References
(Spec_Id
);
816 Process_End_Label
(N
, 't', Ref_Id
);
818 end Analyze_Protected_Body
;
820 ----------------------------------
821 -- Analyze_Protected_Definition --
822 ----------------------------------
824 procedure Analyze_Protected_Definition
(N
: Node_Id
) is
829 Tasking_Used
:= True;
830 Analyze_Declarations
(Visible_Declarations
(N
));
832 if Present
(Private_Declarations
(N
))
833 and then not Is_Empty_List
(Private_Declarations
(N
))
835 L
:= Last_Entity
(Current_Scope
);
836 Analyze_Declarations
(Private_Declarations
(N
));
839 Set_First_Private_Entity
(Current_Scope
, Next_Entity
(L
));
842 Set_First_Private_Entity
(Current_Scope
,
843 First_Entity
(Current_Scope
));
847 E
:= First_Entity
(Current_Scope
);
849 while Present
(E
) loop
851 if Ekind
(E
) = E_Function
852 or else Ekind
(E
) = E_Procedure
854 Set_Convention
(E
, Convention_Protected
);
856 elsif Is_Task_Type
(Etype
(E
))
857 or else Has_Task
(Etype
(E
))
859 Set_Has_Task
(Current_Scope
);
865 Check_Max_Entries
(N
, Max_Protected_Entries
);
866 Process_End_Label
(N
, 'e', Current_Scope
);
867 end Analyze_Protected_Definition
;
869 ----------------------------
870 -- Analyze_Protected_Type --
871 ----------------------------
873 procedure Analyze_Protected_Type
(N
: Node_Id
) is
876 Def_Id
: constant Entity_Id
:= Defining_Identifier
(N
);
879 Tasking_Used
:= True;
880 Check_Restriction
(No_Protected_Types
, N
);
882 T
:= Find_Type_Name
(N
);
884 if Ekind
(T
) = E_Incomplete_Type
then
886 Set_Completion_Referenced
(T
);
889 Set_Ekind
(T
, E_Protected_Type
);
892 Set_Is_First_Subtype
(T
, True);
893 Set_Has_Delayed_Freeze
(T
, True);
894 Set_Girder_Constraint
(T
, No_Elist
);
897 if Present
(Discriminant_Specifications
(N
)) then
898 if Has_Discriminants
(T
) then
900 -- Install discriminants. Also, verify conformance of
901 -- discriminants of previous and current view. ???
903 Install_Declarations
(T
);
905 Process_Discriminants
(N
);
909 Analyze
(Protected_Definition
(N
));
911 -- Protected types with entries are controlled (because of the
912 -- Protection component if nothing else), same for any protected type
913 -- with interrupt handlers. Note that we need to analyze the protected
914 -- definition to set Has_Entries and such.
916 if (Abort_Allowed
or else Restrictions
(No_Entry_Queue
) = False
917 or else Number_Entries
(T
) > 1)
920 or else Has_Interrupt_Handler
(T
)
921 or else Has_Attach_Handler
(T
))
923 Set_Has_Controlled_Component
(T
, True);
926 -- The Ekind of components is E_Void during analysis to detect
927 -- illegal uses. Now it can be set correctly.
929 E
:= First_Entity
(Current_Scope
);
931 while Present
(E
) loop
932 if Ekind
(E
) = E_Void
then
933 Set_Ekind
(E
, E_Component
);
934 Init_Component_Location
(E
);
943 and then Is_Private_Type
(Def_Id
)
944 and then Has_Discriminants
(Def_Id
)
945 and then Expander_Active
947 Exp_Ch9
.Expand_N_Protected_Type_Declaration
(N
);
948 Process_Full_View
(N
, T
, Def_Id
);
951 end Analyze_Protected_Type
;
953 ---------------------
954 -- Analyze_Requeue --
955 ---------------------
957 procedure Analyze_Requeue
(N
: Node_Id
) is
958 Entry_Name
: Node_Id
:= Name
(N
);
959 Entry_Id
: Entity_Id
;
963 Enclosing
: Entity_Id
;
964 Target_Obj
: Node_Id
:= Empty
;
965 Req_Scope
: Entity_Id
;
966 Outer_Ent
: Entity_Id
;
969 Check_Restriction
(No_Requeue
, N
);
970 Check_Unreachable_Code
(N
);
971 Tasking_Used
:= True;
974 for J
in reverse 0 .. Scope_Stack
.Last
loop
975 Enclosing
:= Scope_Stack
.Table
(J
).Entity
;
976 exit when Is_Entry
(Enclosing
);
978 if Ekind
(Enclosing
) /= E_Block
979 and then Ekind
(Enclosing
) /= E_Loop
981 Error_Msg_N
("requeue must appear within accept or entry body", N
);
986 Analyze
(Entry_Name
);
988 if Etype
(Entry_Name
) = Any_Type
then
992 if Nkind
(Entry_Name
) = N_Selected_Component
then
993 Target_Obj
:= Prefix
(Entry_Name
);
994 Entry_Name
:= Selector_Name
(Entry_Name
);
997 -- If an explicit target object is given then we have to check
998 -- the restrictions of 9.5.4(6).
1000 if Present
(Target_Obj
) then
1001 -- Locate containing concurrent unit and determine
1002 -- enclosing entry body or outermost enclosing accept
1003 -- statement within the unit.
1006 for S
in reverse 0 .. Scope_Stack
.Last
loop
1007 Req_Scope
:= Scope_Stack
.Table
(S
).Entity
;
1009 exit when Ekind
(Req_Scope
) in Task_Kind
1010 or else Ekind
(Req_Scope
) in Protected_Kind
;
1012 if Is_Entry
(Req_Scope
) then
1013 Outer_Ent
:= Req_Scope
;
1017 pragma Assert
(Present
(Outer_Ent
));
1019 -- Check that the accessibility level of the target object
1020 -- is not greater or equal to the outermost enclosing accept
1021 -- statement (or entry body) unless it is a parameter of the
1022 -- innermost enclosing accept statement (or entry body).
1024 if Object_Access_Level
(Target_Obj
) >= Scope_Depth
(Outer_Ent
)
1026 (not Is_Entity_Name
(Target_Obj
)
1027 or else Ekind
(Entity
(Target_Obj
)) not in Formal_Kind
1028 or else Enclosing
/= Scope
(Entity
(Target_Obj
)))
1031 ("target object has invalid level for requeue", Target_Obj
);
1035 -- Overloaded case, find right interpretation
1037 if Is_Overloaded
(Entry_Name
) then
1038 Get_First_Interp
(Entry_Name
, I
, It
);
1042 while Present
(It
.Nam
) loop
1044 if No
(First_Formal
(It
.Nam
))
1045 or else Subtype_Conformant
(Enclosing
, It
.Nam
)
1051 Error_Msg_N
("ambiguous entry name in requeue", N
);
1056 Get_Next_Interp
(I
, It
);
1060 Error_Msg_N
("no entry matches context", N
);
1063 Set_Entity
(Entry_Name
, Entry_Id
);
1066 -- Non-overloaded cases
1068 -- For the case of a reference to an element of an entry family,
1069 -- the Entry_Name is an indexed component.
1071 elsif Nkind
(Entry_Name
) = N_Indexed_Component
then
1073 -- Requeue to an entry out of the body
1075 if Nkind
(Prefix
(Entry_Name
)) = N_Selected_Component
then
1076 Entry_Id
:= Entity
(Selector_Name
(Prefix
(Entry_Name
)));
1078 -- Requeue from within the body itself
1080 elsif Nkind
(Prefix
(Entry_Name
)) = N_Identifier
then
1081 Entry_Id
:= Entity
(Prefix
(Entry_Name
));
1084 Error_Msg_N
("invalid entry_name specified", N
);
1088 -- If we had a requeue of the form REQUEUE A (B), then the parser
1089 -- accepted it (because it could have been a requeue on an entry
1090 -- index. If A turns out not to be an entry family, then the analysis
1091 -- of A (B) turned it into a function call.
1093 elsif Nkind
(Entry_Name
) = N_Function_Call
then
1095 ("arguments not allowed in requeue statement",
1096 First
(Parameter_Associations
(Entry_Name
)));
1099 -- Normal case of no entry family, no argument
1102 Entry_Id
:= Entity
(Entry_Name
);
1105 -- Resolve entry, and check that it is subtype conformant with the
1106 -- enclosing construct if this construct has formals (RM 9.5.4(5)).
1108 if not Is_Entry
(Entry_Id
) then
1109 Error_Msg_N
("expect entry name in requeue statement", Name
(N
));
1110 elsif Ekind
(Entry_Id
) = E_Entry_Family
1112 and then Nkind
(Entry_Name
) /= N_Indexed_Component
1114 Error_Msg_N
("missing index for entry family component", Name
(N
));
1117 Resolve_Entry
(Name
(N
));
1119 if Present
(First_Formal
(Entry_Id
)) then
1120 Check_Subtype_Conformant
(Enclosing
, Entry_Id
, Name
(N
));
1122 -- Mark any output parameters as assigned
1125 Ent
: Entity_Id
:= First_Formal
(Enclosing
);
1128 while Present
(Ent
) loop
1129 if Ekind
(Ent
) = E_Out_Parameter
then
1130 Set_Not_Source_Assigned
(Ent
, False);
1139 end Analyze_Requeue
;
1141 ------------------------------
1142 -- Analyze_Selective_Accept --
1143 ------------------------------
1145 procedure Analyze_Selective_Accept
(N
: Node_Id
) is
1146 Alts
: constant List_Id
:= Select_Alternatives
(N
);
1149 Accept_Present
: Boolean := False;
1150 Terminate_Present
: Boolean := False;
1151 Delay_Present
: Boolean := False;
1152 Relative_Present
: Boolean := False;
1153 Alt_Count
: Uint
:= Uint_0
;
1156 Check_Restriction
(No_Select_Statements
, N
);
1157 Tasking_Used
:= True;
1159 Alt
:= First
(Alts
);
1160 while Present
(Alt
) loop
1161 Alt_Count
:= Alt_Count
+ 1;
1164 if Nkind
(Alt
) = N_Delay_Alternative
then
1165 if Delay_Present
then
1167 if (Relative_Present
/=
1168 (Nkind
(Delay_Statement
(Alt
)) = N_Delay_Relative_Statement
))
1171 ("delay_until and delay_relative alternatives ", Alt
);
1173 ("\cannot appear in the same selective_wait", Alt
);
1177 Delay_Present
:= True;
1179 Nkind
(Delay_Statement
(Alt
)) = N_Delay_Relative_Statement
;
1182 elsif Nkind
(Alt
) = N_Terminate_Alternative
then
1183 if Terminate_Present
then
1184 Error_Msg_N
("Only one terminate alternative allowed", N
);
1186 Terminate_Present
:= True;
1187 Check_Restriction
(No_Terminate_Alternatives
, N
);
1190 elsif Nkind
(Alt
) = N_Accept_Alternative
then
1191 Accept_Present
:= True;
1193 -- Check for duplicate accept
1197 Stm
: constant Node_Id
:= Accept_Statement
(Alt
);
1198 EDN
: constant Node_Id
:= Entry_Direct_Name
(Stm
);
1202 if Nkind
(EDN
) = N_Identifier
1203 and then No
(Condition
(Alt
))
1204 and then Present
(Entity
(EDN
)) -- defend against junk
1205 and then Ekind
(Entity
(EDN
)) = E_Entry
1207 Ent
:= Entity
(EDN
);
1209 Alt1
:= First
(Alts
);
1210 while Alt1
/= Alt
loop
1211 if Nkind
(Alt1
) = N_Accept_Alternative
1212 and then No
(Condition
(Alt1
))
1215 Stm1
: constant Node_Id
:= Accept_Statement
(Alt1
);
1216 EDN1
: constant Node_Id
:= Entry_Direct_Name
(Stm1
);
1219 if Nkind
(EDN1
) = N_Identifier
then
1220 if Entity
(EDN1
) = Ent
then
1221 Error_Msg_Sloc
:= Sloc
(Stm1
);
1223 ("?accept duplicates one on line#", Stm
);
1239 Check_Restriction
(Max_Select_Alternatives
, Alt_Count
, N
);
1240 Check_Potentially_Blocking_Operation
(N
);
1242 if Terminate_Present
and Delay_Present
then
1243 Error_Msg_N
("at most one of terminate or delay alternative", N
);
1245 elsif not Accept_Present
then
1247 ("select must contain at least one accept alternative", N
);
1250 if Present
(Else_Statements
(N
)) then
1251 if Terminate_Present
or Delay_Present
then
1252 Error_Msg_N
("else part not allowed with other alternatives", N
);
1255 Analyze_Statements
(Else_Statements
(N
));
1257 end Analyze_Selective_Accept
;
1259 ------------------------------
1260 -- Analyze_Single_Protected --
1261 ------------------------------
1263 procedure Analyze_Single_Protected
(N
: Node_Id
) is
1264 Loc
: constant Source_Ptr
:= Sloc
(N
);
1265 Id
: constant Node_Id
:= Defining_Identifier
(N
);
1269 O_Name
: constant Entity_Id
:= New_Copy
(Id
);
1272 Generate_Definition
(Id
);
1273 Tasking_Used
:= True;
1275 -- The node is rewritten as a protected type declaration,
1276 -- in exact analogy with what is done with single tasks.
1279 Make_Defining_Identifier
(Sloc
(Id
),
1280 New_External_Name
(Chars
(Id
), 'T'));
1283 Make_Protected_Type_Declaration
(Loc
,
1284 Defining_Identifier
=> T
,
1285 Protected_Definition
=> Relocate_Node
(Protected_Definition
(N
)));
1288 Make_Object_Declaration
(Loc
,
1289 Defining_Identifier
=> O_Name
,
1290 Object_Definition
=> Make_Identifier
(Loc
, Chars
(T
)));
1292 Rewrite
(N
, T_Decl
);
1293 Insert_After
(N
, O_Decl
);
1294 Mark_Rewrite_Insertion
(O_Decl
);
1296 -- Enter names of type and object before analysis, because the name
1297 -- of the object may be used in its own body.
1300 Set_Ekind
(T
, E_Protected_Type
);
1303 Enter_Name
(O_Name
);
1304 Set_Ekind
(O_Name
, E_Variable
);
1305 Set_Etype
(O_Name
, T
);
1307 -- Instead of calling Analyze on the new node, call directly
1308 -- the proper analysis procedure. Otherwise the node would be
1309 -- expanded twice, with disastrous result.
1311 Analyze_Protected_Type
(N
);
1313 end Analyze_Single_Protected
;
1315 -------------------------
1316 -- Analyze_Single_Task --
1317 -------------------------
1319 procedure Analyze_Single_Task
(N
: Node_Id
) is
1320 Loc
: constant Source_Ptr
:= Sloc
(N
);
1321 Id
: constant Node_Id
:= Defining_Identifier
(N
);
1325 O_Name
: constant Entity_Id
:= New_Copy
(Id
);
1328 Generate_Definition
(Id
);
1329 Tasking_Used
:= True;
1331 -- The node is rewritten as a task type declaration, followed
1332 -- by an object declaration of that anonymous task type.
1335 Make_Defining_Identifier
(Sloc
(Id
),
1336 New_External_Name
(Chars
(Id
), Suffix
=> "TK"));
1339 Make_Task_Type_Declaration
(Loc
,
1340 Defining_Identifier
=> T
,
1341 Task_Definition
=> Relocate_Node
(Task_Definition
(N
)));
1344 Make_Object_Declaration
(Loc
,
1345 Defining_Identifier
=> O_Name
,
1346 Object_Definition
=> Make_Identifier
(Loc
, Chars
(T
)));
1348 Rewrite
(N
, T_Decl
);
1349 Insert_After
(N
, O_Decl
);
1350 Mark_Rewrite_Insertion
(O_Decl
);
1352 -- Enter names of type and object before analysis, because the name
1353 -- of the object may be used in its own body.
1356 Set_Ekind
(T
, E_Task_Type
);
1359 Enter_Name
(O_Name
);
1360 Set_Ekind
(O_Name
, E_Variable
);
1361 Set_Etype
(O_Name
, T
);
1363 -- Instead of calling Analyze on the new node, call directly
1364 -- the proper analysis procedure. Otherwise the node would be
1365 -- expanded twice, with disastrous result.
1367 Analyze_Task_Type
(N
);
1369 end Analyze_Single_Task
;
1371 -----------------------
1372 -- Analyze_Task_Body --
1373 -----------------------
1375 procedure Analyze_Task_Body
(N
: Node_Id
) is
1376 Body_Id
: constant Entity_Id
:= Defining_Identifier
(N
);
1379 Spec_Id
: Entity_Id
;
1380 -- This is initially the entity of the task or task type involved,
1381 -- but is replaced by the task type always in the case of a single
1382 -- task declaration, since this is the proper scope to be used.
1385 -- This is the entity of the task or task type, and is the entity
1386 -- used for cross-reference purposes (it differs from Spec_Id in
1387 -- the case of a single task, since Spec_Id is set to the task type)
1390 Tasking_Used
:= True;
1391 Set_Ekind
(Body_Id
, E_Task_Body
);
1392 Set_Scope
(Body_Id
, Current_Scope
);
1393 Spec_Id
:= Find_Concurrent_Spec
(Body_Id
);
1395 -- The spec is either a task type declaration, or a single task
1396 -- declaration for which we have created an anonymous type.
1398 if Present
(Spec_Id
)
1399 and then Ekind
(Spec_Id
) = E_Task_Type
1403 elsif Present
(Spec_Id
)
1404 and then Ekind
(Etype
(Spec_Id
)) = E_Task_Type
1405 and then not Comes_From_Source
(Etype
(Spec_Id
))
1410 Error_Msg_N
("missing specification for task body", Body_Id
);
1415 Generate_Reference
(Ref_Id
, Body_Id
, 'b', Set_Ref
=> False);
1416 Style
.Check_Identifier
(Body_Id
, Spec_Id
);
1418 -- Deal with case of body of single task (anonymous type was created)
1420 if Ekind
(Spec_Id
) = E_Variable
then
1421 Spec_Id
:= Etype
(Spec_Id
);
1424 New_Scope
(Spec_Id
);
1425 Set_Corresponding_Spec
(N
, Spec_Id
);
1426 Set_Corresponding_Body
(Parent
(Spec_Id
), Body_Id
);
1427 Set_Has_Completion
(Spec_Id
);
1428 Install_Declarations
(Spec_Id
);
1429 Last_E
:= Last_Entity
(Spec_Id
);
1431 Analyze_Declarations
(Declarations
(N
));
1433 -- For visibility purposes, all entities in the body are private.
1434 -- Set First_Private_Entity accordingly, if there was no private
1435 -- part in the protected declaration.
1437 if No
(First_Private_Entity
(Spec_Id
)) then
1438 if Present
(Last_E
) then
1439 Set_First_Private_Entity
(Spec_Id
, Next_Entity
(Last_E
));
1441 Set_First_Private_Entity
(Spec_Id
, First_Entity
(Spec_Id
));
1445 Analyze
(Handled_Statement_Sequence
(N
));
1446 Check_Completion
(Body_Id
);
1447 Check_References
(Body_Id
);
1449 -- Check for entries with no corresponding accept
1455 Ent
:= First_Entity
(Spec_Id
);
1457 while Present
(Ent
) loop
1459 and then not Entry_Accepted
(Ent
)
1460 and then Comes_From_Source
(Ent
)
1462 Error_Msg_NE
("no accept for entry &?", N
, Ent
);
1469 Process_End_Label
(Handled_Statement_Sequence
(N
), 't', Ref_Id
);
1471 end Analyze_Task_Body
;
1473 -----------------------------
1474 -- Analyze_Task_Definition --
1475 -----------------------------
1477 procedure Analyze_Task_Definition
(N
: Node_Id
) is
1481 Tasking_Used
:= True;
1483 if Present
(Visible_Declarations
(N
)) then
1484 Analyze_Declarations
(Visible_Declarations
(N
));
1487 if Present
(Private_Declarations
(N
)) then
1488 L
:= Last_Entity
(Current_Scope
);
1489 Analyze_Declarations
(Private_Declarations
(N
));
1492 Set_First_Private_Entity
1493 (Current_Scope
, Next_Entity
(L
));
1495 Set_First_Private_Entity
1496 (Current_Scope
, First_Entity
(Current_Scope
));
1500 Check_Max_Entries
(N
, Max_Task_Entries
);
1501 Process_End_Label
(N
, 'e', Current_Scope
);
1502 end Analyze_Task_Definition
;
1504 -----------------------
1505 -- Analyze_Task_Type --
1506 -----------------------
1508 procedure Analyze_Task_Type
(N
: Node_Id
) is
1510 Def_Id
: constant Entity_Id
:= Defining_Identifier
(N
);
1513 Tasking_Used
:= True;
1514 Check_Restriction
(Max_Tasks
, N
);
1515 Check_Restriction
(No_Tasking
, N
);
1516 T
:= Find_Type_Name
(N
);
1517 Generate_Definition
(T
);
1519 if Ekind
(T
) = E_Incomplete_Type
then
1521 Set_Completion_Referenced
(T
);
1524 Set_Ekind
(T
, E_Task_Type
);
1525 Set_Is_First_Subtype
(T
, True);
1526 Set_Has_Task
(T
, True);
1527 Init_Size_Align
(T
);
1529 Set_Has_Delayed_Freeze
(T
, True);
1530 Set_Girder_Constraint
(T
, No_Elist
);
1533 if Present
(Discriminant_Specifications
(N
)) then
1534 if Ada_83
and then Comes_From_Source
(N
) then
1535 Error_Msg_N
("(Ada 83) task discriminant not allowed!", N
);
1538 if Has_Discriminants
(T
) then
1540 -- Install discriminants. Also, verify conformance of
1541 -- discriminants of previous and current view. ???
1543 Install_Declarations
(T
);
1545 Process_Discriminants
(N
);
1549 if Present
(Task_Definition
(N
)) then
1550 Analyze_Task_Definition
(Task_Definition
(N
));
1553 if not Is_Library_Level_Entity
(T
) then
1554 Check_Restriction
(No_Task_Hierarchy
, N
);
1560 and then Is_Private_Type
(Def_Id
)
1561 and then Has_Discriminants
(Def_Id
)
1562 and then Expander_Active
1564 Exp_Ch9
.Expand_N_Task_Type_Declaration
(N
);
1565 Process_Full_View
(N
, T
, Def_Id
);
1567 end Analyze_Task_Type
;
1569 -----------------------------------
1570 -- Analyze_Terminate_Alternative --
1571 -----------------------------------
1573 procedure Analyze_Terminate_Alternative
(N
: Node_Id
) is
1575 Tasking_Used
:= True;
1577 if Present
(Pragmas_Before
(N
)) then
1578 Analyze_List
(Pragmas_Before
(N
));
1581 if Present
(Condition
(N
)) then
1582 Analyze_And_Resolve
(Condition
(N
), Any_Boolean
);
1584 end Analyze_Terminate_Alternative
;
1586 ------------------------------
1587 -- Analyze_Timed_Entry_Call --
1588 ------------------------------
1590 procedure Analyze_Timed_Entry_Call
(N
: Node_Id
) is
1592 Check_Restriction
(No_Select_Statements
, N
);
1593 Tasking_Used
:= True;
1594 Analyze
(Entry_Call_Alternative
(N
));
1595 Analyze
(Delay_Alternative
(N
));
1596 end Analyze_Timed_Entry_Call
;
1598 ------------------------------------
1599 -- Analyze_Triggering_Alternative --
1600 ------------------------------------
1602 procedure Analyze_Triggering_Alternative
(N
: Node_Id
) is
1603 Trigger
: Node_Id
:= Triggering_Statement
(N
);
1605 Tasking_Used
:= True;
1607 if Present
(Pragmas_Before
(N
)) then
1608 Analyze_List
(Pragmas_Before
(N
));
1612 if Comes_From_Source
(Trigger
)
1613 and then Nkind
(Trigger
) /= N_Delay_Until_Statement
1614 and then Nkind
(Trigger
) /= N_Delay_Relative_Statement
1615 and then Nkind
(Trigger
) /= N_Entry_Call_Statement
1618 ("triggering statement must be delay or entry call", Trigger
);
1621 if Is_Non_Empty_List
(Statements
(N
)) then
1622 Analyze_Statements
(Statements
(N
));
1624 end Analyze_Triggering_Alternative
;
1626 -----------------------
1627 -- Check_Max_Entries --
1628 -----------------------
1630 procedure Check_Max_Entries
(Def
: Node_Id
; R
: Restriction_Parameter_Id
) is
1633 procedure Count
(L
: List_Id
);
1634 -- Count entries in given declaration list
1636 procedure Count
(L
: List_Id
) is
1645 while Present
(D
) loop
1646 if Nkind
(D
) = N_Entry_Declaration
then
1648 DSD
: constant Node_Id
:=
1649 Discrete_Subtype_Definition
(D
);
1653 Ecount
:= Ecount
+ 1;
1655 elsif Is_OK_Static_Subtype
(Etype
(DSD
)) then
1657 Lo
: constant Uint
:=
1659 (Type_Low_Bound
(Etype
(DSD
)));
1660 Hi
: constant Uint
:=
1662 (Type_High_Bound
(Etype
(DSD
)));
1666 Ecount
:= Ecount
+ Hi
- Lo
+ 1;
1672 ("static subtype required by Restriction pragma", DSD
);
1681 -- Start of processing for Check_Max_Entries
1684 if Restriction_Parameters
(R
) >= 0 then
1686 Count
(Visible_Declarations
(Def
));
1687 Count
(Private_Declarations
(Def
));
1688 Check_Restriction
(R
, Ecount
, Def
);
1690 end Check_Max_Entries
;
1692 --------------------------
1693 -- Find_Concurrent_Spec --
1694 --------------------------
1696 function Find_Concurrent_Spec
(Body_Id
: Entity_Id
) return Entity_Id
is
1697 Spec_Id
: Entity_Id
:= Current_Entity_In_Scope
(Body_Id
);
1700 -- The type may have been given by an incomplete type declaration.
1701 -- Find full view now.
1703 if Present
(Spec_Id
) and then Ekind
(Spec_Id
) = E_Incomplete_Type
then
1704 Spec_Id
:= Full_View
(Spec_Id
);
1708 end Find_Concurrent_Spec
;
1710 --------------------------
1711 -- Install_Declarations --
1712 --------------------------
1714 procedure Install_Declarations
(Spec
: Entity_Id
) is
1719 E
:= First_Entity
(Spec
);
1721 while Present
(E
) loop
1722 Prev
:= Current_Entity
(E
);
1723 Set_Current_Entity
(E
);
1724 Set_Is_Immediately_Visible
(E
);
1725 Set_Homonym
(E
, Prev
);
1728 end Install_Declarations
;