Skip to content

[flang][OpenMP][Semantics] resolve objects in the flush arg list #139522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,19 @@ 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)}) {
ResolveOmpObject(*object, Symbol::Flag::OmpDependObject);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this is a copy paste error. This is not a DependObject, so I think adding the Symbol::Flag::OmpDependObject is probably not right.

What do we want to do here? Is it just resolving the names in the flush argument list to the appropriate Fortran declarations? If so, we should use ResolveName.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If common blocks are not handled in ResolveName then you can probably use OmpFlushed as the Symbol in ResolveOmpObject.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it was a copy and paste error. Thanks for catching this.

I had assumed that given an object, the right way to resolve it was to call ResolveOmpObject. I have now changed to include only the relevant parts of the code inline.

}
}
}
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