From: Piotr Trojanek Date: Fri, 9 Aug 2024 15:52:51 +0000 (+0200) Subject: ada: Ensure validity checks for private scalar types X-Git-Tag: basepoints/gcc-16~6260 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=299cd64b9e5f1c148b055bd2017a9473fa95227e;p=thirdparty%2Fgcc.git ada: Ensure validity checks for private scalar types To check validity of data values, we must strip privacy from their types. gcc/ada/ * checks.adb (Expr_Known_Valid): Use Validated_View, which strips type derivation and privacy. * exp_ch3.adb (Simple_Init_Private_Type): Kill checks inside unchecked conversions, just like in Simple_Init_Scalar_Type. --- diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 83879a519f7..2fb750c3ba4 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -6833,7 +6833,7 @@ package body Checks is ---------------------- function Expr_Known_Valid (Expr : Node_Id) return Boolean is - Typ : constant Entity_Id := Etype (Expr); + Typ : constant Entity_Id := Validated_View (Etype (Expr)); begin -- Non-scalar types are always considered valid, since they never give diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index bf04ea9d70a..4f6fa4cf6b7 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -10248,7 +10248,8 @@ package body Exp_Ch3 is if Nkind (Expr) = N_Unchecked_Type_Conversion and then Is_Scalar_Type (Under_Typ) then - Set_No_Truncation (Expr); + Set_Kill_Range_Check (Expr); + Set_No_Truncation (Expr); end if; return Expr;