[flang-commits] [flang] 170c0c5 - [Flang] Handle unused entry dummies before processing shape (#157732)
via flang-commits
flang-commits at lists.llvm.org
Wed Sep 17 06:52:37 PDT 2025
Author: Carlos Seo
Date: 2025-09-17T10:52:33-03:00
New Revision: 170c0c52250dab52cbb63de25ad16ff97a407cbf
URL: https://github.com/llvm/llvm-project/commit/170c0c52250dab52cbb63de25ad16ff97a407cbf
DIFF: https://github.com/llvm/llvm-project/commit/170c0c52250dab52cbb63de25ad16ff97a407cbf.diff
LOG: [Flang] Handle unused entry dummies before processing shape (#157732)
Check for unused entry dummy arrays with BaseBoxType that calls
genUnusedEntryPointBox() before processing array shapes.
Fixes #132648
Added:
flang/test/Lower/box-address.f90
Modified:
flang/lib/Lower/ConvertVariable.cpp
Removed:
################################################################################
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index ccfde16ce2c32..da964c956dbd0 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -2439,6 +2439,11 @@ void Fortran::lower::mapSymbolAttributes(
// Compute array extents and lower bounds.
if (ba.isArray()) {
+ // Handle unused entry dummy arrays with BaseBoxType before processing shape
+ if (isUnusedEntryDummy &&
+ llvm::isa<fir::BaseBoxType>(converter.genType(var)))
+ if (genUnusedEntryPointBox())
+ return;
if (ba.isStaticArray()) {
if (ba.lboundIsAllOnes()) {
for (std::int64_t extent :
diff --git a/flang/test/Lower/box-address.f90 b/flang/test/Lower/box-address.f90
new file mode 100644
index 0000000000000..04f14188a7bec
--- /dev/null
+++ b/flang/test/Lower/box-address.f90
@@ -0,0 +1,34 @@
+! RUN: flang -fc1 -emit-hlfir %s -o - | FileCheck %s
+
+module m3
+ type x1
+ integer::ix1
+ end type x1
+ type,extends(x1)::x2
+ end type x2
+ type,extends(x2)::x3
+ end type x3
+ class(x1),pointer,dimension(:)::cy1
+contains
+ subroutine dummy()
+ entry chk(c1)
+ class(x1),dimension(3)::c1
+ end subroutine dummy
+end module m3
+! CHECK-LABEL: func.func @_QMm3Pchk(
+! CHECK-SAME: %[[ARG0:.*]]: !fir.class<!fir.array<3x!fir.type<_QMm3Tx1{ix1:i32}>>> {fir.bindc_name = "c1"}) {
+! CHECK: %[[DUMMY_SCOPE:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[DECLARE:.*]]:2 = hlfir.declare %[[ARG0]] dummy_scope %[[DUMMY_SCOPE]] {uniq_name = "_QMm3FdummyEc1"} : (!fir.class<!fir.array<3x!fir.type<_QMm3Tx1{ix1:i32}>>>, !fir.dscope) -> (!fir.class<!fir.array<3x!fir.type<_QMm3Tx1{ix1:i32}>>>, !fir.class<!fir.array<3x!fir.type<_QMm3Tx1{ix1:i32}>>>)
+
+subroutine s1
+ use m3
+ type(x1),target::ty1(3)
+ ty1%ix1=[1,2,3]
+ cy1=>ty1
+ call chk(cy1)
+end subroutine s1
+
+program main
+ call s1
+ print *,'pass'
+end program main
More information about the flang-commits
mailing list