[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:53:20 PDT 2026
https://github.com/ShashwathiNavada created https://github.com/llvm/llvm-project/pull/202679
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.
>From c1a2aacefdc7f7f7e24414425ec884a294046b9b Mon Sep 17 00:00:00 2001
From: ShashwathiNavada <shashwathinavada at gmail.com>
Date: Tue, 9 Jun 2026 09:43:37 -0500
Subject: [PATCH] [Flang][Openmp]Prevent TODO abort on nothing directive
---
flang/lib/Lower/OpenMP/OpenMP.cpp | 15 ++++++++++++---
flang/test/Lower/OpenMP/nothing.f90 | 8 ++++++++
2 files changed, 20 insertions(+), 3 deletions(-)
create mode 100644 flang/test/Lower/OpenMP/nothing.f90
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
More information about the flang-commits
mailing list