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

via flang-commits flang-commits at lists.llvm.org
Tue Aug 4 07:21:20 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Ville-Markus Yli-Suutala (VeeEM)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/213936.diff


2 Files Affected:

- (modified) flang/lib/Semantics/symbol.cpp (+1) 
- (modified) flang/test/Semantics/OpenMP/declare-target-modfile.f90 (+4) 


``````````diff
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)

``````````

</details>


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


More information about the flang-commits mailing list