This is an archive of the discontinued LLVM Phabricator instance.

[flang] Handle parameter-dependent types in PDT initializers
ClosedPublic

Authored by klausler on Apr 13 2022, 1:15 PM.

Details

Summary

For parameterized derived type component initializers whose
expressions' types depend on parameter values, f18's current
scheme of analyzing the initialization expression once during
name resolution fails. For example,

type :: pdt(k)
  integer, kind :: k
  real :: component = real(0.0, kind=k)
end type

To handle such cases, it is necessary to re-analyze the parse
trees of these initialization expressions once for each distinct
initialization of the type.

This patch adds code to wipe an expression parse tree of its
typed expressions, and update those of its symbol table pointers
that reference type parameters, and then re-analyze that parse
tree to generate the properly typed component initializers.

Diff Detail

Event Timeline

klausler created this revision.Apr 13 2022, 1:15 PM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: jdoerfert. · View Herald Transcript
klausler requested review of this revision.Apr 13 2022, 1:15 PM
This revision is now accepted and ready to land.Apr 13 2022, 1:25 PM
klausler updated this revision to Diff 423168.Apr 15 2022, 2:31 PM

Rebase to pick up GetExpr() changes on which this fix depends.

klausler updated this revision to Diff 423173.Apr 15 2022, 3:02 PM

Patch around MSVC-specific C++ error message.