[flang-commits] [flang] d892d73 - [flang] Fix common block size extension mistake in D109156

Jean Perier via flang-commits flang-commits at lists.llvm.org
Thu Sep 9 00:12:54 PDT 2021


Author: Jean Perier
Date: 2021-09-09T09:12:12+02:00
New Revision: d892d7323e451777ccf206a1e5b1c81ae34b8bfb

URL: https://github.com/llvm/llvm-project/commit/d892d7323e451777ccf206a1e5b1c81ae34b8bfb
DIFF: https://github.com/llvm/llvm-project/commit/d892d7323e451777ccf206a1e5b1c81ae34b8bfb.diff

LOG: [flang] Fix common block size extension mistake in D109156

https://reviews.llvm.org/D109156 did not properly update the case where
the equivalence symbol appearing in the common statement is the
"base symbol of an equivalence group" (this was the only case that previously
worked ok, and the patch broke it).

Fix this and add a test that actually uses this code path.

Differential Revision: https://reviews.llvm.org/D109439

Added: 
    

Modified: 
    flang/lib/Semantics/compute-offsets.cpp
    flang/test/Semantics/offsets03.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/compute-offsets.cpp b/flang/lib/Semantics/compute-offsets.cpp
index c878f6c806035..2451f0abdc7d7 100644
--- a/flang/lib/Semantics/compute-offsets.cpp
+++ b/flang/lib/Semantics/compute-offsets.cpp
@@ -154,7 +154,7 @@ void ComputeOffsetsHelper::DoCommonBlock(Symbol &commonBlock) {
     auto eqIter{equivalenceBlock_.end()};
     auto iter{dependents_.find(symbol)};
     if (iter == dependents_.end()) {
-      auto eqIter = equivalenceBlock_.find(symbol);
+      eqIter = equivalenceBlock_.find(symbol);
       if (eqIter != equivalenceBlock_.end()) {
         DoEquivalenceBlockBase(symbol, eqIter->second);
       }

diff  --git a/flang/test/Semantics/offsets03.f90 b/flang/test/Semantics/offsets03.f90
index 67e68f71f5c59..45d8d80444ae1 100644
--- a/flang/test/Semantics/offsets03.f90
+++ b/flang/test/Semantics/offsets03.f90
@@ -56,4 +56,8 @@ module me
   equivalence(i4, l4)
   equivalence(l4(10), k4)
   common /common6/ i4, j4   ! CHECK: common6 size=76 offset=0: CommonBlockDetails alignment=4:
+
+  integer :: i5, j5, l5(10)
+  equivalence(l5(1), i5)
+  common /common7/ j5, i5   ! CHECK: common7 size=44 offset=0: CommonBlockDetails alignment=4:
 end


        


More information about the flang-commits mailing list