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.
This commit is contained in:
Steve Kargl
2025-11-03 11:47:54 -08:00
committed by Jerry DeLisle
parent f8bb20167f
commit ffe538c831
2 changed files with 27 additions and 1 deletions

View File

@@ -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 "

View File

@@ -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