This is an archive of the discontinued LLVM Phabricator instance.

[flang] Check for undefined derived types
ClosedPublic

Authored by PeteSteinfeld on Jun 4 2021, 1:26 PM.

Details

Summary

It's possible to specify refer to an undefined derived type as the type of a
component of another derived type and then never define the type of the
component. We were not detecting this situation. To fix this, I added
a field to the symbol's DerivedTypeDetails and checked for it when
performing other derived type checks.

I also had to record the fact that error messages were previously
emitted for the same problem in some cases so that I could avoid
duplicate messages.

I also added a test.

Diff Detail

Event Timeline

PeteSteinfeld requested review of this revision.Jun 4 2021, 1:26 PM
PeteSteinfeld created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJun 4 2021, 1:26 PM
PeteSteinfeld added a project: Restricted Project.
klausler added inline comments.Jun 4 2021, 1:45 PM
flang/include/flang/Semantics/symbol.h
293

Is isDefined_ needed? If a type symbol is created due to a forward reference, isForwardReferenced_ will be set; maybe you can clear it when/if the type is defined, and then just test that flag later.

PeteSteinfeld added inline comments.Jun 4 2021, 2:16 PM
flang/include/flang/Semantics/symbol.h
293

Good idea. New update coming ...

Responding to comments from Peter.

klausler accepted this revision.Jun 4 2021, 2:30 PM
This revision is now accepted and ready to land.Jun 4 2021, 2:30 PM
This revision was landed with ongoing or failed builds.Jun 4 2021, 2:34 PM
This revision was automatically updated to reflect the committed changes.