public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r8-10520] PR fortran/93423 - ICE on invalid with argument list for module procedure
@ 2020-09-19 18:42 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2020-09-19 18:42 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:aef149efb6d3fc97a38c74f7022124a6ba247746

commit r8-10520-gaef149efb6d3fc97a38c74f7022124a6ba247746
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Jul 2 20:48:16 2020 +0200

    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.
    
    (cherry picked from commit b88744905a46be44ffa3c57d46080f601ae832b8)

Diff:
---
 gcc/fortran/resolve.c                 |  2 +-
 gcc/testsuite/gfortran.dg/pr93423.f90 | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 462d07351ad..be63ce50bf2 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -15348,7 +15348,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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-19 18:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-19 18:42 [gcc r8-10520] PR fortran/93423 - ICE on invalid with argument list for module procedure Harald Anlauf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).