This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Committed] PR fortran/91642 -- NULL() cannot be in iolength inquire
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 11 Sep 2019 11:29:22 -0700
- Subject: [Committed] PR fortran/91642 -- NULL() cannot be in iolength inquire
- Reply-to: sgk at troutmask dot apl dot washington dot edu
Committed as obvious.
2019-09-11 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-11 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/91642
* gfortran.dg/pr91642.f90: New test.
--
Steve
Index: gcc/fortran/io.c
===================================================================
--- gcc/fortran/io.c (revision 275651)
+++ gcc/fortran/io.c (working copy)
@@ -4641,6 +4641,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: gcc/testsuite/gfortran.dg/pr91642.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr91642.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr91642.f90 (working copy)
@@ -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