public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1877] [Ada] Rewrite Validated_View in recursive style
@ 2021-06-29 14:24 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-29 14:24 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d23455ce238122c20c4fa81fa55eeb9ad1d938ee

commit r12-1877-gd23455ce238122c20c4fa81fa55eeb9ad1d938ee
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Tue Apr 6 13:10:40 2021 +0200

    [Ada] Rewrite Validated_View in recursive style
    
    gcc/ada/
    
            * sem_util.ads (Validated_View): Fix style in comment.
            * sem_util.adb (Validated_View): Rewrite in recursive style.

Diff:
---
 gcc/ada/sem_util.adb | 44 +++++++++++++++++++-------------------------
 gcc/ada/sem_util.ads |  2 +-
 2 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 479bb146b61..169825ec030 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -29471,42 +29471,36 @@ package body Sem_Util is
    --------------------
 
    function Validated_View (Typ : Entity_Id) return Entity_Id is
-      Continue : Boolean;
-      Val_Typ  : Entity_Id;
-
    begin
-      Continue := True;
-      Val_Typ  := Base_Type (Typ);
-
       --  Obtain the full view of the input type by stripping away concurrency,
       --  derivations, and privacy.
 
-      while Continue loop
-         Continue := False;
-
-         if Is_Concurrent_Type (Val_Typ) then
-            if Present (Corresponding_Record_Type (Val_Typ)) then
-               Continue := True;
-               Val_Typ  := Corresponding_Record_Type (Val_Typ);
+      if Is_Base_Type (Typ) then
+         if Is_Concurrent_Type (Typ) then
+            if Present (Corresponding_Record_Type (Typ)) then
+               return Corresponding_Record_Type (Typ);
+            else
+               return Typ;
             end if;
 
-         elsif Is_Derived_Type (Val_Typ) then
-            Continue := True;
-            Val_Typ  := Etype (Val_Typ);
+         elsif Is_Derived_Type (Typ) then
+            return Validated_View (Etype (Typ));
 
-         elsif Is_Private_Type (Val_Typ) then
-            if Present (Underlying_Full_View (Val_Typ)) then
-               Continue := True;
-               Val_Typ  := Underlying_Full_View (Val_Typ);
+         elsif Is_Private_Type (Typ) then
+            if Present (Underlying_Full_View (Typ)) then
+               return Validated_View (Underlying_Full_View (Typ));
 
-            elsif Present (Full_View (Val_Typ)) then
-               Continue := True;
-               Val_Typ  := Full_View (Val_Typ);
+            elsif Present (Full_View (Typ)) then
+               return Validated_View (Full_View (Typ));
+            else
+               return Typ;
             end if;
          end if;
-      end loop;
 
-      return Val_Typ;
+         return Typ;
+      else
+         return Validated_View (Base_Type (Typ));
+      end if;
    end Validated_View;
 
    -----------------------
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index a1ed43cba43..f9db80ea496 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -3290,7 +3290,7 @@ package Sem_Util is
 
    function Validated_View (Typ : Entity_Id) return Entity_Id;
    --  Obtain the "validated view" of arbitrary type Typ which is suitable for
-   --  verification by attributes 'Valid_Scalars. This view is the type itself
+   --  verification by attribute 'Valid_Scalars. This view is the type itself
    --  or its full view while stripping away concurrency, derivations, and
    --  privacy.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-29 14:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29 14:24 [gcc r12-1877] [Ada] Rewrite Validated_View in recursive style 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).