This is an archive of the discontinued LLVM Phabricator instance.

[flang] Handle type-bound procedures with alternate returns
ClosedPublic

Authored by PeteSteinfeld on Mar 11 2021, 8:24 AM.

Details

Summary

If you specify a type-bound procedure with an alternate return, there
will be no symbol associated with that dummy argument. In such cases,
the compiler's list of dummy arguments will contain a nullptr. In our
analysis of the PASS arguments of type-bound procedures, we were
assuming that all dummy arguments had non-null symbols associated with
them and were using that assumption to get the name of the dummy
argument. This caused the compiler to try to dereference a nullptr.

I fixed this by explicitly checking for a nullptr and, in such cases, emitting
an error message. I also added tests that contain type-bound procedures with
alternate returns in both legal and illegal constructs to ensure that semantic
analysis is working for them.

Diff Detail

Event Timeline

PeteSteinfeld requested review of this revision.Mar 11 2021, 8:24 AM
PeteSteinfeld created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2021, 8:24 AM
PeteSteinfeld added a project: Restricted Project.Mar 11 2021, 8:27 AM
tskeith accepted this revision.Mar 11 2021, 9:08 AM
tskeith added inline comments.
flang/lib/Semantics/check-declarations.cpp
1370–1377

It's a little more readable to follow the pattern of: if (error condition) { report error; return; }

This revision is now accepted and ready to land.Mar 11 2021, 9:08 AM
PeteSteinfeld added inline comments.Mar 11 2021, 10:01 AM
flang/lib/Semantics/check-declarations.cpp
1370–1377

Thanks, Tim. I'll change it.

klausler accepted this revision.Mar 11 2021, 10:10 AM

I verified that the default passed-object dummy argument is indeed the first dummy argument in F,2018, not the first named dummy argument (which would have made sense too).

This revision was landed with ongoing or failed builds.Mar 11 2021, 10:20 AM
This revision was automatically updated to reflect the committed changes.