From: Ronan Desplanques <[email protected]>
Setting the proper Ekind on object entities was once needed to catch
cases of premature usages. The introduction of Is_Self_Hidden changed
that, so this patch replaces the Mutate_Ekind calls in the natural
place.
gcc/ada/ChangeLog:
* sem_ch3.adb (Analyze_Object_Declaration): Call Mutate_Ekind earlier.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_ch3.adb | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 4161ce39fa3..59f1dd2d8d3 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -4364,6 +4364,12 @@ package body Sem_Ch3 is
-- Start of processing for Analyze_Object_Declaration
begin
+ if Constant_Present (N) then
+ Mutate_Ekind (Id, E_Constant);
+ else
+ Mutate_Ekind (Id, E_Variable);
+ end if;
+
-- There are three kinds of implicit types generated by an
-- object declaration:
@@ -4443,7 +4449,6 @@ package body Sem_Ch3 is
T := Find_Type_Of_Object (Object_Definition (N), N);
Set_Etype (Id, T);
- Mutate_Ekind (Id, E_Variable);
goto Leave;
end if;
@@ -4469,7 +4474,6 @@ package body Sem_Ch3 is
if Error_Posted (Id) then
Set_Etype (Id, T);
- Mutate_Ekind (Id, E_Variable);
goto Leave;
end if;
end if;
@@ -4758,7 +4762,6 @@ package body Sem_Ch3 is
and then In_Subrange_Of (Etype (Entity (E)), T)
then
Set_Is_Known_Valid (Id);
- Mutate_Ekind (Id, E_Constant);
Set_Actual_Subtype (Id, Etype (Entity (E)));
end if;
@@ -5007,12 +5010,6 @@ package body Sem_Ch3 is
-- for discriminants and are thus not indefinite.
elsif Is_Unchecked_Union (T) then
- if Constant_Present (N) or else Nkind (E) = N_Function_Call then
- Mutate_Ekind (Id, E_Constant);
- else
- Mutate_Ekind (Id, E_Variable);
- end if;
-
-- If the expression is an aggregate it contains the required
-- discriminant values but it has not been resolved yet, so do
-- it now, and treat it as the initial expression of an object
@@ -5073,10 +5070,8 @@ package body Sem_Ch3 is
-- "X : Integer := X;".
if Constant_Present (N) then
- Mutate_Ekind (Id, E_Constant);
Set_Is_True_Constant (Id);
else
- Mutate_Ekind (Id, E_Variable);
if Present (E) then
Set_Has_Initial_Value (Id);
end if;
@@ -5218,12 +5213,9 @@ package body Sem_Ch3 is
end if;
if Constant_Present (N) then
- Mutate_Ekind (Id, E_Constant);
Set_Is_True_Constant (Id);
else
- Mutate_Ekind (Id, E_Variable);
-
-- A variable is set as shared passive if it appears in a shared
-- passive package, and is at the outer level. This is not done for
-- entities generated during expansion, because those are always
--
2.43.0