See attached patch, 1/2 of the fix for PR127208. coindexed_5 checks
that a coindex with a team= or team_number= that does not identify a
valid team sets stat=. With -fcoarray=single, after 2/2, a team_type
value is just the team number, so the test's team and formed_team are
the same integer and such references cannot be told apart from valid
ones. They are not conforming in the first place (F2023 9.6), so this
patch moves those checks into a new test, coindexed_5_validate, which
is skipped for -fcoarray=single, and coindexed_5 keeps its value checks
in all three configurations.

The patch only touches the testsuite: coindexed_5.f90 loses the
validation checks and the variables only they use (formed_team, stat,
lhs), and coindexed_5_validate.f90 makes the same checks.

Regression tested on x86_64.

OK for mainline?

Regards,

Jerry

---

fortran: [PR127208] Split non-conforming team= checks out of coindexed_5

coindexed_5 checks that an invalid team= or team_number= in a coindex
sets stat=.  Those references are not conforming (F2023 9.6), and
rejecting them needs a team identity that -fcoarray=single does not
have: a team_type value there is just the team number.  Move the checks
to coindexed_5_validate.f90, skipped for -fcoarray=single.  The value
checks left in coindexed_5 still hold, because a rejected reference
leaves the cell unchanged.

Assisted-by: Claude Opus 5.5

        PR fortran/127208

gcc/testsuite/ChangeLog:

        * gfortran.dg/coarray/coindexed_5.f90: Move the team= and
        team_number= validation checks out to ...
        * gfortran.dg/coarray/coindexed_5_validate.f90: ... this new test.
>From c4e9c22bcc33df6241298b6603cf9de4de84e07d Mon Sep 17 00:00:00 2001
From: Jerry DeLisle <[email protected]>
Date: Sun, 15 Nov 2026 12:29:29 -0800
Subject: [PATCH] fortran: [PR127208] Split non-conforming team= checks out of
 coindexed_5

coindexed_5 checks that an invalid team= or team_number= in a coindex
sets stat=.  Those references are not conforming (F2023 9.6), and
rejecting them needs a team identity that -fcoarray=single does not
have: a team_type value there is just the team number.  Move the checks
to coindexed_5_validate.f90, skipped for -fcoarray=single.  The value
checks left in coindexed_5 still hold, because a rejected reference
leaves the cell unchanged.

Assisted-by: Claude Opus 5.5

	PR fortran/127208

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray/coindexed_5.f90: Move the team= and
	team_number= validation checks out to ...
	* gfortran.dg/coarray/coindexed_5_validate.f90: ... this new test.
---
 .../gfortran.dg/coarray/coindexed_5.f90       | 43 ++-------------
 .../coarray/coindexed_5_validate.f90          | 54 +++++++++++++++++++
 2 files changed, 59 insertions(+), 38 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/coarray/coindexed_5_validate.f90

diff --git a/gcc/testsuite/gfortran.dg/coarray/coindexed_5.f90 b/gcc/testsuite/gfortran.dg/coarray/coindexed_5.f90
index 8eb64669628..569a6ff1d81 100644
--- a/gcc/testsuite/gfortran.dg/coarray/coindexed_5.f90
+++ b/gcc/testsuite/gfortran.dg/coarray/coindexed_5.f90
@@ -1,12 +1,15 @@
 !{ dg-do run }
 
 ! Check coindexes with team= or team_number= are working.
+!
+! The companion coindexed_5_validate.f90 checks that an invalid team= or
+! team_number= sets stat=; that is not done with a single image.
 
 program coindexed_5
   use, intrinsic :: iso_fortran_env
 
-  type(team_type) :: parentteam, team, formed_team
-  integer :: t_num= 42, stat = 42, lhs
+  type(team_type) :: parentteam, team
+  integer :: t_num= 42
   integer(kind=2) :: st_num=42
   integer :: caf(2)[*]
 
@@ -14,7 +17,6 @@ program coindexed_5
 
   caf = [23, 32]
   form team(t_num, team) !, new_index=num_images() - this_image() + 1)
-  form team(t_num, formed_team)
 
   change team(team, cell[*] => caf(2))
     associate(me => this_image())
@@ -24,15 +26,6 @@ program coindexed_5
       if (cell[me, team_number=st_num] /= 32) stop 2
       if (cell[me, team=parentteam] /= 32) stop 3
 
-      ! Check that team_number is validated
-      lhs = cell[me, team_number=5, stat=stat]
-      if (stat /= 1) stop 4
-
-      ! Check that only access to active teams is valid
-      stat = 42
-      lhs = cell[me, team=formed_team, stat=stat]
-      if (stat /= 1) stop 5
-
       ! for send_to_remote
       ! Checking against caf_single is very limitted.
       cell[me, team_number=t_num] = 45
@@ -42,16 +35,6 @@ program coindexed_5
       cell[me, team=parentteam] = 47
       if (cell /= 47) stop 13
 
-      ! Check that team_number is validated
-      stat = -1
-      cell[me, team_number=5, stat=stat] = 0
-      if (stat /= 1) stop 14
-
-      ! Check that only access to active teams is valid
-      stat = 42
-      cell[me, team=formed_team, stat=stat] = -1
-      if (stat /= 1) stop 15
-
       ! for transfer_between_remotes
       ! Checking against caf_single is very limitted.
       cell[me, team_number=t_num] = caf(1)[me, team_number=-1]
@@ -62,22 +45,6 @@ program coindexed_5
       cell[me, team=parentteam] = caf(1)[me, team= team]
       if (cell /= 23) stop 23
 
-      ! Check that team_number is validated
-      stat = -1
-      cell[me, team_number=5, stat=stat] = caf(1)[me, team_number= -1]
-      if (stat /= 1) stop 24
-      stat = -1
-      cell[me, team_number=t_num] = caf(1)[me, team_number= -2, stat=stat]
-      if (stat /= 1) stop 25
-
-      ! Check that only access to active teams is valid
-      stat = 42
-      cell[me, team=formed_team, stat=stat] = caf(1)[me]
-      if (stat /= 1) stop 26
-      stat = 42
-      cell[me] = caf(1)[me, team=formed_team, stat=stat]
-      if (stat /= 1) stop 27
-
       sync all
     end associate
   end team
diff --git a/gcc/testsuite/gfortran.dg/coarray/coindexed_5_validate.f90 b/gcc/testsuite/gfortran.dg/coarray/coindexed_5_validate.f90
new file mode 100644
index 00000000000..378d5ac11b1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray/coindexed_5_validate.f90
@@ -0,0 +1,54 @@
+!{ dg-do run }
+!{ dg-skip-if "team= and team_number= are not validated with a single image" { *-*-* } { "-fcoarray=single" } { "" } }
+!
+! PR 127208
+
+program coindexed_5_validate
+  use, intrinsic :: iso_fortran_env
+
+  type(team_type) :: team, formed_team
+  integer :: t_num = 42, stat = 42, lhs
+  integer :: caf(2)[*]
+
+  caf = [23, 32]
+  form team(t_num, team)
+  form team(t_num, formed_team)
+
+  change team(team, cell[*] => caf(2))
+    associate(me => this_image())
+      ! for get_from_remote
+      lhs = cell[me, team_number=5, stat=stat]
+      if (stat /= 1) stop 4
+
+      stat = 42
+      lhs = cell[me, team=formed_team, stat=stat]
+      if (stat /= 1) stop 5
+
+      ! for send_to_remote
+      stat = -1
+      cell[me, team_number=5, stat=stat] = 0
+      if (stat /= 1) stop 14
+
+      stat = 42
+      cell[me, team=formed_team, stat=stat] = -1
+      if (stat /= 1) stop 15
+
+      ! for transfer_between_remotes
+      stat = -1
+      cell[me, team_number=5, stat=stat] = caf(1)[me, team_number= -1]
+      if (stat /= 1) stop 24
+      stat = -1
+      cell[me, team_number=t_num] = caf(1)[me, team_number= -2, stat=stat]
+      if (stat /= 1) stop 25
+
+      stat = 42
+      cell[me, team=formed_team, stat=stat] = caf(1)[me]
+      if (stat /= 1) stop 26
+      stat = 42
+      cell[me] = caf(1)[me, team=formed_team, stat=stat]
+      if (stat /= 1) stop 27
+
+      sync all
+    end associate
+  end team
+end program coindexed_5_validate
-- 
2.56.0

Reply via email to