diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp index 8f6a623508aa7..981b9416bce5c 100644 --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -2303,9 +2303,15 @@ void OmpStructureChecker::Enter(const parser::OpenMPFlushConstruct &x) { void OmpStructureChecker::Leave(const parser::OpenMPFlushConstruct &x) { auto &flushList{std::get>(x.v.t)}; + auto isVariableListItemOrCommonBlock{[this](const Symbol &sym) { + return IsVariableListItem(sym) || + sym.detailsIf(); + }}; + if (flushList) { for (const parser::OmpArgument &arg : flushList->v) { - if (auto *sym{GetArgumentSymbol(arg)}; sym && !IsVariableListItem(*sym)) { + if (auto *sym{GetArgumentSymbol(arg)}; + sym && !isVariableListItemOrCommonBlock(*sym)) { context_.Say(arg.source, "FLUSH argument must be a variable list item"_err_en_US); } diff --git a/flang/test/Lower/OpenMP/flush-common.f90 b/flang/test/Lower/OpenMP/flush-common.f90 new file mode 100644 index 0000000000000..7656141dcb295 --- /dev/null +++ b/flang/test/Lower/OpenMP/flush-common.f90 @@ -0,0 +1,13 @@ +! RUN: %flang_fc1 -fopenmp -emit-hlfir -o - %s | FileCheck %s + +! Regression test to ensure that the name /c/ in the flush argument list is +! resolved to the common block symbol and common blocks are allowed in the +! flush argument list. + +! CHECK: %[[GLBL:.*]] = fir.address_of({{.*}}) : !fir.ref> + common /c/ x + real :: x +! CHECK: omp.flush(%[[GLBL]] : !fir.ref>) + !$omp flush(/c/) +end + diff --git a/flang/test/Semantics/OpenMP/flush04.f90 b/flang/test/Semantics/OpenMP/flush04.f90 deleted file mode 100644 index ffc2273b692dc..0000000000000 --- a/flang/test/Semantics/OpenMP/flush04.f90 +++ /dev/null @@ -1,11 +0,0 @@ -! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp - -! Regression test to ensure that the name /c/ in the flush argument list is -! resolved to the common block symbol. - - common /c/ x - real :: x -!ERROR: FLUSH argument must be a variable list item - !$omp flush(/c/) -end -