]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/91642 (ICE: Bad IO basetype (transfer_expr, at fortran/trans-io.c:2507))
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 14 Sep 2019 16:21:33 +0000 (16:21 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 14 Sep 2019 16:21:33 +0000 (16:21 +0000)
2019-09-14  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/91642
* io.c (gfc_match_inquire): null() cannot be in an iolength inquire
list.

2019-09-14  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/91642
* gfortran.dg/pr91642.f90: New test.

From-SVN: r275714

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

index d718706e6e4cc20dd4e41ab1085594313995de01..3ff20a25f6f73e0dae8fd568efe29d6be98461cd 100644 (file)
@@ -1,3 +1,9 @@
+2019-09-14  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/91642
+       * io.c (gfc_match_inquire): null() cannot be in an iolength inquire
+       list.
+
 2019-09-07  Paul Thomas  <pault@gcc.gnu.org>
 
        Backport from mainline
index b3d8696c030af416ba3ae78104c2221212c33cd9..9bee9094e7f8345ffda5c1efa445c38a9732a3a0 100644 (file)
@@ -4583,6 +4583,17 @@ gfc_match_inquire (void)
       if (m == MATCH_NO)
        goto syntax;
 
+      for (gfc_code *c = code; c; c = c->next)
+       if (c->expr1 && c->expr1->expr_type == EXPR_FUNCTION
+           && c->expr1->symtree && c->expr1->symtree->n.sym->attr.function
+           && !c->expr1->symtree->n.sym->attr.external
+           && strcmp (c->expr1->symtree->name, "null") == 0)
+         {
+           gfc_error ("NULL() near %L cannot appear in INQUIRE statement",
+                      &c->expr1->where);
+           goto cleanup;
+         }
+
       new_st.op = EXEC_IOLENGTH;
       new_st.expr1 = inquire->iolength;
       new_st.ext.inquire = inquire;
index 9a424e463e46be9b2c35746bea4c5ad605ee856f..f5d620a9ce0b4d37b9b99f8e1df9252269456197 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-14  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/91642
+       * gfortran.dg/pr91642.f90: New test.
+
 2019-09-11  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.target/sparc/20161111-1.c: XFAIL redundant zero-extension test.
diff --git a/gcc/testsuite/gfortran.dg/pr91642.f90 b/gcc/testsuite/gfortran.dg/pr91642.f90
new file mode 100644 (file)
index 0000000..8c41cd2
--- /dev/null
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! PR fortran/91642
+! Code contributed by Gerhard Steinmetz
+program p
+   integer i
+   integer :: iol
+   integer, external :: null
+   i = 0
+   inquire (iolength=iol) i, null()
+   if (iol == 4) stop 1
+end
+
+subroutine q
+   integer i
+   integer :: iol
+   i = 0
+   inquire (iolength=iol) i, null() ! { dg-error "cannot appear in INQUIRE" }
+   if (iol == 4) stop 1
+end