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

via flang-commits flang-commits at lists.llvm.org
Mon Oct 27 07:50:03 PDT 2025


Author: Krzysztof Parzyszek
Date: 2025-10-27T09:49:58-05:00
New Revision: 48cc443a72d639b226038571958a2464f1fc02b2

URL: https://github.com/llvm/llvm-project/commit/48cc443a72d639b226038571958a2464f1fc02b2
DIFF: https://github.com/llvm/llvm-project/commit/48cc443a72d639b226038571958a2464f1fc02b2.diff

LOG: [flang][OpenMP] Anonymous BLOCK DATA may not have Symbol at all (#165250)

This fixes https://linaro.atlassian.net/browse/LLVM-2106 and
https://github.com/llvm/llvm-project/issues/164815.

Added: 
    flang/test/Semantics/OpenMP/anonymous-block-data.f90

Modified: 
    flang/lib/Semantics/check-omp-structure.cpp

Removed: 
    


################################################################################
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


        


More information about the flang-commits mailing list