[flang-commits] [flang] [flang] fix private pointers and default initialized variables (PR #118494)
via flang-commits
flang-commits at lists.llvm.org
Wed Dec 4 05:53:40 PST 2024
================
@@ -822,7 +830,20 @@ class FirConverter : public Fortran::lower::AbstractConverter {
if_builder.end();
},
[&](const auto &) -> void {
- // Do nothing
+ // Initialize local/private derived types with default
+ // initialization (Fortran 2023 section 11.1.7.5 and OpenMP 5.2
+ // section 5.3). Pointer and allocatable components, when allowed,
+ // also need to be established so that flang runtime can later work
+ // with them.
+ if (const Fortran::semantics::DeclTypeSpec *declTypeSpec =
+ sym.GetType())
+ if (const Fortran::semantics::DerivedTypeSpec *derivedTypeSpec =
+ declTypeSpec->AsDerived())
+ if (derivedTypeSpec->HasDefaultInitialization(
+ /*ignoreAllocatable=*/false, /*ignorePointer=*/false)) {
+ mlir::Value box = builder->createBox(loc, exv);
+ fir::runtime::genDerivedTypeInitialize(*builder, loc, box);
+ }
----------------
jeanPerier wrote:
Indeed, thanks for catching this! I removed the init from `hasDefaultInitialization` and added a flag to the `createHostAssociateVarClone` to disable the init in the firstprivate case (and the doc concurrent local_init).
https://github.com/llvm/llvm-project/pull/118494
More information about the flang-commits
mailing list