[flang-commits] [flang] efb038f - [Flang][Openmp]Prevent TODO abort on nothing directive (#202679)
via flang-commits
flang-commits at lists.llvm.org
Thu Jun 11 22:15:06 PDT 2026
Author: ShashwathiNavada
Date: 2026-06-12T10:45:01+05:30
New Revision: efb038f38f23ee201ac872ae98668c2ef922f0fa
URL: https://github.com/llvm/llvm-project/commit/efb038f38f23ee201ac872ae98668c2ef922f0fa
DIFF: https://github.com/llvm/llvm-project/commit/efb038f38f23ee201ac872ae98668c2ef922f0fa.diff
LOG: [Flang][Openmp]Prevent TODO abort on nothing directive (#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.
Added:
flang/test/Lower/OpenMP/nothing.f90
Modified:
flang/lib/Lower/OpenMP/OpenMP.cpp
flang/test/Lower/OpenMP/Todo/error.f90
Removed:
################################################################################
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 60b7fdc0e5322..e8b9953e2f15e 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -5261,9 +5261,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/Todo/error.f90 b/flang/test/Lower/OpenMP/Todo/error.f90
index d002f72760b1c..c8338278a4267 100644
--- a/flang/test/Lower/OpenMP/Todo/error.f90
+++ b/flang/test/Lower/OpenMP/Todo/error.f90
@@ -1,6 +1,6 @@
! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=51 -o - %s 2>&1 | FileCheck %s
-! CHECK: not yet implemented: OmpUtilityDirective
+! CHECK: not yet implemented: OmpErrorDirective
program p
integer, allocatable :: x
!$omp error at(compilation) severity(warning) message("an error")
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