[flang-commits] [flang] [flang][OpenMP] Anonymous BLOCK DATA may not have Symbol at all (PR #165250)

via flang-commits flang-commits at lists.llvm.org
Mon Oct 27 06:36:57 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-openmp

Author: Krzysztof Parzyszek (kparzysz)

<details>
<summary>Changes</summary>

This fixes https://linaro.atlassian.net/browse/LLVM-2106.

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


2 Files Affected:

- (modified) flang/lib/Semantics/check-omp-structure.cpp (+1-1) 
- (added) flang/test/Semantics/OpenMP/anonymous-block-data.f90 (+11) 


``````````diff
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 41416304c1ea6..e094458f001e3 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -98,7 +98,7 @@ bool OmpStructureChecker::Enter(const parser::BlockData &x) {
   } else {
     for (const Scope &scope : context_.globalScope().children()) {
       if (scope.kind() == Scope::Kind::BlockData) {
-        if (scope.symbol()->name().empty()) {
+        if (auto *s{scope.symbol()}; !s || s->name().empty()) {
           scopeStack_.push_back(&scope);
           break;
         }
diff --git a/flang/test/Semantics/OpenMP/anonymous-block-data.f90 b/flang/test/Semantics/OpenMP/anonymous-block-data.f90
new file mode 100644
index 0000000000000..129a95f9f5621
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/anonymous-block-data.f90
@@ -0,0 +1,11 @@
+!RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck %s
+
+! To trigger the crash, -fsyntax-only was sufficient, but when everything
+! is correct, it won't produce any output. To get something to check on
+! success, run unparse, which does run semantic checks.
+
+block data
+end
+
+!CHECK: BLOCK DATA
+!CHECK: END BLOCK DATA

``````````

</details>


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


More information about the flang-commits mailing list