re PR fortran/87907 (ICE in resolve_contained_fntype, at fortran/resolve.c:587)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 19 Jun 2019 17:58:54 +0000 (17:58 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 19 Jun 2019 17:58:54 +0000 (17:58 +0000)
2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/87907
* resolve.c (resolve_contained_fntype): Do not dereference a NULL
pointer.

2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/87907
* gfortran.dg/pr87907.f90: New testcase.

From-SVN: r272480

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr87907.f90 [new file with mode: 0644]

index 289be5b6c81a7090d6dde1a514c9c7cd2ebd4e2b..62edba78f61c1534924a256661eb86860ab65c10 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/87907
+       * resolve.c (resolve_contained_fntype): Do not dereference a NULL
+       pointer.
+
 2019-06-19  Jim MacArthur  <jim.macarthur@codethink.co.uk>
            Mark Eggleston  <mark.eggleston@codethink.com>
        
index c565325ee2f4db129fd9d8d72548e82d6360b767..afa4e5c2ccfd0030cf26fc807ebdeeb65abd3c8e 100644 (file)
@@ -583,6 +583,9 @@ resolve_contained_fntype (gfc_symbol *sym, gfc_namespace *ns)
       || sym->attr.entry_master)
     return;
 
+  if (!sym->result)
+    return;
+
   /* Try to find out of what the return type is.  */
   if (sym->result->ts.type == BT_UNKNOWN && sym->result->ts.interface == NULL)
     {
index 4247335a6b102a81a12f33114aeec24d83fbead1..aa41d2aac3824b78638396d24740f4956ec2d2f3 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/87907
+       * gfortran.dg/pr87907.f90: New testcase.
+
 2019-06-19  Wilco Dijkstra  <wdijkstr@arm.com>
 
        PR middle-end/84521
diff --git a/gcc/testsuite/gfortran.dg/pr87907.f90 b/gcc/testsuite/gfortran.dg/pr87907.f90
new file mode 100644 (file)
index 0000000..0fe4e50
--- /dev/null
@@ -0,0 +1,23 @@
+! { dg-do compile }
+! PR fortran/pr87907
+! Original testcase contributed by Gerhard Stienmetz <gscfq at t-online dot de>
+module m
+   interface
+      module function g(x) result(z)
+         integer, intent(in) :: x
+         integer, allocatable :: z
+      end
+   end interface
+end
+
+submodule(m) m2
+   contains
+      subroutine g(x)   ! { dg-error "mismatch in argument" }
+      end
+end
+
+program p
+   use m                ! { dg-error "has a type" }
+   integer :: x = 3
+   call g(x)            ! { dg-error "which is not consistent with" }
+end