This is an archive of the discontinued LLVM Phabricator instance.

[flang] Support BIND(C) variable scope check
ClosedPublic

Authored by peixin on May 30 2022, 7:34 AM.

Details

Summary

As Fortran 2018 C819, a variable with the BIND attribute shall be declared
in the specification part of a module. Add the support for this check.

Diff Detail

Event Timeline

peixin created this revision.May 30 2022, 7:34 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: jdoerfert. · View Herald Transcript
peixin requested review of this revision.May 30 2022, 7:34 AM
klausler requested changes to this revision.May 30 2022, 8:59 AM

Your change will still allow BIND(C) variables to be declared in submodules, and I don't think that is allowed.

This revision now requires changes to proceed.May 30 2022, 8:59 AM
peixin updated this revision to Diff 432958.May 30 2022, 9:55 AM

Thanks @klausler for the comment. Addressed it.

klausler accepted this revision.May 30 2022, 10:02 AM
klausler added inline comments.
flang/lib/Semantics/check-declarations.cpp
107

Rather than making the name of this function longer (because it does more now), consider making it shorter, like "CheckBindC", since further checks may be added to it in the future.

1876

Consider adding a CHECK() here to ensure that the symbol is BIND(C). Or test for BIND(C) and return if it is not, in which case you can continue to call it unconditionally. The second option seems safer.

This revision is now accepted and ready to land.May 30 2022, 10:02 AM
peixin updated this revision to Diff 433024.May 30 2022, 11:52 PM

Address the comments:

  1. Rename to CheckBindC.
  1. Call it unconditionally and return if it does not have BIND(C) attr.
This revision was automatically updated to reflect the committed changes.