https://gcc.gnu.org/g:ffe538c831daeb72d935fb7fd796b6ce4a13c820

commit r16-5014-gffe538c831daeb72d935fb7fd796b6ce4a13c820
Author: Steve Kargl <[email protected]>
Date:   Mon Nov 3 11:47:54 2025 -0800

    Fortran: Fix check on locality spec DO CONCURRENT
    
            PR fortran/122513
    
    gcc/fortran/ChangeLog:
    
            * resolve.cc (check_default_none_expr): Do not allow an
            iterator in a locality spec. Allow a named constant to be
            used within the loop.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/pr122513.f90: New test.

Diff:
---
 gcc/fortran/resolve.cc                 | 15 ++++++++++++++-
 gcc/testsuite/gfortran.dg/pr122513.f90 | 13 +++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 03e26f000843..5fa408ec48cc 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -8461,7 +8461,20 @@ check_default_none_expr (gfc_expr **e, int *, void *data)
                break;
              ns2 = ns2->parent;
            }
-         if (ns2 != NULL)
+
+         /* A DO CONCURRENT iterator cannot appear in a locality spec.  */
+         if (sym->ns->code->ext.concur.forall_iterator)
+           {
+             gfc_forall_iterator *iter
+               = sym->ns->code->ext.concur.forall_iterator;
+             for (; iter; iter = iter->next)
+               if (iter->var->symtree
+                   && strcmp(sym->name, iter->var->symtree->name) == 0)
+                 return 0;
+           }
+
+         /* A named constant is not a variable, so skip test.  */
+         if (ns2 != NULL && sym->attr.flavor != FL_PARAMETER)
            {
              gfc_error ("Variable %qs at %L not specified in a locality spec "
                        "of DO CONCURRENT at %L but required due to "
diff --git a/gcc/testsuite/gfortran.dg/pr122513.f90 
b/gcc/testsuite/gfortran.dg/pr122513.f90
new file mode 100644
index 000000000000..9e12ab159a63
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr122513.f90
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! PR122513 do concurrent default (none) fails on parameter arrays
+program test
+  implicit none
+  integer :: i
+  do concurrent (i=1:2) default (none)
+     block
+       integer, dimension(2,3), parameter :: &
+            ii = reshape((/ 1,2,3,4,5,6 /), (/2, 3/))
+       print*,ii(i,:)
+     end block
+  end do
+end program test

Reply via email to