public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-1460] [Ada] Remove redundant guard from Find_Overlaid_Entity
Date: Tue, 15 Jun 2021 10:21:32 +0000 (GMT)	[thread overview]
Message-ID: <20210615102132.11279398B84B@sourceware.org> (raw)

https://gcc.gnu.org/g:9880492caa6f56e7abe10163157d0c2149d72ba4

commit r12-1460-g9880492caa6f56e7abe10163157d0c2149d72ba4
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Mon Feb 8 13:55:05 2021 +0100

    [Ada] Remove redundant guard from Find_Overlaid_Entity
    
    gcc/ada/
    
            * sem_util.ads (Find_Overlaid_Entity): Simplify comment for
            spec.
            * sem_util.adb (Find_Overlaid_Entity): Remove defensive code
            from body.

Diff:
---
 gcc/ada/sem_util.adb | 81 ++++++++++++++++++++++++++--------------------------
 gcc/ada/sem_util.ads | 11 ++++---
 2 files changed, 45 insertions(+), 47 deletions(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 12b54293dbb..98ca0466e0b 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -9371,6 +9371,10 @@ package body Sem_Util is
       Ent : out Entity_Id;
       Off : out Boolean)
    is
+      pragma Assert
+        (Nkind (N) = N_Attribute_Definition_Clause
+         and then Chars (N) = Name_Address);
+
       Expr : Node_Id;
 
    begin
@@ -9390,61 +9394,56 @@ package body Sem_Util is
       Ent := Empty;
       Off := False;
 
-      if Nkind (N) = N_Attribute_Definition_Clause
-        and then Chars (N) = Name_Address
-      then
-         Expr := Expression (N);
+      Expr := Expression (N);
 
-         --  This loop checks the form of the expression for Y'Address,
-         --  using recursion to deal with intermediate constants.
+      --  This loop checks the form of the expression for Y'Address, using
+      --  recursion to deal with intermediate constants.
 
-         loop
-            --  Check for Y'Address
+      loop
+         --  Check for Y'Address
 
-            if Nkind (Expr) = N_Attribute_Reference
-              and then Attribute_Name (Expr) = Name_Address
-            then
-               Expr := Prefix (Expr);
-               exit;
+         if Nkind (Expr) = N_Attribute_Reference
+           and then Attribute_Name (Expr) = Name_Address
+         then
+            Expr := Prefix (Expr);
+            exit;
 
-            --  Check for Const where Const is a constant entity
+         --  Check for Const where Const is a constant entity
 
-            elsif Is_Entity_Name (Expr)
-              and then Ekind (Entity (Expr)) = E_Constant
-            then
-               Expr := Constant_Value (Entity (Expr));
+         elsif Is_Entity_Name (Expr)
+           and then Ekind (Entity (Expr)) = E_Constant
+         then
+            Expr := Constant_Value (Entity (Expr));
 
-            --  Anything else does not need checking
+         --  Anything else does not need checking
 
-            else
-               return;
-            end if;
-         end loop;
+         else
+            return;
+         end if;
+      end loop;
 
-         --  This loop checks the form of the prefix for an entity, using
-         --  recursion to deal with intermediate components.
+      --  This loop checks the form of the prefix for an entity, using
+      --  recursion to deal with intermediate components.
 
-         loop
-            --  Check for Y where Y is an entity
+      loop
+         --  Check for Y where Y is an entity
 
-            if Is_Entity_Name (Expr) then
-               Ent := Entity (Expr);
-               return;
+         if Is_Entity_Name (Expr) then
+            Ent := Entity (Expr);
+            return;
 
-            --  Check for components
+         --  Check for components
 
-            elsif Nkind (Expr) in N_Selected_Component | N_Indexed_Component
-            then
-               Expr := Prefix (Expr);
-               Off := True;
+         elsif Nkind (Expr) in N_Selected_Component | N_Indexed_Component then
+            Expr := Prefix (Expr);
+            Off  := True;
 
-            --  Anything else does not need checking
+         --  Anything else does not need checking
 
-            else
-               return;
-            end if;
-         end loop;
-      end if;
+         else
+            return;
+         end if;
+      end loop;
    end Find_Overlaid_Entity;
 
    -------------------------
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index a8f8e0bd9c1..a986ae65547 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -900,12 +900,11 @@ package Sem_Util is
      (N   : Node_Id;
       Ent : out Entity_Id;
       Off : out Boolean);
-   --  The node N should be an address representation clause. Determines if
-   --  the target expression is the address of an entity with an optional
-   --  offset. If so, set Ent to the entity and, if there is an offset, set
-   --  Off to True, otherwise to False. If N is not an address representation
-   --  clause, or if it is not possible to determine that the address is of
-   --  this form, then set Ent to Empty.
+   --  The node N should be an address representation clause. Determines if the
+   --  target expression is the address of an entity with an optional offset.
+   --  If so, set Ent to the entity and, if there is an offset, set Off to
+   --  True, otherwise to False. If it is not possible to determine that the
+   --  address is of this form, then set Ent to Empty.
 
    function Find_Parameter_Type (Param : Node_Id) return Entity_Id;
    --  Return the type of formal parameter Param as determined by its


                 reply	other threads:[~2021-06-15 10:21 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=20210615102132.11279398B84B@sourceware.org \
    --to=pmderodat@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).