[flang-commits] [flang] [Flang][OpenMP] Add declare simd to all subprogram entries (PR #215777)

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Mon Aug 24 03:34:35 PDT 2026


================
@@ -0,0 +1,60 @@
+! DECLARE SIMD applies to all entries of a subprogram, not just to the main one.
----------------
skatrak wrote:

Thank you @mjklemm. Reading the draft Fortran 2023 (13th June 2023), I see how `y` would be illegal there. It says:
> In a subprogram, a dummy argument specified in an ENTRY statement shall not appear in an executable statement preceding that ENTRY statement, [...]

So I guess that's one base language semantics check we're currently missing. We could fix the example with:
```f90
subroutine s(x)
  implicit none
  !$omp declare_simd linear(x:1)
  integer :: x, y

  call foo(x)
  return

entry e(y)
  call bar(x, y)
  return
end subroutine
```
Then, there's another piece that I'm not quite sure to fully understand what it means:
> If a dummy argument appears in an executable statement, the execution of the executable statement is permitted during the execution of a reference to the function or subroutine only f the dummy argument appears in the dummy argument list of the referenced procedure.

Does that make using `x` inside of `entry e(y)` above invalid as well, or am I misinterpreting it? If not, that's another base language check we're missing.

In terms of OpenMP, I can't find anything specific relating to `entry` statements except from an entry name being disallowed as a `proc-name` for `declare_{simd,target,variant}`. I would lean towards interpreting that, if one of these directives applies to a function or subroutine, then it's as if they were copy-pasted into every one of their entries. Making the following, which avoids the previous potentially illegal Fortran programs, an OpenMP semantics error:
```f90
subroutine s(x)
  implicit none
  !$omp declare_simd linear(x:1)
  integer :: x, y

  call foo(x)
  return

! Error here because `x` is not a dummy argument of `e`.
entry e(y)
  call foo(y)
  return
end subroutine
```

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


More information about the flang-commits mailing list