public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [8/9/10/11 Regression] ICE on invalid with argument list for module procedure
@ 2020-06-25 20:57 Harald Anlauf
  2020-06-29 19:03 ` [PATCH] [8/9/10/11 Regression] PR fortran/93423 - " Harald Anlauf
  0 siblings, 1 reply; 2+ messages in thread
From: Harald Anlauf @ 2020-06-25 20:57 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 440 bytes --]

A simple situation where a NULL pointer dereference occurs during error recovery.

Regtested on x86_64-pc-linux-gnu.

OK for master / backports?

Thanks,
Harald


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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr93423.patch --]
[-- Type: text/x-patch, Size: 1169 bytes --]

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 6fa34caec54..c9447a24885 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -15901,7 +15901,7 @@ resolve_symbol (gfc_symbol *sym)
       if (formal)
 	{
 	  sym->formal_ns = formal->sym->ns;
-          if (sym->ns != formal->sym->ns)
+	  if (sym->ns != formal->sym->ns && sym->formal_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] 2+ messages in thread

* [PATCH] [8/9/10/11 Regression] PR fortran/93423 - ICE on invalid with argument list for module procedure
  2020-06-25 20:57 [PATCH] [8/9/10/11 Regression] ICE on invalid with argument list for module procedure Harald Anlauf
@ 2020-06-29 19:03 ` Harald Anlauf
  0 siblings, 0 replies; 2+ messages in thread
From: Harald Anlauf @ 2020-06-29 19:03 UTC (permalink / raw)
  To: Harald Anlauf; +Cc: fortran, gcc-patches

Early ping (might make it into 10.2).

> A simple situation where a NULL pointer dereference occurs during error recovery.
>
> Regtested on x86_64-pc-linux-gnu.
>
> OK for master / backports?
>
> Thanks,
> Harald
>
>
> 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.
>

Thanks,
Harald


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-29 19:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-25 20:57 [PATCH] [8/9/10/11 Regression] ICE on invalid with argument list for module procedure Harald Anlauf
2020-06-29 19:03 ` [PATCH] [8/9/10/11 Regression] PR fortran/93423 - " 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).