[flang-commits] [flang] [Flang][OpenMP] Fixed semantic error when list item with a private da… (PR #109775)
Thirumalai Shaktivel via flang-commits
flang-commits at lists.llvm.org
Mon Oct 7 04:36:20 PDT 2024
https://github.com/Thirumalai-Shaktivel updated https://github.com/llvm/llvm-project/pull/109775
>From 8214f43b162823955c977206a041ee21cff34c0c Mon Sep 17 00:00:00 2001
From: Kaviya Rajendiran <kaviyara2000 at gmail.com>
Date: Mon, 7 Oct 2024 17:03:07 +0530
Subject: [PATCH] [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 | 11 +++++++++--
.../test/Semantics/OpenMP/omp_taskgroup_allocate.f90 | 12 ++++++++++++
2 files changed, 21 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 3d3630e8f388ca..1910941dc32a5b 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1542,8 +1542,15 @@ 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..82e08254ffb319
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/omp_taskgroup_allocate.f90
@@ -0,0 +1,12 @@
+! RUN: %flang_fc1 -fopenmp -fopenmp-version=50 -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
More information about the flang-commits
mailing list