diff mbox series

Fortran/OpenMP: event handle in task detach cannot be a coarray [PR104131]

Message ID trinity-76dfe0ea-4622-4ed6-84a0-66c17dfa3e04-1698175501511@3c-app-gmx-bap20
State New
Headers show
Series Fortran/OpenMP: event handle in task detach cannot be a coarray [PR104131] | expand

Commit Message

Harald Anlauf Oct. 24, 2023, 7:25 p.m. UTC
Dear all,

the attached simple patch adds a forgotten check that an event handle
cannot be a coarray.  This case appears to have been overlooked in the
original fix for this PR.

I intend to commit as obvious within 24h unless there are comments.

Thanks,
Harald

Comments

Bernhard Reutner-Fischer Oct. 24, 2023, 8:23 p.m. UTC | #1
On 24 October 2023 21:25:01 CEST, Harald Anlauf <anlauf@gmx.de> wrote:
>Dear all,
>
>the attached simple patch adds a forgotten check that an event handle
>cannot be a coarray.  This case appears to have been overlooked in the
>original fix for this PR.
>
>I intend to commit as obvious within 24h unless there are comments.

diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 1cc65d7fa49..08081dacde4 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -8967,6 +8967,9 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
       else if (omp_clauses->detach->symtree->n.sym->attr.dimension > 0)
 	gfc_error ("The event handle at %L must not be an array element",
 		   &omp_clauses->detach->where);
+      else if (omp_clauses->detach->symtree->n.sym->attr.codimension)
+	gfc_error ("The event handle at %L must not be a coarray",

ISTM that we usually do not mention "element" when talking about undue (co)array access.

Maybe we want to streamline this specific error message?

LGTM otherwise.
Thanks for your dedication!


+		   &omp_clauses->detach->where);
       else if (omp_clauses->detach->symtree->n.sym->ts.type == BT_DERIVED
 	       || omp_clauses->detach->symtree->n.sym->ts.type == BT_CLASS)
 	gfc_error ("The event handle at %L must not be part of "
Harald Anlauf Oct. 24, 2023, 8:38 p.m. UTC | #2
Dear all,

Tobias argued in the PR that the testcase should actually be valid.
Therefore withdrawing the patch.

Sorry for expecting this to be a low-hanging fruit...

Harald

On 10/24/23 22:23, rep.dot.nop@gmail.com wrote:
> On 24 October 2023 21:25:01 CEST, Harald Anlauf <anlauf@gmx.de> wrote:
>> Dear all,
>>
>> the attached simple patch adds a forgotten check that an event handle
>> cannot be a coarray.  This case appears to have been overlooked in the
>> original fix for this PR.
>>
>> I intend to commit as obvious within 24h unless there are comments.
>
> diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
> index 1cc65d7fa49..08081dacde4 100644
> --- a/gcc/fortran/openmp.cc
> +++ b/gcc/fortran/openmp.cc
> @@ -8967,6 +8967,9 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
>         else if (omp_clauses->detach->symtree->n.sym->attr.dimension > 0)
>   	gfc_error ("The event handle at %L must not be an array element",
>   		   &omp_clauses->detach->where);
> +      else if (omp_clauses->detach->symtree->n.sym->attr.codimension)
> +	gfc_error ("The event handle at %L must not be a coarray",
>
> ISTM that we usually do not mention "element" when talking about undue (co)array access.
>
> Maybe we want to streamline this specific error message?
>
> LGTM otherwise.
> Thanks for your dedication!
>
>
> +		   &omp_clauses->detach->where);
>         else if (omp_clauses->detach->symtree->n.sym->ts.type == BT_DERIVED
>   	       || omp_clauses->detach->symtree->n.sym->ts.type == BT_CLASS)
>   	gfc_error ("The event handle at %L must not be part of "
>
>
diff mbox series

Patch

From 2b5ed32cacfe84dc4df74b4dccf16ac830d9eb98 Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Tue, 24 Oct 2023 21:18:02 +0200
Subject: [PATCH] Fortran/OpenMP: event handle in task detach cannot be a
 coarray [PR104131]

gcc/fortran/ChangeLog:

	PR fortran/104131
	* openmp.cc (resolve_omp_clauses): Add check that event handle is
	not a coarray.

gcc/testsuite/ChangeLog:

	PR fortran/104131
	* gfortran.dg/gomp/pr104131-2.f90: New test.
---
 gcc/fortran/openmp.cc                         |  3 +++
 gcc/testsuite/gfortran.dg/gomp/pr104131-2.f90 | 12 ++++++++++++
 2 files changed, 15 insertions(+)
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/pr104131-2.f90

diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 1cc65d7fa49..08081dacde4 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -8967,6 +8967,9 @@  resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
       else if (omp_clauses->detach->symtree->n.sym->attr.dimension > 0)
 	gfc_error ("The event handle at %L must not be an array element",
 		   &omp_clauses->detach->where);
+      else if (omp_clauses->detach->symtree->n.sym->attr.codimension)
+	gfc_error ("The event handle at %L must not be a coarray",
+		   &omp_clauses->detach->where);
       else if (omp_clauses->detach->symtree->n.sym->ts.type == BT_DERIVED
 	       || omp_clauses->detach->symtree->n.sym->ts.type == BT_CLASS)
 	gfc_error ("The event handle at %L must not be part of "
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr104131-2.f90 b/gcc/testsuite/gfortran.dg/gomp/pr104131-2.f90
new file mode 100644
index 00000000000..3978a6ac31a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/pr104131-2.f90
@@ -0,0 +1,12 @@ 
+! { dg-do compile }
+! { dg-options "-fopenmp -fcoarray=single" }
+! PR fortran/104131 - event handle cannot be a coarray
+
+program p
+  use iso_c_binding, only: c_intptr_t
+  implicit none
+  integer, parameter :: omp_event_handle_kind = c_intptr_t
+  integer (kind=omp_event_handle_kind) :: x[*]
+!$omp task detach (x) ! { dg-error "The event handle at \\\(1\\\) must not be a coarray" }
+!$omp end task
+end
--
2.35.3