llvm-project
5f71480b - [flang][OpenMP] Fix USE-associated declare reduction symbol resolution (#200328)

Commit
131 days ago
[flang][OpenMP] Fix USE-associated declare reduction symbol resolution (#200328) When a declare reduction is accessed via USE association, the symbol in the consuming scope has `UseDetails` rather than `UserReductionDetails`. Calling `detailsIf<UserReductionDetails>()` directly on such a symbol returns nullptr. This causes two distinct failure modes: 1. **Operator/identifier validation** (`CheckReductionOperator`): named reductions and defined operators are rejected with "Invalid reduction identifier" or "Invalid reduction operator". 2. **Type validation** (`CheckSymbolSupportsType`, `IsReductionAllowedForType`): the type compatibility check cannot find `UserReductionDetails` for the reduction, producing "The type of 'x' is incompatible with the reduction operator". This bug has existed since `UserReductionDetails` was introduced (June 2025). Only intrinsic operator reductions (like `+`) worked via USE, because they bypass the operator validation check and their type checking was handled by a global module scan workaround (added Feb 2026). **Fix:** Add `GetUltimate()` at 4 locations in `check-omp-structure.cpp` to resolve through `UseDetails` chains before checking for `UserReductionDetails`: two in `CheckReductionOperator` (validation paths 1 and 2 above), one in `CheckSymbolSupportsType`, and one in `IsReductionAllowedForType`. Fixes https://github.com/llvm/llvm-project/issues/184932 Co-authored-by: Matt P. Dziubinski <matt-p.dziubinski@hpe.com>
Author
Parents
Loading