[COMMITTED 01/40] ada: Fix for validity checking of limited scalar types
Marc Poulhiès
poulhies@adacore.com
Fri Jun 6 08:39:33 GMT 2025
From: Piotr Trojanek <trojanek@adacore.com>
With a recent change we are now validity checking objects of private scalar
types, but need to handle private scalar types whose public view is limited.
gcc/ada/ChangeLog:
* checks.adb (Insert_Valid_Check): Set flag Assignment_OK in the object
declaration inserted for the validity checks.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/checks.adb | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index dcfcaa33bcc..6a98292d1cc 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -8163,6 +8163,7 @@ package body Checks is
end if;
declare
+ Decl : Node_Id;
CE : Node_Id;
PV : Node_Id;
Var_Id : Entity_Id;
@@ -8215,12 +8216,20 @@ package body Checks is
Mutate_Ekind (Var_Id, E_Variable);
Set_Etype (Var_Id, Typ);
- Insert_Action (Exp,
+ Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Var_Id,
Object_Definition => New_Occurrence_Of (Typ, Loc),
- Expression => New_Copy_Tree (Exp)),
- Suppress => Validity_Check);
+ Expression => New_Copy_Tree (Exp));
+
+ -- We might be validity-checking object whose type is declared as
+ -- limited but completion is a scalar type. We need to explicitly
+ -- flag its assignment as OK, as otherwise it would be rejected by
+ -- the language rules.
+
+ Set_Assignment_OK (Decl);
+
+ Insert_Action (Exp, Decl, Suppress => Validity_Check);
Set_Validated_Object (Var_Id, New_Copy_Tree (Exp));
--
2.43.0
More information about the Gcc-patches
mailing list