===================================================================
@@ -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 <anlauf@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.
===================================================================
@@ -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
===================================================================
@@ -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
===================================================================
@@ -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