[PATCH] D93345: [flang] Handle undeclared names in EQUIVALENCE statements
Pete Steinfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 16 11:04:55 PST 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4e90cad6a6b5: [flang] Handle undeclared names in EQUIVALENCE statements (authored by PeteSteinfeld).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93345/new/
https://reviews.llvm.org/D93345
Files:
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/equivalence01.f90
Index: flang/test/Semantics/equivalence01.f90
===================================================================
--- flang/test/Semantics/equivalence01.f90
+++ flang/test/Semantics/equivalence01.f90
@@ -197,3 +197,20 @@
end interface
end subroutine s16
+
+module m17
+ real :: dupName
+contains
+ real function f17a()
+ implicit none
+ real :: y
+ !ERROR: No explicit type declared for 'dupname'
+ equivalence (dupName, y)
+ end function f17a
+ real function f17b()
+ real :: y
+ ! The following implicitly declares an object called "dupName" local to
+ ! the function f17b(). OK since there's no "implicit none
+ equivalence (dupName, y)
+ end function f17b
+end module m17
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -597,6 +597,7 @@
bool inExecutionPart_{false};
bool inSpecificationPart_{false};
+ bool inEquivalenceStmt_{false};
std::set<SourceName> specPartForwardRefs_;
private:
@@ -2021,7 +2022,11 @@
}
return FindSymbol(scope.parent(), name);
} else {
- return Resolve(name, scope.FindSymbol(name.source));
+ // In EQUIVALENCE statements only resolve names in the local scope, see
+ // 19.5.1.4, paragraph 2, item (10)
+ return Resolve(name,
+ inEquivalenceStmt_ ? FindInScope(scope, name)
+ : scope.FindSymbol(name.source));
}
}
@@ -4347,15 +4352,17 @@
bool DeclarationVisitor::Pre(const parser::EquivalenceStmt &x) {
// save equivalence sets to be processed after specification part
- CheckNotInBlock("EQUIVALENCE"); // C1107
- for (const std::list<parser::EquivalenceObject> &set : x.v) {
- equivalenceSets_.push_back(&set);
+ if (CheckNotInBlock("EQUIVALENCE")) { // C1107
+ for (const std::list<parser::EquivalenceObject> &set : x.v) {
+ equivalenceSets_.push_back(&set);
+ }
}
return false; // don't implicitly declare names yet
}
void DeclarationVisitor::CheckEquivalenceSets() {
EquivalenceSets equivSets{context()};
+ inEquivalenceStmt_ = true;
for (const auto *set : equivalenceSets_) {
const auto &source{set->front().v.value().source};
if (set->size() <= 1) { // R871
@@ -4372,6 +4379,7 @@
}
equivSets.FinishSet(source);
}
+ inEquivalenceStmt_ = false;
for (auto &set : equivSets.sets()) {
if (!set.empty()) {
currScope().add_equivalenceSet(std::move(set));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93345.312265.patch
Type: text/x-patch
Size: 2533 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201216/a363e99b/attachment.bin>
More information about the llvm-commits
mailing list