https://gcc.gnu.org/g:5a8191d7fd64479756cce7063602b1dd34436d52

commit r16-1231-g5a8191d7fd64479756cce7063602b1dd34436d52
Author: Ronan Desplanques <desplanq...@adacore.com>
Date:   Wed Feb 26 11:22:45 2025 +0100

    ada: Set Ekind early for entities created in expansion
    
    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.

Diff:
---
 gcc/ada/contracts.adb |  1 +
 gcc/ada/exp_ch9.adb   |  1 +
 gcc/ada/exp_dist.adb  |  2 ++
 gcc/ada/exp_fixd.adb  | 14 ++++++++++++++
 gcc/ada/inline.adb    |  1 +
 5 files changed, 19 insertions(+)

diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb
index c0a57e6d0bae..fc48d7f97da6 100644
--- a/gcc/ada/contracts.adb
+++ b/gcc/ada/contracts.adb
@@ -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
diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
index ff5668e08c4c..9cfc6b536e92 100644
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -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));
diff --git a/gcc/ada/exp_dist.adb b/gcc/ada/exp_dist.adb
index 694fbe47daba..a351b9b8a8fb 100644
--- a/gcc/ada/exp_dist.adb
+++ b/gcc/ada/exp_dist.adb
@@ -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;
diff --git a/gcc/ada/exp_fixd.adb b/gcc/ada/exp_fixd.adb
index 03c7ca849158..8759099c193e 100644
--- a/gcc/ada/exp_fixd.adb
+++ b/gcc/ada/exp_fixd.adb
@@ -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 (
diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb
index 494f1f8f004f..4ede1a4031a1 100644
--- a/gcc/ada/inline.adb
+++ b/gcc/ada/inline.adb
@@ -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

Reply via email to