re PR fortran/56007 (Remarkably bad error message with DO array=1,2)

2016-02-28  Harald Anlauf <anlauf@gmx.de>
	    Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/56007
	* match.c (gfc_match_iterator): Add diagnostic for array variable
	as do loop index.

	* gfortran.dg/coarray_8.f90: Adjust error message.
	* gfortran.dg/pr56007.f90: New test.
	* gfortran.dg/pr56007.f: New test.

Co-Authored-By: Jerry DeLisle <jvdelisle@gcc.gnu.org>

From-SVN: r233795
This commit is contained in:
Harald Anlauf 2016-02-28 19:07:42 +00:00 committed by Jerry DeLisle
parent cdc1a2c805
commit b2fd537394
6 changed files with 43 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2016-02-28 Harald Anlauf <anlauf@gmx.de>
Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/56007
* match.c (gfc_match_iterator): Add diagnostic for array variable
as do loop index.
2016-02-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Steven G. Kargl <kargl@gcc.gnu.org>

View File

@ -877,6 +877,12 @@ gfc_match_iterator (gfc_iterator *iter, int init_flag)
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)
{

View File

@ -1,3 +1,11 @@
2016-02-28 Harald Anlauf <anlauf@gmx.de>
Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/56007
* gfortran.dg/coarray_8.f90: Adjust error message.
* gfortran.dg/pr56007.f90: New test.
* gfortran.dg/pr56007.f: New test.
2016-02-28 H.J. Lu <hongjiu.lu@intel.com>
PR tree-optimization/69989

View File

@ -146,7 +146,7 @@ end module mmm4
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

View File

@ -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

View File

@ -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