From: Piotr Trojanek Date: Tue, 4 Mar 2025 11:33:34 +0000 (+0100) Subject: ada: Check validity using signedness from the type and not its base type X-Git-Tag: releases/gcc-15.2.0~399 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=e68026cd01d87a89d52c74238d4c1bff8764f9fc;p=thirdparty%2Fgcc.git 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 --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 455cc226bbf..18179d3a4e9 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -7872,9 +7872,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;