[flang-commits] [PATCH] D92638: [Flang][openmp]Fix crash in OpenMP semantic check( bug 48308)

sameeran joshi via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Dec 16 04:48:26 PST 2020


sameeranjoshi updated this revision to Diff 312177.
sameeranjoshi added a comment.

Try to simplify comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92638/new/

https://reviews.llvm.org/D92638

Files:
  flang/lib/Semantics/resolve-directives.cpp
  flang/test/Semantics/omp-no-dowhile-in-parallel.f90


Index: flang/test/Semantics/omp-no-dowhile-in-parallel.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/omp-no-dowhile-in-parallel.f90
@@ -0,0 +1,28 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+
+subroutine bug48308(x,i)
+  real :: x(:)
+  integer :: i
+  !$omp parallel firstprivate(i)
+    do while (i>0)
+      x(i) = i
+      i = i - 1
+    end do
+  !$omp end parallel
+end subroutine
+
+subroutine s1(x,i)
+  real :: x(:)
+  integer :: i
+  !$omp parallel firstprivate(i)
+    do i = 10, 1, -1
+      x(i) = i
+    end do
+  !$omp end parallel
+
+  !$omp parallel firstprivate(i)
+    do concurrent (i = 1:10:1)
+      x(i) = i
+    end do
+  !$omp end parallel
+end subroutine
Index: flang/lib/Semantics/resolve-directives.cpp
===================================================================
--- flang/lib/Semantics/resolve-directives.cpp
+++ flang/lib/Semantics/resolve-directives.cpp
@@ -875,17 +875,24 @@
   }
 }
 
-// 2.15.1.1 Data-sharing Attribute Rules - Predetermined
+// [OMP-4.5]2.15.1.1 Data-sharing Attribute Rules - Predetermined
 //   - A loop iteration variable for a sequential loop in a parallel
 //     or task generating construct is private in the innermost such
 //     construct that encloses the loop
+// Loop iteration variables are not well defined for DO WHILE loop.
+// Use of DO CONCURRENT inside OpenMP construct is unspecified behavior
+// till OpenMP-5.0 standard.
+// In above both cases we skip the privatization of iteration variables.
 bool OmpAttributeVisitor::Pre(const parser::DoConstruct &x) {
-  if (!dirContext_.empty() && GetContext().withinConstruct) {
-    if (const auto &iv{GetLoopIndex(x)}; iv.symbol) {
-      if (!iv.symbol->test(Symbol::Flag::OmpPreDetermined)) {
-        ResolveSeqLoopIndexInParallelOrTaskConstruct(iv);
-      } else {
-        // TODO: conflict checks with explicitly determined DSA
+  // TODO:[OpenMP 5.1] DO CONCURRENT indices are private
+  if (x.IsDoNormal()) {
+    if (!dirContext_.empty() && GetContext().withinConstruct) {
+      if (const auto &iv{GetLoopIndex(x)}; iv.symbol) {
+        if (!iv.symbol->test(Symbol::Flag::OmpPreDetermined)) {
+          ResolveSeqLoopIndexInParallelOrTaskConstruct(iv);
+        } else {
+          // TODO: conflict checks with explicitly determined DSA
+        }
       }
     }
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92638.312177.patch
Type: text/x-patch
Size: 2379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20201216/b080c332/attachment.bin>


More information about the flang-commits mailing list