Skip to content

Commit 1860c03

Browse files
[Flang][OpenMP] Make a private copy for the common block variables in copyin clause
Issue: Incorrect execution result when common block name is specified in copyin clause
1 parent 88478a8 commit 1860c03

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

flang/lib/Lower/Bridge.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,13 +921,20 @@ class FirConverter : public Fortran::lower::AbstractConverter {
921921
std::function<void(const Fortran::semantics::Symbol &, bool)>
922922
insertSymbols = [&](const Fortran::semantics::Symbol &oriSymbol,
923923
bool collectSymbol) {
924-
if (collectSymbol && oriSymbol.test(flag))
924+
if (collectSymbol && oriSymbol.test(flag)) {
925925
symbolSet.insert(&oriSymbol);
926-
else if (checkHostAssociatedSymbols)
926+
} else if (const auto *commonDetails =
927+
oriSymbol.detailsIf<
928+
Fortran::semantics::CommonBlockDetails>()) {
929+
for (const auto &mem : commonDetails->objects())
930+
if (collectSymbol && mem->test(flag))
931+
symbolSet.insert(&(*mem).GetUltimate());
932+
} else if (checkHostAssociatedSymbols) {
927933
if (const auto *details{
928934
oriSymbol
929935
.detailsIf<Fortran::semantics::HostAssocDetails>()})
930936
insertSymbols(details->symbol(), true);
937+
}
931938
};
932939
insertSymbols(sym, collectSymbols);
933940
};

0 commit comments

Comments
 (0)