[flang-commits] [flang] [flang][OpenMP] Fix component-level initializer in declare reduction (PR #195751)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Thu May 7 06:19:49 PDT 2026
https://github.com/tblah commented:
For the typed assignment case, I think something like this would be clearer:
```
if (privArg && assign) {
lower::StatementContext assignCtx;
hlfir::Entity rhs = lower::convertExprToHLFIR(
loc, converter, assign->rhs, symMap, assignCtx);
rhs = hlfir::loadTrivialScalar(loc, builder, rhs);
hlfir::Entity lhs = lower::convertExprToHLFIR(
loc, converter, assign->lhs, symMap, assignCtx);
hlfir::AssignOp::create(builder, loc, rhs, lhs);
assignCtx.finalizeAndPop();
return mlir::Value{};
}
```
This avoids using `exprResult.getType() !=
fir::unwrapRefType(privArg.getType())` as a proxy for “this was a component
assignment”, and makes the intent clearer.
(The above code snippet was suggested by codex in collaborative brainstorming, I've verified that something similar to this can work for some simple cases)
https://github.com/llvm/llvm-project/pull/195751
More information about the flang-commits
mailing list