Re: [PATCH v6 05/11] openmp, fortran: Add support for iterators in OpenMP 'target update' constructs (Fortran)

Sandra Loosemore <[email protected]>
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
On 6/5/26 03:49, Tobias Burnus wrote:
> @Sandra - please fix the u3 issue before committing the 4/11 and this 5/11
> patch, cf. below.
> 
> [snip]
> 
> I am not sure what's the best way - by possibly to do what Kwok
> did in commit (here: OG14):
>    2afb6281a5a  openmp, fortran: Move udm field of gfc_omp_namelist into 
> a new union
> 
> * * *
> 
> Thus: Could you do so? On mainline, it currently only affects:
> 
> gcc/fortran/gfortran.h:      struct gfc_omp_namelist_udm udm;
> gcc/fortran/match.cc:   { } /* For now, u2.udm is not a pointer.  */
> gcc/fortran/openmp.cc:                    n->u2.udm.udm = udm;
> 
> As Kwok's change reduced to those three cases is trivial,
> please just commit it.

Thanks for the speedy review.  :-)  I've pushed the attached patch, 
along with parts 4 and 5.

-Sandra
0001-openmp-fortran-Move-udm-field-of-gfc_omp_namelist-in.patch (text/x-patch, 2.2 KB)
From 98741d8fe7dc47f856ad99cf4369f671ea7903d7 Mon Sep 17 00:00:00 2001
From: Kwok Cheung Yeung <[email protected]>
Date: Sun, 7 Jun 2026 01:37:15 +0000
Subject: [PATCH 1/9] openmp, fortran: Move udm field of gfc_omp_namelist into
 a new union

This patch moves u2.udm into u3.udm.

This is necessary to avoid clashes when mappers are used together with
iterators, which uses u2.ns.

gcc/fortran/

	* gfortran.h (struct gfc_omp_namelist): Move udm field into a new
	union u3.
	* match.cc (gfc_free_omp_namelist): Change reference to u2.udm to
	u3.udm.
	* openmp.cc (gfc_match_omp_clauses): Likewise.

Co-authored-by: Sandra Loosemore <[email protected]>
---
 gcc/fortran/gfortran.h | 5 ++++-
 gcc/fortran/match.cc   | 2 +-
 gcc/fortran/openmp.cc  | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index d8d8f3faae2..ef6239cd667 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1477,13 +1477,16 @@ typedef struct gfc_omp_namelist
   union
     {
       struct gfc_omp_namelist_udr *udr;
-      struct gfc_omp_namelist_udm udm;
       gfc_namespace *ns;
       gfc_expr *allocator;
       struct gfc_symbol *traits_sym;
       struct gfc_omp_namelist *duplicate_of;
       char *init_interop;
     } u2;
+  union
+    {
+      struct gfc_omp_namelist_udm udm;
+    } u3;
   struct gfc_omp_namelist *next;
   locus where;
 }
diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc
index 9172f46ed7c..98b59cc3379 100644
--- a/gcc/fortran/match.cc
+++ b/gcc/fortran/match.cc
@@ -6554,7 +6554,7 @@ gfc_free_omp_namelist (gfc_omp_namelist *name, enum gfc_omp_list_type list)
 	    }
 	}
       else if (free_mapper)
-	{ } /* For now, u2.udm is not a pointer.  */
+	{ } /* For now, u3.udm is not a pointer.  */
       else if (!free_mapper && name->u2.udr)
 	{
 	  if (name->u2.udr->combiner)
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 476a6604892..73a96b05cb2 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -3856,7 +3856,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
 			= gfc_find_omp_udm (gfc_current_ns, mapper_id, ts);
 		      if (udm)
 			{
-			  n->u2.udm.udm = udm;
+			  n->u3.udm.udm = udm;
 			}
 		    }
 		  continue;
-- 
2.39.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.