[flang-commits] [flang] [Flang][Openmp]Prevent TODO abort on nothing directive (PR #202679)
via flang-commits
flang-commits at lists.llvm.org
Tue Jun 9 07:54:10 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-openmp
Author: ShashwathiNavada
<details>
<summary>Changes</summary>
Since nothing is a no-op directive (OpenMP 5.2, 8.4), handle it during lowering instead of falling through to the generic unimplemented utility-directive path and triggering a TODO abort.
---
Full diff: https://github.com/llvm/llvm-project/pull/202679.diff
2 Files Affected:
- (modified) flang/lib/Lower/OpenMP/OpenMP.cpp (+12-3)
- (added) flang/test/Lower/OpenMP/nothing.f90 (+8)
``````````diff
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 266b06f353675..f4c46ed238dcb 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -4899,9 +4899,18 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
semantics::SemanticsContext &semaCtx,
lower::pft::Evaluation &eval,
- const parser::OmpUtilityDirective &) {
- if (!semaCtx.langOptions().OpenMPSimd)
- TODO(converter.getCurrentLocation(), "OmpUtilityDirective");
+ const parser::OmpUtilityDirective &dir) {
+ common::visit(
+ common::visitors{
+ [&](const parser::OmpNothingDirective &) {
+ // nothing-directive is a no-op (OpenMP 5.2 [8.4])
+ },
+ [&](const parser::OmpErrorDirective &) {
+ if (!semaCtx.langOptions().OpenMPSimd)
+ TODO(converter.getCurrentLocation(), "OmpErrorDirective");
+ },
+ },
+ dir.u);
}
static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
diff --git a/flang/test/Lower/OpenMP/nothing.f90 b/flang/test/Lower/OpenMP/nothing.f90
new file mode 100644
index 0000000000000..775b6a34db45e
--- /dev/null
+++ b/flang/test/Lower/OpenMP/nothing.f90
@@ -0,0 +1,8 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s
+!RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s
+
+! CHECK-LABEL: func @_QPfoo
+subroutine foo
+ ! CHECK-NOT: omp.
+ !$omp nothing
+end subroutine
``````````
</details>
https://github.com/llvm/llvm-project/pull/202679
More information about the flang-commits
mailing list