public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1589] [Ada] Remove dubious wrapper of a recursive function
@ 2021-06-17 14:34 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-17 14:34 UTC (permalink / raw)
To: gcc-cvs
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-17 14:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 14:34 [gcc r12-1589] [Ada] Remove dubious wrapper of a recursive function Pierre-Marie de Rodat
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).