]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix Valid_Scalars attribute applied to types from limited with
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 2 Jul 2023 08:07:55 +0000 (10:07 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 27 Sep 2023 08:16:29 +0000 (10:16 +0200)
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.

gcc/ada/sem_util.adb
gcc/ada/sem_util.ads

index e9eb92936ee81b7101a627da4df485a73656b430..a77a0e8330a24ad78e27c39370baa918c9e89043 100644 (file)
@@ -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;
index 70b50bf15f86c50a683341dbde7b598eb67fa96a..aa328df6fdc48a8064199f6841ded80959f33612 100644 (file)
@@ -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