This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix CHECK() calls on erroneous procedure declarations
ClosedPublic

Authored by PeteSteinfeld on Mar 25 2021, 8:05 AM.

Details

Summary

When writing tests for a previous problem, I ran across situations where the
compiler was failing calls to CHECK(). In these situations, the compiler had
inconsistent semantic information because the programs were erroneous. This
inconsistent information was causing the calls to CHECK().

I fixed this by avoiding the code that ended up making the failed calls to
CHECK() and making sure that we were only avoiding these situations when the
associated symbols were erroneous.

I also added tests that would cause the calls to CHECK() without these changes.

Diff Detail

Event Timeline

PeteSteinfeld requested review of this revision.Mar 25 2021, 8:05 AM
PeteSteinfeld created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2021, 8:05 AM
PeteSteinfeld added a project: Restricted Project.Mar 25 2021, 8:06 AM
klausler added inline comments.Mar 25 2021, 10:18 AM
flang/include/flang/Semantics/symbol.h
86 ↗(On Diff #333307)

The f18 naming conventions would prefer something like GetResult.

PeteSteinfeld added inline comments.Mar 25 2021, 10:32 AM
flang/include/flang/Semantics/symbol.h
86 ↗(On Diff #333307)

Thanks for catching this. I meant to create an accessor for result_. I'll rename it to result().

PeteSteinfeld added inline comments.Mar 25 2021, 10:41 AM
flang/include/flang/Semantics/symbol.h
86 ↗(On Diff #333307)

Oops. There's already an accessor. I'll rename it GetResult as you suggest.

tskeith added inline comments.Mar 25 2021, 11:28 AM
flang/lib/Semantics/resolve-names.cpp
2949–2958

You can use details.isFunction() here and avoid the need for a new accessor.

Renamed a function based on feedback from Peter.

PeteSteinfeld added inline comments.Mar 25 2021, 12:40 PM
flang/lib/Semantics/resolve-names.cpp
2949–2958

Thanks, Tim. That's a much better alternative.

Avoiding creating a new interface from a suggestion from Tim.

tskeith added inline comments.Mar 25 2021, 4:39 PM
flang/lib/Semantics/resolve-names.cpp
3226

This was the only use of GetGenericDetails so you can eliminate it.

3233

Since the assumption is that GetGenericSymbol always returns a non-null pointer, it would be better if it returned a reference instead to make that explicit.

PeteSteinfeld added inline comments.Mar 25 2021, 4:56 PM
flang/lib/Semantics/resolve-names.cpp
3226

Thanks, Tim. Will do.

3233

Thanks, Tim. Will do.

More changes in response to Tim's comments ...

klausler accepted this revision.Mar 29 2021, 9:53 AM
klausler added inline comments.
flang/lib/Semantics/resolve-names.cpp
686

return DEREF(genericSymbol);

This revision is now accepted and ready to land.Mar 29 2021, 9:53 AM
tskeith accepted this revision.Mar 29 2021, 9:56 AM
tskeith added inline comments.
flang/lib/Semantics/resolve-names.cpp
688

This could be just: return DEREF(genericInfo_.top().symbol);

PeteSteinfeld added inline comments.Mar 29 2021, 10:19 AM
flang/lib/Semantics/resolve-names.cpp
686

Thanks!

688

Thanks!