Skip to content

[flang][OpenACC] Fix crash due to truncated scope source range #136206

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 1 commit into from
Apr 18, 2025

Conversation

klausler
Copy link
Contributor

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

Fixes #136076.

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

Fixes llvm#136076.
@klausler klausler requested a review from clementval April 17, 2025 21:37
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Apr 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 17, 2025

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

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

Fixes #136076.


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

1 Files Affected:

  • (modified) flang/lib/Semantics/resolve-names.cpp (+14)
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;

Copy link
Contributor

@clementval clementval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@klausler klausler merged commit 0dd2ed4 into llvm:main Apr 18, 2025
14 checks passed
@klausler klausler deleted the bug136076 branch April 18, 2025 19:52
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…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 llvm#136076.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…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 llvm#136076.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…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 llvm#136076.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Flang][OpenACC] fatal internal error: SemanticsContext::FindScope(): invalid source location for 'kernels loop'
3 participants