public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-7897] ada: Fix Valid_Scalars attribute applied to types from limited with
@ 2023-09-27  8:27 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2023-09-27  8:27 UTC (permalink / raw)
  To: gcc-cvs

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

commit r13-7897-ge68906c444e6488960908c89c26ebdba67b6f2cb
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Sun Jul 2 10:07:55 2023 +0200

    ada: Fix Valid_Scalars attribute applied to types from limited with
    
    The attribute is wrongly computed as always True because, unlike for e.g.
    private types, Validated_View does not look through the limited view.
    
    gcc/ada/
    
            * sem_util.ads (Validated_View): Document enhanced behavior.
            * sem_util.adb (Validated_View): Return the nonlimited view, if any,
            of types coming from a limited with.

Diff:
---
 gcc/ada/sem_util.adb | 7 +++++++
 gcc/ada/sem_util.ads | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index e9eb92936ee..a77a0e8330a 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -29230,6 +29230,13 @@ package body Sem_Util is
             return Typ;
          end if;
 
+      elsif From_Limited_With (Typ) then
+         if Has_Non_Limited_View (Typ) then
+            return Validated_View (Non_Limited_View (Typ));
+         else
+            return Typ;
+         end if;
+
       else
          return Typ;
       end if;
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index 70b50bf15f8..aa328df6fdc 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -3342,8 +3342,8 @@ 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 attribute 'Valid_Scalars. This view is the type itself
-   --  or its full view while stripping away concurrency, derivations, and
-   --  privacy.
+   --  or its full view or nonlimited view, while stripping away concurrency,
+   --  derivations, and privacy.
 
    function Visible_Ancestors (Typ : Entity_Id) return Elist_Id;
    --  [Ada 2012:AI-0125-1]: Collect all the visible parents and progenitors

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

only message in thread, other threads:[~2023-09-27  8:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27  8:27 [gcc r13-7897] ada: Fix Valid_Scalars attribute applied to types from limited with Eric Botcazou

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).