[PATCH] D95175: [flang] Address name resolution problems
Peter Klausler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 21 16:16:03 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3738447c96c7: [flang] Address name resolution problems (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95175/new/
https://reviews.llvm.org/D95175
Files:
flang/lib/Semantics/resolve-names.cpp
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -2238,6 +2238,12 @@
bool ScopeHandler::CheckPossibleBadForwardRef(const Symbol &symbol) {
if (!context().HasError(symbol)) {
if (auto fwdRef{HadForwardRef(symbol)}) {
+ const Symbol *outer{symbol.owner().FindSymbol(symbol.name())};
+ if (outer && symbol.has<UseDetails>() &&
+ &symbol.GetUltimate() == &outer->GetUltimate()) {
+ // e.g. IMPORT of host's USE association
+ return false;
+ }
Say(*fwdRef,
"Forward reference to '%s' is not allowed in the same specification part"_err_en_US,
*fwdRef)
@@ -2332,7 +2338,8 @@
}
for (const auto &[name, symbol] : *useModuleScope_) {
if (symbol->attrs().test(Attr::PUBLIC) &&
- !symbol->attrs().test(Attr::INTRINSIC) &&
+ (!symbol->attrs().test(Attr::INTRINSIC) ||
+ symbol->has<UseDetails>()) &&
!symbol->has<MiscDetails>() && useNames.count(name) == 0) {
SourceName location{x.moduleName.source};
if (auto *localSymbol{FindInScope(name)}) {
@@ -3310,10 +3317,11 @@
bool DeclarationVisitor::Pre(const parser::Enumerator &enumerator) {
const parser::Name &name{std::get<parser::NamedConstant>(enumerator.t).v};
Symbol *symbol{FindSymbol(name)};
- if (symbol) {
+ if (symbol && !symbol->has<UnknownDetails>()) {
// Contrary to named constants appearing in a PARAMETER statement,
// enumerator names should not have their type, dimension or any other
- // attributes defined before they are declared in the enumerator statement.
+ // attributes defined before they are declared in the enumerator statement,
+ // with the exception of accessibility.
// This is not explicitly forbidden by the standard, but they are scalars
// which type is left for the compiler to chose, so do not let users try to
// tamper with that.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95175.318347.patch
Type: text/x-patch
Size: 2055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210122/2b703e49/attachment.bin>
More information about the llvm-commits
mailing list