Skip to content

Commit 48cc443

Browse files
authored
[flang][OpenMP] Anonymous BLOCK DATA may not have Symbol at all (#165250)
This fixes https://linaro.atlassian.net/browse/LLVM-2106 and #164815.
1 parent 86cd1df commit 48cc443

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ bool OmpStructureChecker::Enter(const parser::BlockData &x) {
9898
} else {
9999
for (const Scope &scope : context_.globalScope().children()) {
100100
if (scope.kind() == Scope::Kind::BlockData) {
101-
if (scope.symbol()->name().empty()) {
101+
if (auto *s{scope.symbol()}; !s || s->name().empty()) {
102102
scopeStack_.push_back(&scope);
103103
break;
104104
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
!RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck %s
2+
3+
! To trigger the crash, -fsyntax-only was sufficient, but when everything
4+
! is correct, it won't produce any output. To get something to check on
5+
! success, run unparse, which does run semantic checks.
6+
7+
block data
8+
end
9+
10+
!CHECK: BLOCK DATA
11+
!CHECK: END BLOCK DATA

0 commit comments

Comments
 (0)