public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Arnaud Charlet <charlet@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Ed Schonberg <schonberg@adacore.com>
Subject: [Ada] Spurious error on call to protected op. of same type as current instance.
Date: Tue, 25 Apr 2017 09:29:00 -0000	[thread overview]
Message-ID: <20170425092257.GA13213@adacore.com> (raw)

[-- 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 "

                 reply	other threads:[~2017-04-25  9:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170425092257.GA13213@adacore.com \
    --to=charlet@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=schonberg@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).