]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Check validity using signedness from the type and not its base type
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 4 Mar 2025 11:33:34 +0000 (12:33 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 9 Jun 2025 06:32:05 +0000 (08:32 +0200)
When attribute Valid is applied to a private type, we used the signedness of
its implementation base type which wrongly included negative values.

gcc/ada/ChangeLog:

* exp_attr.adb (Expand_N_Attribute_Reference): When expanding attribute
Valid, use signedness from the validated view, not from its base type.

gcc/ada/exp_attr.adb

index f1f8424d720228598124823290377d9960d499ed..3d1bff93b408eca2f8ecb868e9c653dc73268778 100644 (file)
@@ -8183,9 +8183,8 @@ package body Exp_Attr is
          else
             declare
                Uns  : constant Boolean :=
-                        Is_Unsigned_Type (Ptyp)
-                          or else (Is_Private_Type (Ptyp)
-                                    and then Is_Unsigned_Type (PBtyp));
+                 Is_Unsigned_Type (Validated_View (Ptyp));
+
                Size : Uint;
                P    : Node_Id := Pref;