[flang-commits] [flang] [flang][openmp] Support importing module declare target globals (PR #213930)

Ville-Markus Yli-Suutala via flang-commits flang-commits at lists.llvm.org
Tue Aug 25 13:02:26 PDT 2026


================
@@ -1510,8 +1511,10 @@ static void getDeclareTargetInfo(
     List<Clause> clauses = makeClauses(construct.v.Clauses(), semaCtx);
     if (clauses.empty()) {
       // Case: implicit capture of the enclosing function/subroutine.
+      assert(eval.has_value() &&
+             "expected eval to have value when clauses is empty");
----------------
VeeEM wrote:

The module writer looks at the Symbol for the clauses, and a declare directive without clauses does get written as an enter clause:
https://github.com/llvm/llvm-project/blob/9ed81e3f037565d69c90e2f0f372eb2a8c5e1fb7/flang/lib/Semantics/resolve-directives.cpp#L2375-L2384

There is in flang/test/Semantics/OpenMP/declare-target-modfile.f90 a test that checks that 
```
interface
  real function g(v)
    real :: v(10)
    !$omp declare_target
  end
end interface
```
gets written as
```
!$omp declare_target enter(g)
```

Does this address your concern on this point? I'm not entirely sure I got you.

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


More information about the flang-commits mailing list