This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/56007] Remarkably bad error message with DO array=1,2
- From: "anlauf at gmx dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 05 Feb 2016 22:04:05 +0000
- Subject: [Bug fortran/56007] Remarkably bad error message with DO array=1,2
- Auto-submitted: auto-generated
- References: <bug-56007-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56007
--- Comment #4 from Harald Anlauf <anlauf at gmx dot de> ---
(In reply to Tobias SchlÃter from comment #3)
> Just for the fun of it, another confusing way this error message appears:
> $ cat t3.f90
> character c(5)
>
> do c=2,3
> end do
>
> END
> $ gfortran t3.f90
> t3.f90:3.4:
>
> do c=2,3
> 1
> Error: Loop variable at (1) cannot be a sub-component
> t3.f90:4.3:
>
> end do
> 1
> Error: Expecting END PROGRAM statement at (1)
> $
>
> Of course this behavior is expected once you look at the code.
The above error message is somewhat improved with the following patch:
Index: gcc/fortran/match.c
===================================================================
--- gcc/fortran/match.c (revision 232904)
+++ gcc/fortran/match.c (working copy)
@@ -877,6 +877,12 @@
if (m != MATCH_YES)
return MATCH_NO;
+ if (var->ts.type == BT_CHARACTER)
+ {
+ gfc_error ("Loop variable at %C cannot be of type CHARACTER");
+ goto cleanup;
+ }
+
/* F2008, C617 & C565. */
if (var->symtree->n.sym->attr.codimension)
{
I now get:
t3.f90:3:4:
do c=2,3
1
Error: Loop variable at (1) cannot be of type CHARACTER
t3.f90:4:3:
end do
1
Error: Expecting END PROGRAM statement at (1)