[flang-commits] [flang] [flang][OpenMP] Convert default assertion into a semantic error (PR #93438)

via flang-commits flang-commits at lists.llvm.org
Thu May 30 00:21:33 PDT 2024


https://github.com/NimishMishra updated https://github.com/llvm/llvm-project/pull/93438

>From 8a923cb9d04f426c56e55eb938b1ca45e70184ba Mon Sep 17 00:00:00 2001
From: Nimish Mishra <neelam.nimish at gmail.com>
Date: Thu, 30 May 2024 12:50:29 +0530
Subject: [PATCH] [flang][OpenMP] Skip assertion while processing default
 clause on disallowed constructs

---
 flang/lib/Semantics/resolve-directives.cpp | 8 +++++---
 flang/test/Semantics/OpenMP/ordered01.f90  | 9 +++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index dbc531372c3f4..ea23f42fb5707 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2108,9 +2108,11 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
           dirContext.defaultDSA == Symbol::Flag::OmpFirstPrivate ||
           dirContext.defaultDSA == Symbol::Flag::OmpShared) {
         // 1) default
-        // Allowed only with parallel, teams and task generating constructs.
-        assert(parallelDir || taskGenDir ||
-            llvm::omp::allTeamsSet.test(dirContext.directive));
+        // Allowed only with parallel, teams and task generating constructs,
+        // skip creating symbols thus.
+        if (!(parallelDir || taskGenDir ||
+                llvm::omp::allTeamsSet.test(dirContext.directive)))
+          return;
         if (dirContext.defaultDSA != Symbol::Flag::OmpShared)
           declNewSymbol(dirContext.defaultDSA);
         else
diff --git a/flang/test/Semantics/OpenMP/ordered01.f90 b/flang/test/Semantics/OpenMP/ordered01.f90
index 9433120fab10f..7b46c28e858ce 100644
--- a/flang/test/Semantics/OpenMP/ordered01.f90
+++ b/flang/test/Semantics/OpenMP/ordered01.f90
@@ -7,6 +7,15 @@ program main
   integer :: i, N = 10
   real :: a, arrayA(10), arrayB(10), arrayC(10)
   real, external :: foo, bar, baz
+ 
+  !ERROR: DEFAULT clause is not allowed on the DO directive
+  !$omp do ordered default(private)
+  do i = 1, N
+     !$omp ordered
+       arrayA(i) = arrayA(i) + 1
+     !$omp end ordered
+  end do
+  !$omp end do
 
   !$omp do ordered
   do i = 1, N



More information about the flang-commits mailing list