[flang-commits] [flang] [Flang][OpenMP] Fix issue with empty critical or critical without surrounding context (PR #71944)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Thu Nov 23 04:55:46 PST 2023
https://github.com/kiranchandramohan updated https://github.com/llvm/llvm-project/pull/71944
>From 4740fe15c629e30e86de8d5be322920efc6e1db6 Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Fri, 10 Nov 2023 13:02:15 +0000
Subject: [PATCH 1/2] [Flang][OpenMP] Fix issue with empty critical section
Add the sourcerange for critical directive.
Fixes #65571
---
flang/lib/Semantics/resolve-names.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 98773a1b9d6ab45..58d88f1bb428387 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -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) {
>From f56e966eee1a0690a38a51ed94841fe56a0905a4 Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Thu, 23 Nov 2023 12:45:07 +0000
Subject: [PATCH 2/2] Add test
---
flang/test/Semantics/OpenMP/critical-empty.f90 | 6 ++++++
1 file changed, 6 insertions(+)
create mode 100644 flang/test/Semantics/OpenMP/critical-empty.f90
diff --git a/flang/test/Semantics/OpenMP/critical-empty.f90 b/flang/test/Semantics/OpenMP/critical-empty.f90
new file mode 100644
index 000000000000000..2001c8a14a7ba40
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/critical-empty.f90
@@ -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
More information about the flang-commits
mailing list