Hi Steve, all,

On 11/19/16 02:18, Steve Kargl wrote:
> The error message is still not clear.  42 is a scalar integer.  Why
> not use the language in the standard?
> 
> C739 (R753) The index-name shall be a named scalar variable of type integer.

I had adjusted the error message to the same appearing in resolve.c
in another place, but you are absolutely right.  The attached patch
takes this into account.  The testcase is derived from the PR.

>>
>> Whoever wants to take this one.
>>
> 
> Ever thought about getting a commit bit and getting more involved
> in gfortran development?  I know 4 or 5 other gentlemen that would
> welcome you with open arms.
> 

Thanks.

During the stabilization phase of gcc-6 I tried to understand more
of the internals of gfortran.  However, most of the time I just got
lost.  I therefore decided to tackle a few simple things.

I don't have the resources to follow the development continuously,
especially when there are changes to ABI or module format.  So it
makes more sense for me to wait till the dust settles.

I'll try to find some time during the current stage 3 to check
whether there are regressions affecting my codes, but no promises.

Harald


2016-11-19  Harald Anlauf  <anl...@gmx.de>

        PR fortran/69741
        * resolve.c (gfc_resolve_forall): Check for non-scalar index
        variables.

2016-11-19  Harald Anlauf  <anl...@gmx.de>

        PR fortran/69741
        * gfortran.dg/forall_18.f90: New testcase.

Index: gfortran.dg/forall_18.f90
===================================================================
--- gfortran.dg/forall_18.f90   (revision 0)
+++ gfortran.dg/forall_18.f90   (revision 0)
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR 69741 - improve error message for non-scalar FORALL index variables
+!
+subroutine check
+  integer :: ii(2), i, j
+  real :: a(3,2)
+
+  forall (ii(1)=1:3, ii(2)=1:2) ! { dg-error "scalar variable of type
integer" }
+     a(ii(1),ii(2)) = ii(1) * ii(2)
+  end forall
+
+end subroutine check

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 variable "
+		     "of type 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++)

Reply via email to