When recovering from an error, a NULL pointer dereference could occur.
Check for that situation and punt.
gcc/fortran/
PR fortran/93423
* resolve.c (resolve_symbol): Avoid NULL pointer dereference.
if (formal)
{
sym->formal_ns = formal->sym->ns;
- if (sym->ns != formal->sym->ns)
+ if (sym->formal_ns && sym->ns != formal->sym->ns)
sym->formal_ns->refs++;
}
}
--- /dev/null
+! { dg-do compile }
+! PR fortran/93423 - ICE on invalid with argument list for module procedure
+
+module t
+ type :: b
+ contains
+ procedure :: p => bp
+ end type b
+ interface
+ module function bp(s)
+ class(b), intent(inout) :: s
+ integer, pointer :: bp
+ end function
+ end interface
+end module t
+
+submodule (t) ts
+contains
+ module procedure bp(s) ! { dg-error "must be in a generic module interface" }
+ end procedure bp ! { dg-error "Expecting END SUBMODULE statement" }
+end submodule ts