public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Spurious error on call to protected op. of same type as current instance.
@ 2017-04-25  9:29 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2017-04-25  9:29 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ed Schonberg

[-- Attachment #1: Type: text/plain, Size: 805 bytes --]

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  <schonberg@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.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 2047 bytes --]

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 "

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-25  9:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-25  9:29 [Ada] Spurious error on call to protected op. of same type as current instance Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).