llvm-project
3688619b - [flang][OpenMP] Do not emit a use-only item for an operator reduction in a module file (#207492)

Commit
2 days ago
[flang][OpenMP] Do not emit a use-only item for an operator reduction in a module file (#207492) Stop writing a module file that cannot be re-parsed (reading it crashes) when a module re-exports a USE-associated user-defined operator declare reduction. Such a reduction is represented by an internal symbol whose name is the mangled operator (e.g. "op.remote." or "op.+"), which is not valid Fortran. The module-file writer emitted it as a `use MODULE, only: op.remote.` item, which the reader cannot parse. This affected both a plain re-export facade and an embedded module in a hermetic module file. Skip the use-only item for a reduction whose operator is itself re-exported (a defined operator, or an intrinsic operator with a user interface): the reduction is re-exported implicitly with that operator, which is emitted, and the reduction resolver recovers it from there (FindUserReductionSymbol). This covers a derived-type `operator(+)` reduction as well as a defined operator like `.remote.`. The test checks the re-exporting module file round-trips and that a consumer reading it resolves the reduction through the operator. Assisted-by: Claude Opus 4.8, GPT-5.5.
Author
Parents
Loading