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

Add the sourcerange for critical directive.

Fixes #65571
This commit is contained in:
Kiran Chandramohan
2023-11-27 15:56:39 +00:00
committed by GitHub
parent 12bb2910c3
commit 63a6e51f8a
2 changed files with 20 additions and 0 deletions

View File

@@ -1459,6 +1459,20 @@ public:
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) {

View File

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