Le 18/05/2023 à 17:18, Bernhard Reutner-Fischer a écrit :
On Sun, 14 May 2023 15:10:12 +0200
Mikael Morin <morin-mik...@orange.fr> wrote:
Le 14/05/2023 à 01:23, Bernhard Reutner-Fischer via Gcc-patches a écrit :
From: Bernhard Reutner-Fischer <al...@gcc.gnu.org>
gcc/fortran/ChangeLog:
* trans-array.cc (is_pointer_array): Use _P() defines from tree.h.
(gfc_conv_scalarized_array_ref): Ditto.
(gfc_conv_array_ref): Ditto.
* trans-decl.cc (gfc_finish_decl): Ditto.
(gfc_get_symbol_decl): Ditto.
* trans-expr.cc (gfc_trans_pointer_assignment): Ditto.
(gfc_trans_arrayfunc_assign): Ditto.
(gfc_trans_assignment_1): Ditto.
* trans-intrinsic.cc (gfc_conv_intrinsic_minmax): Ditto.
(conv_intrinsic_ieee_value): Ditto.
* trans-io.cc (gfc_convert_array_to_string): Ditto.
* trans-openmp.cc (gfc_omp_is_optional_argument): Ditto.
(gfc_trans_omp_clauses): Ditto.
* trans-stmt.cc (gfc_conv_label_variable): Ditto.
* trans.cc (gfc_build_addr_expr): Ditto.
(get_array_span): Ditto.
OK from the fortran side.
Thanks
Thanks, i'll push it during the weekend.
I've fed gfortran.h into the script and found some CLASS_DATA spots,
see attached bootstrapped and tested patch.
Do we want to have that?
Some of it makes sense, but not all of it.
It is a macro to access the _data component of a class container.
So for class-related stuff it makes sense to use CLASS_DATA, and
typically there will be a check that the type is BT_CLASS before.
But for cases where we loop over all of the components of a type that is
not necessarily a class container, it doesn't make sense to use CLASS_DATA.
So I suggest to only keep the following hunks.
diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index aa01a4d3d22..a6b4ef0a0bf 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -5847,9 +5847,9 @@ gfc_get_corank (gfc_expr *e)
if (!gfc_is_coarray (e))
return 0;
- if (e->ts.type == BT_CLASS && e->ts.u.derived->components)
- corank = e->ts.u.derived->components->as
- ? e->ts.u.derived->components->as->corank : 0;
+ if (e->ts.type == BT_CLASS && CLASS_DATA (e))
+ corank = CLASS_DATA (e)->as
+ ? CLASS_DATA (e)->as->corank : 0;
else
corank = e->symtree->n.sym->as ? e->symtree->n.sym->as->corank : 0;
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 9c92958a397..6e26fb07ddd 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -15176,7 +15176,7 @@ resolve_component (gfc_component *c, gfc_symbol *sym)
/* Check type-spec if this is not the parent-type component. */
if (((sym->attr.is_class
&& (!sym->components->ts.u.derived->attr.extension
- || c != sym->components->ts.u.derived->components))
+ || c != CLASS_DATA (sym->components)))
|| (!sym->attr.is_class
&& (!sym->attr.extension || c != sym->components)))
&& !sym->attr.vtype
@@ -15189,7 +15189,7 @@ resolve_component (gfc_component *c, gfc_symbol *sym)
component. */
if (super_type
&& ((sym->attr.is_class
- && c == sym->components->ts.u.derived->components)
+ && c == CLASS_DATA (sym->components))
|| (!sym->attr.is_class && c == sym->components))
&& strcmp (super_type->name, c->name) == 0)
c->attr.access = super_type->attr.access;
@@ -15435,7 +15435,7 @@ resolve_fl_derived0 (gfc_symbol *sym)
return false;
}
- c = (sym->attr.is_class) ? sym->components->ts.u.derived->components
+ c = (sym->attr.is_class) ? CLASS_DATA (sym->components)
: sym->components;
success = true;
diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index a7b4784d73a..6ba2040e61c 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -3116,28 +3116,28 @@ gfc_simplify_extends_type_of (gfc_expr *a, gfc_expr
*mold)
/* Return .false. if the dynamic type can never be an extension. */
if ((a->ts.type == BT_CLASS && mold->ts.type == BT_CLASS
&& !gfc_type_is_extension_of
- (mold->ts.u.derived->components->ts.u.derived,
- a->ts.u.derived->components->ts.u.derived)
+ (CLASS_DATA (mold)->ts.u.derived,
+ CLASS_DATA (a)->ts.u.derived)
&& !gfc_type_is_extension_of
- (a->ts.u.derived->components->ts.u.derived,
- mold->ts.u.derived->components->ts.u.derived))
+ (CLASS_DATA (a)->ts.u.derived,
+ CLASS_DATA (mold)->ts.u.derived))
|| (a->ts.type == BT_DERIVED && mold->ts.type == BT_CLASS
&& !gfc_type_is_extension_of
- (mold->ts.u.derived->components->ts.u.derived,
+ (CLASS_DATA (mold)->ts.u.derived,
a->ts.u.derived))
|| (a->ts.type == BT_CLASS && mold->ts.type == BT_DERIVED
&& !gfc_type_is_extension_of
(mold->ts.u.derived,
- a->ts.u.derived->components->ts.u.derived)
+ CLASS_DATA (a)->ts.u.derived)
&& !gfc_type_is_extension_of
- (a->ts.u.derived->components->ts.u.derived,
+ (CLASS_DATA (a)->ts.u.derived,
mold->ts.u.derived)))
return gfc_get_logical_expr (gfc_default_logical_kind, &a->where, false);
/* Return .true. if the dynamic type is guaranteed to be an extension. */
if (a->ts.type == BT_CLASS && mold->ts.type == BT_DERIVED
&& gfc_type_is_extension_of (mold->ts.u.derived,
- a->ts.u.derived->components->ts.u.derived))
+ CLASS_DATA (a)->ts.u.derived))
return gfc_get_logical_expr (gfc_default_logical_kind, &a->where, true);
return NULL;
@@ -4344,8 +4344,8 @@ simplify_cobound (gfc_expr *array, gfc_expr *dim,
gfc_expr *kind, int upper)
return NULL;
/* Follow any component references. */
- as = (array->ts.type == BT_CLASS && array->ts.u.derived->components)
- ? array->ts.u.derived->components->as
+ as = (array->ts.type == BT_CLASS && CLASS_DATA (array))
+ ? CLASS_DATA (array)->as
: array->symtree->n.sym->as;
for (ref = array->ref; ref; ref = ref->next)
{
OK for those hunks.
Thanks