[flang-commits] [flang] [flang][OpenMP] Anonymous BLOCK DATA may not have Symbol at all (PR #165250)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Mon Oct 27 06:36:10 PDT 2025
https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/165250
This fixes https://linaro.atlassian.net/browse/LLVM-2106.
>From 27926fab706f3bdc96bdc77a55b4a354d7ec6390 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Mon, 27 Oct 2025 08:13:01 -0500
Subject: [PATCH] [flang][OpenMP] Anonymous BLOCK DATA may not have Symbol at
all
This fixes https://linaro.atlassian.net/browse/LLVM-2106.
---
flang/lib/Semantics/check-omp-structure.cpp | 2 +-
flang/test/Semantics/OpenMP/anonymous-block-data.f90 | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
create mode 100644 flang/test/Semantics/OpenMP/anonymous-block-data.f90
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