From: Steven G. Kargl Date: Wed, 2 Oct 2019 17:04:57 +0000 (+0000) Subject: re PR fortran/91942 (ICE in match_vtag, at fortran/io.c:1485) X-Git-Tag: upstream/12.2.0~21446 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=939e9f696b843f2c6472ac0fd541399e2b3faa7e;p=platform%2Fupstream%2Fgcc.git re PR fortran/91942 (ICE in match_vtag, at fortran/io.c:1485) 2019-10-02 Steven G. Kargl PR fortran/91942 * io.c (match_vtag): Check for non-NULL result->symtree. (match_out_tag): Check for invalid constant due to inquiry parameter. (match_filepos): Instead of a syntax error, go to cleanup to get better error messages. 2019-10-02 Steven G. Kargl PR fortran/91942 * gfortran.dg/pr91587.f90: Update dg-error regex. * gfortran.dg/pr91942.f90: New test. From-SVN: r276472 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f225ff2..476973d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,13 @@ 2019-10-02 Steven G. Kargl + PR fortran/91942 + * io.c (match_vtag): Check for non-NULL result->symtree. + (match_out_tag): Check for invalid constant due to inquiry parameter. + (match_filepos): Instead of a syntax error, go to cleanup to get better + error messages. + +2019-10-02 Steven G. Kargl + PR fortran/91943 * match.c (gfc_match_call): BOZ cannot be an actual argument in a subroutine reference. diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 9ae06b1..b969a1a 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -1482,24 +1482,29 @@ match_vtag (const io_tag *tag, gfc_expr **v) return MATCH_ERROR; } - if (result->symtree->n.sym->attr.intent == INTENT_IN) + if (result->symtree) { - gfc_error ("Variable %s cannot be INTENT(IN) at %C", tag->name); - gfc_free_expr (result); - return MATCH_ERROR; - } + bool impure; - bool impure = gfc_impure_variable (result->symtree->n.sym); - if (impure && gfc_pure (NULL)) - { - gfc_error ("Variable %s cannot be assigned in PURE procedure at %C", - tag->name); - gfc_free_expr (result); - return MATCH_ERROR; - } + if (result->symtree->n.sym->attr.intent == INTENT_IN) + { + gfc_error ("Variable %s cannot be INTENT(IN) at %C", tag->name); + gfc_free_expr (result); + return MATCH_ERROR; + } + + impure = gfc_impure_variable (result->symtree->n.sym); + if (impure && gfc_pure (NULL)) + { + gfc_error ("Variable %s cannot be assigned in PURE procedure at %C", + tag->name); + gfc_free_expr (result); + return MATCH_ERROR; + } - if (impure) - gfc_unset_implicit_pure (NULL); + if (impure) + gfc_unset_implicit_pure (NULL); + } *v = result; return MATCH_YES; @@ -1515,7 +1520,16 @@ match_out_tag (const io_tag *tag, gfc_expr **result) m = match_vtag (tag, result); if (m == MATCH_YES) - gfc_check_do_variable ((*result)->symtree); + { + if ((*result)->symtree) + gfc_check_do_variable ((*result)->symtree); + + if ((*result)->expr_type == EXPR_CONSTANT) + { + gfc_error ("Expecting a variable at %L", &(*result)->where); + return MATCH_ERROR; + } + } return m; } @@ -2845,7 +2859,7 @@ match_filepos (gfc_statement st, gfc_exec_op op) m = match_file_element (fp); if (m == MATCH_ERROR) - goto syntax; + goto cleanup; if (m == MATCH_NO) { m = gfc_match_expr (&fp->unit); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3256a02..88e4d32 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2019-10-02 Steven G. Kargl + PR fortran/91942 + * gfortran.dg/pr91587.f90: Update dg-error regex. + * gfortran.dg/pr91942.f90: New test. + +2019-10-02 Steven G. Kargl + PR fortran/91943 gfortran.dg/pr91943.f90 diff --git a/gcc/testsuite/gfortran.dg/pr91587.f90 b/gcc/testsuite/gfortran.dg/pr91587.f90 index c07735d..c304be1 100644 --- a/gcc/testsuite/gfortran.dg/pr91587.f90 +++ b/gcc/testsuite/gfortran.dg/pr91587.f90 @@ -2,9 +2,9 @@ ! PR fortran/91587 ! Code contributed by Gerhard Steinmetz program p - backspace(err=!) ! { dg-error "Syntax error in" } - flush(err=!) ! { dg-error "Syntax error in" } - rewind(err=!) ! { dg-error "Syntax error in" } + backspace(err=!) ! { dg-error "Invalid value for" } + flush(err=!) ! { dg-error "Invalid value for" } + rewind(err=!) ! { dg-error "Invalid value for" } end subroutine bar ! An other matcher runs, and gives a different error. diff --git a/gcc/testsuite/gfortran.dg/pr91942.f90 b/gcc/testsuite/gfortran.dg/pr91942.f90 new file mode 100644 index 0000000..cd237d3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91942.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! PR fortran/91942 +! Code contributed by Gerhard Steinmetz +program p + integer :: i + backspace (iostat=i%kind) ! { dg-error "Expecting a variable at" } + endfile (iostat=i%kind) ! { dg-error "Expecting END PROGRAM" } + flush (iostat=i%kind) ! { dg-error "Expecting a variable at" } + rewind (iostat=i%kind) ! { dg-error "Expecting a variable at" } +end