[flang-commits] [flang] [flang][OpenACC] Skip non-loop evaluations when descending a collapsed/tiled DO nest (PR #223579)
Ron Green [NVIDIA] via flang-commits
flang-commits at lists.llvm.org
Wed Sep 16 12:11:11 PDT 2026
ronGreenNV wrote:
Good catch, and worth digging into — I tried switching to `SemanticsContext::Warn(UsageWarning::IgnoredDirective, ...)` to match the other "directive ignored" diagnostics, but it doesn't actually work from lowering.
`SemanticsContext::EmitMessages()` is called exactly once, immediately after semantic analysis (`semantics.Perform()`) and *before* lowering ever starts. I checked all three call sites in the tree:
- `FrontendAction.cpp:252` (main compile path, right after `Perform()`)
- `FrontendAction.cpp:311` (fatal-semantic-error early exit)
- `bbc.cpp:469` (same pattern)
None of them flush again after lowering. So a `Warn()` call made during lowering — which is when this collapse/tile descent runs — gets buffered into `SemanticsContext`'s message list and is silently never printed. I confirmed this empirically: with the `SemanticsContext::Warn` version, the reproducer compiled cleanly with exit code 0 and zero diagnostic output, even though the call itself succeeded.
That also explains why no other code under `flang/lib/Lower/` calls `SemanticsContext::Warn`/`Say` — I grepped the whole directory and this patch was the only place trying it. Every other lowering-time diagnostic (including the inlining-directive warning right below this one) uses `mlir::emitWarning` instead, presumably for exactly this reason.
So I've kept `mlir::emitWarning` and added a comment (387073535776) recording why, so it doesn't come up as a "should be using X" question again. Agreed it means this particular warning doesn't participate in `-W`/`-Wno-`/`-Werror` the way the semantic-analysis-phase ones do — that's a real, if unfortunate, consequence of the check needing to happen at lowering time rather than during semantic analysis.
https://github.com/llvm/llvm-project/pull/223579
More information about the flang-commits
mailing list