]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Set Ekind early for entities created in expansion
authorRonan Desplanques <desplanques@adacore.com>
Wed, 26 Feb 2025 10:22:45 +0000 (11:22 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 6 Jun 2025 08:37:10 +0000 (10:37 +0200)
This patch adds early Ekind assignments to entities created for the
expansion of a few constructs. The only effect is to enable more dynamic
checks for the uses of those entities that used to happen before the
Ekind had been set.

gcc/ada/ChangeLog:

* contracts.adb (Add_Invariant_And_Predicate_Checks): Assign Ekind.
* inline.adb (Expand_Inlined_Call): Likewise.
* exp_ch9.adb (Build_Simple_Entry_Call): Likewise.
* exp_dist.adb (Append_Array_Traversal): Likewise.
* exp_fixd.adb (Build_Double_Divide_Code, Build_Scaled_Divide_Code):
Likewise.

gcc/ada/contracts.adb
gcc/ada/exp_ch9.adb
gcc/ada/exp_dist.adb
gcc/ada/exp_fixd.adb
gcc/ada/inline.adb

index c0a57e6d0baeae1cf89d7bf175967ba6d114602b..fc48d7f97da60f235a29cc1b1ac189fef466c859 100644 (file)
@@ -2422,6 +2422,7 @@ package body Contracts is
             --  verify the return value.
 
             Result := Make_Defining_Identifier (Loc, Name_uResult);
+            Mutate_Ekind (Result, E_Constant);
             Set_Etype (Result, Typ);
 
             --  Add an invariant check when the return type has invariants and
index ff5668e08c4cbed7c69c422238d3ea2dfd8985a6..9cfc6b536e9212b0da9dd2ea56487025d3fa35ac 100644 (file)
@@ -4273,6 +4273,7 @@ package body Exp_Ch9 is
                    Defining_Identifier => Obj,
                    Object_Definition   => New_Occurrence_Of (Conctyp, Loc),
                    Expression          => ExpR);
+               Mutate_Ekind (Obj, E_Variable);
                Set_Etype (Obj, Conctyp);
                Decls := New_List (Decl);
                Rewrite (Concval, New_Occurrence_Of (Obj, Loc));
index 694fbe47daba7a7660a89be0a8de69571a42a364..a351b9b8a8fbf220945b7faad5737886063c33fd 100644 (file)
@@ -10980,6 +10980,7 @@ package body Exp_Dist is
             if not Constrained or else Depth > 1 then
                Inner_Any := Make_Defining_Identifier (Loc,
                               New_External_Name ('A', Depth));
+               Mutate_Ekind (Inner_Any, E_Variable);
                Set_Etype (Inner_Any, RTE (RE_Any));
             else
                Inner_Any := Empty;
@@ -10988,6 +10989,7 @@ package body Exp_Dist is
             if Present (Counter) then
                Inner_Counter := Make_Defining_Identifier (Loc,
                                   New_External_Name ('J', Depth));
+               Mutate_Ekind (Inner_Counter, E_Variable);
             else
                Inner_Counter := Empty;
             end if;
index 03c7ca849158eb08a3aad15f33041adb49e8afb3..8759099c193eb4c7e4198ade37713111c7b3810f 100644 (file)
@@ -570,12 +570,16 @@ package body Exp_Fixd is
       --  Case where we can compute the denominator in Max_Integer_Size bits
 
       if QR_Id = RE_Null then
+         Mutate_Ekind (Qnn, E_Constant);
+         Mutate_Ekind (Rnn, E_Constant);
 
          --  Create temporaries for numerator and denominator and set Etypes,
          --  so that New_Occurrence_Of picks them up for Build_xxx calls.
 
          Nnn := Make_Temporary (Loc, 'N');
+         Mutate_Ekind (Nnn, E_Constant);
          Dnn := Make_Temporary (Loc, 'D');
+         Mutate_Ekind (Dnn, E_Constant);
 
          Set_Etype (Nnn, QR_Typ);
          Set_Etype (Dnn, QR_Typ);
@@ -621,6 +625,8 @@ package body Exp_Fixd is
       --  to call the runtime routine to compute the quotient and remainder.
 
       else
+         Mutate_Ekind (Qnn, E_Variable);
+         Mutate_Ekind (Rnn, E_Variable);
          Rnd := Boolean_Literals (Rounded_Result_Set (N));
 
          Code := New_List (
@@ -935,8 +941,13 @@ package body Exp_Fixd is
       --  Case where we can compute the numerator in Max_Integer_Size bits
 
       if QR_Id = RE_Null then
+         Mutate_Ekind (Qnn, E_Constant);
+         Mutate_Ekind (Rnn, E_Constant);
+
          Nnn := Make_Temporary (Loc, 'N');
+         Mutate_Ekind (Nnn, E_Constant);
          Dnn := Make_Temporary (Loc, 'D');
+         Mutate_Ekind (Dnn, E_Constant);
 
          --  Set Etypes, so that they can be picked up by New_Occurrence_Of
 
@@ -982,6 +993,9 @@ package body Exp_Fixd is
       --  to call the runtime routine to compute the quotient and remainder.
 
       else
+         Mutate_Ekind (Qnn, E_Variable);
+         Mutate_Ekind (Rnn, E_Variable);
+
          Rnd := Boolean_Literals (Rounded_Result_Set (N));
 
          Code := New_List (
index 494f1f8f004fc91fded905a480b15d154844b9c8..4ede1a4031a1c968f3a94b2371c7299b70c849ba 100644 (file)
@@ -4077,6 +4077,7 @@ package body Inline is
             --  Replace call with temporary and create its declaration
 
             Temp := Make_Temporary (Loc, 'C');
+            Mutate_Ekind (Temp, E_Constant);
             Set_Is_Internal (Temp);
 
             --  For the unconstrained case, the generated temporary has the