1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2007, 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 3, 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Atree
; use Atree
;
27 with Checks
; use Checks
;
28 with Einfo
; use Einfo
;
29 with Errout
; use Errout
;
30 with Exp_Ch9
; use Exp_Ch9
;
31 with Elists
; use Elists
;
32 with Freeze
; use Freeze
;
33 with Itypes
; use Itypes
;
34 with Lib
.Xref
; use Lib
.Xref
;
35 with Namet
; use Namet
;
36 with Nlists
; use Nlists
;
37 with Nmake
; use Nmake
;
39 with Restrict
; use Restrict
;
40 with Rident
; use Rident
;
41 with Rtsfind
; use Rtsfind
;
43 with Sem_Ch3
; use Sem_Ch3
;
44 with Sem_Ch5
; use Sem_Ch5
;
45 with Sem_Ch6
; use Sem_Ch6
;
46 with Sem_Ch8
; use Sem_Ch8
;
47 with Sem_Eval
; use Sem_Eval
;
48 with Sem_Res
; use Sem_Res
;
49 with Sem_Type
; use Sem_Type
;
50 with Sem_Util
; use Sem_Util
;
51 with Sem_Warn
; use Sem_Warn
;
52 with Snames
; use Snames
;
53 with Stand
; use Stand
;
54 with Sinfo
; use Sinfo
;
56 with Targparm
; use Targparm
;
57 with Tbuild
; use Tbuild
;
58 with Uintp
; use Uintp
;
60 package body Sem_Ch9
is
62 -----------------------
63 -- Local Subprograms --
64 -----------------------
66 procedure Check_Max_Entries
(D
: Node_Id
; R
: All_Parameter_Restrictions
);
67 -- Given either a protected definition or a task definition in D, check
68 -- the corresponding restriction parameter identifier R, and if it is set,
69 -- count the entries (checking the static requirement), and compare with
72 procedure Check_Interfaces
(N
: Node_Id
; T
: Entity_Id
);
73 -- N is an N_Protected_Type_Declaration or N_Task_Type_Declaration node.
74 -- Complete decoration of T and check legality of the covered interfaces.
76 procedure Check_Triggering_Statement
79 Is_Dispatching
: out Boolean);
80 -- Examine the triggering statement of a select statement, conditional or
81 -- timed entry call. If Trigger is a dispatching call, return its status
82 -- in Is_Dispatching and check whether the primitive belongs to a limited
83 -- interface. If it does not, emit an error at Error_Node.
85 function Find_Concurrent_Spec
(Body_Id
: Entity_Id
) return Entity_Id
;
86 -- Find entity in corresponding task or protected declaration. Use full
87 -- view if first declaration was for an incomplete type.
89 procedure Install_Declarations
(Spec
: Entity_Id
);
90 -- Utility to make visible in corresponding body the entities defined in
91 -- task, protected type declaration, or entry declaration.
93 -----------------------------
94 -- Analyze_Abort_Statement --
95 -----------------------------
97 procedure Analyze_Abort_Statement
(N
: Node_Id
) is
101 Tasking_Used
:= True;
102 T_Name
:= First
(Names
(N
));
103 while Present
(T_Name
) loop
106 if Is_Task_Type
(Etype
(T_Name
))
107 or else (Ada_Version
>= Ada_05
108 and then Ekind
(Etype
(T_Name
)) = E_Class_Wide_Type
109 and then Is_Interface
(Etype
(T_Name
))
110 and then Is_Task_Interface
(Etype
(T_Name
)))
114 if Ada_Version
>= Ada_05
then
115 Error_Msg_N
("expect task name or task interface class-wide "
116 & "object for ABORT", T_Name
);
118 Error_Msg_N
("expect task name for ABORT", T_Name
);
127 Check_Restriction
(No_Abort_Statements
, N
);
128 Check_Potentially_Blocking_Operation
(N
);
129 end Analyze_Abort_Statement
;
131 --------------------------------
132 -- Analyze_Accept_Alternative --
133 --------------------------------
135 procedure Analyze_Accept_Alternative
(N
: Node_Id
) is
137 Tasking_Used
:= True;
139 if Present
(Pragmas_Before
(N
)) then
140 Analyze_List
(Pragmas_Before
(N
));
143 if Present
(Condition
(N
)) then
144 Analyze_And_Resolve
(Condition
(N
), Any_Boolean
);
147 Analyze
(Accept_Statement
(N
));
149 if Is_Non_Empty_List
(Statements
(N
)) then
150 Analyze_Statements
(Statements
(N
));
152 end Analyze_Accept_Alternative
;
154 ------------------------------
155 -- Analyze_Accept_Statement --
156 ------------------------------
158 procedure Analyze_Accept_Statement
(N
: Node_Id
) is
159 Nam
: constant Entity_Id
:= Entry_Direct_Name
(N
);
160 Formals
: constant List_Id
:= Parameter_Specifications
(N
);
161 Index
: constant Node_Id
:= Entry_Index
(N
);
162 Stats
: constant Node_Id
:= Handled_Statement_Sequence
(N
);
163 Accept_Id
: Entity_Id
;
164 Entry_Nam
: Entity_Id
;
167 Task_Nam
: Entity_Id
;
169 -----------------------
170 -- Actual_Index_Type --
171 -----------------------
173 function Actual_Index_Type
(E
: Entity_Id
) return Entity_Id
;
174 -- If the bounds of an entry family depend on task discriminants, create
175 -- a new index type where a discriminant is replaced by the local
176 -- variable that renames it in the task body.
178 -----------------------
179 -- Actual_Index_Type --
180 -----------------------
182 function Actual_Index_Type
(E
: Entity_Id
) return Entity_Id
is
183 Typ
: constant Entity_Id
:= Entry_Index_Type
(E
);
184 Lo
: constant Node_Id
:= Type_Low_Bound
(Typ
);
185 Hi
: constant Node_Id
:= Type_High_Bound
(Typ
);
188 function Actual_Discriminant_Ref
(Bound
: Node_Id
) return Node_Id
;
189 -- If bound is discriminant reference, replace with corresponding
190 -- local variable of the same name.
192 -----------------------------
193 -- Actual_Discriminant_Ref --
194 -----------------------------
196 function Actual_Discriminant_Ref
(Bound
: Node_Id
) return Node_Id
is
197 Typ
: constant Entity_Id
:= Etype
(Bound
);
200 if not Is_Entity_Name
(Bound
)
201 or else Ekind
(Entity
(Bound
)) /= E_Discriminant
205 Ref
:= Make_Identifier
(Sloc
(N
), Chars
(Entity
(Bound
)));
210 end Actual_Discriminant_Ref
;
212 -- Start of processing for Actual_Index_Type
215 if not Has_Discriminants
(Task_Nam
)
216 or else (not Is_Entity_Name
(Lo
)
217 and then not Is_Entity_Name
(Hi
))
219 return Entry_Index_Type
(E
);
221 New_T
:= Create_Itype
(Ekind
(Typ
), N
);
222 Set_Etype
(New_T
, Base_Type
(Typ
));
223 Set_Size_Info
(New_T
, Typ
);
224 Set_RM_Size
(New_T
, RM_Size
(Typ
));
225 Set_Scalar_Range
(New_T
,
226 Make_Range
(Sloc
(N
),
227 Low_Bound
=> Actual_Discriminant_Ref
(Lo
),
228 High_Bound
=> Actual_Discriminant_Ref
(Hi
)));
232 end Actual_Index_Type
;
234 -- Start of processing for Analyze_Accept_Statement
237 Tasking_Used
:= True;
239 -- Entry name is initialized to Any_Id. It should get reset to the
240 -- matching entry entity. An error is signalled if it is not reset.
244 for J
in reverse 0 .. Scope_Stack
.Last
loop
245 Task_Nam
:= Scope_Stack
.Table
(J
).Entity
;
246 exit when Ekind
(Etype
(Task_Nam
)) = E_Task_Type
;
247 Kind
:= Ekind
(Task_Nam
);
249 if Kind
/= E_Block
and then Kind
/= E_Loop
250 and then not Is_Entry
(Task_Nam
)
252 Error_Msg_N
("enclosing body of accept must be a task", N
);
257 if Ekind
(Etype
(Task_Nam
)) /= E_Task_Type
then
258 Error_Msg_N
("invalid context for accept statement", N
);
262 -- In order to process the parameters, we create a defining
263 -- identifier that can be used as the name of the scope. The
264 -- name of the accept statement itself is not a defining identifier,
265 -- and we cannot use its name directly because the task may have
266 -- any number of accept statements for the same entry.
268 if Present
(Index
) then
269 Accept_Id
:= New_Internal_Entity
270 (E_Entry_Family
, Current_Scope
, Sloc
(N
), 'E');
272 Accept_Id
:= New_Internal_Entity
273 (E_Entry
, Current_Scope
, Sloc
(N
), 'E');
276 Set_Etype
(Accept_Id
, Standard_Void_Type
);
277 Set_Accept_Address
(Accept_Id
, New_Elmt_List
);
279 if Present
(Formals
) then
280 Push_Scope
(Accept_Id
);
281 Process_Formals
(Formals
, N
);
282 Create_Extra_Formals
(Accept_Id
);
286 -- We set the default expressions processed flag because we don't need
287 -- default expression functions. This is really more like body entity
288 -- than a spec entity anyway.
290 Set_Default_Expressions_Processed
(Accept_Id
);
292 E
:= First_Entity
(Etype
(Task_Nam
));
293 while Present
(E
) loop
294 if Chars
(E
) = Chars
(Nam
)
295 and then (Ekind
(E
) = Ekind
(Accept_Id
))
296 and then Type_Conformant
(Accept_Id
, E
)
305 if Entry_Nam
= Any_Id
then
306 Error_Msg_N
("no entry declaration matches accept statement", N
);
309 Set_Entity
(Nam
, Entry_Nam
);
310 Generate_Reference
(Entry_Nam
, Nam
, 'b', Set_Ref
=> False);
311 Style
.Check_Identifier
(Nam
, Entry_Nam
);
314 -- Verify that the entry is not hidden by a procedure declared in the
315 -- current block (pathological but possible).
317 if Current_Scope
/= Task_Nam
then
322 E1
:= First_Entity
(Current_Scope
);
323 while Present
(E1
) loop
324 if Ekind
(E1
) = E_Procedure
325 and then Chars
(E1
) = Chars
(Entry_Nam
)
326 and then Type_Conformant
(E1
, Entry_Nam
)
328 Error_Msg_N
("entry name is not visible", N
);
336 Set_Convention
(Accept_Id
, Convention
(Entry_Nam
));
337 Check_Fully_Conformant
(Accept_Id
, Entry_Nam
, N
);
339 for J
in reverse 0 .. Scope_Stack
.Last
loop
340 exit when Task_Nam
= Scope_Stack
.Table
(J
).Entity
;
342 if Entry_Nam
= Scope_Stack
.Table
(J
).Entity
then
343 Error_Msg_N
("duplicate accept statement for same entry", N
);
354 when N_Task_Body | N_Compilation_Unit
=>
356 when N_Asynchronous_Select
=>
357 Error_Msg_N
("accept statements are not allowed within" &
358 " an asynchronous select inner" &
359 " to the enclosing task body", N
);
367 if Ekind
(E
) = E_Entry_Family
then
369 Error_Msg_N
("missing entry index in accept for entry family", N
);
371 Analyze_And_Resolve
(Index
, Entry_Index_Type
(E
));
372 Apply_Range_Check
(Index
, Actual_Index_Type
(E
));
375 elsif Present
(Index
) then
376 Error_Msg_N
("invalid entry index in accept for simple entry", N
);
379 -- If label declarations present, analyze them. They are declared in the
380 -- enclosing task, but their enclosing scope is the entry itself, so
381 -- that goto's to the label are recognized as local to the accept.
383 if Present
(Declarations
(N
)) then
389 Decl
:= First
(Declarations
(N
));
390 while Present
(Decl
) loop
394 (Nkind
(Decl
) = N_Implicit_Label_Declaration
);
396 Id
:= Defining_Identifier
(Decl
);
397 Set_Enclosing_Scope
(Id
, Entry_Nam
);
403 -- If statements are present, they must be analyzed in the context of
404 -- the entry, so that references to formals are correctly resolved. We
405 -- also have to add the declarations that are required by the expansion
406 -- of the accept statement in this case if expansion active.
408 -- In the case of a select alternative of a selective accept, the
409 -- expander references the address declaration even if there is no
412 -- We also need to create the renaming declarations for the local
413 -- variables that will replace references to the formals within the
416 Exp_Ch9
.Expand_Accept_Declarations
(N
, Entry_Nam
);
418 -- Set Never_Set_In_Source and clear Is_True_Constant/Current_Value
419 -- fields on all entry formals (this loop ignores all other entities).
420 -- Reset Referenced, Referenced_As_xxx and Has_Pragma_Unreferenced as
421 -- well, so that we can post accurate warnings on each accept statement
422 -- for the same entry.
424 E
:= First_Entity
(Entry_Nam
);
425 while Present
(E
) loop
426 if Is_Formal
(E
) then
427 Set_Never_Set_In_Source
(E
, True);
428 Set_Is_True_Constant
(E
, False);
429 Set_Current_Value
(E
, Empty
);
430 Set_Referenced
(E
, False);
431 Set_Referenced_As_LHS
(E
, False);
432 Set_Referenced_As_Out_Parameter
(E
, False);
433 Set_Has_Pragma_Unreferenced
(E
, False);
439 -- Analyze statements if present
441 if Present
(Stats
) then
442 Push_Scope
(Entry_Nam
);
443 Install_Declarations
(Entry_Nam
);
445 Set_Actual_Subtypes
(N
, Current_Scope
);
448 Process_End_Label
(Handled_Statement_Sequence
(N
), 't', Entry_Nam
);
452 -- Some warning checks
454 Check_Potentially_Blocking_Operation
(N
);
455 Check_References
(Entry_Nam
, N
);
456 Set_Entry_Accepted
(Entry_Nam
);
457 end Analyze_Accept_Statement
;
459 ---------------------------------
460 -- Analyze_Asynchronous_Select --
461 ---------------------------------
463 procedure Analyze_Asynchronous_Select
(N
: Node_Id
) is
464 Is_Disp_Select
: Boolean := False;
468 Tasking_Used
:= True;
469 Check_Restriction
(Max_Asynchronous_Select_Nesting
, N
);
470 Check_Restriction
(No_Select_Statements
, N
);
472 if Ada_Version
>= Ada_05
then
473 Trigger
:= Triggering_Statement
(Triggering_Alternative
(N
));
477 -- Ada 2005 (AI-345): Check for a potential dispatching select
479 Check_Triggering_Statement
(Trigger
, N
, Is_Disp_Select
);
482 -- Ada 2005 (AI-345): The expansion of the dispatching asynchronous
483 -- select will have to duplicate the triggering statements. Postpone
484 -- the analysis of the statements till expansion. Analyze only if the
485 -- expander is disabled in order to catch any semantic errors.
487 if Is_Disp_Select
then
488 if not Expander_Active
then
489 Analyze_Statements
(Statements
(Abortable_Part
(N
)));
490 Analyze
(Triggering_Alternative
(N
));
493 -- Analyze the statements. We analyze statements in the abortable part,
494 -- because this is the section that is executed first, and that way our
495 -- remembering of saved values and checks is accurate.
498 Analyze_Statements
(Statements
(Abortable_Part
(N
)));
499 Analyze
(Triggering_Alternative
(N
));
501 end Analyze_Asynchronous_Select
;
503 ------------------------------------
504 -- Analyze_Conditional_Entry_Call --
505 ------------------------------------
507 procedure Analyze_Conditional_Entry_Call
(N
: Node_Id
) is
508 Trigger
: constant Node_Id
:=
509 Entry_Call_Statement
(Entry_Call_Alternative
(N
));
510 Is_Disp_Select
: Boolean := False;
513 Check_Restriction
(No_Select_Statements
, N
);
514 Tasking_Used
:= True;
516 -- Ada 2005 (AI-345): The trigger may be a dispatching call
518 if Ada_Version
>= Ada_05
then
520 Check_Triggering_Statement
(Trigger
, N
, Is_Disp_Select
);
523 if List_Length
(Else_Statements
(N
)) = 1
524 and then Nkind
(First
(Else_Statements
(N
))) in N_Delay_Statement
527 ("suspicious form of conditional entry call?!", N
);
529 ("\`SELECT OR` may be intended rather than `SELECT ELSE`!", N
);
532 -- Postpone the analysis of the statements till expansion. Analyze only
533 -- if the expander is disabled in order to catch any semantic errors.
535 if Is_Disp_Select
then
536 if not Expander_Active
then
537 Analyze
(Entry_Call_Alternative
(N
));
538 Analyze_Statements
(Else_Statements
(N
));
541 -- Regular select analysis
544 Analyze
(Entry_Call_Alternative
(N
));
545 Analyze_Statements
(Else_Statements
(N
));
547 end Analyze_Conditional_Entry_Call
;
549 --------------------------------
550 -- Analyze_Delay_Alternative --
551 --------------------------------
553 procedure Analyze_Delay_Alternative
(N
: Node_Id
) is
558 Tasking_Used
:= True;
559 Check_Restriction
(No_Delay
, N
);
561 if Present
(Pragmas_Before
(N
)) then
562 Analyze_List
(Pragmas_Before
(N
));
565 if Nkind_In
(Parent
(N
), N_Selective_Accept
, N_Timed_Entry_Call
) then
566 Expr
:= Expression
(Delay_Statement
(N
));
568 -- Defer full analysis until the statement is expanded, to insure
569 -- that generated code does not move past the guard. The delay
570 -- expression is only evaluated if the guard is open.
572 if Nkind
(Delay_Statement
(N
)) = N_Delay_Relative_Statement
then
573 Pre_Analyze_And_Resolve
(Expr
, Standard_Duration
);
575 Pre_Analyze_And_Resolve
(Expr
);
578 Typ
:= First_Subtype
(Etype
(Expr
));
580 if Nkind
(Delay_Statement
(N
)) = N_Delay_Until_Statement
581 and then not Is_RTE
(Typ
, RO_CA_Time
)
582 and then not Is_RTE
(Typ
, RO_RT_Time
)
584 Error_Msg_N
("expect Time types for `DELAY UNTIL`", Expr
);
587 Check_Restriction
(No_Fixed_Point
, Expr
);
590 Analyze
(Delay_Statement
(N
));
593 if Present
(Condition
(N
)) then
594 Analyze_And_Resolve
(Condition
(N
), Any_Boolean
);
597 if Is_Non_Empty_List
(Statements
(N
)) then
598 Analyze_Statements
(Statements
(N
));
600 end Analyze_Delay_Alternative
;
602 ----------------------------
603 -- Analyze_Delay_Relative --
604 ----------------------------
606 procedure Analyze_Delay_Relative
(N
: Node_Id
) is
607 E
: constant Node_Id
:= Expression
(N
);
609 Check_Restriction
(No_Relative_Delay
, N
);
610 Tasking_Used
:= True;
611 Check_Restriction
(No_Delay
, N
);
612 Check_Potentially_Blocking_Operation
(N
);
613 Analyze_And_Resolve
(E
, Standard_Duration
);
614 Check_Restriction
(No_Fixed_Point
, E
);
615 end Analyze_Delay_Relative
;
617 -------------------------
618 -- Analyze_Delay_Until --
619 -------------------------
621 procedure Analyze_Delay_Until
(N
: Node_Id
) is
622 E
: constant Node_Id
:= Expression
(N
);
626 Tasking_Used
:= True;
627 Check_Restriction
(No_Delay
, N
);
628 Check_Potentially_Blocking_Operation
(N
);
630 Typ
:= First_Subtype
(Etype
(E
));
632 if not Is_RTE
(Typ
, RO_CA_Time
) and then
633 not Is_RTE
(Typ
, RO_RT_Time
)
635 Error_Msg_N
("expect Time types for `DELAY UNTIL`", E
);
637 end Analyze_Delay_Until
;
639 ------------------------
640 -- Analyze_Entry_Body --
641 ------------------------
643 procedure Analyze_Entry_Body
(N
: Node_Id
) is
644 Id
: constant Entity_Id
:= Defining_Identifier
(N
);
645 Decls
: constant List_Id
:= Declarations
(N
);
646 Stats
: constant Node_Id
:= Handled_Statement_Sequence
(N
);
647 Formals
: constant Node_Id
:= Entry_Body_Formal_Part
(N
);
648 P_Type
: constant Entity_Id
:= Current_Scope
;
649 Entry_Name
: Entity_Id
;
653 Tasking_Used
:= True;
655 -- Entry_Name is initialized to Any_Id. It should get reset to the
656 -- matching entry entity. An error is signalled if it is not reset
658 Entry_Name
:= Any_Id
;
662 if Present
(Entry_Index_Specification
(Formals
)) then
663 Set_Ekind
(Id
, E_Entry_Family
);
665 Set_Ekind
(Id
, E_Entry
);
668 Set_Scope
(Id
, Current_Scope
);
669 Set_Etype
(Id
, Standard_Void_Type
);
670 Set_Accept_Address
(Id
, New_Elmt_List
);
672 E
:= First_Entity
(P_Type
);
673 while Present
(E
) loop
674 if Chars
(E
) = Chars
(Id
)
675 and then (Ekind
(E
) = Ekind
(Id
))
676 and then Type_Conformant
(Id
, E
)
679 Set_Convention
(Id
, Convention
(E
));
680 Set_Corresponding_Body
(Parent
(Entry_Name
), Id
);
681 Check_Fully_Conformant
(Id
, E
, N
);
683 if Ekind
(Id
) = E_Entry_Family
then
684 if not Fully_Conformant_Discrete_Subtypes
(
685 Discrete_Subtype_Definition
(Parent
(E
)),
686 Discrete_Subtype_Definition
687 (Entry_Index_Specification
(Formals
)))
690 ("index not fully conformant with previous declaration",
691 Discrete_Subtype_Definition
692 (Entry_Index_Specification
(Formals
)));
695 -- The elaboration of the entry body does not recompute the
696 -- bounds of the index, which may have side effects. Inherit
697 -- the bounds from the entry declaration. This is critical
698 -- if the entry has a per-object constraint. If a bound is
699 -- given by a discriminant, it must be reanalyzed in order
700 -- to capture the discriminal of the current entry, rather
701 -- than that of the protected type.
704 Index_Spec
: constant Node_Id
:=
705 Entry_Index_Specification
(Formals
);
707 Def
: constant Node_Id
:=
709 (Discrete_Subtype_Definition
(Parent
(E
)));
714 (Discrete_Subtype_Definition
(Index_Spec
))) = N_Range
716 Set_Etype
(Def
, Empty
);
717 Set_Analyzed
(Def
, False);
719 -- Keep the original subtree to ensure a properly
720 -- formed tree (e.g. for ASIS use).
723 (Discrete_Subtype_Definition
(Index_Spec
), Def
);
725 Set_Analyzed
(Low_Bound
(Def
), False);
726 Set_Analyzed
(High_Bound
(Def
), False);
728 if Denotes_Discriminant
(Low_Bound
(Def
)) then
729 Set_Entity
(Low_Bound
(Def
), Empty
);
732 if Denotes_Discriminant
(High_Bound
(Def
)) then
733 Set_Entity
(High_Bound
(Def
), Empty
);
737 Make_Index
(Def
, Index_Spec
);
739 (Defining_Identifier
(Index_Spec
), Etype
(Def
));
751 if Entry_Name
= Any_Id
then
752 Error_Msg_N
("no entry declaration matches entry body", N
);
755 elsif Has_Completion
(Entry_Name
) then
756 Error_Msg_N
("duplicate entry body", N
);
760 Set_Has_Completion
(Entry_Name
);
761 Generate_Reference
(Entry_Name
, Id
, 'b', Set_Ref
=> False);
762 Style
.Check_Identifier
(Id
, Entry_Name
);
765 Exp_Ch9
.Expand_Entry_Barrier
(N
, Entry_Name
);
766 Push_Scope
(Entry_Name
);
768 Exp_Ch9
.Expand_Entry_Body_Declarations
(N
);
769 Install_Declarations
(Entry_Name
);
770 Set_Actual_Subtypes
(N
, Current_Scope
);
772 -- The entity for the protected subprogram corresponding to the entry
773 -- has been created. We retain the name of this entity in the entry
774 -- body, for use when the corresponding subprogram body is created.
775 -- Note that entry bodies have no corresponding_spec, and there is no
776 -- easy link back in the tree between the entry body and the entity for
777 -- the entry itself, which is why we must propagate some attributes
778 -- explicitly from spec to body.
780 Set_Protected_Body_Subprogram
781 (Id
, Protected_Body_Subprogram
(Entry_Name
));
783 Set_Entry_Parameters_Type
784 (Id
, Entry_Parameters_Type
(Entry_Name
));
786 if Present
(Decls
) then
787 Analyze_Declarations
(Decls
);
790 if Present
(Stats
) then
794 -- Check for unreferenced variables etc. Before the Check_References
795 -- call, we transfer Never_Set_In_Source and Referenced flags from
796 -- parameters in the spec to the corresponding entities in the body,
797 -- since we want the warnings on the body entities. Note that we do
798 -- not have to transfer Referenced_As_LHS, since that flag can only
799 -- be set for simple variables.
801 -- At the same time, we set the flags on the spec entities to suppress
802 -- any warnings on the spec formals, since we also scan the spec.
803 -- Finally, we propagate the Entry_Component attribute to the body
804 -- formals, for use in the renaming declarations created later for the
805 -- formals (see exp_ch9.Add_Formal_Renamings).
812 E1
:= First_Entity
(Entry_Name
);
813 while Present
(E1
) loop
814 E2
:= First_Entity
(Id
);
815 while Present
(E2
) loop
816 exit when Chars
(E1
) = Chars
(E2
);
820 -- If no matching body entity, then we already had a detected
821 -- error of some kind, so just don't worry about these warnings.
827 if Ekind
(E1
) = E_Out_Parameter
then
828 Set_Never_Set_In_Source
(E2
, Never_Set_In_Source
(E1
));
829 Set_Never_Set_In_Source
(E1
, False);
832 Set_Referenced
(E2
, Referenced
(E1
));
834 Set_Entry_Component
(E2
, Entry_Component
(E1
));
840 Check_References
(Id
);
843 -- We still need to check references for the spec, since objects
844 -- declared in the body are chained (in the First_Entity sense) to
845 -- the spec rather than the body in the case of entries.
847 Check_References
(Entry_Name
);
849 -- Process the end label, and terminate the scope
851 Process_End_Label
(Handled_Statement_Sequence
(N
), 't', Entry_Name
);
854 -- If this is an entry family, remove the loop created to provide
855 -- a scope for the entry index.
857 if Ekind
(Id
) = E_Entry_Family
858 and then Present
(Entry_Index_Specification
(Formals
))
862 end Analyze_Entry_Body
;
864 ------------------------------------
865 -- Analyze_Entry_Body_Formal_Part --
866 ------------------------------------
868 procedure Analyze_Entry_Body_Formal_Part
(N
: Node_Id
) is
869 Id
: constant Entity_Id
:= Defining_Identifier
(Parent
(N
));
870 Index
: constant Node_Id
:= Entry_Index_Specification
(N
);
871 Formals
: constant List_Id
:= Parameter_Specifications
(N
);
874 Tasking_Used
:= True;
876 if Present
(Index
) then
879 -- The entry index functions like a loop variable, thus it is known
880 -- to have a valid value.
882 Set_Is_Known_Valid
(Defining_Identifier
(Index
));
885 if Present
(Formals
) then
886 Set_Scope
(Id
, Current_Scope
);
888 Process_Formals
(Formals
, Parent
(N
));
891 end Analyze_Entry_Body_Formal_Part
;
893 ------------------------------------
894 -- Analyze_Entry_Call_Alternative --
895 ------------------------------------
897 procedure Analyze_Entry_Call_Alternative
(N
: Node_Id
) is
898 Call
: constant Node_Id
:= Entry_Call_Statement
(N
);
901 Tasking_Used
:= True;
903 if Present
(Pragmas_Before
(N
)) then
904 Analyze_List
(Pragmas_Before
(N
));
907 if Nkind
(Call
) = N_Attribute_Reference
then
909 -- Possibly a stream attribute, but definitely illegal. Other
910 -- illegalitles, such as procedure calls, are diagnosed after
913 Error_Msg_N
("entry call alternative requires an entry call", Call
);
919 if Is_Non_Empty_List
(Statements
(N
)) then
920 Analyze_Statements
(Statements
(N
));
922 end Analyze_Entry_Call_Alternative
;
924 -------------------------------
925 -- Analyze_Entry_Declaration --
926 -------------------------------
928 procedure Analyze_Entry_Declaration
(N
: Node_Id
) is
929 Formals
: constant List_Id
:= Parameter_Specifications
(N
);
930 Id
: constant Entity_Id
:= Defining_Identifier
(N
);
931 D_Sdef
: constant Node_Id
:= Discrete_Subtype_Definition
(N
);
934 Generate_Definition
(Id
);
935 Tasking_Used
:= True;
938 Set_Ekind
(Id
, E_Entry
);
941 Set_Ekind
(Id
, E_Entry_Family
);
943 Make_Index
(D_Sdef
, N
, Id
);
946 Set_Etype
(Id
, Standard_Void_Type
);
947 Set_Convention
(Id
, Convention_Entry
);
948 Set_Accept_Address
(Id
, New_Elmt_List
);
950 if Present
(Formals
) then
951 Set_Scope
(Id
, Current_Scope
);
953 Process_Formals
(Formals
, N
);
954 Create_Extra_Formals
(Id
);
958 if Ekind
(Id
) = E_Entry
then
959 New_Overloaded_Entity
(Id
);
962 Generate_Reference_To_Formals
(Id
);
963 end Analyze_Entry_Declaration
;
965 ---------------------------------------
966 -- Analyze_Entry_Index_Specification --
967 ---------------------------------------
969 -- The Defining_Identifier of the entry index specification is local to the
970 -- entry body, but it must be available in the entry barrier which is
971 -- evaluated outside of the entry body. The index is eventually renamed as
972 -- a run-time object, so is visibility is strictly a front-end concern. In
973 -- order to make it available to the barrier, we create an additional
974 -- scope, as for a loop, whose only declaration is the index name. This
975 -- loop is not attached to the tree and does not appear as an entity local
976 -- to the protected type, so its existence need only be knwown to routines
977 -- that process entry families.
979 procedure Analyze_Entry_Index_Specification
(N
: Node_Id
) is
980 Iden
: constant Node_Id
:= Defining_Identifier
(N
);
981 Def
: constant Node_Id
:= Discrete_Subtype_Definition
(N
);
982 Loop_Id
: constant Entity_Id
:=
983 Make_Defining_Identifier
(Sloc
(N
),
984 Chars
=> New_Internal_Name
('L'));
987 Tasking_Used
:= True;
990 -- There is no elaboration of the entry index specification. Therefore,
991 -- if the index is a range, it is not resolved and expanded, but the
992 -- bounds are inherited from the entry declaration, and reanalyzed.
993 -- See Analyze_Entry_Body.
995 if Nkind
(Def
) /= N_Range
then
999 Set_Ekind
(Loop_Id
, E_Loop
);
1000 Set_Scope
(Loop_Id
, Current_Scope
);
1001 Push_Scope
(Loop_Id
);
1003 Set_Ekind
(Iden
, E_Entry_Index_Parameter
);
1004 Set_Etype
(Iden
, Etype
(Def
));
1005 end Analyze_Entry_Index_Specification
;
1007 ----------------------------
1008 -- Analyze_Protected_Body --
1009 ----------------------------
1011 procedure Analyze_Protected_Body
(N
: Node_Id
) is
1012 Body_Id
: constant Entity_Id
:= Defining_Identifier
(N
);
1015 Spec_Id
: Entity_Id
;
1016 -- This is initially the entity of the protected object or protected
1017 -- type involved, but is replaced by the protected type always in the
1018 -- case of a single protected declaration, since this is the proper
1019 -- scope to be used.
1022 -- This is the entity of the protected object or protected type
1023 -- involved, and is the entity used for cross-reference purposes (it
1024 -- differs from Spec_Id in the case of a single protected object, since
1025 -- Spec_Id is set to the protected type in this case).
1028 Tasking_Used
:= True;
1029 Set_Ekind
(Body_Id
, E_Protected_Body
);
1030 Spec_Id
:= Find_Concurrent_Spec
(Body_Id
);
1032 if Present
(Spec_Id
)
1033 and then Ekind
(Spec_Id
) = E_Protected_Type
1037 elsif Present
(Spec_Id
)
1038 and then Ekind
(Etype
(Spec_Id
)) = E_Protected_Type
1039 and then not Comes_From_Source
(Etype
(Spec_Id
))
1044 Error_Msg_N
("missing specification for protected body", Body_Id
);
1049 Generate_Reference
(Ref_Id
, Body_Id
, 'b', Set_Ref
=> False);
1050 Style
.Check_Identifier
(Body_Id
, Spec_Id
);
1052 -- The declarations are always attached to the type
1054 if Ekind
(Spec_Id
) /= E_Protected_Type
then
1055 Spec_Id
:= Etype
(Spec_Id
);
1058 Push_Scope
(Spec_Id
);
1059 Set_Corresponding_Spec
(N
, Spec_Id
);
1060 Set_Corresponding_Body
(Parent
(Spec_Id
), Body_Id
);
1061 Set_Has_Completion
(Spec_Id
);
1062 Install_Declarations
(Spec_Id
);
1064 Exp_Ch9
.Expand_Protected_Body_Declarations
(N
, Spec_Id
);
1066 Last_E
:= Last_Entity
(Spec_Id
);
1068 Analyze_Declarations
(Declarations
(N
));
1070 -- For visibility purposes, all entities in the body are private. Set
1071 -- First_Private_Entity accordingly, if there was no private part in the
1072 -- protected declaration.
1074 if No
(First_Private_Entity
(Spec_Id
)) then
1075 if Present
(Last_E
) then
1076 Set_First_Private_Entity
(Spec_Id
, Next_Entity
(Last_E
));
1078 Set_First_Private_Entity
(Spec_Id
, First_Entity
(Spec_Id
));
1082 Check_Completion
(Body_Id
);
1083 Check_References
(Spec_Id
);
1084 Process_End_Label
(N
, 't', Ref_Id
);
1086 end Analyze_Protected_Body
;
1088 ----------------------------------
1089 -- Analyze_Protected_Definition --
1090 ----------------------------------
1092 procedure Analyze_Protected_Definition
(N
: Node_Id
) is
1097 Tasking_Used
:= True;
1098 Analyze_Declarations
(Visible_Declarations
(N
));
1100 if Present
(Private_Declarations
(N
))
1101 and then not Is_Empty_List
(Private_Declarations
(N
))
1103 L
:= Last_Entity
(Current_Scope
);
1104 Analyze_Declarations
(Private_Declarations
(N
));
1107 Set_First_Private_Entity
(Current_Scope
, Next_Entity
(L
));
1109 Set_First_Private_Entity
(Current_Scope
,
1110 First_Entity
(Current_Scope
));
1114 E
:= First_Entity
(Current_Scope
);
1115 while Present
(E
) loop
1116 if Ekind
(E
) = E_Function
1117 or else Ekind
(E
) = E_Procedure
1119 Set_Convention
(E
, Convention_Protected
);
1121 elsif Is_Task_Type
(Etype
(E
))
1122 or else Has_Task
(Etype
(E
))
1124 Set_Has_Task
(Current_Scope
);
1130 Check_Max_Entries
(N
, Max_Protected_Entries
);
1131 Process_End_Label
(N
, 'e', Current_Scope
);
1132 end Analyze_Protected_Definition
;
1134 ----------------------------
1135 -- Analyze_Protected_Type --
1136 ----------------------------
1138 procedure Analyze_Protected_Type
(N
: Node_Id
) is
1139 Def_Id
: constant Entity_Id
:= Defining_Identifier
(N
);
1144 if No_Run_Time_Mode
then
1145 Error_Msg_CRT
("protected type", N
);
1149 Tasking_Used
:= True;
1150 Check_Restriction
(No_Protected_Types
, N
);
1152 T
:= Find_Type_Name
(N
);
1154 if Ekind
(T
) = E_Incomplete_Type
then
1156 Set_Completion_Referenced
(T
);
1159 Set_Ekind
(T
, E_Protected_Type
);
1160 Set_Is_First_Subtype
(T
, True);
1161 Init_Size_Align
(T
);
1163 Set_Has_Delayed_Freeze
(T
, True);
1164 Set_Stored_Constraint
(T
, No_Elist
);
1167 if Ada_Version
>= Ada_05
then
1168 Check_Interfaces
(N
, T
);
1171 if Present
(Discriminant_Specifications
(N
)) then
1172 if Has_Discriminants
(T
) then
1174 -- Install discriminants. Also, verify conformance of
1175 -- discriminants of previous and current view. ???
1177 Install_Declarations
(T
);
1179 Process_Discriminants
(N
);
1183 Set_Is_Constrained
(T
, not Has_Discriminants
(T
));
1185 -- Perform minimal expansion of protected type while inside a generic.
1186 -- The corresponding record is needed for various semantic checks.
1188 if Ada_Version
>= Ada_05
1189 and then Inside_A_Generic
1191 Insert_After_And_Analyze
(N
,
1192 Build_Corresponding_Record
(N
, T
, Sloc
(T
)));
1195 Analyze
(Protected_Definition
(N
));
1197 -- Protected types with entries are controlled (because of the
1198 -- Protection component if nothing else), same for any protected type
1199 -- with interrupt handlers. Note that we need to analyze the protected
1200 -- definition to set Has_Entries and such.
1202 if (Abort_Allowed
or else Restriction_Active
(No_Entry_Queue
) = False
1203 or else Number_Entries
(T
) > 1)
1206 or else Has_Interrupt_Handler
(T
)
1207 or else Has_Attach_Handler
(T
))
1209 Set_Has_Controlled_Component
(T
, True);
1212 -- The Ekind of components is E_Void during analysis to detect illegal
1213 -- uses. Now it can be set correctly.
1215 E
:= First_Entity
(Current_Scope
);
1216 while Present
(E
) loop
1217 if Ekind
(E
) = E_Void
then
1218 Set_Ekind
(E
, E_Component
);
1219 Init_Component_Location
(E
);
1227 -- Case of a completion of a private declaration
1230 and then Is_Private_Type
(Def_Id
)
1232 -- Deal with preelaborable initialization. Note that this processing
1233 -- is done by Process_Full_View, but as can be seen below, in this
1234 -- case the call to Process_Full_View is skipped if any serious
1235 -- errors have occurred, and we don't want to lose this check.
1237 if Known_To_Have_Preelab_Init
(Def_Id
) then
1238 Set_Must_Have_Preelab_Init
(T
);
1241 -- Create corresponding record now, because some private dependents
1242 -- may be subtypes of the partial view. Skip if errors are present,
1243 -- to prevent cascaded messages.
1245 if Serious_Errors_Detected
= 0
1246 and then Expander_Active
1248 Expand_N_Protected_Type_Declaration
(N
);
1249 Process_Full_View
(N
, T
, Def_Id
);
1252 end Analyze_Protected_Type
;
1254 ---------------------
1255 -- Analyze_Requeue --
1256 ---------------------
1258 procedure Analyze_Requeue
(N
: Node_Id
) is
1259 Count
: Natural := 0;
1260 Entry_Name
: Node_Id
:= Name
(N
);
1261 Entry_Id
: Entity_Id
;
1263 Is_Disp_Req
: Boolean;
1265 Enclosing
: Entity_Id
;
1266 Target_Obj
: Node_Id
:= Empty
;
1267 Req_Scope
: Entity_Id
;
1268 Outer_Ent
: Entity_Id
;
1271 Check_Restriction
(No_Requeue_Statements
, N
);
1272 Check_Unreachable_Code
(N
);
1273 Tasking_Used
:= True;
1276 for J
in reverse 0 .. Scope_Stack
.Last
loop
1277 Enclosing
:= Scope_Stack
.Table
(J
).Entity
;
1278 exit when Is_Entry
(Enclosing
);
1280 if Ekind
(Enclosing
) /= E_Block
1281 and then Ekind
(Enclosing
) /= E_Loop
1283 Error_Msg_N
("requeue must appear within accept or entry body", N
);
1288 Analyze
(Entry_Name
);
1290 if Etype
(Entry_Name
) = Any_Type
then
1294 if Nkind
(Entry_Name
) = N_Selected_Component
then
1295 Target_Obj
:= Prefix
(Entry_Name
);
1296 Entry_Name
:= Selector_Name
(Entry_Name
);
1299 -- If an explicit target object is given then we have to check the
1300 -- restrictions of 9.5.4(6).
1302 if Present
(Target_Obj
) then
1304 -- Locate containing concurrent unit and determine enclosing entry
1305 -- body or outermost enclosing accept statement within the unit.
1308 for S
in reverse 0 .. Scope_Stack
.Last
loop
1309 Req_Scope
:= Scope_Stack
.Table
(S
).Entity
;
1311 exit when Ekind
(Req_Scope
) in Task_Kind
1312 or else Ekind
(Req_Scope
) in Protected_Kind
;
1314 if Is_Entry
(Req_Scope
) then
1315 Outer_Ent
:= Req_Scope
;
1319 pragma Assert
(Present
(Outer_Ent
));
1321 -- Check that the accessibility level of the target object is not
1322 -- greater or equal to the outermost enclosing accept statement (or
1323 -- entry body) unless it is a parameter of the innermost enclosing
1324 -- accept statement (or entry body).
1326 if Object_Access_Level
(Target_Obj
) >= Scope_Depth
(Outer_Ent
)
1328 (not Is_Entity_Name
(Target_Obj
)
1329 or else Ekind
(Entity
(Target_Obj
)) not in Formal_Kind
1330 or else Enclosing
/= Scope
(Entity
(Target_Obj
)))
1333 ("target object has invalid level for requeue", Target_Obj
);
1337 -- Overloaded case, find right interpretation
1339 if Is_Overloaded
(Entry_Name
) then
1342 -- Loop over candidate interpretations and filter out any that are
1343 -- not parameterless, are not type conformant, are not entries, or
1344 -- do not come from source.
1346 Get_First_Interp
(Entry_Name
, I
, It
);
1347 while Present
(It
.Nam
) loop
1349 -- Note: we test type conformance here, not subtype conformance.
1350 -- Subtype conformance will be tested later on, but it is better
1351 -- for error output in some cases not to do that here.
1353 if (No
(First_Formal
(It
.Nam
))
1354 or else (Type_Conformant
(Enclosing
, It
.Nam
)))
1355 and then Ekind
(It
.Nam
) = E_Entry
1357 -- Ada 2005 (AI-345): Since protected and task types have
1358 -- primitive entry wrappers, we only consider source entries.
1360 if Comes_From_Source
(It
.Nam
) then
1368 Get_Next_Interp
(I
, It
);
1372 Error_Msg_N
("no entry matches context", N
);
1375 elsif Count
> 1 then
1376 Error_Msg_N
("ambiguous entry name in requeue", N
);
1380 Set_Is_Overloaded
(Entry_Name
, False);
1381 Set_Entity
(Entry_Name
, Entry_Id
);
1384 -- Non-overloaded cases
1386 -- For the case of a reference to an element of an entry family, the
1387 -- Entry_Name is an indexed component.
1389 elsif Nkind
(Entry_Name
) = N_Indexed_Component
then
1391 -- Requeue to an entry out of the body
1393 if Nkind
(Prefix
(Entry_Name
)) = N_Selected_Component
then
1394 Entry_Id
:= Entity
(Selector_Name
(Prefix
(Entry_Name
)));
1396 -- Requeue from within the body itself
1398 elsif Nkind
(Prefix
(Entry_Name
)) = N_Identifier
then
1399 Entry_Id
:= Entity
(Prefix
(Entry_Name
));
1402 Error_Msg_N
("invalid entry_name specified", N
);
1406 -- If we had a requeue of the form REQUEUE A (B), then the parser
1407 -- accepted it (because it could have been a requeue on an entry index.
1408 -- If A turns out not to be an entry family, then the analysis of A (B)
1409 -- turned it into a function call.
1411 elsif Nkind
(Entry_Name
) = N_Function_Call
then
1413 ("arguments not allowed in requeue statement",
1414 First
(Parameter_Associations
(Entry_Name
)));
1417 -- Normal case of no entry family, no argument
1420 Entry_Id
:= Entity
(Entry_Name
);
1423 -- Ada 2005 (AI05-0030): Potential dispatching requeue statement. The
1424 -- target type must be a concurrent interface class-wide type and the
1425 -- entry name must be a procedure, flagged by pragma Implemented_By_
1429 Ada_Version
>= Ada_05
1430 and then Present
(Target_Obj
)
1431 and then Is_Class_Wide_Type
(Etype
(Target_Obj
))
1432 and then Is_Concurrent_Interface
(Etype
(Target_Obj
))
1433 and then Ekind
(Entry_Id
) = E_Procedure
1434 and then Implemented_By_Entry
(Entry_Id
);
1436 -- Resolve entry, and check that it is subtype conformant with the
1437 -- enclosing construct if this construct has formals (RM 9.5.4(5)).
1438 -- Ada 2005 (AI05-0030): Do not emit an error for this specific case.
1440 if not Is_Entry
(Entry_Id
)
1441 and then not Is_Disp_Req
1443 Error_Msg_N
("expect entry name in requeue statement", Name
(N
));
1445 elsif Ekind
(Entry_Id
) = E_Entry_Family
1446 and then Nkind
(Entry_Name
) /= N_Indexed_Component
1448 Error_Msg_N
("missing index for entry family component", Name
(N
));
1451 Resolve_Entry
(Name
(N
));
1452 Generate_Reference
(Entry_Id
, Entry_Name
);
1454 if Present
(First_Formal
(Entry_Id
)) then
1455 if VM_Target
= JVM_Target
and then not Inspector_Mode
then
1457 ("arguments unsupported in requeue statement",
1458 First_Formal
(Entry_Id
));
1462 -- Ada 2005 (AI05-0030): Perform type conformance after skipping
1463 -- the first parameter of Entry_Id since it is the interface
1464 -- controlling formal.
1468 Enclosing_Formal
: Entity_Id
;
1469 Target_Formal
: Entity_Id
;
1472 Enclosing_Formal
:= First_Formal
(Enclosing
);
1473 Target_Formal
:= Next_Formal
(First_Formal
(Entry_Id
));
1474 while Present
(Enclosing_Formal
)
1475 and then Present
(Target_Formal
)
1477 if not Conforming_Types
1478 (T1
=> Etype
(Enclosing_Formal
),
1479 T2
=> Etype
(Target_Formal
),
1480 Ctype
=> Subtype_Conformant
)
1482 Error_Msg_Node_2
:= Target_Formal
;
1484 ("formal & is not subtype conformant with &" &
1485 "in dispatching requeue", N
, Enclosing_Formal
);
1488 Next_Formal
(Enclosing_Formal
);
1489 Next_Formal
(Target_Formal
);
1493 Check_Subtype_Conformant
(Enclosing
, Entry_Id
, Name
(N
));
1496 -- Processing for parameters accessed by the requeue
1502 Ent
:= First_Formal
(Enclosing
);
1503 while Present
(Ent
) loop
1505 -- For OUT or IN OUT parameter, the effect of the requeue is
1506 -- to assign the parameter a value on exit from the requeued
1507 -- body, so we can set it as source assigned. We also clear
1508 -- the Is_True_Constant indication. We do not need to clear
1509 -- Current_Value, since the effect of the requeue is to
1510 -- perform an unconditional goto so that any further
1511 -- references will not occur anyway.
1513 if Ekind
(Ent
) = E_Out_Parameter
1515 Ekind
(Ent
) = E_In_Out_Parameter
1517 Set_Never_Set_In_Source
(Ent
, False);
1518 Set_Is_True_Constant
(Ent
, False);
1521 -- For all parameters, the requeue acts as a reference,
1522 -- since the value of the parameter is passed to the new
1523 -- entry, so we want to suppress unreferenced warnings.
1525 Set_Referenced
(Ent
);
1531 end Analyze_Requeue
;
1533 ------------------------------
1534 -- Analyze_Selective_Accept --
1535 ------------------------------
1537 procedure Analyze_Selective_Accept
(N
: Node_Id
) is
1538 Alts
: constant List_Id
:= Select_Alternatives
(N
);
1541 Accept_Present
: Boolean := False;
1542 Terminate_Present
: Boolean := False;
1543 Delay_Present
: Boolean := False;
1544 Relative_Present
: Boolean := False;
1545 Alt_Count
: Uint
:= Uint_0
;
1548 Check_Restriction
(No_Select_Statements
, N
);
1549 Tasking_Used
:= True;
1551 -- Loop to analyze alternatives
1553 Alt
:= First
(Alts
);
1554 while Present
(Alt
) loop
1555 Alt_Count
:= Alt_Count
+ 1;
1558 if Nkind
(Alt
) = N_Delay_Alternative
then
1559 if Delay_Present
then
1561 if Relative_Present
/=
1562 (Nkind
(Delay_Statement
(Alt
)) = N_Delay_Relative_Statement
)
1565 ("delay_until and delay_relative alternatives ", Alt
);
1567 ("\cannot appear in the same selective_wait", Alt
);
1571 Delay_Present
:= True;
1573 Nkind
(Delay_Statement
(Alt
)) = N_Delay_Relative_Statement
;
1576 elsif Nkind
(Alt
) = N_Terminate_Alternative
then
1577 if Terminate_Present
then
1578 Error_Msg_N
("only one terminate alternative allowed", N
);
1580 Terminate_Present
:= True;
1581 Check_Restriction
(No_Terminate_Alternatives
, N
);
1584 elsif Nkind
(Alt
) = N_Accept_Alternative
then
1585 Accept_Present
:= True;
1587 -- Check for duplicate accept
1591 Stm
: constant Node_Id
:= Accept_Statement
(Alt
);
1592 EDN
: constant Node_Id
:= Entry_Direct_Name
(Stm
);
1596 if Nkind
(EDN
) = N_Identifier
1597 and then No
(Condition
(Alt
))
1598 and then Present
(Entity
(EDN
)) -- defend against junk
1599 and then Ekind
(Entity
(EDN
)) = E_Entry
1601 Ent
:= Entity
(EDN
);
1603 Alt1
:= First
(Alts
);
1604 while Alt1
/= Alt
loop
1605 if Nkind
(Alt1
) = N_Accept_Alternative
1606 and then No
(Condition
(Alt1
))
1609 Stm1
: constant Node_Id
:= Accept_Statement
(Alt1
);
1610 EDN1
: constant Node_Id
:= Entry_Direct_Name
(Stm1
);
1613 if Nkind
(EDN1
) = N_Identifier
then
1614 if Entity
(EDN1
) = Ent
then
1615 Error_Msg_Sloc
:= Sloc
(Stm1
);
1617 ("?accept duplicates one on line#", Stm
);
1633 Check_Restriction
(Max_Select_Alternatives
, N
, Alt_Count
);
1634 Check_Potentially_Blocking_Operation
(N
);
1636 if Terminate_Present
and Delay_Present
then
1637 Error_Msg_N
("at most one of terminate or delay alternative", N
);
1639 elsif not Accept_Present
then
1641 ("select must contain at least one accept alternative", N
);
1644 if Present
(Else_Statements
(N
)) then
1645 if Terminate_Present
or Delay_Present
then
1646 Error_Msg_N
("else part not allowed with other alternatives", N
);
1649 Analyze_Statements
(Else_Statements
(N
));
1651 end Analyze_Selective_Accept
;
1653 ------------------------------
1654 -- Analyze_Single_Protected --
1655 ------------------------------
1657 procedure Analyze_Single_Protected
(N
: Node_Id
) is
1658 Loc
: constant Source_Ptr
:= Sloc
(N
);
1659 Id
: constant Node_Id
:= Defining_Identifier
(N
);
1663 O_Name
: constant Entity_Id
:= Id
;
1666 Generate_Definition
(Id
);
1667 Tasking_Used
:= True;
1669 -- The node is rewritten as a protected type declaration, in exact
1670 -- analogy with what is done with single tasks.
1673 Make_Defining_Identifier
(Sloc
(Id
),
1674 New_External_Name
(Chars
(Id
), 'T'));
1677 Make_Protected_Type_Declaration
(Loc
,
1678 Defining_Identifier
=> T
,
1679 Protected_Definition
=> Relocate_Node
(Protected_Definition
(N
)),
1680 Interface_List
=> Interface_List
(N
));
1683 Make_Object_Declaration
(Loc
,
1684 Defining_Identifier
=> O_Name
,
1685 Object_Definition
=> Make_Identifier
(Loc
, Chars
(T
)));
1687 Rewrite
(N
, T_Decl
);
1688 Insert_After
(N
, O_Decl
);
1689 Mark_Rewrite_Insertion
(O_Decl
);
1691 -- Enter names of type and object before analysis, because the name of
1692 -- the object may be used in its own body.
1695 Set_Ekind
(T
, E_Protected_Type
);
1698 Enter_Name
(O_Name
);
1699 Set_Ekind
(O_Name
, E_Variable
);
1700 Set_Etype
(O_Name
, T
);
1702 -- Instead of calling Analyze on the new node, call the proper analysis
1703 -- procedure directly. Otherwise the node would be expanded twice, with
1704 -- disastrous result.
1706 Analyze_Protected_Type
(N
);
1707 end Analyze_Single_Protected
;
1709 -------------------------
1710 -- Analyze_Single_Task --
1711 -------------------------
1713 procedure Analyze_Single_Task
(N
: Node_Id
) is
1714 Loc
: constant Source_Ptr
:= Sloc
(N
);
1715 Id
: constant Node_Id
:= Defining_Identifier
(N
);
1719 O_Name
: constant Entity_Id
:= Id
;
1722 Generate_Definition
(Id
);
1723 Tasking_Used
:= True;
1725 -- The node is rewritten as a task type declaration, followed by an
1726 -- object declaration of that anonymous task type.
1729 Make_Defining_Identifier
(Sloc
(Id
),
1730 New_External_Name
(Chars
(Id
), Suffix
=> "TK"));
1733 Make_Task_Type_Declaration
(Loc
,
1734 Defining_Identifier
=> T
,
1735 Task_Definition
=> Relocate_Node
(Task_Definition
(N
)),
1736 Interface_List
=> Interface_List
(N
));
1738 -- We use the original defining identifier of the single task in the
1739 -- generated object declaration, so that debugging information can
1740 -- be attached to it when compiling with -gnatD. The parent of the
1741 -- entity is the new object declaration. The single_task_declaration
1742 -- is not used further in semantics or code generation, but is scanned
1743 -- when generating debug information, and therefore needs the updated
1744 -- Sloc information for the entity (see Sprint).
1747 Make_Object_Declaration
(Loc
,
1748 Defining_Identifier
=> O_Name
,
1749 Object_Definition
=> Make_Identifier
(Loc
, Chars
(T
)));
1751 Rewrite
(N
, T_Decl
);
1752 Insert_After
(N
, O_Decl
);
1753 Mark_Rewrite_Insertion
(O_Decl
);
1755 -- Enter names of type and object before analysis, because the name of
1756 -- the object may be used in its own body.
1759 Set_Ekind
(T
, E_Task_Type
);
1762 Enter_Name
(O_Name
);
1763 Set_Ekind
(O_Name
, E_Variable
);
1764 Set_Etype
(O_Name
, T
);
1766 -- Instead of calling Analyze on the new node, call the proper analysis
1767 -- procedure directly. Otherwise the node would be expanded twice, with
1768 -- disastrous result.
1770 Analyze_Task_Type
(N
);
1771 end Analyze_Single_Task
;
1773 -----------------------
1774 -- Analyze_Task_Body --
1775 -----------------------
1777 procedure Analyze_Task_Body
(N
: Node_Id
) is
1778 Body_Id
: constant Entity_Id
:= Defining_Identifier
(N
);
1779 HSS
: constant Node_Id
:= Handled_Statement_Sequence
(N
);
1782 Spec_Id
: Entity_Id
;
1783 -- This is initially the entity of the task or task type involved, but
1784 -- is replaced by the task type always in the case of a single task
1785 -- declaration, since this is the proper scope to be used.
1788 -- This is the entity of the task or task type, and is the entity used
1789 -- for cross-reference purposes (it differs from Spec_Id in the case of
1790 -- a single task, since Spec_Id is set to the task type)
1793 Tasking_Used
:= True;
1794 Set_Ekind
(Body_Id
, E_Task_Body
);
1795 Set_Scope
(Body_Id
, Current_Scope
);
1796 Spec_Id
:= Find_Concurrent_Spec
(Body_Id
);
1798 -- The spec is either a task type declaration, or a single task
1799 -- declaration for which we have created an anonymous type.
1801 if Present
(Spec_Id
)
1802 and then Ekind
(Spec_Id
) = E_Task_Type
1806 elsif Present
(Spec_Id
)
1807 and then Ekind
(Etype
(Spec_Id
)) = E_Task_Type
1808 and then not Comes_From_Source
(Etype
(Spec_Id
))
1813 Error_Msg_N
("missing specification for task body", Body_Id
);
1817 if Has_Completion
(Spec_Id
)
1818 and then Present
(Corresponding_Body
(Parent
(Spec_Id
)))
1820 if Nkind
(Parent
(Spec_Id
)) = N_Task_Type_Declaration
then
1821 Error_Msg_NE
("duplicate body for task type&", N
, Spec_Id
);
1824 Error_Msg_NE
("duplicate body for task&", N
, Spec_Id
);
1829 Generate_Reference
(Ref_Id
, Body_Id
, 'b', Set_Ref
=> False);
1830 Style
.Check_Identifier
(Body_Id
, Spec_Id
);
1832 -- Deal with case of body of single task (anonymous type was created)
1834 if Ekind
(Spec_Id
) = E_Variable
then
1835 Spec_Id
:= Etype
(Spec_Id
);
1838 Push_Scope
(Spec_Id
);
1839 Set_Corresponding_Spec
(N
, Spec_Id
);
1840 Set_Corresponding_Body
(Parent
(Spec_Id
), Body_Id
);
1841 Set_Has_Completion
(Spec_Id
);
1842 Install_Declarations
(Spec_Id
);
1843 Last_E
:= Last_Entity
(Spec_Id
);
1845 Analyze_Declarations
(Declarations
(N
));
1847 -- For visibility purposes, all entities in the body are private. Set
1848 -- First_Private_Entity accordingly, if there was no private part in the
1849 -- protected declaration.
1851 if No
(First_Private_Entity
(Spec_Id
)) then
1852 if Present
(Last_E
) then
1853 Set_First_Private_Entity
(Spec_Id
, Next_Entity
(Last_E
));
1855 Set_First_Private_Entity
(Spec_Id
, First_Entity
(Spec_Id
));
1859 -- Mark all handlers as not suitable for local raise optimization,
1860 -- since this optimization causes difficulties in a task context.
1862 if Present
(Exception_Handlers
(HSS
)) then
1866 Handlr
:= First
(Exception_Handlers
(HSS
));
1867 while Present
(Handlr
) loop
1868 Set_Local_Raise_Not_OK
(Handlr
);
1874 -- Now go ahead and complete analysis of the task body
1877 Check_Completion
(Body_Id
);
1878 Check_References
(Body_Id
);
1879 Check_References
(Spec_Id
);
1881 -- Check for entries with no corresponding accept
1887 Ent
:= First_Entity
(Spec_Id
);
1888 while Present
(Ent
) loop
1890 and then not Entry_Accepted
(Ent
)
1891 and then Comes_From_Source
(Ent
)
1893 Error_Msg_NE
("no accept for entry &?", N
, Ent
);
1900 Process_End_Label
(HSS
, 't', Ref_Id
);
1902 end Analyze_Task_Body
;
1904 -----------------------------
1905 -- Analyze_Task_Definition --
1906 -----------------------------
1908 procedure Analyze_Task_Definition
(N
: Node_Id
) is
1912 Tasking_Used
:= True;
1914 if Present
(Visible_Declarations
(N
)) then
1915 Analyze_Declarations
(Visible_Declarations
(N
));
1918 if Present
(Private_Declarations
(N
)) then
1919 L
:= Last_Entity
(Current_Scope
);
1920 Analyze_Declarations
(Private_Declarations
(N
));
1923 Set_First_Private_Entity
1924 (Current_Scope
, Next_Entity
(L
));
1926 Set_First_Private_Entity
1927 (Current_Scope
, First_Entity
(Current_Scope
));
1931 Check_Max_Entries
(N
, Max_Task_Entries
);
1932 Process_End_Label
(N
, 'e', Current_Scope
);
1933 end Analyze_Task_Definition
;
1935 -----------------------
1936 -- Analyze_Task_Type --
1937 -----------------------
1939 procedure Analyze_Task_Type
(N
: Node_Id
) is
1940 Def_Id
: constant Entity_Id
:= Defining_Identifier
(N
);
1944 Check_Restriction
(No_Tasking
, N
);
1945 Tasking_Used
:= True;
1946 T
:= Find_Type_Name
(N
);
1947 Generate_Definition
(T
);
1949 if Ekind
(T
) = E_Incomplete_Type
then
1951 Set_Completion_Referenced
(T
);
1954 Set_Ekind
(T
, E_Task_Type
);
1955 Set_Is_First_Subtype
(T
, True);
1956 Set_Has_Task
(T
, True);
1957 Init_Size_Align
(T
);
1959 Set_Has_Delayed_Freeze
(T
, True);
1960 Set_Stored_Constraint
(T
, No_Elist
);
1963 if Ada_Version
>= Ada_05
then
1964 Check_Interfaces
(N
, T
);
1967 if Present
(Discriminant_Specifications
(N
)) then
1968 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
1969 Error_Msg_N
("(Ada 83) task discriminant not allowed!", N
);
1972 if Has_Discriminants
(T
) then
1974 -- Install discriminants. Also, verify conformance of
1975 -- discriminants of previous and current view. ???
1977 Install_Declarations
(T
);
1979 Process_Discriminants
(N
);
1983 Set_Is_Constrained
(T
, not Has_Discriminants
(T
));
1985 -- Perform minimal expansion of the task type while inside a generic
1986 -- context. The corresponding record is needed for various semantic
1989 if Inside_A_Generic
then
1990 Insert_After_And_Analyze
(N
,
1991 Build_Corresponding_Record
(N
, T
, Sloc
(T
)));
1994 if Present
(Task_Definition
(N
)) then
1995 Analyze_Task_Definition
(Task_Definition
(N
));
1998 if not Is_Library_Level_Entity
(T
) then
1999 Check_Restriction
(No_Task_Hierarchy
, N
);
2004 -- Case of a completion of a private declaration
2007 and then Is_Private_Type
(Def_Id
)
2009 -- Deal with preelaborable initialization. Note that this processing
2010 -- is done by Process_Full_View, but as can be seen below, in this
2011 -- case the call to Process_Full_View is skipped if any serious
2012 -- errors have occurred, and we don't want to lose this check.
2014 if Known_To_Have_Preelab_Init
(Def_Id
) then
2015 Set_Must_Have_Preelab_Init
(T
);
2018 -- Create corresponding record now, because some private dependents
2019 -- may be subtypes of the partial view. Skip if errors are present,
2020 -- to prevent cascaded messages.
2022 if Serious_Errors_Detected
= 0
2023 and then Expander_Active
2025 Expand_N_Task_Type_Declaration
(N
);
2026 Process_Full_View
(N
, T
, Def_Id
);
2029 end Analyze_Task_Type
;
2031 -----------------------------------
2032 -- Analyze_Terminate_Alternative --
2033 -----------------------------------
2035 procedure Analyze_Terminate_Alternative
(N
: Node_Id
) is
2037 Tasking_Used
:= True;
2039 if Present
(Pragmas_Before
(N
)) then
2040 Analyze_List
(Pragmas_Before
(N
));
2043 if Present
(Condition
(N
)) then
2044 Analyze_And_Resolve
(Condition
(N
), Any_Boolean
);
2046 end Analyze_Terminate_Alternative
;
2048 ------------------------------
2049 -- Analyze_Timed_Entry_Call --
2050 ------------------------------
2052 procedure Analyze_Timed_Entry_Call
(N
: Node_Id
) is
2053 Trigger
: constant Node_Id
:=
2054 Entry_Call_Statement
(Entry_Call_Alternative
(N
));
2055 Is_Disp_Select
: Boolean := False;
2058 Check_Restriction
(No_Select_Statements
, N
);
2059 Tasking_Used
:= True;
2061 -- Ada 2005 (AI-345): The trigger may be a dispatching call
2063 if Ada_Version
>= Ada_05
then
2065 Check_Triggering_Statement
(Trigger
, N
, Is_Disp_Select
);
2068 -- Postpone the analysis of the statements till expansion. Analyze only
2069 -- if the expander is disabled in order to catch any semantic errors.
2071 if Is_Disp_Select
then
2072 if not Expander_Active
then
2073 Analyze
(Entry_Call_Alternative
(N
));
2074 Analyze
(Delay_Alternative
(N
));
2077 -- Regular select analysis
2080 Analyze
(Entry_Call_Alternative
(N
));
2081 Analyze
(Delay_Alternative
(N
));
2083 end Analyze_Timed_Entry_Call
;
2085 ------------------------------------
2086 -- Analyze_Triggering_Alternative --
2087 ------------------------------------
2089 procedure Analyze_Triggering_Alternative
(N
: Node_Id
) is
2090 Trigger
: constant Node_Id
:= Triggering_Statement
(N
);
2093 Tasking_Used
:= True;
2095 if Present
(Pragmas_Before
(N
)) then
2096 Analyze_List
(Pragmas_Before
(N
));
2101 if Comes_From_Source
(Trigger
)
2102 and then Nkind
(Trigger
) not in N_Delay_Statement
2103 and then Nkind
(Trigger
) /= N_Entry_Call_Statement
2105 if Ada_Version
< Ada_05
then
2107 ("triggering statement must be delay or entry call", Trigger
);
2109 -- Ada 2005 (AI-345): If a procedure_call_statement is used for a
2110 -- procedure_or_entry_call, the procedure_name or pro- cedure_prefix
2111 -- of the procedure_call_statement shall denote an entry renamed by a
2112 -- procedure, or (a view of) a primitive subprogram of a limited
2113 -- interface whose first parameter is a controlling parameter.
2115 elsif Nkind
(Trigger
) = N_Procedure_Call_Statement
2116 and then not Is_Renamed_Entry
(Entity
(Name
(Trigger
)))
2117 and then not Is_Controlling_Limited_Procedure
2118 (Entity
(Name
(Trigger
)))
2120 Error_Msg_N
("triggering statement must be delay, procedure " &
2121 "or entry call", Trigger
);
2125 if Is_Non_Empty_List
(Statements
(N
)) then
2126 Analyze_Statements
(Statements
(N
));
2128 end Analyze_Triggering_Alternative
;
2130 -----------------------
2131 -- Check_Max_Entries --
2132 -----------------------
2134 procedure Check_Max_Entries
(D
: Node_Id
; R
: All_Parameter_Restrictions
) is
2137 procedure Count
(L
: List_Id
);
2138 -- Count entries in given declaration list
2144 procedure Count
(L
: List_Id
) is
2153 while Present
(D
) loop
2154 if Nkind
(D
) = N_Entry_Declaration
then
2156 DSD
: constant Node_Id
:=
2157 Discrete_Subtype_Definition
(D
);
2160 -- If not an entry family, then just one entry
2163 Ecount
:= Ecount
+ 1;
2165 -- If entry family with static bounds, count entries
2167 elsif Is_OK_Static_Subtype
(Etype
(DSD
)) then
2169 Lo
: constant Uint
:=
2171 (Type_Low_Bound
(Etype
(DSD
)));
2172 Hi
: constant Uint
:=
2174 (Type_High_Bound
(Etype
(DSD
)));
2178 Ecount
:= Ecount
+ Hi
- Lo
+ 1;
2182 -- Entry family with non-static bounds
2185 -- If restriction is set, then this is an error
2187 if Restrictions
.Set
(R
) then
2189 ("static subtype required by Restriction pragma",
2192 -- Otherwise we record an unknown count restriction
2195 Check_Restriction
(R
, D
);
2205 -- Start of processing for Check_Max_Entries
2209 Count
(Visible_Declarations
(D
));
2210 Count
(Private_Declarations
(D
));
2213 Check_Restriction
(R
, D
, Ecount
);
2215 end Check_Max_Entries
;
2217 ----------------------
2218 -- Check_Interfaces --
2219 ----------------------
2221 procedure Check_Interfaces
(N
: Node_Id
; T
: Entity_Id
) is
2223 Iface_Typ
: Entity_Id
;
2227 (Nkind_In
(N
, N_Protected_Type_Declaration
, N_Task_Type_Declaration
));
2229 if Present
(Interface_List
(N
)) then
2230 Set_Is_Tagged_Type
(T
);
2232 Iface
:= First
(Interface_List
(N
));
2233 while Present
(Iface
) loop
2234 Iface_Typ
:= Find_Type_Of_Subtype_Indic
(Iface
);
2236 if not Is_Interface
(Iface_Typ
) then
2238 ("(Ada 2005) & must be an interface", Iface
, Iface_Typ
);
2241 -- Ada 2005 (AI-251): "The declaration of a specific descendant
2242 -- of an interface type freezes the interface type" RM 13.14.
2244 Freeze_Before
(N
, Etype
(Iface
));
2246 if Nkind
(N
) = N_Protected_Type_Declaration
then
2248 -- Ada 2005 (AI-345): Protected types can only implement
2249 -- limited, synchronized, or protected interfaces (note that
2250 -- the predicate Is_Limited_Interface includes synchronized
2251 -- and protected interfaces).
2253 if Is_Task_Interface
(Iface_Typ
) then
2254 Error_Msg_N
("(Ada 2005) protected type cannot implement "
2255 & "a task interface", Iface
);
2257 elsif not Is_Limited_Interface
(Iface_Typ
) then
2258 Error_Msg_N
("(Ada 2005) protected type cannot implement "
2259 & "a non-limited interface", Iface
);
2262 else pragma Assert
(Nkind
(N
) = N_Task_Type_Declaration
);
2264 -- Ada 2005 (AI-345): Task types can only implement limited,
2265 -- synchronized, or task interfaces (note that the predicate
2266 -- Is_Limited_Interface includes synchronized and task
2269 if Is_Protected_Interface
(Iface_Typ
) then
2270 Error_Msg_N
("(Ada 2005) task type cannot implement a " &
2271 "protected interface", Iface
);
2273 elsif not Is_Limited_Interface
(Iface_Typ
) then
2274 Error_Msg_N
("(Ada 2005) task type cannot implement a " &
2275 "non-limited interface", Iface
);
2284 if not Has_Private_Declaration
(T
) then
2288 -- Additional checks on full-types associated with private type
2289 -- declarations. Search for the private type declaration.
2292 Full_T_Ifaces
: Elist_Id
;
2295 Priv_T_Ifaces
: Elist_Id
;
2298 Priv_T
:= First_Entity
(Scope
(T
));
2300 pragma Assert
(Present
(Priv_T
));
2302 if Is_Type
(Priv_T
) and then Present
(Full_View
(Priv_T
)) then
2303 exit when Full_View
(Priv_T
) = T
;
2306 Next_Entity
(Priv_T
);
2309 -- In case of synchronized types covering interfaces the private type
2310 -- declaration must be limited.
2312 if Present
(Interface_List
(N
))
2313 and then not Is_Limited_Record
(Priv_T
)
2315 Error_Msg_Sloc
:= Sloc
(Priv_T
);
2316 Error_Msg_N
("(Ada 2005) limited type declaration expected for " &
2317 "private type#", T
);
2320 -- RM 7.3 (7.1/2): If the full view has a partial view that is
2321 -- tagged then check RM 7.3 subsidiary rules.
2323 if Is_Tagged_Type
(Priv_T
)
2324 and then not Error_Posted
(N
)
2326 -- RM 7.3 (7.2/2): The partial view shall be a synchronized tagged
2327 -- type if and only if the full type is a synchronized tagged type
2329 if Is_Synchronized_Tagged_Type
(Priv_T
)
2330 and then not Is_Synchronized_Tagged_Type
(T
)
2333 ("(Ada 2005) full view must be a synchronized tagged " &
2334 "type (RM 7.3 (7.2/2))", Priv_T
);
2336 elsif Is_Synchronized_Tagged_Type
(T
)
2337 and then not Is_Synchronized_Tagged_Type
(Priv_T
)
2340 ("(Ada 2005) partial view must be a synchronized tagged " &
2341 "type (RM 7.3 (7.2/2))", T
);
2344 -- RM 7.3 (7.3/2): The partial view shall be a descendant of an
2345 -- interface type if and only if the full type is descendant of
2346 -- the interface type.
2348 if Present
(Interface_List
(N
))
2349 or else (Is_Tagged_Type
(Priv_T
)
2350 and then Has_Abstract_Interfaces
2351 (Priv_T
, Use_Full_View
=> False))
2353 if Is_Tagged_Type
(Priv_T
) then
2354 Collect_Abstract_Interfaces
2355 (Priv_T
, Priv_T_Ifaces
, Use_Full_View
=> False);
2358 if Is_Tagged_Type
(T
) then
2359 Collect_Abstract_Interfaces
(T
, Full_T_Ifaces
);
2362 Iface
:= Find_Hidden_Interface
(Priv_T_Ifaces
, Full_T_Ifaces
);
2364 if Present
(Iface
) then
2365 Error_Msg_NE
("interface & not implemented by full type " &
2366 "(RM-2005 7.3 (7.3/2))", Priv_T
, Iface
);
2369 Iface
:= Find_Hidden_Interface
(Full_T_Ifaces
, Priv_T_Ifaces
);
2371 if Present
(Iface
) then
2372 Error_Msg_NE
("interface & not implemented by partial " &
2373 "view (RM-2005 7.3 (7.3/2))", T
, Iface
);
2378 end Check_Interfaces
;
2380 --------------------------------
2381 -- Check_Triggering_Statement --
2382 --------------------------------
2384 procedure Check_Triggering_Statement
2386 Error_Node
: Node_Id
;
2387 Is_Dispatching
: out Boolean)
2392 Is_Dispatching
:= False;
2394 -- It is not possible to have a dispatching trigger if we are not in
2397 if Ada_Version
>= Ada_05
2398 and then Nkind
(Trigger
) = N_Procedure_Call_Statement
2399 and then Present
(Parameter_Associations
(Trigger
))
2401 Param
:= First
(Parameter_Associations
(Trigger
));
2403 if Is_Controlling_Actual
(Param
)
2404 and then Is_Interface
(Etype
(Param
))
2406 if Is_Limited_Record
(Etype
(Param
)) then
2407 Is_Dispatching
:= True;
2410 ("dispatching operation of limited or synchronized " &
2411 "interface required (RM 9.7.2(3))!", Error_Node
);
2415 end Check_Triggering_Statement
;
2417 --------------------------
2418 -- Find_Concurrent_Spec --
2419 --------------------------
2421 function Find_Concurrent_Spec
(Body_Id
: Entity_Id
) return Entity_Id
is
2422 Spec_Id
: Entity_Id
:= Current_Entity_In_Scope
(Body_Id
);
2425 -- The type may have been given by an incomplete type declaration.
2426 -- Find full view now.
2428 if Present
(Spec_Id
) and then Ekind
(Spec_Id
) = E_Incomplete_Type
then
2429 Spec_Id
:= Full_View
(Spec_Id
);
2433 end Find_Concurrent_Spec
;
2435 --------------------------
2436 -- Install_Declarations --
2437 --------------------------
2439 procedure Install_Declarations
(Spec
: Entity_Id
) is
2443 E
:= First_Entity
(Spec
);
2444 while Present
(E
) loop
2445 Prev
:= Current_Entity
(E
);
2446 Set_Current_Entity
(E
);
2447 Set_Is_Immediately_Visible
(E
);
2448 Set_Homonym
(E
, Prev
);
2451 end Install_Declarations
;