================
@@ -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;
+    }
----------------
jeanPerier wrote:

I think you are accepting dummy variables here (that goes through the 
instantiateLocal route). Note that `details->init()` is for initial value which 
implies the variable is SAVE (global), so it can be skipped if rejecting 
globals.

A better check could be: `if (var.isGlobal() || 
Fortran::semantics::IsDummy(sym)) return false;`

Note that `Fortran::lower::hasDefaultInitialization(sym` is only relevant for 
derived type objects and so I am omitting since derived types are not accepted 
here anyway.

https://github.com/llvm/llvm-project/pull/159788
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to