[flang] Handle multiple USE statements for the same module
authorPeter Steinfeld <psteinfeld@nvidia.com>
Fri, 11 Jun 2021 16:28:26 +0000 (09:28 -0700)
committerPeter Steinfeld <psteinfeld@nvidia.com>
Fri, 11 Jun 2021 19:27:19 +0000 (12:27 -0700)
commit1b241b9b400bdfc5b8e0d157f0f46436677927b8
tree7aa541e1be8954c72d1e2c35943065d05ab7c198
parente0b469ffa142353fc90bfc6eadb638a805ebed75
[flang] Handle multiple USE statements for the same module

It's possible to have several USE statements for the same module that
have different mixes of rename clauses and ONLY clauses.  The presence
of a rename cause has the effect of hiding a previously associated name,
and the presence of an ONLY clause forces the name to be visible even in
the presence of a rename.

I fixed this by keeping track of the names that appear on rename and ONLY
clauses.  Then, when processing the USE association of a name, I check to see
if it previously appeared in a rename clause and not in a USE clause.  If so, I
remove its USE associated symbol.  Also, when USE associating all of the names
in a module, I do not USE associate names that have appeared in rename clauses.

I also added a test.

Differential Revision: https://reviews.llvm.org/D104130
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/modfile41.f90 [new file with mode: 0644]