-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[flang][OpenMP] Anonymous BLOCK DATA may not have Symbol at all #165250
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
Conversation
|
@llvm/pr-subscribers-flang-openmp Author: Krzysztof Parzyszek (kparzysz) ChangesThis fixes https://linaro.atlassian.net/browse/LLVM-2106. Full diff: https://github.com/llvm/llvm-project/pull/165250.diff 2 Files Affected:
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
|
|
@llvm/pr-subscribers-flang-semantics Author: Krzysztof Parzyszek (kparzysz) ChangesThis fixes https://linaro.atlassian.net/browse/LLVM-2106. Full diff: https://github.com/llvm/llvm-project/pull/165250.diff 2 Files Affected:
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
|
|
This also fixes #164815 |
eugeneepshteyn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Our latest tests have confirmed that all regressions detected in https://linaro.atlassian.net/browse/LLVM-2106 have been resolved. Thank you for the patch. |
This fixes https://linaro.atlassian.net/browse/LLVM-2106.