[flang-commits] [clang-tools-extra] [clang] [llvm] [flang] [Flang][OpenMP] Avoid default none errors for seq loop indices in par… (PR #76258)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Fri Jan 12 04:35:03 PST 2024
https://github.com/kiranchandramohan updated https://github.com/llvm/llvm-project/pull/76258
>From 03e611d413cffa6ff7432a8a88db5d6901449f3c Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Fri, 22 Dec 2023 18:35:00 +0000
Subject: [PATCH] [Flang][OpenMP] Avoid default none errors for seq loop
indices in parallel
---
flang/lib/Semantics/resolve-directives.cpp | 6 +++++-
flang/test/Semantics/OpenMP/resolve05.f90 | 13 +++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index da6c865ad56a3b..6e782204e6368c 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1910,7 +1910,11 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
if (Symbol * found{currScope().FindSymbol(name.source)}) {
if (symbol != found) {
name.symbol = found; // adjust the symbol within region
- } else if (GetContext().defaultDSA == Symbol::Flag::OmpNone) {
+ } else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
+ // Exclude indices of sequential loops that are privatised in
+ // the scope of the parallel region, and not in this scope.
+ // TODO: check whether this should be caught in IsObjectWithDSA
+ !symbol->test(Symbol::Flag::OmpPrivate)) {
context_.Say(name.source,
"The DEFAULT(NONE) clause requires that '%s' must be listed in "
"a data-sharing attribute clause"_err_en_US,
diff --git a/flang/test/Semantics/OpenMP/resolve05.f90 b/flang/test/Semantics/OpenMP/resolve05.f90
index 00f4860302183d..c4cebb48ac5c2b 100644
--- a/flang/test/Semantics/OpenMP/resolve05.f90
+++ b/flang/test/Semantics/OpenMP/resolve05.f90
@@ -17,7 +17,20 @@ subroutine default_none()
!$omp end parallel
end subroutine default_none
+! Test that indices of sequential loops are privatised and hence do not error
+! for DEFAULT(NONE)
+subroutine default_none_seq_loop
+ integer :: i
+
+ !$omp parallel do default(none)
+ do i = 1, 10
+ do j = 1, 20
+ enddo
+ enddo
+end subroutine
+
program mm
call default_none()
+ call default_none_seq_loop()
!TODO: private, firstprivate, shared
end
More information about the flang-commits
mailing list