From 5eb947601bdce59f2ff26694327ad173c51c2724 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sat, 20 Jun 2020 16:05:13 +0200 Subject: [PATCH] PR fortran/95587 - ICE in gfc_target_encode_expr, at fortran/target-memory.c:362 EQUIVALENCE objects are subject to constraints listed in the Fortran 2018 standard, section 8.10.1.1. These constraints are to be checked also for CLASS variables. gcc/fortran/ PR fortran/95587 * match.c (gfc_match_equivalence): Check constraints on EQUIVALENCE objects also for CLASS variables. --- gcc/fortran/match.c | 5 +++++ gcc/testsuite/gfortran.dg/pr95587.f90 | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr95587.f90 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 82d2b50..8063fca 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -5700,6 +5700,11 @@ gfc_match_equivalence (void) if (!gfc_add_in_equivalence (&sym->attr, sym->name, NULL)) goto cleanup; + if (sym->ts.type == BT_CLASS + && CLASS_DATA (sym) + && !gfc_add_in_equivalence (&CLASS_DATA (sym)->attr, + sym->name, NULL)) + goto cleanup; if (sym->attr.in_common) { diff --git a/gcc/testsuite/gfortran.dg/pr95587.f90 b/gcc/testsuite/gfortran.dg/pr95587.f90 new file mode 100644 index 0000000..a543fb9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr95587.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! PR fortran/95587 - ICE in gfc_target_encode_expr, at fortran/target-memory.c:362 + +program p + type t + end type t + class(*), allocatable :: x, y + class(t), allocatable :: u, v + class(t), pointer :: c, d + equivalence (x, y) ! { dg-error "conflicts with ALLOCATABLE" } + equivalence (u, v) ! { dg-error "conflicts with ALLOCATABLE" } + equivalence (c, d) ! { dg-error "conflicts with POINTER" } +end -- 2.7.4