[flang-commits] [flang] [flang][openmp] Write to clause symbols to modfile (PR #213936)

Ville-Markus Yli-Suutala via flang-commits flang-commits at lists.llvm.org
Tue Aug 4 06:24:00 PDT 2026


https://github.com/VeeEM created https://github.com/llvm/llvm-project/pull/213936

Fix bug where the list of variables would be ignored when writing the to clause of a declare target directive to a modfile.

>From b4706a0aeb4e665b09193774ead36b6c1298f75e Mon Sep 17 00:00:00 2001
From: Ville-Markus Yli-Suutala <ville-markus.yli-suutala at helsinki.fi>
Date: Mon, 3 Aug 2026 18:59:50 +0300
Subject: [PATCH] [flang][openmp] Write to clause symbols to modfile

Fix bug where the list of variables would be ignored when writing the to
clause of a declare target directive to a modfile.
---
 flang/lib/Semantics/symbol.cpp                         | 1 +
 flang/test/Semantics/OpenMP/declare-target-modfile.f90 | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/flang/lib/Semantics/symbol.cpp b/flang/lib/Semantics/symbol.cpp
index b802930326a6f..cf0810e01b92d 100644
--- a/flang/lib/Semantics/symbol.cpp
+++ b/flang/lib/Semantics/symbol.cpp
@@ -95,6 +95,7 @@ void WithOmpDeclarative::printClauseSet(llvm::raw_ostream &os,
     }
     case llvm::omp::Clause::OMPC_enter:
     case llvm::omp::Clause::OMPC_link:
+    case llvm::omp::Clause::OMPC_to:
       if (!name.empty()) {
         os << '(' << name.ToString() << ')';
       }
diff --git a/flang/test/Semantics/OpenMP/declare-target-modfile.f90 b/flang/test/Semantics/OpenMP/declare-target-modfile.f90
index 9a2f9a3026947..b232bdbe44755 100644
--- a/flang/test/Semantics/OpenMP/declare-target-modfile.f90
+++ b/flang/test/Semantics/OpenMP/declare-target-modfile.f90
@@ -3,6 +3,8 @@
 module m
 integer :: x
 !$omp declare_target link(x) device_type(nohost)
+integer :: y
+!$omp declare target to(y)
 real :: w(10), u(10)
 common /named_block/ w, u
 !$omp declare_target link(/named_block/)
@@ -28,6 +30,7 @@ subroutine h
 !Expect: m.mod
 !module m
 !integer(4)::x
+!integer(4)::y
 !real(4)::w(1_8:10_8)
 !real(4)::u(1_8:10_8)
 !interface
@@ -38,6 +41,7 @@ subroutine h
 !end interface
 !common/named_block/w,u
 !!$omp declare_target device_type(nohost) link(x)
+!!$omp declare_target to(y)
 !!$omp declare_target enter(g)
 !!$omp declare_target enter(f)
 !!$omp declare_target enter(h)



More information about the flang-commits mailing list