From 84e33251331478d41b1c05768ccf0d060ce5b242 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Wed, 11 Sep 2019 18:27:17 +0000 Subject: [PATCH] re PR fortran/91642 (ICE: Bad IO basetype (transfer_expr, at fortran/trans-io.c:2507)) 2019-09-11 Steven G. Kargl PR fortran/91642 * io.c (gfc_match_inquire): null() cannot be in an iolength inquire list. 2019-09-11 Steven G. Kargl PR fortran/91642 * gfortran.dg/pr91642.f90: New test. From-SVN: r275655 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/io.c | 11 +++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr91642.f90 | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr91642.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9c787f73bfd..b3770ce0454 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-09-11 Steven G. Kargl + + PR fortran/91642 + * io.c (gfc_match_inquire): null() cannot be in an iolength inquire + list. + 2019-09-05 Harald Anlauf PR fortran/91496 diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index d57b7471da2..bb645602a2c 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index aa3127cf3fd..6c316ee7f93 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-09-11 Steven G. Kargl + + PR fortran/91642 + * gfortran.dg/pr91642.f90: New test. + 2019-09-11 Jakub Jelinek PR rtl-optimization/89435 diff --git a/gcc/testsuite/gfortran.dg/pr91642.f90 b/gcc/testsuite/gfortran.dg/pr91642.f90 new file mode 100644 index 00000000000..b3cc40f50ec --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91642.f90 @@ -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) 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 2 +end -- 2.30.2