Skip to content

Commit 170c0c5

Browse files
authored
[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
1 parent 1f05682 commit 170c0c5

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

flang/lib/Lower/ConvertVariable.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,6 +2439,11 @@ void Fortran::lower::mapSymbolAttributes(
24392439

24402440
// Compute array extents and lower bounds.
24412441
if (ba.isArray()) {
2442+
// Handle unused entry dummy arrays with BaseBoxType before processing shape
2443+
if (isUnusedEntryDummy &&
2444+
llvm::isa<fir::BaseBoxType>(converter.genType(var)))
2445+
if (genUnusedEntryPointBox())
2446+
return;
24422447
if (ba.isStaticArray()) {
24432448
if (ba.lboundIsAllOnes()) {
24442449
for (std::int64_t extent :

flang/test/Lower/box-address.f90

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
! RUN: flang -fc1 -emit-hlfir %s -o - | FileCheck %s
2+
3+
module m3
4+
type x1
5+
integer::ix1
6+
end type x1
7+
type,extends(x1)::x2
8+
end type x2
9+
type,extends(x2)::x3
10+
end type x3
11+
class(x1),pointer,dimension(:)::cy1
12+
contains
13+
subroutine dummy()
14+
entry chk(c1)
15+
class(x1),dimension(3)::c1
16+
end subroutine dummy
17+
end module m3
18+
! CHECK-LABEL: func.func @_QMm3Pchk(
19+
! CHECK-SAME: %[[ARG0:.*]]: !fir.class<!fir.array<3x!fir.type<_QMm3Tx1{ix1:i32}>>> {fir.bindc_name = "c1"}) {
20+
! CHECK: %[[DUMMY_SCOPE:.*]] = fir.dummy_scope : !fir.dscope
21+
! 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}>>>)
22+
23+
subroutine s1
24+
use m3
25+
type(x1),target::ty1(3)
26+
ty1%ix1=[1,2,3]
27+
cy1=>ty1
28+
call chk(cy1)
29+
end subroutine s1
30+
31+
program main
32+
call s1
33+
print *,'pass'
34+
end program main

0 commit comments

Comments
 (0)