gcc/fortran/ChangeLog:
PR fortran/103606
* resolve.c (resolve_fl_procedure): Do not access CLASS components
before class container has been built.
gcc/testsuite/ChangeLog:
PR fortran/103606
* gfortran.dg/pr103606.f90: New test.
/* An elemental function is required to return a scalar 12.7.1 */
if (sym->attr.elemental && sym->attr.function
- && (sym->as || (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->as)))
+ && (sym->as || (sym->ts.type == BT_CLASS && sym->attr.class_ok
+ && CLASS_DATA (sym)->as)))
{
gfc_error ("ELEMENTAL function %qs at %L must have a scalar "
"result", sym->name, &sym->declared_at);
--- /dev/null
+! { dg-do compile }
+! PR fortran/103606 - ICE in resolve_fl_procedure
+! Contributed by G.Steinmetz
+
+program p
+ type t
+ end type
+contains
+ elemental function f() result(z) ! { dg-error "CLASS variable" }
+ class(t) :: z
+ end
+end