Skip to content

Commit dc0dcab

Browse files
authored
[flang][OpenMP] Allow flush of common block (#139528)
I think this was denied by accident in 68180d8. Flush of a common block is allowed by the standard on my reading. It is not allowed by classic-flang but is supported by gfortran and ifx. This doesn't need any lowering changes. The LLVM translation ignores the flush argument list because the openmp runtime library doesn't support flushing specific data. Depends upon #139522. Ignore the first commit in this PR.
1 parent f594cd0 commit dc0dcab

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,9 +2303,15 @@ void OmpStructureChecker::Enter(const parser::OpenMPFlushConstruct &x) {
23032303
void OmpStructureChecker::Leave(const parser::OpenMPFlushConstruct &x) {
23042304
auto &flushList{std::get<std::optional<parser::OmpArgumentList>>(x.v.t)};
23052305

2306+
auto isVariableListItemOrCommonBlock{[this](const Symbol &sym) {
2307+
return IsVariableListItem(sym) ||
2308+
sym.detailsIf<semantics::CommonBlockDetails>();
2309+
}};
2310+
23062311
if (flushList) {
23072312
for (const parser::OmpArgument &arg : flushList->v) {
2308-
if (auto *sym{GetArgumentSymbol(arg)}; sym && !IsVariableListItem(*sym)) {
2313+
if (auto *sym{GetArgumentSymbol(arg)};
2314+
sym && !isVariableListItemOrCommonBlock(*sym)) {
23092315
context_.Say(arg.source,
23102316
"FLUSH argument must be a variable list item"_err_en_US);
23112317
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
! RUN: %flang_fc1 -fopenmp -emit-hlfir -o - %s | FileCheck %s
2+
3+
! Regression test to ensure that the name /c/ in the flush argument list is
4+
! resolved to the common block symbol and common blocks are allowed in the
5+
! flush argument list.
6+
7+
! CHECK: %[[GLBL:.*]] = fir.address_of({{.*}}) : !fir.ref<!fir.array<4xi8>>
8+
common /c/ x
9+
real :: x
10+
! CHECK: omp.flush(%[[GLBL]] : !fir.ref<!fir.array<4xi8>>)
11+
!$omp flush(/c/)
12+
end
13+

flang/test/Semantics/OpenMP/flush04.f90

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)