This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix spurious errors from runtime derived type table construction
ClosedPublic

Authored by klausler on Apr 21 2021, 3:13 PM.

Details

Summary

Andrezj W. @ Arm discovered that the runtime derived type table
building code in semantics was detecting fatal errors in the tests
that the f18 driver wasn't printing. This patch fixes f18 so that
these messages are printed; however, the messages were not valid user
errors, and the rest of this patch fixes them up.

There were two sources of the bogus errors. One was that the runtime
derived type information table builder was calculating the shapes of
allocatable and pointer array components in derived types, and then
complaining that they weren't constant or LEN parameter values, which
of course they couldn't be since they have to have deferred shapes
and those bounds were expressions like LBOUND(component,dim=1).

The second was that f18 was forwarding the actual LEN type parameter
expressions of a type instantiation too far into the uses of those
parameters in various expressions in the declarations of components;
when an actual LEN type parameter is not a constant value, it needs
to remain a "bare" type parameter inquiry so that it will be lowered
to a descriptor inquiry and acquire a captured expression value.

Fixing this up properly involved: moving some code into new utility
function templates in Evaluate/tools.h, tweaking the rewriting of
conversions in expression folding to elide needless integer kind
conversions of type parameter inquiries, making type parameter
inquiry folding *not* replace bare LEN type parameters with
non-constant actual parameter values, and cleaning up some
altered test results.

Diff Detail

Event Timeline

klausler created this revision.Apr 21 2021, 3:13 PM
klausler requested review of this revision.Apr 21 2021, 3:13 PM
PeteSteinfeld accepted this revision.Apr 22 2021, 6:15 AM

All builds, tests, and looks good.

This revision is now accepted and ready to land.Apr 22 2021, 6:15 AM

Thank you for fixing this @klausler.

The changes in the driver LGTM. As for the other changes, I will defer to @PeteSteinfeld.

awarzynski accepted this revision.Apr 22 2021, 6:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2021, 9:44 AM