[flang-commits] [flang] [flang][OpenMP] Don't abort when default is used on an invalid directive (PR #107586)

via flang-commits flang-commits at lists.llvm.org
Fri Sep 6 06:36:58 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Leandro Lupori (luporl)

<details>
<summary>Changes</summary>

The previous assert was not considering programs with semantic errors.

Fixes https://github.com/llvm/llvm-project/issues/107495


---
Full diff: https://github.com/llvm/llvm-project/pull/107586.diff


1 Files Affected:

- (modified) flang/lib/Semantics/resolve-directives.cpp (+3-1) 


``````````diff
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 4aecb8b8e7b479..01ce8d989fdd15 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2152,7 +2152,9 @@ void OmpAttributeVisitor::CreateImplicitSymbols(
         dirContext.defaultDSA == Symbol::Flag::OmpShared) {
       // 1) default
       // Allowed only with parallel, teams and task generating constructs.
-      assert(parallelDir || taskGenDir || teamsDir);
+      if (!parallelDir && !taskGenDir && !teamsDir) {
+        return;
+      }
       if (dirContext.defaultDSA != Symbol::Flag::OmpShared)
         makePrivateSymbol(dirContext.defaultDSA);
       else

``````````

</details>


https://github.com/llvm/llvm-project/pull/107586


More information about the flang-commits mailing list