[gcc r16-1206] ada: Fix for validity checking of limited scalar types
Marc Poulhies
dkm@gcc.gnu.org
Fri Jun 6 08:39:47 GMT 2025
https://gcc.gnu.org/g:b449898970a502d31f30334cf0dd630f93d12bd8
commit r16-1206-gb449898970a502d31f30334cf0dd630f93d12bd8
Author: Piotr Trojanek <trojanek@adacore.com>
Date: Tue Jan 28 12:12:23 2025 +0100
ada: Fix for validity checking of limited scalar types
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.
Diff:
---
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 dcfcaa33bcc4..6a98292d1cc1 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));
More information about the Gcc-cvs
mailing list