diff options
author | Peter Klausler <35819229+klausler@users.noreply.github.com> | 2024-01-15 11:37:46 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-15 11:37:46 -0800 |
commit | d0708e6285b88510649722fe8e6832ee1d7abfb1 (patch) | |
tree | 437f0ba9bc2aebf56ceaebc711efd9a5758db7fc /flang/lib/Semantics/mod-file.cpp | |
parent | 6719a5a3f6744efdb31095933e272163b294c8f7 (diff) | |
download | llvm-d0708e6285b88510649722fe8e6832ee1d7abfb1.zip llvm-d0708e6285b88510649722fe8e6832ee1d7abfb1.tar.gz llvm-d0708e6285b88510649722fe8e6832ee1d7abfb1.tar.bz2 |
[flang] Refine IMPORT processing in module file generation (#77133)
Procedure interfaces emitted to module files are including IMPORT
statements for some symbols that don't need to be imported (base types
and procedure interfaces for components of imported derived types) and
omitting others (procedure interfaces for bindings in locally-defined
derived types that are material to the interface).
Diffstat (limited to 'flang/lib/Semantics/mod-file.cpp')
-rw-r--r-- | flang/lib/Semantics/mod-file.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp index e871255..ffdc315 100644 --- a/flang/lib/Semantics/mod-file.cpp +++ b/flang/lib/Semantics/mod-file.cpp @@ -1464,6 +1464,9 @@ void SubprogramSymbolCollector::DoSymbol( DoType(details.type()); } }, + [this](const ProcBindingDetails &details) { + DoSymbol(details.symbol()); + }, [](const auto &) {}, }, symbol.details()); @@ -1489,17 +1492,21 @@ void SubprogramSymbolCollector::DoType(const DeclTypeSpec *type) { default: if (const DerivedTypeSpec * derived{type->AsDerived()}) { const auto &typeSymbol{derived->typeSymbol()}; - if (const DerivedTypeSpec * extends{typeSymbol.GetParentTypeSpec()}) { - DoSymbol(extends->name(), extends->typeSymbol()); - } for (const auto &pair : derived->parameters()) { DoParamValue(pair.second); } - for (const auto &pair : *typeSymbol.scope()) { - const Symbol &comp{*pair.second}; - DoSymbol(comp); + // The components of the type (including its parent component, if + // any) matter to IMPORT symbol collection only for derived types + // defined in the subprogram. + if (typeSymbol.owner() == scope_) { + if (const DerivedTypeSpec * extends{typeSymbol.GetParentTypeSpec()}) { + DoSymbol(extends->name(), extends->typeSymbol()); + } + for (const auto &pair : *typeSymbol.scope()) { + DoSymbol(*pair.second); + } } - DoSymbol(derived->name(), derived->typeSymbol()); + DoSymbol(derived->name(), typeSymbol); } } } @@ -1531,8 +1538,8 @@ bool SubprogramSymbolCollector::NeedImport( // detect import from ancestor of use-associated symbol return found->has<UseDetails>() && found->owner() != scope_; } else { - // "found" can be null in the case of a use-associated derived type's parent - // type + // "found" can be null in the case of a use-associated derived type's + // parent type CHECK(symbol.has<DerivedTypeDetails>()); return false; } |