]> git.ipfire.org Git - thirdparty/gcc.git/commit
fortran: Fix DO CONCURRENT nested-in-block iterator counting [PR123943]
authorChristopher Albert <albert@tugraz.at>
Wed, 11 Feb 2026 23:06:13 +0000 (00:06 +0100)
committerHarald Anlauf <anlauf@gmx.de>
Sat, 14 Feb 2026 14:09:48 +0000 (15:09 +0100)
commitedced0fe1e28a37c75b4e2c80a2a12db93d5002c
tree8951d45f5d0034183fdc7eaa21f85733c1f86955
parent904b7a3010aaf2abe22643b92a1374ace40ec574
fortran: Fix DO CONCURRENT nested-in-block iterator counting [PR123943]

Fix iterator-depth pre-counting in gfc_resolve_forall for nested
DO CONCURRENT/FORALL constructs inside block arms (e.g. IF/ELSE,
SELECT CASE).  The previous logic only scanned a flat next-chain,
which could undercount and trigger an ICE assertion.

Add a regression test based on a reduced testcase from Harald Anlauf.
Adjust wording in one comment to avoid GNU-style checker complaints.

PR fortran/123943

gcc/fortran/ChangeLog:

* resolve.cc (gfc_max_forall_iterators_in_chain): New helper
function for factorization of iterator-depth counting.
(gfc_count_forall_iterators): Use it.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr123943.f90: New test.

Co-authored-by: Harald Anlauf <anlauf@gcc.gnu.org>
Signed-off-by: Christopher Albert <albert@tugraz.at>
gcc/fortran/resolve.cc
gcc/testsuite/gfortran.dg/pr123943.f90 [new file with mode: 0644]