[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 08:00:05 PDT 2026


https://github.com/ShashwathiNavada updated https://github.com/llvm/llvm-project/pull/202679

>From a5727ebee621e07eb843934057ace014ebaeacf3 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..20be07d463a64 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