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

commit r16-1315-gbba4596132cb75d2892e7475aa67d32e15439c39
Author: Piotr Trojanek <troja...@adacore.com>
Date:   Tue Mar 4 12:33:34 2025 +0100

    ada: Check validity using signedness from the type and not its base type
    
    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.

Diff:
---
 gcc/ada/exp_attr.adb | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index f1f8424d7202..3d1bff93b408 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -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;

Reply via email to