re PR fortran/78592 (ICE in gfc_find_specific_dtio_proc, at fortran/interface.c:4939)
authorJanus Weil <janus@gcc.gnu.org>
Wed, 30 Nov 2016 09:50:04 +0000 (10:50 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Wed, 30 Nov 2016 09:50:04 +0000 (10:50 +0100)
2016-11-30  Janus Weil  <janus@gcc.gnu.org>

PR fortran/78592
* interface.c (gfc_find_specific_dtio_proc): Rearrange code to avoid
dereferencing a null pointer.

2016-11-30  Janus Weil  <janus@gcc.gnu.org>

PR fortran/78592
* gfortran.dg/dtio_18.f90: New test case.

From-SVN: r243005

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

index 840eb8f17b8e6c4fcc2a8fcae74f48fe7ea23b5d..3b4799abdaa1908a66e88c9c44ad3625aaa93a26 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-30  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/78592
+       * interface.c (gfc_find_specific_dtio_proc): Rearrange code to avoid
+       dereferencing a null pointer.
+
 2016-11-30  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/78573
index f5d3f7762ca098da9a7aea532b2f14377f489788..8afba84a697f5bc38fb66dfff0646edfffed05a6 100644 (file)
@@ -4933,15 +4933,15 @@ gfc_find_specific_dtio_proc (gfc_symbol *derived, bool write, bool formatted)
          && tb_io_st->n.sym
          && tb_io_st->n.sym->generic)
        {
-         gfc_interface *intr;
-         for (intr = tb_io_st->n.sym->generic; intr; intr = intr->next)
+         for (gfc_interface *intr = tb_io_st->n.sym->generic;
+              intr && intr->sym && intr->sym->formal;
+              intr = intr->next)
            {
              gfc_symbol *fsym = intr->sym->formal->sym;
-             if (intr->sym && intr->sym->formal
-                 && ((fsym->ts.type == BT_CLASS
-                     && CLASS_DATA (fsym)->ts.u.derived == extended)
-                   || (fsym->ts.type == BT_DERIVED
-                       && fsym->ts.u.derived == extended)))
+             if ((fsym->ts.type == BT_CLASS
+                  && CLASS_DATA (fsym)->ts.u.derived == extended)
+                 || (fsym->ts.type == BT_DERIVED
+                     && fsym->ts.u.derived == extended))
                {
                  dtio_sub = intr->sym;
                  break;
index 3074e6d05a584cd35db95cfde1a8b5cd968d7b8e..3ed27c4c2359d75d8dd3275398aeb76c9e840fae 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-30  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/78592
+       * gfortran.dg/dtio_18.f90: New test case.
+
 2016-11-30  Martin Liska  <mliska@suse.cz>
 
        PR sanitizer/78541
diff --git a/gcc/testsuite/gfortran.dg/dtio_18.f90 b/gcc/testsuite/gfortran.dg/dtio_18.f90
new file mode 100644 (file)
index 0000000..cc85ba5
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+!
+! PR 78592: [7 Regression] ICE in gfc_find_specific_dtio_proc, at fortran/interface.c:4939
+!
+! Contributed by Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de>
+
+program p
+   type t
+   end type
+   type(t) :: z
+   interface write(formatted)
+      module procedure wf    ! { dg-error "is neither function nor subroutine" }
+   end interface
+   print *, z
+end