From: Harald Anlauf Date: Thu, 2 Jul 2020 18:48:16 +0000 (+0200) Subject: PR fortran/93423 - ICE on invalid with argument list for module procedure X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b88744905a46be44ffa3c57d46080f601ae832b8;p=gcc.git 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. --- diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 1952b53d821..5cc9f72e55c 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -15918,7 +15918,7 @@ resolve_symbol (gfc_symbol *sym) 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++; } } diff --git a/gcc/testsuite/gfortran.dg/pr93423.f90 b/gcc/testsuite/gfortran.dg/pr93423.f90 new file mode 100644 index 00000000000..fed5914daba --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr93423.f90 @@ -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