[flang-commits] [flang] [Flang][OpenMP] Fixed semantic error when list item with a private da… (PR #109775)

via flang-commits flang-commits at lists.llvm.org
Tue Sep 24 03:31:54 PDT 2024


https://github.com/kaviya2510 updated https://github.com/llvm/llvm-project/pull/109775

>From 777187bba3c3936f79c4b6a4e425d9b97a9c0843 Mon Sep 17 00:00:00 2001
From: Kaviya Rajendiran <Kaviya.Rajendran at amd.com>
Date: Tue, 24 Sep 2024 14:49:44 +0530
Subject: [PATCH 1/2] [Flang][OpenMP] Fixed semantic error when list item with
 a private data-sharing clause used in 'allocate' clause of 'taskgroup'
 construct

---
 flang/lib/Semantics/resolve-directives.cpp           | 12 ++++++++++--
 .../test/Semantics/OpenMP/omp_taskgroup_allocate.f90 | 12 ++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 flang/test/Semantics/OpenMP/omp_taskgroup_allocate.f90

diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 17567a555db326..6de37f5235e098 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1540,8 +1540,16 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
   }
   if (beginDir.v == llvm::omp::Directive::OMPD_master)
     IssueNonConformanceWarning(beginDir.v, beginDir.source);
-  ClearDataSharingAttributeObjects();
-  ClearPrivateDataSharingAttributeObjects();
+
+  // The omp_taskgroup directive doesn't have its own data-sharing clauses.
+  // It inherits data-sharing attributes from the surrounding context.
+  // Therefore, don't clear the data-sharing attributes if it's an omp taskgroup
+  if (beginDir.v != llvm::omp::Directive::OMPD_taskgroup)
+  {
+    ClearDataSharingAttributeObjects();
+    ClearPrivateDataSharingAttributeObjects();
+  }
+
   ClearAllocateNames();
   return true;
 }
diff --git a/flang/test/Semantics/OpenMP/omp_taskgroup_allocate.f90 b/flang/test/Semantics/OpenMP/omp_taskgroup_allocate.f90
new file mode 100644
index 00000000000000..36bb713f3a13fa
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/omp_taskgroup_allocate.f90
@@ -0,0 +1,12 @@
+! RUN: %flang_fc1 -fopenmp -fsyntax-only %s
+
+! Verify that a list item with a private data-sharing clause used in the 'allocate' clause of 'taskgroup'
+! causes no semantic errors.
+
+subroutine omp_allocate_taskgroup
+   integer :: x
+   !$omp parallel private(x)
+   !$omp taskgroup allocate(x)
+   !$omp end taskgroup
+   !$omp end parallel
+end subroutine

>From 076ded0d75afcebf3a30e4784a2e55fb4ec2533e Mon Sep 17 00:00:00 2001
From: Kaviya Rajendiran <Kaviya.Rajendran at amd.com>
Date: Tue, 24 Sep 2024 14:49:44 +0530
Subject: [PATCH 2/2] [Flang][OpenMP] Fixed semantic error when list item with
 a private data-sharing clause used in 'allocate' clause of 'taskgroup'
 construct

---
 flang/lib/Semantics/resolve-directives.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 6de37f5235e098..a72b5e4b432790 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1544,8 +1544,7 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
   // The omp_taskgroup directive doesn't have its own data-sharing clauses.
   // It inherits data-sharing attributes from the surrounding context.
   // Therefore, don't clear the data-sharing attributes if it's an omp taskgroup
-  if (beginDir.v != llvm::omp::Directive::OMPD_taskgroup)
-  {
+  if (beginDir.v != llvm::omp::Directive::OMPD_taskgroup) {
     ClearDataSharingAttributeObjects();
     ClearPrivateDataSharingAttributeObjects();
   }



More information about the flang-commits mailing list