[committed] Fix UB in gfc_trans_omp_clauses (PR fortran/93162)

Thomas Schwinge thomas@codesourcery.com
Tue Jan 7 17:34:00 GMT 2020


Hi!

On 2020-01-07T08:20:44+0100, Jakub Jelinek <jakub@redhat.com> wrote:
> When I wrote the code, for map clause the arguments couldn't contain any
> REF_COMPONENT (nor REF_UNQUIRY nor REF_SUBSTRING) and therefore it was
> ok (although unclean) to just look at u.ar.type

Jakub, thanks for fixing this.

> but now that REF_COMPONENT
> can appear there (so far for OpenACC only, although OpenMP 5.0 also allows
> it), that is no longer the case.

Do I understand correctly that this relates to the r279631 "Fortran
polymorphic class-type support for OpenACC" changes?

> Not really sure if the code doesn't need
> further changes (how will e.g. var%comp(:) be handled in the mapping
> clauses?), but this conditional is clearly wrong.

Julian and/or Tobias, will you please review that at some point (in
context of the OpenACC usage/support recently introduced), and add test
cases etc.  (... but need not be done right now.)


Grüße
 Thomas


> 2020-01-07  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR fortran/93162
> 	* trans-openmp.c (gfc_trans_omp_clauses): Check for REF_ARRAY type
> 	before testing u.ar.type == AR_FULL.
>
> --- gcc/fortran/trans-openmp.c.jj	2020-01-04 00:14:28.511400132 +0100
> +++ gcc/fortran/trans-openmp.c	2020-01-06 17:01:10.538816323 +0100
> @@ -2495,7 +2495,9 @@ gfc_trans_omp_clauses (stmtblock_t *bloc
>  	      tree decl = gfc_trans_omp_variable (n->sym, false);
>  	      if (DECL_P (decl))
>  		TREE_ADDRESSABLE (decl) = 1;
> -	      if (n->expr == NULL || n->expr->ref->u.ar.type == AR_FULL)
> +	      if (n->expr == NULL
> +		  || (n->expr->ref->type == REF_ARRAY
> +		      && n->expr->ref->u.ar.type == AR_FULL))
>  		{
>  		  tree present = gfc_omp_check_optional_argument (decl, true);
>  		  if (n->sym->ts.type == BT_CLASS)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 658 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20200107/aa6e18b0/attachment.sig>


More information about the Fortran mailing list