This is an archive of the discontinued LLVM Phabricator instance.

[flang] Check & include default component initialization in static initializers
ClosedPublic

Authored by klausler on Aug 31 2021, 1:34 PM.

Details

Summary

The combined initializers constructed from DATA statements and explicit
static initialization in declarations needs to include derived type
component default initializations, overriding those default values
without complaint with values from explicit DATA statement or declaration
initializations when they overlap. This also has to work for objects
with storage association due to EQUIVALENCE. When storage association causes
default component initializations to overlap, emit errors if and only
if the values differ (See Fortran 2018 subclause 19.5.3, esp. paragraph
10).

The f18 front-end has a module that analyzes and converts DATA statements
into equivalent static initializers for objects. For storage-associated
objects, compiler-generated objects are created that overlay the entire
association and fill it with a combined initializer. This "data-to-inits"
module already exists, and this patch is essentially extension and
clean-up of its machinery to complete the job.

Also: emit EQUIVALENCE to module files; mark compiler-created symbols
and *don't* emit those to module files; check non-static EQUIVALENCE
sets for conflicting default component initializations, so lowering
doesn't have to check them or emit diagnostics.

Diff Detail

Event Timeline

klausler created this revision.Aug 31 2021, 1:34 PM
klausler requested review of this revision.Aug 31 2021, 1:34 PM
jeanPerier accepted this revision.Aug 31 2021, 11:46 PM
This revision is now accepted and ready to land.Aug 31 2021, 11:46 PM
This revision was landed with ongoing or failed builds.Sep 1 2021, 9:40 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2021, 9:41 AM