aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/io.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-11-20 10:06:42 +0000
committerJakub Jelinek <jakub@redhat.com>2019-11-20 10:06:42 +0000
commit9f3d9a570819cb522d2ff3e36c04f742c3870537 (patch)
tree8531ed8dcb46358788a528f026095e0bee664ef7 /gcc/fortran/io.c
parent522f3b741606e806f058efcdf6474f2cdcc56718 (diff)
parentc59fa98026086e9886257fce39d27dcfd16cc4f6 (diff)
svn merge -r274943:278492 svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-9-branchredhat/gcc-9-branch
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/redhat/gcc-9-branch@278493 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/io.c')
-rw-r--r--gcc/fortran/io.c72
1 files changed, 53 insertions, 19 deletions
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
index 9828897852a..b9a29a0f932 100644
--- a/gcc/fortran/io.c
+++ b/gcc/fortran/io.c
@@ -1441,24 +1441,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;
+ }
- if (impure)
- gfc_unset_implicit_pure (NULL);
+ 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);
+ }
*v = result;
return MATCH_YES;
@@ -1474,7 +1479,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;
}
@@ -2804,7 +2818,7 @@ match_filepos (gfc_statement st, gfc_exec_op op)
m = match_file_element (fp);
if (m == MATCH_ERROR)
- goto done;
+ goto cleanup;
if (m == MATCH_NO)
{
m = gfc_match_expr (&fp->unit);
@@ -3608,7 +3622,17 @@ match_io_element (io_kind k, gfc_code **cpp)
{
m = gfc_match_variable (&expr, 0);
if (m == MATCH_NO)
- gfc_error ("Expected variable in READ statement at %C");
+ {
+ gfc_error ("Expecting variable in READ statement at %C");
+ m = MATCH_ERROR;
+ }
+
+ if (m == MATCH_YES && expr->expr_type == EXPR_CONSTANT)
+ {
+ gfc_error ("Expecting variable or io-implied-do in READ statement "
+ "at %L", &expr->where);
+ m = MATCH_ERROR;
+ }
if (m == MATCH_YES
&& expr->expr_type == EXPR_VARIABLE
@@ -3618,7 +3642,6 @@ match_io_element (io_kind k, gfc_code **cpp)
&expr->where);
m = MATCH_ERROR;
}
-
}
else
{
@@ -4583,6 +4606,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;