This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix bug for forward referenced type
ClosedPublic

Authored by PeteSteinfeld on Sep 11 2020, 11:08 AM.

Details

Summary

A type name in an IMPLICIT declaration that was later used in a PARAMETER
statement caused problems because the default symbol scope had not yet been
initialized. I avoided dereferencing in the situation where the default scope
was uninitialized and added a test that triggers the problem.

Diff Detail

Event Timeline

PeteSteinfeld created this revision.Sep 11 2020, 11:08 AM
Herald added a project: Restricted Project. · View Herald Transcript
PeteSteinfeld requested review of this revision.Sep 11 2020, 11:08 AM
PeteSteinfeld added a project: Restricted Project.Sep 11 2020, 11:08 AM
klausler added inline comments.Sep 11 2020, 11:17 AM
flang/lib/Semantics/symbol.cpp
544–545

if (const Scope *localScope{scope ? scope : scope_}) { return dtDetails->GetParentComponent(localScope); }

PeteSteinfeld added inline comments.Sep 11 2020, 11:43 AM
flang/lib/Semantics/symbol.cpp
544–545

Thanks, Peter. I'll redo this section of code.

Reworked some code as recommended by Peter Klausler.

klausler accepted this revision.Sep 11 2020, 11:45 AM
This revision is now accepted and ready to land.Sep 11 2020, 11:45 AM
This revision was automatically updated to reflect the committed changes.
tskeith added inline comments.Sep 11 2020, 2:42 PM
flang/test/Semantics/bad-forward-type.f90
76

These messages both seem to be wrong: type t2 is defined later. And they are not associated with the line that has the error.

Sorry about the late comment.

PeteSteinfeld reopened this revision.Sep 11 2020, 3:03 PM

Reopening to fix Tim's comments.

flang/test/Semantics/bad-forward-type.f90
76

I agree. I was focused on fixing the crash, but I should clean this up while I'm at it. I'll reopen the revision. Stay tuned for more changes.

This revision is now accepted and ready to land.Sep 11 2020, 3:03 PM

I added code to detect the actual error and associate it with the correct
source line. Note that the git commit message is changed with a more
detailed explanation.

tskeith accepted this revision.Sep 14 2020, 2:36 PM

Looks good.

This revision was automatically updated to reflect the committed changes.