Hi, the simple patch below rejects arrays as do loop index variable before another (confusing) error message is emitted. Two new testcases derived from the PR, plus adaption of one testcase that relies on the old error message.
Whoever wants to take it... Harald 2016-02-08 Harald Anlauf <anl...@gmx.de> PR fortran/56007 * match.c (gfc_match_iterator): Add diagnostic for array variable as do loop index. Index: gcc/fortran/match.c =================================================================== --- gcc/fortran/match.c (revision 233203) +++ gcc/fortran/match.c (working copy) @@ -877,6 +877,12 @@ if (m != MATCH_YES) return MATCH_NO; + if (var->symtree->n.sym->attr.dimension) + { + gfc_error ("Loop variable at %C cannot be an array"); + goto cleanup; + } + /* F2008, C617 & C565. */ if (var->symtree->n.sym->attr.codimension) { 2016-02-08 Harald Anlauf <anl...@gmx.de> PR fortran/56007 * gfortran.dg/coarray_8.f90: Adjust error message. * gfortran.dg/pr56007.f90: New test. * gfortran.dg/pr56007.f: New test. Index: gcc/testsuite/gfortran.dg/coarray_8.f90 =================================================================== --- gcc/testsuite/gfortran.dg/coarray_8.f90 (revision 233203) +++ gcc/testsuite/gfortran.dg/coarray_8.f90 (working copy) @@ -146,7 +146,7 @@ subroutine tfgh() integer :: i(2) DATA i/(i, i=1,2)/ ! { dg-error "Expected PARAMETER symbol" } - do i = 1, 5 ! { dg-error "cannot be a sub-component" } + do i = 1, 5 ! { dg-error "cannot be an array" } end do ! { dg-error "Expecting END SUBROUTINE" } end subroutine tfgh Index: gcc/testsuite/gfortran.dg/pr56007.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr56007.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/pr56007.f90 (revision 0) @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR fortran/56007 +! Based on testcase by Tobias Schlüter + + integer iw1(90), doiw1(90) + do iw1=1,2 ! { dg-error "cannot be an array" } + end do ! { dg-error "Expecting END PROGRAM statement" } + do iw1(1)=1 ! { dg-error "Unclassifiable statement" } + do iw1=1 ! { dg-error "cannot be an array" } + end do ! { dg-error "Expecting END PROGRAM statement" } +END program Index: gcc/testsuite/gfortran.dg/pr56007.f =================================================================== --- gcc/testsuite/gfortran.dg/pr56007.f (revision 0) +++ gcc/testsuite/gfortran.dg/pr56007.f (revision 0) @@ -0,0 +1,10 @@ +! { dg-do compile } +! PR fortran/56007 +! Based on testcase by Tobias Schlüter + + integer iw1(90), doiw1(90) + do iw1(1)=1 + do iw1=1 + do iw1=1,2 ! { dg-error "cannot be an array" } + end do ! { dg-error "Expecting END PROGRAM statement" } + END