diff options
| author | Bob Duff <duff@adacore.com> | 2023-01-08 18:22:17 -0500 |
|---|---|---|
| committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-15 11:36:42 +0200 |
| commit | d2a1dcf72f793d671512bd5638d5b66eb19e8ca6 (patch) | |
| tree | 5ab875c75a755fefd8cc712048ccb8f91d2ba549 /gcc/ada/sem_ch3.adb | |
| parent | 0ca7fcf5635bdd363a5a18e7cf5828d87b5aac55 (diff) | |
| download | gcc-d2a1dcf72f793d671512bd5638d5b66eb19e8ca6.zip gcc-d2a1dcf72f793d671512bd5638d5b66eb19e8ca6.tar.gz gcc-d2a1dcf72f793d671512bd5638d5b66eb19e8ca6.tar.bz2 | |
ada: Clean up vanishing entity fields
Fix all the failures caused by enabling Check_Vanishing_Fields on
entities in all cases except the case of converting to or from E_Void.
But leave Check_Vanishing_Fields disabled by default (controlled by
-gnatd_v flag), because it might be too slow even for assertions-on
mode, and we should deal with the E_Void cases eventually.
The failures are fixed either by adding calls to Reinit_Field_To_Zero,
or by changing which entities have which fields.
Note that in a series of Reinit_Field_To_Zero calls, the optional
Old_Ekind parameter is only useful on the first such call.
gcc/ada/
* atree.adb
(Check_Vanishing_Fields): Disable the check for "root/base type
only" fields. This is a bug fix -- if we're checking some subtype
S, we don't want to reach over to the root or base type and
Reinit_Field_To_Zero of that, thus modifying the field for lots of
subtypes other than S. Disable in the to/from E_Void cases. Misc
cleanup.
* gen_il-gen-gen_entities.adb: Define First_Entity, Last_Entity,
and Stored_Constraint for all type entities, because there are too
many cases where Reinit_Field_To_Zero would otherwise be needed.
In any case, it seems cleaner to have First_Entity and Last_Entity
defined in the same entity kinds.
* einfo.ads:
(First_Entity, Last_Entity, Stored_Constraint): Update comments to
reflect gen_il-gen-gen_entities.adb changes.
(Lit_Hash): Add missing "[root type only]" comment.
* exp_ch5.adb: Add Reinit_Field_To_Zero calls for vanishing
fields.
* sem_ch10.adb: Likewise.
* sem_ch6.adb: Likewise.
* sem_ch7.adb: Likewise.
* sem_ch8.adb: Likewise.
* sem_ch3.adb: Likewise. Also remove now-unnecessary
Reinit_Field_To_Zero calls.
Diffstat (limited to 'gcc/ada/sem_ch3.adb')
| -rw-r--r-- | gcc/ada/sem_ch3.adb | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 299ea6e..66013ca 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -6462,13 +6462,6 @@ package body Sem_Ch3 is end if; if Nkind (Def) = N_Constrained_Array_Definition then - - if Ekind (T) in Incomplete_Or_Private_Kind then - Reinit_Field_To_Zero (T, F_Stored_Constraint); - else - pragma Assert (Ekind (T) = E_Void); - end if; - -- Establish Implicit_Base as unconstrained base type Implicit_Base := Create_Itype (E_Array_Type, P, Related_Id, 'B'); @@ -6509,13 +6502,6 @@ package body Sem_Ch3 is -- Unconstrained array case else pragma Assert (Nkind (Def) = N_Unconstrained_Array_Definition); - - if Ekind (T) in Incomplete_Or_Private_Kind then - Reinit_Field_To_Zero (T, F_Stored_Constraint); - else - pragma Assert (Ekind (T) = E_Void); - end if; - Mutate_Ekind (T, E_Array_Type); Reinit_Size_Align (T); Set_Etype (T, T); @@ -10030,9 +10016,9 @@ package body Sem_Ch3 is -- Set common attributes if Ekind (Derived_Type) in Incomplete_Or_Private_Kind - and then Ekind (Parent_Base) in Modular_Integer_Kind | Array_Kind + and then Ekind (Parent_Base) in Elementary_Kind then - Reinit_Field_To_Zero (Derived_Type, F_Stored_Constraint); + Reinit_Field_To_Zero (Derived_Type, F_Discriminant_Constraint); end if; Set_Scope (Derived_Type, Current_Scope); @@ -17367,8 +17353,8 @@ package body Sem_Ch3 is Error_Msg_N ("type cannot be used in its own definition", Indic); end if; - Mutate_Ekind (T, Ekind (Parent_Type)); - Set_Etype (T, Any_Type); + Mutate_Ekind (T, Ekind (Parent_Type)); + Set_Etype (T, Any_Type); Set_Scalar_Range (T, Scalar_Range (Any_Type)); -- Initialize the list of primitive operations to an empty list, @@ -19726,6 +19712,9 @@ package body Sem_Ch3 is if Ekind (CW_Type) in E_Task_Type | E_Protected_Type then Reinit_Field_To_Zero (CW_Type, F_SPARK_Aux_Pragma_Inherited); end if; + + elsif Ekind (CW_Type) = E_Record_Type then + Reinit_Field_To_Zero (CW_Type, F_Corresponding_Concurrent_Type); end if; Mutate_Ekind (CW_Type, E_Class_Wide_Type); @@ -20112,10 +20101,6 @@ package body Sem_Ch3 is Analyze_And_Resolve (Mod_Expr, Any_Integer); - if Ekind (T) in Incomplete_Or_Private_Kind then - Reinit_Field_To_Zero (T, F_Stored_Constraint); - end if; - Set_Etype (T, T); Mutate_Ekind (T, E_Modular_Integer_Type); Reinit_Alignment (T); |
