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

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


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

The previous assert was not considering programs with semantic errors.

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


>From 84bbca866dd6d21eba82a38e7c13eb177166c226 Mon Sep 17 00:00:00 2001
From: Leandro Lupori <leandro.lupori at linaro.org>
Date: Fri, 6 Sep 2024 10:29:53 -0300
Subject: [PATCH] [flang][OpenMP] Don't abort when default is used on an
 invalid directive

The previous assert was not considering programs with semantic errors.

Fixes https://github.com/llvm/llvm-project/issues/107495
---
 flang/lib/Semantics/resolve-directives.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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



More information about the flang-commits mailing list