===================================================================
@@ -1248,8 +1248,22 @@ match_sym_complex_part (gfc_expr **result)
if (sym->attr.flavor != FL_PARAMETER)
{
- gfc_error ("Expected PARAMETER symbol in complex constant at %C");
- return MATCH_ERROR;
+ /* Give the matcher for implied do-loops a chance to run. This yields
+ a much saner error message for "write(*,*) (i, i=1, 6" where the
+ right parenthesis is missing. */
+ char c;
+ gfc_gobble_whitespace ();
+ c = gfc_peek_ascii_char ();
+ if (c == '=' || c == ',')
+ {
+ m = MATCH_NO;
+ }
+ else
+ {
+ gfc_error ("Expected PARAMETER symbol in complex constant at %C");
+ m = MATCH_ERROR;
+ }
+ return m;
}
if (!sym->value)
===================================================================
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/56667
+program error_message
+ implicit none
+ integer :: ir
+ write(*,*) ( ir, ir = 1,10 ! { dg-error "Expected a right parenthesis" }
+end program error_message
===================================================================
@@ -145,7 +145,7 @@ end module mmm4
subroutine tfgh()
integer :: i(2)
- DATA i/(i, i=1,2)/ ! { dg-error "Expected PARAMETER symbol" }
+ DATA i/(i, i=1,2)/ ! { dg-error "Syntax error in DATA" }
do i = 1, 5 ! { dg-error "cannot be an array" }
end do ! { dg-error "Expecting END SUBROUTINE" }
end subroutine tfgh
@@ -153,7 +153,7 @@ end subroutine tfgh
subroutine tfgh2()
integer, save :: x[*]
integer :: i(2)
- DATA i/(x, x=1,2)/ ! { dg-error "Expected PARAMETER symbol" }
+ DATA i/(x, x=1,2)/ ! { dg-error "Syntax error in DATA" }
do x = 1, 5 ! { dg-error "cannot be a coarray" }
end do ! { dg-error "Expecting END SUBROUTINE" }
end subroutine tfgh2