public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mikael Morin <morin-mikael@orange.fr>
To: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Cc: gcc-patches@gcc.gnu.org,
	Bernhard Reutner-Fischer <aldot@gcc.gnu.org>,
	fortran@gcc.gnu.org
Subject: Re: [PATCH 08/14] fortran: use _P() defines from tree.h
Date: Thu, 18 May 2023 21:20:41 +0200	[thread overview]
Message-ID: <0815cec8-7180-3f55-a479-9aea2cac7026@orange.fr> (raw)
In-Reply-To: <20230518171851.1e09c436@nbbrfq.loc>

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

  reply	other threads:[~2023-05-18 19:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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     ` Bernhard Reutner-Fischer
2023-05-18 19:20       ` Mikael Morin [this message]
2023-05-19 19:19         ` Bernhard Reutner-Fischer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0815cec8-7180-3f55-a479-9aea2cac7026@orange.fr \
    --to=morin-mikael@orange.fr \
    --cc=aldot@gcc.gnu.org \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rep.dot.nop@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).