+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
&& 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;
--- /dev/null
+! { 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