Skip to content

Commit 93849a3

Browse files
[flang] Check for ultimate ALLOCATABLE component in LOCAL_INIT() (#145800)
Fortran 2023 constraint C1130 disallows variables of derived type with ultimate allocatable component to appear in LOCAL_INIT().
1 parent a68e447 commit 93849a3

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7278,6 +7278,14 @@ bool DeclarationVisitor::PassesLocalityChecks(
72787278
specName);
72797279
return false;
72807280
}
7281+
if (const DerivedTypeSpec *derived{type->AsDerived()}) { // F'2023 C1130
7282+
if (auto bad{FindAllocatableUltimateComponent(*derived)}) {
7283+
SayWithDecl(name, symbol,
7284+
"Derived type variable '%s' with ultimate ALLOCATABLE component '%s' not allowed in a %s locality-spec"_err_en_US,
7285+
bad.BuildResultDesignatorName(), specName);
7286+
return false;
7287+
}
7288+
}
72817289
}
72827290
if (symbol.attrs().test(Attr::ASYNCHRONOUS) && isReduce) { // F'2023 C1131
72837291
SayWithDecl(name, symbol,

flang/test/Semantics/resolve55.f90

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,23 @@ subroutine s8(arg)
9494
do concurrent(i=1:5) local(arg)
9595
end do
9696
end subroutine s8
97+
98+
subroutine s9()
99+
type l3
100+
integer, allocatable :: a
101+
end type
102+
type l2
103+
type(l3) :: l2_3
104+
end type
105+
type l1
106+
type(l2) :: l1_2
107+
end type
108+
type(l1) :: v
109+
integer sum
110+
111+
sum = 0
112+
!ERROR: Derived type variable 'v' with ultimate ALLOCATABLE component '%l1_2%l2_3%a' not allowed in a LOCAL_INIT locality-spec
113+
do concurrent (i = 1:10) local_init(v)
114+
sum = sum + i
115+
end do
116+
end subroutine s9

0 commit comments

Comments
 (0)