From b2fd5373948c2d030783e74df4a9b52174ac30fb Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sun, 28 Feb 2016 19:07:42 +0000 Subject: [PATCH] re PR fortran/56007 (Remarkably bad error message with DO array=1,2) 2016-02-28 Harald Anlauf Jerry DeLisle 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 From-SVN: r233795 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/match.c | 6 ++++++ gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/gfortran.dg/coarray_8.f90 | 2 +- gcc/testsuite/gfortran.dg/pr56007.f | 10 ++++++++++ gcc/testsuite/gfortran.dg/pr56007.f90 | 11 +++++++++++ 6 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr56007.f create mode 100644 gcc/testsuite/gfortran.dg/pr56007.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c460a7eb70a8..56f2bdde04a7 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2016-02-28 Harald Anlauf + Jerry DeLisle + + PR fortran/56007 + * match.c (gfc_match_iterator): Add diagnostic for array variable + as do loop index. + 2016-02-27 Jerry DeLisle Steven G. Kargl diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index ef41781105b0..2490f85626e7 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -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) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e7ad0db2c29f..6dcb33134523 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2016-02-28 Harald Anlauf + Jerry DeLisle + + 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 PR tree-optimization/69989 diff --git a/gcc/testsuite/gfortran.dg/coarray_8.f90 b/gcc/testsuite/gfortran.dg/coarray_8.f90 index 91d6e9a57abc..db6eb6c2e2d8 100644 --- a/gcc/testsuite/gfortran.dg/coarray_8.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_8.f90 @@ -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 diff --git a/gcc/testsuite/gfortran.dg/pr56007.f b/gcc/testsuite/gfortran.dg/pr56007.f new file mode 100644 index 000000000000..644f28efe625 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr56007.f @@ -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 diff --git a/gcc/testsuite/gfortran.dg/pr56007.f90 b/gcc/testsuite/gfortran.dg/pr56007.f90 new file mode 100644 index 000000000000..b91baf5b4e7c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr56007.f90 @@ -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