[flang-commits] [flang] [flang][OpenACC] Attach a source location to the skipped-directive warning (PR #224348)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Thu Sep 17 09:00:31 PDT 2026


eugeneepshteyn wrote:

Implementation details:

- The "compiler directive ignored: it appears between loop levels of a collapsed or tiled loop nest" warning was emitted with an unknown source location: directive evaluations are created without a `position` (`enterConstructOrDirective` in `flang/lib/Lower/PFTBuilder.cpp`), so `genLocation(e->position)` produced an unknown location and the warning printed as a bare `warning: ...` with no file or line — unactionable in any nontrivial file. Use the `CompilerDirective`'s own `source` instead, so the warning points at the ignored directive.
- Harden `flang/test/Lower/OpenACC/acc-loop-collapse-directive-between-loops.f90`:
  - a `WARN` FileCheck prefix pinning one *located* warning per skipped directive (four in the file) and, via `WARN-NOT`, that nothing else warns — this also pins that the `collapse(force:)` path stays silent;
  - a `collapse(force:2)` subroutine with a real statement and a directive between the levels — the `!collapseForce` carve-out in the descent is load-bearing (without it this shape would hit the "unsupported statement between the levels" TODO on code that semantic analysis accepts under `force`) and previously had no coverage;
  - exact `control(...)` arity on each `acc.loop` CHECK, so a regression that collapses fewer levels than requested (leaving a nested `fir.do_loop` with the body still inside the region and the clause-derived `collapse([n])` attribute still printed) can no longer pass.

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


More information about the flang-commits mailing list