gcc/fortran/ChangeLog:
PR fortran/108544
* resolve.cc (check_host_association): Extend host association check
so that it is not restricted to functions. Also prevent NULL pointer
dereference.
gcc/testsuite/ChangeLog:
PR fortran/108544
* gfortran.dg/pr108544.f90: New test.
* gfortran.dg/pr96102b.f90: New test.
gfc_find_symbol (e->symtree->name, gfc_current_ns, 1, &sym);
if (sym && old_sym != sym
- && sym->ts.type == old_sym->ts.type
&& sym->attr.flavor == FL_PROCEDURE
&& sym->attr.contained)
{
return false;
}
+ if (ref == NULL)
+ return false;
+
gcc_assert (ref->type == REF_ARRAY);
/* Grab the start expressions from the array ref and
--- /dev/null
+! { dg-do compile }
+! PR fortran/108544 - ICE in check_host_association
+! Contributed by G.Steinmetz
+
+module m
+contains
+ subroutine s
+ select type (s => 1) ! { dg-error "Selector shall be polymorphic" }
+ end select
+ end
+end
--- /dev/null
+! { dg-do compile }
+!
+! PR fortran/108544 - host association
+! Variation of testcase pr96102.f90 using subroutines instead of functions
+
+module m
+ type mytype
+ integer :: i
+ end type
+ type(mytype) :: d = mytype (42) ! { dg-error "is host associated" }
+ integer :: n = 2 ! { dg-error "is host associated" }
+contains
+ subroutine s
+ if ( n /= 0 ) stop 1 ! { dg-error "internal procedure of the same name" }
+ if ( d%i /= 0 ) stop 2 ! { dg-error "internal procedure of the same name" }
+ contains
+ subroutine n()
+ end
+ subroutine d()
+ end
+ end
+end
+
+! { dg-prune-output "Operands of comparison operator" }