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 references to u2.udm to
u3.udm.
* module.cc (load_omp_udms): Likewise.
(write_omp_udm): Likewise.
* openmp.cc (gfc_match_motion_var_list): Likewise.
(gfc_match_omp_clauses): Likewise.
(resolve_omp_clauses): Likewise.
(gfc_omp_instantiate_mapper): Likewise.
* trans-openmp.cc (gfc_trans_omp_clauses): Likewise.
(gfc_find_nested_mappers): Likewise.
+2025-04-17 Kwok Cheung Yeung <kcyeung@baylibre.com>
+
+ * gfortran.h (struct gfc_omp_namelist): Move udm field into a new
+ union u3.
+ * match.cc (gfc_free_omp_namelist): Change references to u2.udm to
+ u3.udm.
+ * module.cc (load_omp_udms): Likewise.
+ (write_omp_udm): Likewise.
+ * openmp.cc (gfc_match_motion_var_list): Likewise.
+ (gfc_match_omp_clauses): Likewise.
+ (resolve_omp_clauses): Likewise.
+ (gfc_omp_instantiate_mapper): Likewise.
+ * trans-openmp.cc (gfc_trans_omp_clauses): Likewise.
+ (gfc_find_nested_mappers): Likewise.
+
2025-03-21 Paul-Antoine Arras <parras@baylibre.com>
Backported from master:
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;
}
free (name->u2.init_interop);
}
}
- else if (free_mapper && name->u2.udm)
- free (name->u2.udm);
+ else if (free_mapper && name->u3.udm)
+ free (name->u3.udm);
else if (!free_mapper && name->u2.udr)
{
if (name->u2.udr->combiner)
if (peek_atom () != ATOM_RPAREN)
{
- n->u2.udm = gfc_get_omp_namelist_udm ();
- mio_pool_string (&n->u2.udm->mapper_id);
+ n->u3.udm = gfc_get_omp_namelist_udm ();
+ mio_pool_string (&n->u3.udm->mapper_id);
- if (n->u2.udm->mapper_id == NULL)
- n->u2.udm->mapper_id = gfc_get_string ("%s", "");
+ if (n->u3.udm->mapper_id == NULL)
+ n->u3.udm->mapper_id = gfc_get_string ("%s", "");
- n->u2.udm->multiple_elems_p = mio_name (0, omp_map_cardinality);
- mio_pointer_ref (&n->u2.udm->udm);
+ n->u3.udm->multiple_elems_p = mio_name (0, omp_map_cardinality);
+ mio_pointer_ref (&n->u3.udm->udm);
}
mio_rparen ();
mio_lparen ();
- if (n->u2.udm)
+ if (n->u3.udm)
{
- mio_pool_string (&n->u2.udm->mapper_id);
- mio_name (n->u2.udm->multiple_elems_p, omp_map_cardinality);
- mio_pointer_ref (&n->u2.udm->udm);
+ mio_pool_string (&n->u3.udm->mapper_id);
+ mio_name (n->u3.udm->multiple_elems_p, omp_map_cardinality);
+ mio_pointer_ref (&n->u3.udm->udm);
}
mio_rparen ();
if (mapper_id[0] != '\0')
{
- n->u2.udm = gfc_get_omp_namelist_udm ();
- n->u2.udm->mapper_id = gfc_get_string ("%s", mapper_id);
+ n->u3.udm = gfc_get_omp_namelist_udm ();
+ n->u3.udm->mapper_id = gfc_get_string ("%s", mapper_id);
}
}
return MATCH_YES;
n->u.map.op = map_op;
if (mapper_id[0] != '\0')
{
- n->u2.udm = gfc_get_omp_namelist_udm ();
- n->u2.udm->mapper_id
+ n->u3.udm = gfc_get_omp_namelist_udm ();
+ n->u3.udm->mapper_id
= gfc_get_string ("%s", mapper_id);
}
}
ts = &n->sym->ts;
const char *mapper_id
- = n->u2.udm ? n->u2.udm->mapper_id : "";
+ = n->u3.udm ? n->u3.udm->mapper_id : "";
gfc_omp_udm *udm = gfc_find_omp_udm (gfc_current_ns,
mapper_id, ts);
mapper_id, &n->where);
else if (udm)
{
- if (!n->u2.udm)
+ if (!n->u3.udm)
{
- n->u2.udm = gfc_get_omp_namelist_udm ();
+ n->u3.udm = gfc_get_omp_namelist_udm ();
gcc_assert (mapper_id[0] == '\0');
- n->u2.udm->mapper_id = mapper_id;
+ n->u3.udm->mapper_id = mapper_id;
}
- n->u2.udm->udm = udm;
+ n->u3.udm->udm = udm;
}
}
}
else
multiple_elems_p = true;
- if (multiple_elems_p && clause->u2.udm)
+ if (multiple_elems_p && clause->u3.udm)
{
- clause->u2.udm->multiple_elems_p = true;
+ clause->u3.udm->multiple_elems_p = true;
*outlistp = clause;
return &(*outlistp)->next;
}
new_clause->where = clause->where;
- if (mapper_clause->u2.udm
- && mapper_clause->u2.udm->udm != udm)
+ if (mapper_clause->u3.udm
+ && mapper_clause->u3.udm->udm != udm)
{
- gfc_omp_udm *inner_udm = mapper_clause->u2.udm->udm;
+ gfc_omp_udm *inner_udm = mapper_clause->u3.udm->udm;
outlistp = gfc_omp_instantiate_mapper (outlistp, new_clause,
outer_map_op, inner_udm, cd,
list);
for (; clause; clause = *clausep)
{
- if (clause->u2.udm)
+ if (clause->u3.udm)
{
gfc_omp_map_op outer_map_op;
gcc_unreachable ();
}
clausep = gfc_omp_instantiate_mapper (clausep, clause, outer_map_op,
- clause->u2.udm->udm, cd, list);
+ clause->u3.udm->udm, cd, list);
*clausep = clause->next;
invoked_mappers = true;
}
if (drop_mapping)
continue;
- if (n->u2.udm && n->u2.udm->multiple_elems_p)
+ if (n->u3.udm && n->u3.udm->multiple_elems_p)
{
gfc_error ("cannot map non-unit size array "
"with mapper at %C");
goto finalize_map_clause;
}
- if (n->u2.udm && n->u2.udm->multiple_elems_p)
+ if (n->u3.udm && n->u3.udm->multiple_elems_p)
{
gfc_error ("cannot map non-unit size array "
"with mapper at %C");
else
container = cl;
- if (n->u2.udm
- && n->u2.udm->udm->mapper_id
- && n->u2.udm->udm->mapper_id[0] != '\0')
+ if (n->u3.udm
+ && n->u3.udm->udm->mapper_id
+ && n->u3.udm->udm->mapper_id[0] != '\0')
{
tree push = build_omp_clause (input_location,
OMP_CLAUSE_MAP);
OMP_CLAUSE_SET_MAP_KIND (push, GOMP_MAP_PUSH_MAPPER_NAME);
OMP_CLAUSE_DECL (push)
- = get_identifier (n->u2.udm->udm->mapper_id);
+ = get_identifier (n->u3.udm->udm->mapper_id);
tree pop = build_omp_clause (input_location,
OMP_CLAUSE_MAP);
OMP_CLAUSE_SET_MAP_KIND (pop, GOMP_MAP_POP_MAPPER_NAME);
for (; ns; ns = ns->next)
{
- if (ns->u2.udm && ns->u2.udm->udm != udm)
+ if (ns->u3.udm && ns->u3.udm->udm != udm)
{
- gfc_omp_udm *nested_udm = ns->u2.udm->udm;
+ gfc_omp_udm *nested_udm = ns->u3.udm->udm;
tree mapper_id
= (nested_udm->mapper_id ? get_identifier (nested_udm->mapper_id)
: NULL_TREE);