[flang-commits] [flang] 3ae8746 - [Flang][OpenMP] Avoid default none errors for seq loop indices in par… (#76258)

via flang-commits flang-commits at lists.llvm.org
Mon Jan 15 08:07:48 PST 2024


Author: Kiran Chandramohan
Date: 2024-01-15T16:07:43Z
New Revision: 3ae87467a6ba4c91fb4c94ca80aeac528e636b88

URL: https://github.com/llvm/llvm-project/commit/3ae87467a6ba4c91fb4c94ca80aeac528e636b88
DIFF: https://github.com/llvm/llvm-project/commit/3ae87467a6ba4c91fb4c94ca80aeac528e636b88.diff

LOG: [Flang][OpenMP] Avoid default none errors for seq loop indices in par… (#76258)

…allel

Added: 
    

Modified: 
    flang/lib/Semantics/resolve-directives.cpp
    flang/test/Semantics/OpenMP/resolve05.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index d7b13631ab4df0..b30b81cf90c951 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1946,7 +1946,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