This is an archive of the discontinued LLVM Phabricator instance.

[flang] Avoid crash from forward referenced derived type
ClosedPublic

Authored by klausler on Jul 13 2022, 11:53 AM.

Details

Summary

Fortran permits forward references to derived types in contexts that don't
require knowledge of the derived type definition for semantic analysis,
such as in the declaration of a pointer or allocatable variable or component.
But when the forward-referenced derived type is used later for a component
reference, it is possible for the DerivedTypeSpec in he base variable or component
declaration to still have a null scope pointer even if the type has been defined,
since DerivedTypeSpec and TypeSpec objects are created in scopes of use
rather than in scopes of definition. The fix is to call
DerivedTypeSpec::Instantiate() in the name resolution of each component
name so that the scope gets filled in if it is still null.

Diff Detail

Event Timeline

klausler created this revision.Jul 13 2022, 11:53 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: jdoerfert. · View Herald Transcript
klausler requested review of this revision.Jul 13 2022, 11:53 AM
PeteSteinfeld accepted this revision.Jul 13 2022, 1:17 PM

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Jul 13 2022, 1:17 PM
This revision was automatically updated to reflect the committed changes.