PR69741: Bad error in formal with array scalar loop counters

Harald Anlauf anlauf@gmx.de
Fri Nov 18 23:34:00 GMT 2016


Hi,

the above PR is about poor reporting of invalid code.
I would like to bring this to attention again.

I'd suggest a slightly updated version of my patch in comment #7,
which generates less noise:

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c       (revision 242607)
+++ gcc/fortran/resolve.c       (working copy)
@@ -9668,6 +9668,13 @@
      and stride. The FORALL index can not appear in start, end or
stride.  */
   for (fa = code->ext.forall_iterator; fa; fa = fa->next)
     {
+      if (fa->var->ref && fa->var->ref->type == REF_ARRAY)
+       {
+         gfc_error ("FORALL index-name at %L must be a scalar INTEGER",
+                    &fa->var->where);
+         continue;
+       }
+
       /* Check if any outer FORALL index name is the same as the current
         one.  */
       for (i = 0; i < nvar; i++)


With this patch, the reporter's testcase generates:


pr69741.f90:5:10:

   forall (ii(1)=1:3 , ii(2)=1:2)
          1
Error: FORALL index-name at (1) must be a scalar INTEGER
pr69741.f90:5:21:

   forall (ii(1)=1:3 , ii(2)=1:2)
                     1
Error: FORALL index-name at (1) must be a scalar INTEGER


Whoever wants to take this one.

Harald



More information about the Fortran mailing list