PR fortran/93423 - ICE on invalid with argument list for module procedure

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.
This commit is contained in:
Harald Anlauf 2020-07-02 20:48:16 +02:00
parent d9fb6f2b4f
commit b88744905a
2 changed files with 22 additions and 1 deletions

View File

@ -15918,7 +15918,7 @@ resolve_symbol (gfc_symbol *sym)
if (formal) if (formal)
{ {
sym->formal_ns = formal->sym->ns; 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++; sym->formal_ns->refs++;
} }
} }

View File

@ -0,0 +1,21 @@
! { 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