diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-10-02 17:04:57 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-10-02 17:04:57 +0000 |
commit | 939e9f696b843f2c6472ac0fd541399e2b3faa7e (patch) | |
tree | 6bcf774400741a997958500188cbca00b1bb7529 /gcc/fortran/io.c | |
parent | 8b4e5e711d9b2b979dcee445498a7f570ea49e2e (diff) | |
download | gcc-939e9f696b843f2c6472ac0fd541399e2b3faa7e.zip gcc-939e9f696b843f2c6472ac0fd541399e2b3faa7e.tar.gz gcc-939e9f696b843f2c6472ac0fd541399e2b3faa7e.tar.bz2 |
re PR fortran/91942 (ICE in match_vtag, at fortran/io.c:1485)
2019-10-02 Steven G. Kargl <kargl@gcc.gnu.org>
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 <kargl@gcc.gnu.org>
PR fortran/91942
* gfortran.dg/pr91587.f90: Update dg-error regex.
* gfortran.dg/pr91942.f90: New test.
From-SVN: r276472
Diffstat (limited to 'gcc/fortran/io.c')
-rw-r--r-- | gcc/fortran/io.c | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 9ae06b1f..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); |