================
@@ -1317,6 +1381,50 @@ static void
instantiateLocal(Fortran::lower::AbstractConverter &converter,
Fortran::lower::genUnpackArray(*converterPtr, loc, *varDef, *sym);
});
}
+
+ /// These options do not initialize:
+ /// 1) Any variable already initialized
+ /// 2) objects with the POINTER attribute
+ /// 3) allocatable arrays
+ /// 4) variables that appear in an EQUIVALENCE statement
+
+ auto isEligibleForImplicitAssignment = [&var, &converter]() -> bool {
+ if (!var.hasSymbol())
+ return false;
+
+ const Fortran::semantics::Symbol &sym = var.getSymbol();
+ if (!sym.GetType())
+ return false;
+ if (const auto *details =
+ sym.detailsIf<Fortran::semantics::ObjectEntityDetails>()) {
+ if (details->init())
+ return false;
+ }
+
+ if (sym.attrs().test(Fortran::semantics::Attr::POINTER))
+ return false;
+
+ if (sym.Rank() > 0 &&
+ sym.attrs().test(Fortran::semantics::Attr::ALLOCATABLE))
+ return false;
+
+ if (Fortran::lower::pft::getDependentVariableList(sym).size() > 1)
+ return false;
+
+ if (auto ty = converter.genType(sym)) {
+ auto charTy =
+ mlir::dyn_cast<fir::CharacterType>(hlfir::getFortranElementType(ty));
+ if (charTy && !charTy.hasConstantLen())
+ return false;
+ }
----------------
jeanPerier wrote:
My concern was only with allocatables scalar character with deferred length
(that I now think should be rejected). The following should still be zero
initialized:
```
subroutine char_init(n)
character(n) :: x
call bar(x)
end subroutine
```
https://github.com/llvm/llvm-project/pull/159788
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits