Skip to content

[Flang][OpenMP] Fix issue with empty critical or critical without surrounding context #71944

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
Nov 27, 2023
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
14 changes: 14 additions & 0 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,20 @@ class OmpVisitor : public virtual DeclarationVisitor {
void Post(const parser::OmpEndSectionsDirective &) {
messageHandler().set_currStmtSource(std::nullopt);
}
bool Pre(const parser::OmpCriticalDirective &x) {
AddOmpSourceRange(x.source);
return true;
}
void Post(const parser::OmpCriticalDirective &) {
messageHandler().set_currStmtSource(std::nullopt);
}
bool Pre(const parser::OmpEndCriticalDirective &x) {
AddOmpSourceRange(x.source);
return true;
}
void Post(const parser::OmpEndCriticalDirective &) {
messageHandler().set_currStmtSource(std::nullopt);
}
};

bool OmpVisitor::NeedsScope(const parser::OpenMPBlockConstruct &x) {
Expand Down
6 changes: 6 additions & 0 deletions flang/test/Semantics/OpenMP/critical-empty.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! Test that there are no errors for an empty critical construct

!$omp critical
!$omp end critical
end