[flang-commits] [flang] 4d32f9a - [flang] Don't implicitly host-associate unknown EQUIVALENCE designators
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Tue Aug 29 08:33:47 PDT 2023
Author: Peter Klausler
Date: 2023-08-29T08:33:39-07:00
New Revision: 4d32f9ad0eb7e602ba5000baaacf926f3756769d
URL: https://github.com/llvm/llvm-project/commit/4d32f9ad0eb7e602ba5000baaacf926f3756769d
DIFF: https://github.com/llvm/llvm-project/commit/4d32f9ad0eb7e602ba5000baaacf926f3756769d.diff
LOG: [flang] Don't implicitly host-associate unknown EQUIVALENCE designators
When resolving names in a specification part, unknown names that appear
in a specification expression before any local declaration are assumed
to be implicitly declared objects in the host scope. Objects in
EQUIVALENCE sets are not part of specification expressions, so ensure
that they do not receive this treatment; besides being wrong and
unimplementable, it will lead to a later crash during offset assignment.
Differential Revision: https://reviews.llvm.org/D159030
Added:
Modified:
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/offsets03.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 930f1d78eb655f..dcd9a8d2ab2d8e 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -7277,7 +7277,7 @@ const parser::Name *DeclarationVisitor::ResolveName(const parser::Name &name) {
// be wrong we report an error later in CheckDeclarations().
bool DeclarationVisitor::CheckForHostAssociatedImplicit(
const parser::Name &name) {
- if (!inSpecificationPart_) {
+ if (!inSpecificationPart_ || inEquivalenceStmt_) {
return false;
}
if (name.symbol) {
diff --git a/flang/test/Semantics/offsets03.f90 b/flang/test/Semantics/offsets03.f90
index 9d2716db7fc50b..7416b6d3f37d47 100644
--- a/flang/test/Semantics/offsets03.f90
+++ b/flang/test/Semantics/offsets03.f90
@@ -29,7 +29,7 @@ subroutine mc !CHECK: Subprogram scope: mc size=12 alignment=1
! Common block: objects are in order from COMMON statement and not part of module
module md !CHECK: Module scope: md size=1 alignment=1
- integer(1) :: i
+ integer(1) :: i
integer(2) :: d1 !CHECK: d1, PUBLIC size=2 offset=8:
integer(4) :: d2 !CHECK: d2, PUBLIC size=4 offset=4:
integer(1) :: d3 !CHECK: d3, PUBLIC size=1 offset=0:
@@ -65,3 +65,13 @@ module me
equivalence(a1,a3(1)),(a2,a3(2))
common /common8/ a1, a2 ! CHECK: common8 size=8 offset=0: CommonBlockDetails alignment=4:
end
+
+! Ensure EQUIVALENCE of undeclared names in internal subprogram doesn't
+! attempt to host-associate
+subroutine host1
+ contains
+ subroutine internal
+ common /b/ x(4) ! CHECK: x (Implicit) size=16 offset=0: ObjectEntity type: REAL(4) shape: 1_8:4_8
+ equivalence(x,y) ! CHECK: y (Implicit) size=4 offset=0: ObjectEntity type: REAL(4)
+ end
+end
More information about the flang-commits
mailing list