[flang-commits] [flang] [flang][openMP] skip CompilerDirective on ResolveOmpTopLevelParts. (PR #69580)

via flang-commits flang-commits at lists.llvm.org
Mon Oct 23 22:22:45 PDT 2023


https://github.com/Z572 updated https://github.com/llvm/llvm-project/pull/69580

>From 70acf307f081802cad9ad1cc01659cbe2b1a559d Mon Sep 17 00:00:00 2001
From: Zheng Junjie <zhengjunjie at iscas.ac.cn>
Date: Thu, 19 Oct 2023 13:50:26 +0800
Subject: [PATCH] [flang][openMP] skip CompilerDirective on
 ResolveOmpTopLevelParts.

---
 flang/lib/Semantics/resolve-directives.cpp         | 4 +++-
 flang/test/Semantics/OpenMP/compiler-directive.f90 | 8 ++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Semantics/OpenMP/compiler-directive.f90

diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index e8448a36a7b273c..355d5ede3f54ab7 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2228,7 +2228,9 @@ void ResolveOmpTopLevelParts(
       if (!std::holds_alternative<common::Indirection<parser::Module>>(
               unit.u) &&
           !std::holds_alternative<common::Indirection<parser::Submodule>>(
-              unit.u)) {
+              unit.u) &&
+          !std::holds_alternative<
+              common::Indirection<parser::CompilerDirective>>(unit.u)) {
         Symbol *symbol{common::visit(
             [&context](auto &x) {
               Scope *scope = GetScope(context, x.value());
diff --git a/flang/test/Semantics/OpenMP/compiler-directive.f90 b/flang/test/Semantics/OpenMP/compiler-directive.f90
new file mode 100644
index 000000000000000..5d3e9bae27fd8fa
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/compiler-directive.f90
@@ -0,0 +1,8 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+! CompilerDirective with openmp tests
+
+!ERROR: !DIR$ IGNORE_TKR directive must appear in a subroutine or function
+!dir$ ignore_tkr
+
+program main
+end program main



More information about the flang-commits mailing list