+2017-05-02 Hristian Kirtchev <kirtchev@adacore.com>
+
+ * exp_attr.adb: Minor reformatting.
+
+2017-05-02 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch4.adb (Analyze_Selected_Component): Improve error
+ detection for illegal references to private components or
+ operations of a protected type in the body of the type.
+
2017-05-02 Eric Botcazou <ebotcazou@adacore.com>
* opt.ads: Add missing GNAT markers in comments.
---------------------------------
function Build_Disp_Get_Task_Id_Call (Actual : Node_Id) return Node_Id is
- Typ : constant Entity_Id := Etype (Actual);
- Id : constant Node_Id :=
- New_Occurrence_Of
- (Find_Prim_Op (Typ, Name_uDisp_Get_Task_Id), Sloc (Actual));
- Result : constant Node_Id :=
- Make_Function_Call (Sloc (Actual),
- Name => Id,
- Parameter_Associations => New_List (Actual));
+ Loc : constant Source_Ptr := Sloc (Actual);
+ Typ : constant Entity_Id := Etype (Actual);
+ Subp : constant Entity_Id := Find_Prim_Op (Typ, Name_uDisp_Get_Task_Id);
+
begin
- return Result;
+ -- Generate:
+ -- _Disp_Get_Task_Id (Actual)
+
+ return
+ Make_Function_Call (Loc,
+ Name => New_Occurrence_Of (Subp, Loc),
+ Parameter_Associations => New_List (Actual));
end Build_Disp_Get_Task_Id_Call;
--------------------------
then
Rewrite (N,
Make_Function_Call (Loc,
- Name =>
+ Name =>
New_Occurrence_Of (RTE (RE_Callable), Loc),
Parameter_Associations => New_List (
Make_Unchecked_Type_Conversion (Loc,
Subtype_Mark =>
New_Occurrence_Of (RTE (RO_ST_Task_Id), Loc),
- Expression => Build_Disp_Get_Task_Id_Call (Pref)))));
+ Expression => Build_Disp_Get_Task_Id_Call (Pref)))));
else
Rewrite (N, Build_Call_With_Task (Pref, RTE (RE_Callable)));
and then Is_Interface (Ptyp)
and then Is_Task_Interface (Ptyp)
then
- Rewrite
- (N, Unchecked_Convert_To
- (Id_Kind, Build_Disp_Get_Task_Id_Call (Pref)));
+ Rewrite (N,
+ Unchecked_Convert_To
+ (Id_Kind, Build_Disp_Get_Task_Id_Call (Pref)));
else
Rewrite (N,
then
Rewrite (N,
Make_Function_Call (Loc,
- Name =>
+ Name =>
New_Occurrence_Of (RTE (RE_Terminated), Loc),
Parameter_Associations => New_List (
Make_Unchecked_Type_Conversion (Loc,
Subtype_Mark =>
New_Occurrence_Of (RTE (RO_ST_Task_Id), Loc),
- Expression => Build_Disp_Get_Task_Id_Call (Pref)))));
+ Expression => Build_Disp_Get_Task_Id_Call (Pref)))));
elsif Restricted_Profile then
Rewrite (N,
Act_Decl : Node_Id;
Comp : Entity_Id;
Has_Candidate : Boolean := False;
+ Hidden_Comp : Entity_Id;
In_Scope : Boolean;
Is_Private_Op : Boolean;
Parent_N : Node_Id;
-- can only be a direct name or an expanded name.
Set_Etype (Sel, Any_Type);
+ Hidden_Comp := Empty;
In_Scope := In_Open_Scopes (Prefix_Type);
Is_Private_Op := False;
Has_Candidate := True;
else
+ if Ekind (Comp) = E_Component then
+ Hidden_Comp := Comp;
+ end if;
+
goto Next_Comp;
end if;
end if;
<<Next_Comp>>
+ if Comp = First_Private_Entity (Type_To_Use) then
+ if Etype (Sel) /= Any_Type then
+
+ -- We have a candiate.
+ exit;
+
+ else
+ -- Indicate that subsequent operations are private,
+ -- for better error reporting.
+
+ Is_Private_Op := True;
+ end if;
+ end if;
+
Next_Entity (Comp);
exit when not In_Scope
and then
elsif In_Scope
and then Is_Object_Reference (Original_Node (Prefix (N)))
+ and then Comes_From_Source (N)
and then Is_Private_Op
then
- Error_Msg_NE
- ("invalid reference to private operation of some object of "
- & "type &", N, Type_To_Use);
+ if Present (Hidden_Comp) then
+ Error_Msg_NE
+ ("invalid reference to private component of object "
+ & "of type &", N, Type_To_Use);
+
+ else
+ Error_Msg_NE
+ ("invalid reference to private operation of some object of "
+ & "type &", N, Type_To_Use);
+ end if;
+
Set_Entity (Sel, Any_Id);
Set_Etype (Sel, Any_Type);
return;