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.
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)
{
--- /dev/null
+! { 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