[flang] Perform default value initialization on abstract type if needed
authorValentin Clement <clementval@gmail.com>
Fri, 24 Feb 2023 08:21:45 +0000 (09:21 +0100)
committerValentin Clement <clementval@gmail.com>
Fri, 24 Feb 2023 08:22:30 +0000 (09:22 +0100)
Abstract derived-type components can have default value so perform
the default value initialization if necessary.

```
type, abstract :: a
  integer :: b = 10
end type

type, extends(a) :: b
  integer :: d
end type
```

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D144668

flang/lib/Semantics/runtime-type-info.cpp

index e5fb2d9..153b984 100644 (file)
@@ -613,8 +613,8 @@ const Symbol *RuntimeTableBuilder::DescribeType(Scope &dtScope) {
     // instances without any initialized components, analyze the type
     // and set a flag if there's nothing to do for it at run time.
     AddValue(dtValues, derivedTypeSchema_, "noinitializationneeded"s,
-        IntExpr<1>(isAbstractType ||
-            (derivedTypeSpec && !derivedTypeSpec->HasDefaultInitialization())));
+        IntExpr<1>(
+            derivedTypeSpec && !derivedTypeSpec->HasDefaultInitialization()));
     // Similarly, a flag to short-circuit destruction when not needed.
     AddValue(dtValues, derivedTypeSchema_, "nodestructionneeded"s,
         IntExpr<1>(isAbstractType ||