aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2024-08-09 17:52:51 +0200
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-08-29 15:06:27 +0200
commit299cd64b9e5f1c148b055bd2017a9473fa95227e (patch)
treeed95611d11419006640b339f95edb0238f742682 /gcc
parent6a3ff84a7790ae008e5f557d74c83bcf196c2162 (diff)
downloadgcc-299cd64b9e5f1c148b055bd2017a9473fa95227e.zip
gcc-299cd64b9e5f1c148b055bd2017a9473fa95227e.tar.gz
gcc-299cd64b9e5f1c148b055bd2017a9473fa95227e.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/checks.adb2
-rw-r--r--gcc/ada/exp_ch3.adb3
2 files changed, 3 insertions, 2 deletions
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 83879a51..2fb750c 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 bf04ea9..4f6fa4c 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;