If the prefix of a selected component denotes a synchronized object the selected component is part of an external call (or requeue) that can only access public operations of the object. The previous check on this construct was too restrictive, and did not allow public protected operations, only task entries.
No short example available. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-04-25 Ed Schonberg <schonb...@adacore.com> * sem_ch4.adb (Analyze_Selected_Component): Refine analysis of prefix whose type is a current instance of a synchronized type. If the prefix is an object this is an external call (or requeue) that can only access public operations of the object. The previous predicate was too restrictive, and did not allow public protected operations, only task entries.
Index: sem_ch4.adb =================================================================== --- sem_ch4.adb (revision 247135) +++ sem_ch4.adb (working copy) @@ -4295,6 +4295,7 @@ Comp : Entity_Id; Has_Candidate : Boolean := False; In_Scope : Boolean; + Is_Private_Op : Boolean; Parent_N : Node_Id; Pent : Entity_Id := Empty; Prefix_Type : Entity_Id; @@ -4825,7 +4826,7 @@ -- Find visible operation with given name. For a protected type, -- the possible candidates are discriminants, entries or protected - -- procedures. For a task type, the set can only include entries or + -- subprograms. For a task type, the set can only include entries or -- discriminants if the task type is not an enclosing scope. If it -- is an enclosing scope (e.g. in an inner task) then all entities -- are visible, but the prefix must denote the enclosing scope, i.e. @@ -4833,6 +4834,7 @@ Set_Etype (Sel, Any_Type); In_Scope := In_Open_Scopes (Prefix_Type); + Is_Private_Op := False; while Present (Comp) loop @@ -4845,6 +4847,9 @@ or else Comp /= First_Private_Entity (Type_To_Use)) then Add_One_Interp (Sel, Comp, Etype (Comp)); + if Comp = First_Private_Entity (Type_To_Use) then + Is_Private_Op := True; + end if; -- If the prefix is tagged, the correct interpretation may -- lie in the primitive or class-wide operations of the @@ -4924,6 +4929,12 @@ then null; + elsif Is_Protected_Type (Prefix_Type) + and then Is_Overloadable (Entity (Sel)) + and then not Is_Private_Op + then + null; + else Error_Msg_NE ("invalid reference to internal operation of some object of "