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

via flang-commits flang-commits at lists.llvm.org
Fri Nov 10 06:13:45 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Kiran Chandramohan (kiranchandramohan)

<details>
<summary>Changes</summary>

Add the sourcerange for critical directive.

Fixes #<!-- -->65571

---
Full diff: https://github.com/llvm/llvm-project/pull/71944.diff


1 Files Affected:

- (modified) flang/lib/Semantics/resolve-names.cpp (+14) 


``````````diff
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) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/71944


More information about the flang-commits mailing list