[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().
This commit is contained in:
Eugene Epshteyn
2025-06-30 15:49:07 -04:00
committed by GitHub
parent a68e4470c1
commit 93849a39c4
2 changed files with 28 additions and 0 deletions

View File

@@ -7278,6 +7278,14 @@ bool DeclarationVisitor::PassesLocalityChecks(
specName);
return false;
}
if (const DerivedTypeSpec *derived{type->AsDerived()}) { // F'2023 C1130
if (auto bad{FindAllocatableUltimateComponent(*derived)}) {
SayWithDecl(name, symbol,
"Derived type variable '%s' with ultimate ALLOCATABLE component '%s' not allowed in a %s locality-spec"_err_en_US,
bad.BuildResultDesignatorName(), specName);
return false;
}
}
}
if (symbol.attrs().test(Attr::ASYNCHRONOUS) && isReduce) { // F'2023 C1131
SayWithDecl(name, symbol,