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-1589] [Ada] Remove dubious wrapper of a recursive function
Date: Thu, 17 Jun 2021 14:34:35 +0000 (GMT)	[thread overview]
Message-ID: <20210617143435.E856A396BC0E@sourceware.org> (raw)

https://gcc.gnu.org/g:4476d9345547473030a8a041d3178bb54ed49bef

commit r12-1589-g4476d9345547473030a8a041d3178bb54ed49bef
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Wed Mar 10 23:20:58 2021 +0100

    [Ada] Remove dubious wrapper of a recursive function
    
    gcc/ada/
    
            * sem_util.adb (Is_Valid_Renaming): Body moved from its nested
            routine.

Diff:
---
 gcc/ada/sem_util.adb | 94 ++++++++++++++++++++++------------------------------
 1 file changed, 40 insertions(+), 54 deletions(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index c9d97a93464..855195dd220 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -7294,70 +7294,56 @@ package body Sem_Util is
       -----------------------
 
       function Is_Valid_Renaming (N : Node_Id) return Boolean is
-         function Check_Renaming (N : Node_Id) return Boolean;
-         --  Recursive function used to traverse all the prefixes of N
-
-         --------------------
-         -- Check_Renaming --
-         --------------------
-
-         function Check_Renaming (N : Node_Id) return Boolean is
-         begin
-            if Is_Renaming (N)
-              and then not Check_Renaming (Renamed_Entity (Entity (N)))
-            then
-               return False;
-            end if;
-
-            if Nkind (N) = N_Indexed_Component then
-               declare
-                  Indx : Node_Id;
-
-               begin
-                  Indx := First (Expressions (N));
-                  while Present (Indx) loop
-                     if not Is_OK_Static_Expression (Indx) then
-                        return False;
-                     end if;
-
-                     Next_Index (Indx);
-                  end loop;
-               end;
-            end if;
+      begin
+         if Is_Renaming (N)
+           and then not Is_Valid_Renaming (Renamed_Entity (Entity (N)))
+         then
+            return False;
+         end if;
 
-            if Has_Prefix (N) then
-               declare
-                  P : constant Node_Id := Prefix (N);
+         if Nkind (N) = N_Indexed_Component then
+            declare
+               Indx : Node_Id;
 
-               begin
-                  if Nkind (N) = N_Explicit_Dereference
-                    and then Is_Variable (P)
-                  then
+            begin
+               Indx := First (Expressions (N));
+               while Present (Indx) loop
+                  if not Is_OK_Static_Expression (Indx) then
                      return False;
+                  end if;
 
-                  elsif Is_Entity_Name (P)
-                    and then Ekind (Entity (P)) = E_Function
-                  then
-                     return False;
+                  Next_Index (Indx);
+               end loop;
+            end;
+         end if;
 
-                  elsif Nkind (P) = N_Function_Call then
-                     return False;
-                  end if;
+         if Has_Prefix (N) then
+            declare
+               P : constant Node_Id := Prefix (N);
+
+            begin
+               if Nkind (N) = N_Explicit_Dereference
+                 and then Is_Variable (P)
+               then
+                  return False;
 
-                  --  Recursion to continue traversing the prefix of the
-                  --  renaming expression
+               elsif Is_Entity_Name (P)
+                 and then Ekind (Entity (P)) = E_Function
+               then
+                  return False;
 
-                  return Check_Renaming (P);
-               end;
-            end if;
+               elsif Nkind (P) = N_Function_Call then
+                  return False;
+               end if;
 
-            return True;
-         end Check_Renaming;
+               --  Recursion to continue traversing the prefix of the
+               --  renaming expression
 
-      --  Start of processing for Is_Valid_Renaming
+               return Is_Valid_Renaming (P);
+            end;
+         end if;
 
-      begin
-         return Check_Renaming (N);
+         return True;
       end Is_Valid_Renaming;
 
       --  Local variables


                 reply	other threads:[~2021-06-17 14:34 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=20210617143435.E856A396BC0E@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).