This is an archive of the discontinued LLVM Phabricator instance.

[flang] Copy attributes and flags onto host-assoc symbols
ClosedPublic

Authored by tskeith on Aug 11 2020, 11:03 AM.

Details

Summary

As with use-associated symbols, copy the attributes and flags from the
original symbol onto host-associated symbols when they are created.

This was showing up as an error on a deallocate of a host-associated
name. We reported an error because the symbol didn't have the POINTER
or ALLOCATABLE attribute.

Diff Detail

Event Timeline

tskeith created this revision.Aug 11 2020, 11:03 AM
Herald added a project: Restricted Project. · View Herald Transcript
tskeith requested review of this revision.Aug 11 2020, 11:03 AM

What if the attributes of the host symbol change after the association symbol is created? It might be safer to fetch the attributes and flags from the original host symbol when they're needed.

What if the attributes of the host symbol change after the association symbol is created? It might be safer to fetch the attributes and flags from the original host symbol when they're needed.

I don't think that can happen because we process the host first, though I'm not positive.

Doing it when requested means we need to know which attributes we look for on the local symbol and which on the host symbol (or maybe it works to check both).

klausler accepted this revision.Aug 11 2020, 11:58 AM
This revision is now accepted and ready to land.Aug 11 2020, 11:58 AM

Rather than creating a new symbol, you could call GetAssociationRoot in check-deallocate.cpp at line 29:

} else if (!IsAllocatableOrPointer(
               *GetAssociationRoot(*symbol))) { // C932

Rather than creating a new symbol, you could call GetAssociationRoot in check-deallocate.cpp at line 29:

} else if (!IsAllocatableOrPointer(
               *GetAssociationRoot(*symbol))) { // C932

We're already creating the HostAssocDetails symbols, this change is about getting the right attributes on them. We can follow the associations to test for pointer and allocatable, but some attributes can be on the HostAssocDetails symbol so in those cases we need to check both symbols. This is simpler and similar to how use-association symbols are managed.

This revision was automatically updated to reflect the committed changes.