@@ -4994,7 +4994,15 @@ package body Sem_Ch4 is
if Comp = First_Private_Entity (Type_To_Use) then
if Etype (Sel) /= Any_Type then
- -- We have a candiate
+ -- If the first private entity's name matches, then treat
+ -- it as a private op: needed for the error check for
+ -- illegal selection of private entities further below.
+
+ if Chars (Comp) = Chars (Sel) then
+ Is_Private_Op := True;
+ end if;
+
+ -- We have a candidate, so exit the loop
exit;
new file mode 100644
@@ -0,0 +1,26 @@
+procedure Task5 is
+
+ task type T is
+ entry E (V1, V2 : Integer);
+ end T;
+
+ T_Obj : T;
+
+ task body T is
+ V1 : Integer;
+ V2 : Integer;
+ V3 : Integer;
+ begin
+ accept E (V1, V2 : Integer) do
+ T.V1 := V1;
+ T.V2 := V2;
+
+ T_Obj.V1 := V1; -- { dg-error "invalid reference to private operation of some object of type \"T\"" }
+ T_Obj.V2 := V2; -- { dg-error "invalid reference to private operation of some object of type \"T\"" }
+ T_Obj.V3 := V3; -- { dg-error "invalid reference to private operation of some object of type \"T\"" }
+ end E;
+ end T;
+
+begin
+ null;
+end Task5;