public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH 08/14] fortran: use _P() defines from tree.h
       [not found]   ` <8beeaf61-a292-24b3-b821-ad31200d7ca6@orange.fr>
@ 2023-05-18 15:18     ` Bernhard Reutner-Fischer
  2023-05-18 19:20       ` Mikael Morin
  0 siblings, 1 reply; 3+ messages in thread
From: Bernhard Reutner-Fischer @ 2023-05-18 15:18 UTC (permalink / raw)
  To: Mikael Morin; +Cc: gcc-patches, Bernhard Reutner-Fischer, fortran

[-- Attachment #1: Type: text/plain, Size: 1335 bytes --]

On Sun, 14 May 2023 15:10:12 +0200
Mikael Morin <morin-mikael@orange.fr> wrote:

> Le 14/05/2023 à 01:23, Bernhard Reutner-Fischer via Gcc-patches a écrit :
> > From: Bernhard Reutner-Fischer <aldot@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?
If so, i'd write a proper ChangeLog, of course.

Thanks!

[-- Attachment #2: 0020-gfortran_h-use-defines.patch --]
[-- Type: text/x-patch, Size: 12737 bytes --]

diff --git a/gcc/fortran/class.cc b/gcc/fortran/class.cc
index 9d0c802b867..1466b07e260 100644
--- a/gcc/fortran/class.cc
+++ b/gcc/fortran/class.cc
@@ -889,7 +889,7 @@ copy_vtab_proc_comps (gfc_symbol *declared, gfc_symbol *vtype)
 
   vtab = gfc_find_derived_vtab (declared);
 
-  for (cmp = vtab->ts.u.derived->components; cmp; cmp = cmp->next)
+  for (cmp = CLASS_DATA (vtab); cmp; cmp = cmp->next)
     {
       if (gfc_find_component (vtype, cmp->name, true, true, NULL))
 	continue;
@@ -1078,7 +1078,7 @@ finalize_component (gfc_expr *expr, gfc_symbol *derived, gfc_component *comp,
       gfc_component *c;
 
       vtab = gfc_find_derived_vtab (comp->ts.u.derived);
-      for (c = vtab->ts.u.derived->components; c; c = c->next)
+      for (c = CLASS_DATA (vtab); c; c = c->next)
 	if (strcmp (c->name, "_final") == 0)
 	  break;
 
@@ -1143,7 +1143,7 @@ finalize_component (gfc_expr *expr, gfc_symbol *derived, gfc_component *comp,
     {
       gfc_component *c;
 
-      for (c = comp->ts.u.derived->components; c; c = c->next)
+      for (c = CLASS_DATA (comp); c; c = c->next)
 	finalize_component (e, comp->ts.u.derived, c, stat, fini_coarray, code,
 			    sub_ns);
       gfc_free_expr (e);
@@ -1675,7 +1675,7 @@ generate_finalization_wrapper (gfc_symbol *derived, gfc_namespace *ns,
       gfc_component *comp;
 
       vtab = gfc_find_derived_vtab (derived->components->ts.u.derived);
-      for (comp = vtab->ts.u.derived->components; comp; comp = comp->next)
+      for (comp = CLASS_DATA (vtab); comp; comp = comp->next)
 	if (comp->name[0] == '_' && comp->name[1] == 'f')
 	  {
 	    ancestor_wrapper = comp->initializer;
@@ -2752,7 +2752,7 @@ yes:
     {
       /* Return finalizer expression.  */
       gfc_component *final;
-      final = vtab->ts.u.derived->components->next->next->next->next->next;
+      final = CLASS_DATA (vtab)->next->next->next->next->next;
       gcc_assert (strcmp (final->name, "_final") == 0);
       gcc_assert (final->initializer
 		  && final->initializer->expr_type != EXPR_NULL);
diff --git a/gcc/fortran/data.cc b/gcc/fortran/data.cc
index d29eb12c1b1..f907bb35eb1 100644
--- a/gcc/fortran/data.cc
+++ b/gcc/fortran/data.cc
@@ -730,7 +730,7 @@ formalize_structure_cons (gfc_expr *expr)
   if (!cur || cur->n.component == NULL)
     return;
 
-  for (order = expr->ts.u.derived->components; order; order = order->next)
+  for (order = CLASS_DATA (expr); order; order = order->next)
     {
       cur = find_con_by_component (order, expr->value.constructor);
       if (cur)
diff --git a/gcc/fortran/dependency.cc b/gcc/fortran/dependency.cc
index b398b29a642..864470afdec 100644
--- a/gcc/fortran/dependency.cc
+++ b/gcc/fortran/dependency.cc
@@ -1253,7 +1253,7 @@ check_data_pointer_types (gfc_expr *expr1, gfc_expr *expr2)
 
   if (sym1->ts.type == BT_DERIVED && !seen_component_ref)
     {
-      for (cm1 = sym1->ts.u.derived->components; cm1; cm1 = cm1->next)
+      for (cm1 = CLASS_DATA (sym1); cm1; cm1 = cm1->next)
 	{
 	  if (cm1->ts.type == BT_DERIVED)
 	    return false;
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
@@ -2671,7 +2671,7 @@ check_alloc_comp_init (gfc_expr *e)
   gcc_assert (e->expr_type == EXPR_STRUCTURE);
   gcc_assert (e->ts.type == BT_DERIVED || e->ts.type == BT_CLASS);
 
-  for (comp = e->ts.u.derived->components,
+  for (comp = CLASS_DATA (e),
        ctor = gfc_constructor_first (e->value.constructor);
        comp; comp = comp->next, ctor = gfc_constructor_next (ctor))
     {
@@ -5061,7 +5061,7 @@ component_initializer (gfc_component *c, bool generate)
   else if (c->ts.type == BT_DERIVED || c->ts.type == BT_CLASS)
     init = gfc_generate_initializer (&c->ts, true);
 
-  else if (c->ts.type == BT_UNION && c->ts.u.derived->components)
+  else if (c->ts.type == BT_UNION && CLASS_DATA (c))
     {
       gfc_component *map = NULL;
       gfc_constructor *ctor;
@@ -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
@@ -1319,7 +1319,7 @@ resolve_structure_cons (gfc_expr *expr, int init)
   else if ((expr->ts.type == BT_DERIVED || expr->ts.type == BT_CLASS
 	    || expr->ts.type == BT_UNION)
 	   && expr->ts.u.derived)
-    comp = expr->ts.u.derived->components;
+    comp = CLASS_DATA (expr);
   else
     return false;
 
@@ -11810,8 +11810,8 @@ generate_component_assignments (gfc_code **code, gfc_namespace *ns)
       add_code_to_chain (&this_code, &head, &tail);
     }
 
-  comp1 = (*code)->expr1->ts.u.derived->components;
-  comp2 = (*code)->expr2->ts.u.derived->components;
+  comp1 = CLASS_DATA ((*code)->expr1);
+  comp2 = CLASS_DATA ((*code)->expr2);
 
   for (; comp1; comp1 = comp1->next, comp2 = comp2->next)
     {
@@ -14169,7 +14169,7 @@ error:
 		 derived->name, &derived->declared_at);
 
   vtab = gfc_find_derived_vtab (derived);
-  c = vtab->ts.u.derived->components->next->next->next->next->next;
+  c = CLASS_DATA (vtab)->next->next->next->next->next;
   gfc_set_sym_referenced (c->initializer->symtree->n.sym);
 
   if (finalizable)
@@ -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;
@@ -15312,7 +15312,7 @@ resolve_component (gfc_component *c, gfc_symbol *sym)
      pointer components might not have been declared.  */
   if (c->ts.type == BT_DERIVED
         && c->ts.u.derived
-        && c->ts.u.derived->components
+	&& CLASS_DATA (c)
         && c->attr.pointer
         && sym != c->ts.u.derived)
     add_dt_to_dt_list (c->ts.u.derived);
@@ -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;
@@ -16322,7 +16322,7 @@ resolve_symbol (gfc_symbol *sym)
      statement. Change the type to BT_UNKNOWN, both because it is so
      and to prevent an ICE.  */
   if (sym->ts.type == BT_DERIVED && !sym->attr.is_iso_c
-      && sym->ts.u.derived->components == NULL
+      && CLASS_DATA (sym) == NULL
       && !sym->ts.u.derived->attr.zero_comp)
     {
       gfc_error ("The derived type %qs at %L is of type %qs, "
@@ -16393,7 +16393,7 @@ resolve_symbol (gfc_symbol *sym)
       && sym->as
       && sym->as->type == AS_ASSUMED_SIZE)
     {
-      for (c = sym->ts.u.derived->components; c; c = c->next)
+      for (c = CLASS_DATA (sym); c; c = c->next)
 	{
 	  if (c->initializer)
 	    {
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)
     {
diff --git a/gcc/fortran/target-memory.cc b/gcc/fortran/target-memory.cc
index edc30bddb52..e5c6245c588 100644
--- a/gcc/fortran/target-memory.cc
+++ b/gcc/fortran/target-memory.cc
@@ -503,7 +503,7 @@ gfc_interpret_derived (unsigned char *buffer, size_t buffer_size, gfc_expr *resu
   /* The attributes of the derived type need to be bolted to the floor.  */
   result->expr_type = EXPR_STRUCTURE;
 
-  cmp = result->ts.u.derived->components;
+  cmp = CLASS_DATA (result);
 
   if (result->ts.u.derived->from_intmod == INTMOD_ISO_C_BINDING
       && (result->ts.u.derived->intmod_sym_id == ISOCBINDING_PTR
@@ -683,7 +683,7 @@ expr_to_char (gfc_expr *e, locus *loc,
   if (e->ts.type == BT_DERIVED)
     {
       for (c = gfc_constructor_first (e->value.constructor),
-	   cmp = e->ts.u.derived->components;
+	   cmp = CLASS_DATA (e);
 	   c; c = gfc_constructor_next (c), cmp = cmp->next)
 	{
 	  gcc_assert (cmp && cmp->backend_decl);
diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 7f21dc2b09f..9923d194584 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -5473,7 +5473,7 @@ check_constant_initializer (gfc_expr *expr, gfc_typespec *ts, bool array,
     case_bt_struct:
       if (expr->expr_type != EXPR_STRUCTURE)
 	return false;
-      cm = expr->ts.u.derived->components;
+      cm = CLASS_DATA (expr);
       for (c = gfc_constructor_first (expr->value.constructor);
 	   c; c = gfc_constructor_next (c), cm = cm->next)
 	{
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 292aba76aaa..55ef797c077 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -9173,7 +9173,7 @@ gfc_trans_structure_assign (tree dest, gfc_expr * expr, bool init, bool coarray)
       gcc_assert (tmp);
     }
 
-  cm = expr->ts.u.derived->components;
+  cm = CLASS_DATA (expr);
 
 
   if (coarray)
@@ -9330,7 +9330,7 @@ gfc_conv_structure (gfc_se * se, gfc_expr * expr, int init)
       return;
     }
 
-  cm = expr->ts.u.derived->components;
+  cm = CLASS_DATA (expr);
 
   for (c = gfc_constructor_first (expr->value.constructor);
        c; c = gfc_constructor_next (c), cm = cm->next)
diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index b5b82941b41..52f20d6b712 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -1670,7 +1670,7 @@ gfc_trans_critical (gfc_code *code)
 static bool
 class_has_len_component (gfc_symbol *sym)
 {
-  gfc_component *comp = sym->ts.u.derived->components;
+  gfc_component *comp = CLASS_DATA (sym);
   while (comp)
     {
       if (strcmp (comp->name, "_len") == 0)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 08/14] fortran: use _P() defines from tree.h
  2023-05-18 15:18     ` [PATCH 08/14] fortran: use _P() defines from tree.h Bernhard Reutner-Fischer
@ 2023-05-18 19:20       ` Mikael Morin
  2023-05-19 19:19         ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Morin @ 2023-05-18 19:20 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer; +Cc: gcc-patches, Bernhard Reutner-Fischer, fortran

Le 18/05/2023 à 17:18, Bernhard Reutner-Fischer a écrit :
> On Sun, 14 May 2023 15:10:12 +0200
> Mikael Morin <morin-mikael@orange.fr> wrote:
> 
>> Le 14/05/2023 à 01:23, Bernhard Reutner-Fischer via Gcc-patches a écrit :
>>> From: Bernhard Reutner-Fischer <aldot@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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 08/14] fortran: use _P() defines from tree.h
  2023-05-18 19:20       ` Mikael Morin
@ 2023-05-19 19:19         ` Bernhard Reutner-Fischer
  0 siblings, 0 replies; 3+ messages in thread
From: Bernhard Reutner-Fischer @ 2023-05-19 19:19 UTC (permalink / raw)
  To: Mikael Morin; +Cc: gcc-patches, Bernhard Reutner-Fischer, fortran

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

On Thu, 18 May 2023 21:20:41 +0200
Mikael Morin <morin-mikael@orange.fr> wrote:

> Le 18/05/2023 à 17:18, Bernhard Reutner-Fischer a écrit :

> > 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.
[]
> OK for those hunks.

Pushed those as r14-1001-g05b7cc7daac8b3
Many thanks!

PS: I'm attaching the fugly script i used to do these macro
replacements FYA.

[-- Attachment #2: use-defines.1.awk --]
[-- Type: application/x-awk, Size: 3554 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-19 19:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230513232321.279733-1-rep.dot.nop@gmail.com>
     [not found] ` <20230513232321.279733-9-rep.dot.nop@gmail.com>
     [not found]   ` <8beeaf61-a292-24b3-b821-ad31200d7ca6@orange.fr>
2023-05-18 15:18     ` [PATCH 08/14] fortran: use _P() defines from tree.h Bernhard Reutner-Fischer
2023-05-18 19:20       ` Mikael Morin
2023-05-19 19:19         ` Bernhard Reutner-Fischer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).