[flang-commits] [flang] [flang][OpenACC] Fix crash due to truncated scope source range (PR #136206)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Thu Apr 17 14:37:31 PDT 2025


https://github.com/klausler created https://github.com/llvm/llvm-project/pull/136206

A combined construct needs to ensure that the source range of their initial statement is part of the source range of their scope.

Fixes https://github.com/llvm/llvm-project/issues/136076.

>From a9f79b9a896953126a42a4a6907a255c82aa7159 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Thu, 17 Apr 2025 14:34:24 -0700
Subject: [PATCH] [flang][OpenACC] Fix crash due to truncated scope source
 range

A combined construct needs to ensure that the source range of
their initial statement is part of the source range of their
scope.

Fixes https://github.com/llvm/llvm-project/issues/136076.
---
 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 74367b5229548..a04d976c69f05 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1384,6 +1384,20 @@ class AccVisitor : public virtual DeclarationVisitor {
   void Post(const parser::AccEndBlockDirective &) {
     messageHandler().set_currStmtSource(std::nullopt);
   }
+  bool Pre(const parser::AccBeginCombinedDirective &x) {
+    AddAccSourceRange(x.source);
+    return true;
+  }
+  void Post(const parser::AccBeginCombinedDirective &) {
+    messageHandler().set_currStmtSource(std::nullopt);
+  }
+  bool Pre(const parser::AccEndCombinedDirective &x) {
+    AddAccSourceRange(x.source);
+    return true;
+  }
+  void Post(const parser::AccEndCombinedDirective &) {
+    messageHandler().set_currStmtSource(std::nullopt);
+  }
   bool Pre(const parser::AccBeginLoopDirective &x) {
     AddAccSourceRange(x.source);
     return true;



More information about the flang-commits mailing list