diff mbox series

[2/4] openacc: Use class_pointer instead of pointer attribute for class types

Message ID 1ac13f53bd9bfe128fe0889760a735aa3d860c49.1612271845.git.julian@codesourcery.com
State New
Headers show
Series openacc: Mixing array elements and derived types | expand

Commit Message

Julian Brown Feb. 2, 2021, 1:28 p.m. UTC
Elsewhere in the Fortran front-end, the class_pointer attribute is
used for BT_CLASS entities instead of the pointer attribute. This patch
follows suit for OpenACC. I couldn't actually come up with a test case
where this makes a difference (i.e., where "class_pointer" and "pointer"
have different values at this point in the code), but this may nonetheless
fix a latent bug.

Tested with offloading to AMD GCN. OK for mainline?

Thanks,

Julian

2020-02-02  Julian Brown  <julian@codesourcery.com>

gcc/fortran/
	* trans-openmp.c (gfc_trans_omp_clauses): Use class_pointer attribute
	for BT_CLASS.
---
 gcc/fortran/trans-openmp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Tobias Burnus Feb. 3, 2021, 10:27 a.m. UTC | #1
On 02.02.21 14:28, Julian Brown wrote:

> Elsewhere in the Fortran front-end, the class_pointer attribute is
> used for BT_CLASS entities instead of the pointer attribute. [...]This patch
> follows suit for OpenACC. I couldn't actually come up with a test case
> where this makes a difference (i.e., where "class_pointer" and "pointer"
> have different values at this point in the code), but this may nonetheless
> fix a latent bug.
>
> Tested with offloading to AMD GCN. OK for mainline?

I think attr.pointer == true != attr.class_pointer only happens
for dummy arguments and select-type temporaries, neither of which
can occur for derived-type components.

Thus, I think it is not needed – but there are merits of having
consistency. Hence, OK.

Tobias

> 2020-02-02  Julian Brown<julian@codesourcery.com>
>
> gcc/fortran/
>       * trans-openmp.c (gfc_trans_omp_clauses): Use class_pointer attribute
>       for BT_CLASS.
> ---
>   gcc/fortran/trans-openmp.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
> index 8d8da4593c3..7be34ef9a35 100644
> --- a/gcc/fortran/trans-openmp.c
> +++ b/gcc/fortran/trans-openmp.c
> @@ -2997,7 +2997,10 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
>                 if (lastcomp->u.c.component->ts.type == BT_DERIVED
>                     || lastcomp->u.c.component->ts.type == BT_CLASS)
>                   {
> -                   if (sym_attr.pointer || (openacc && sym_attr.allocatable))
> +                   bool pointer
> +                     = (lastcomp->u.c.component->ts.type == BT_CLASS
> +                        ? sym_attr.class_pointer : sym_attr.pointer);
> +                   if (pointer || (openacc && sym_attr.allocatable))
>                       {
>                         tree data, size;
>
> -- 2.29.2
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf
diff mbox series

Patch

diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 8d8da4593c3..7be34ef9a35 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -2997,7 +2997,10 @@  gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 		  if (lastcomp->u.c.component->ts.type == BT_DERIVED
 		      || lastcomp->u.c.component->ts.type == BT_CLASS)
 		    {
-		      if (sym_attr.pointer || (openacc && sym_attr.allocatable))
+		      bool pointer
+			= (lastcomp->u.c.component->ts.type == BT_CLASS
+			   ? sym_attr.class_pointer : sym_attr.pointer);
+		      if (pointer || (openacc && sym_attr.allocatable))
 			{
 			  tree data, size;