public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [Ada] Fix detection of overlapping actuals with renamings
Date: Mon, 21 Jun 2021 07:05:33 -0400	[thread overview]
Message-ID: <20210621110533.GA41258@adacore.com> (raw)

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

Simplify detection of renamings within actuals that denote the same
object. This code only needs to take object renamings and shouldn't care
about renamings of subprogram, packages or exceptions.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_util.adb (Is_Object_Renaming): Rename from Is_Renaming;
	simplify; adapt callers.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2935 bytes --]

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -7262,8 +7262,8 @@ package body Sem_Util is
    -------------------------
 
    function Denotes_Same_Object (A1, A2 : Node_Id) return Boolean is
-      function Is_Renaming (N : Node_Id) return Boolean;
-      --  Return true if N names a renaming entity
+      function Is_Object_Renaming (N : Node_Id) return Boolean;
+      --  Return true if N names an object renaming entity
 
       function Is_Valid_Renaming (N : Node_Id) return Boolean;
       --  For renamings, return False if the prefix of any dereference within
@@ -7271,35 +7271,16 @@ package body Sem_Util is
       --  renamed object_name contains references to variables or calls on
       --  nonstatic functions; otherwise return True (RM 6.4.1(6.10/3))
 
-      -----------------
-      -- Is_Renaming --
-      -----------------
+      ------------------------
+      -- Is_Object_Renaming --
+      ------------------------
 
-      function Is_Renaming (N : Node_Id) return Boolean is
+      function Is_Object_Renaming (N : Node_Id) return Boolean is
       begin
-         if not Is_Entity_Name (N) then
-            return False;
-         end if;
-
-         case Ekind (Entity (N)) is
-            when E_Variable | E_Constant =>
-               return Present (Renamed_Object (Entity (N)));
-
-            when E_Exception
-               | E_Function
-               | E_Generic_Function
-               | E_Generic_Package
-               | E_Generic_Procedure
-               | E_Operator
-               | E_Package
-               | E_Procedure
-            =>
-               return Present (Renamed_Entity (Entity (N)));
-
-            when others =>
-               return False;
-         end case;
-      end Is_Renaming;
+         return Is_Entity_Name (N)
+           and then Ekind (Entity (N)) in E_Variable | E_Constant
+           and then Present (Renamed_Object (Entity (N)));
+      end Is_Object_Renaming;
 
       -----------------------
       -- Is_Valid_Renaming --
@@ -7307,7 +7288,7 @@ package body Sem_Util is
 
       function Is_Valid_Renaming (N : Node_Id) return Boolean is
       begin
-         if Is_Renaming (N)
+         if Is_Object_Renaming (N)
            and then not Is_Valid_Renaming (Renamed_Entity (Entity (N)))
          then
             return False;
@@ -7494,12 +7475,12 @@ package body Sem_Util is
       --  no references to variables nor calls on nonstatic functions (RM
       --  6.4.1(6.11/3)).
 
-      elsif Is_Renaming (A1)
+      elsif Is_Object_Renaming (A1)
         and then Is_Valid_Renaming (A1)
       then
          return Denotes_Same_Object (Renamed_Entity (Entity (A1)), A2);
 
-      elsif Is_Renaming (A2)
+      elsif Is_Object_Renaming (A2)
         and then Is_Valid_Renaming (A2)
       then
          return Denotes_Same_Object (A1, Renamed_Entity (Entity (A2)));



             reply	other threads:[~2021-06-21 11:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-21 11:05 Pierre-Marie de Rodat [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-06-18  8:38 Pierre-Marie de Rodat

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=20210621110533.GA41258@adacore.com \
    --to=derodat@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=trojanek@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).