https://gcc.gnu.org/g:649bde867ae0a808b21e837744211339476c8099
commit r15-9791-g649bde867ae0a808b21e837744211339476c8099 Author: Piotr Trojanek <troja...@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));