This is an archive of the discontinued LLVM Phabricator instance.

[flang] Handle expression in SELECT TYPE selector
ClosedPublic

Authored by clementval on Feb 16 2023, 6:29 AM.

Details

Summary

Expression in selector were raising an error. In some
cases expression can be found in selector. This patch
updates the code to accept expression and adds a lowering
test.

Diff Detail

Event Timeline

clementval created this revision.Feb 16 2023, 6:29 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 16 2023, 6:29 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Feb 16 2023, 6:29 AM
PeteSteinfeld accepted this revision.Feb 16 2023, 8:32 AM

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Feb 16 2023, 8:32 AM
vdonaldson added inline comments.Feb 16 2023, 8:59 AM
flang/lib/Lower/Bridge.cpp
2207

Could the expression generate a temp that requires deallocation?

To add some detail - if an expression includes a function call that returns memory, the memory needs to be freed. And since the construct could have an early exit, the normal exit cleanup might not be invoked. That can be accommodated by immediately finalizing stmtCtx.

vdonaldson accepted this revision.Feb 16 2023, 11:05 AM

We can delay dealing with rare early-exit cases until we have general code for handling them, which should be fairly soon. So this code is ok as is for now.

clementval added inline comments.Feb 16 2023, 11:59 AM
flang/lib/Lower/Bridge.cpp
2207

There is likely some cases where we need it. Since creation of polymorphic temporary is currently a TODO let's do it at the same time.

This revision was automatically updated to reflect the committed changes.