[PATCH, fortran] PR84957 - [8 Regression] ICE in gfc_sym_type, at fortran/trans-types.c:2255
Harald Anlauf
anlauf@gmx.de
Wed Mar 21 20:40:00 GMT 2018
The attached obvious patch fixes a NULL pointer dereference.
Testcase derived from report. Changelogs below.
Regtested on i686-pc-linux-gnu.
Whoever reviews this, please feel free to commit.
Thanks,
Harald
2018-03-21 Harald Anlauf <anlauf@gmx.de>
PR fortran/84957
* trans-types.c (gfc_sym_type): Do not dereference NULL pointer.
2018-03-21 Harald Anlauf <anlauf@gmx.de>
PR fortran/84957
* gfortran.dg/pr84957.f90: New test.
-------------- next part --------------
Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c (revision 258740)
+++ gcc/fortran/trans-types.c (working copy)
@@ -2252,6 +2252,7 @@
&& sym->ts.type == BT_CHARACTER
&& sym->ts.u.cl->backend_decl == NULL_TREE
&& sym->ns->proc_name
+ && sym->ns->proc_name->ts.u.cl
&& sym->ns->proc_name->ts.u.cl->backend_decl != NULL_TREE)
sym->ts.u.cl->backend_decl = sym->ns->proc_name->ts.u.cl->backend_decl;
-------------- next part --------------
Index: gcc/testsuite/gfortran.dg/pr84957.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr84957.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/pr84957.f90 (revision 0)
@@ -0,0 +1,17 @@
+! { dg-do compile }
+! PR 84957
+!
+! Testcase derived from PR by G. Steinmetz <gscfq@t-online.de>
+!
+function f() result(u)
+ entry g() result(v)
+contains
+ function v(x) result(z)
+ character :: x(2)
+ character(sum(len_trim(x))) :: z
+ end function v
+ function u(x) result(z)
+ character :: x(2)
+ character(sum(len_trim(x))) :: z
+ end function u
+end function f
More information about the Fortran
mailing list