[Flang] Fix a crash when equivalence and namelist statements are used (#150081)
Check for equivalence when generating namelist descriptors in IO.cpp. Fixes #124489
This commit is contained in:
parent
1db54c705a
commit
3db29aaee5
@ -464,8 +464,10 @@ getNamelistGroup(Fortran::lower::AbstractConverter &converter,
|
||||
fir::BoxType boxTy =
|
||||
fir::BoxType::get(fir::PointerType::get(converter.genType(s)));
|
||||
auto descFunc = [&](fir::FirOpBuilder &b) {
|
||||
bool couldBeInEquivalence =
|
||||
Fortran::semantics::FindEquivalenceSet(s) != nullptr;
|
||||
auto box = Fortran::lower::genInitialDataTarget(
|
||||
converter, loc, boxTy, *expr, /*couldBeInEquivalence=*/true);
|
||||
converter, loc, boxTy, *expr, couldBeInEquivalence);
|
||||
b.create<fir::HasValueOp>(loc, box);
|
||||
};
|
||||
builder.createGlobalConstant(loc, boxTy, mangleName, descFunc, linkOnce);
|
||||
|
19
flang/test/Lower/equivalence-3.f
Normal file
19
flang/test/Lower/equivalence-3.f
Normal file
@ -0,0 +1,19 @@
|
||||
! RUN: bbc -emit-fir -o - %s | FileCheck %s
|
||||
|
||||
! CHECK-LABEL: func @_QQmain
|
||||
program main
|
||||
real a1,a2
|
||||
equivalence (a1,a2)
|
||||
! A fir.alloca should never appear in a global constant initialization.
|
||||
! CHECK: fir.global linkonce @_QFEx1.desc constant : !fir.box<!fir.ptr<!fir.array<5xf64>>>
|
||||
! CHECK: arith.constant 5 : index
|
||||
! CHECK:fir.address_of(@_QFEx1) : !fir.ref<!fir.array<5xf64>>
|
||||
! CHECK: fir.shape %c5 : (index) -> !fir.shape<1>
|
||||
! CHECK: fir.declare %0(%1) {uniq_name = "_QFEx1"} : (!fir.ref<!fir.array<5xf64>>, !fir.shape<1>) -> !fir.ref<!fir.array<5xf64>>
|
||||
! CHECK: fir.embox %2(%1) : (!fir.ref<!fir.array<5xf64>>, !fir.shape<1>) -> !fir.box<!fir.array<5xf64>>
|
||||
! CHECK: fir.rebox %3 : (!fir.box<!fir.array<5xf64>>) -> !fir.box<!fir.ptr<!fir.array<5xf64>>>
|
||||
! CHECK: fir.has_value %4 : !fir.box<!fir.ptr<!fir.array<5xf64>>>
|
||||
real*8 x1(5)
|
||||
namelist /y1/x1
|
||||
read (5,y1)
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user