re PR fortran/85542 (ICE in check_inquiry, at fortran/expr.c:2426)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 11 May 2018 18:58:21 +0000 (18:58 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 11 May 2018 18:58:21 +0000 (18:58 +0000)
2018-05-11  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/85542
* expr.c (check_inquiry): Avoid NULL pointer dereference.

2018-05-11  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/85542
* gfortran.dg/pr85542.f90: New test.

From-SVN: r260182

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

index 03dbc626c925fbed1d398ab29c15c1e67e7ed856..e603fef4f3f4dbe35604aed9d42d8467ebc65ef4 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-11  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/85542
+       * expr.c (check_inquiry): Avoid NULL pointer dereference.
 2018-05-10  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/85687
index 9e113d26a59311c85f5356c5eed46860217431f4..e6ab82272f10270a4fd0dd7ab9bfeb5a33547b6b 100644 (file)
@@ -2422,7 +2422,7 @@ check_inquiry (gfc_expr *e, int not_restricted)
 
        /* Assumed character length will not reduce to a constant expression
           with LEN, as required by the standard.  */
-       if (i == 5 && not_restricted
+       if (i == 5 && not_restricted && ap->expr->symtree
            && ap->expr->symtree->n.sym->ts.type == BT_CHARACTER
            && (ap->expr->symtree->n.sym->ts.u.cl->length == NULL
                || ap->expr->symtree->n.sym->ts.deferred))
index 90bda6e95075a91c4e5828ca316f55ef164c1235..ddcba1fd220e719a28c665021cad98cb2b46798e 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-11  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/85542
+       * gfortran.dg/pr85542.f90: New test.
+
 2018-05-11  Martin Jambor  <mjambor@suse.cz>
 
        PR ipa/85655
diff --git a/gcc/testsuite/gfortran.dg/pr85542.f90 b/gcc/testsuite/gfortran.dg/pr85542.f90
new file mode 100644 (file)
index 0000000..f61d2c9
--- /dev/null
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/85542
+function f(x)
+   character(*), intent(in) :: x
+   character((len((x)))) :: f
+   f = x
+end