+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/91943
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;
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;
}
m = match_file_element (fp);
if (m == MATCH_ERROR)
- goto syntax;
+ goto cleanup;
if (m == MATCH_NO)
{
m = gfc_match_expr (&fp->unit);
! 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.
--- /dev/null
+! { 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