aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.c
diff options
context:
space:
mode:
authorJustin Squirek <squirek@adacore.com>2021-11-15 22:14:39 +0000
committerPierre-Marie de Rodat <derodat@adacore.com>2021-12-02 16:26:30 +0000
commit9e10b7002acb3ce6134a6343cba04691f8c2d8ff (patch)
treec6f0a4226088ca3ee2ba20686806c01233d48407 /gcc/ada/gcc-interface/decl.c
parent298339effd464b57635e6ca8ba7ff45f3a3ebd11 (diff)
downloadgcc-9e10b7002acb3ce6134a6343cba04691f8c2d8ff.zip
gcc-9e10b7002acb3ce6134a6343cba04691f8c2d8ff.tar.gz
gcc-9e10b7002acb3ce6134a6343cba04691f8c2d8ff.tar.bz2
[Ada] Invalid memory access on finalization of class-wide type
gcc/ada/ * gcc-interface/decl.c (gnat_to_gnu_entity): Skip normal processing for Itypes that are E_Class_Wide_Subtype with Equivalent_Type set.
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r--gcc/ada/gcc-interface/decl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 449463e..3d14b5f 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -335,11 +335,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
/* Since a use of an itype is a definition, process it as such if it is in
the main unit, except for E_Access_Subtype because it's actually a use
- of its base type, see below. */
+ of its base type, and for E_Class_Wide_Subtype with an Equivalent_Type
+ because it's actually a use of the latter type. */
if (!definition
&& is_type
&& Is_Itype (gnat_entity)
&& Ekind (gnat_entity) != E_Access_Subtype
+ && !(Ekind (gnat_entity) == E_Class_Wide_Subtype
+ && Present (Equivalent_Type (gnat_entity)))
&& !present_gnu_tree (gnat_entity)
&& In_Extended_Main_Code_Unit (gnat_entity))
{