Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,26 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
}
void Post(const parser::OpenMPDepobjConstruct &) { PopContext(); }

bool Pre(const parser::OpenMPFlushConstruct &x) {
PushContext(x.source, llvm::omp::Directive::OMPD_flush);
for (auto &arg : x.v.Arguments().v) {
if (auto *locator{std::get_if<parser::OmpLocator>(&arg.u)}) {
if (auto *object{std::get_if<parser::OmpObject>(&locator->u)}) {
if (auto *name{std::get_if<parser::Name>(&object->u)}) {
// ResolveOmpCommonBlockName resolves the symbol as a side effect
if (!ResolveOmpCommonBlockName(name)) {
context_.Say(name->source, // 2.15.3
"COMMON block must be declared in the same scoping unit "
"in which the OpenMP directive or clause appears"_err_en_US);
}
}
}
}
}
return true;
}
void Post(const parser::OpenMPFlushConstruct &) { PopContext(); }

bool Pre(const parser::OpenMPRequiresConstruct &x) {
using Flags = WithOmpDeclarative::RequiresFlags;
using Requires = WithOmpDeclarative::RequiresFlag;
Expand Down
11 changes: 11 additions & 0 deletions flang/test/Semantics/OpenMP/flush04.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
! 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