-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[OpenMP] Fix crash when diagnosing dist_schedule #139277
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
We were failing to pass a required argument when emitting the diagnostic, so the source range was being used in place of an index. This caused a failed assertion due to the incorrect index. Fixes llvm#139266
@llvm/pr-subscribers-openmp @llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) ChangesWe were failing to pass a required argument when emitting the diagnostic, so the source range was being used in place of an index. This caused a failed assertion due to the incorrect index. Fixes #139266 Full diff: https://github.com/llvm/llvm-project/pull/139277.diff 3 Files Affected:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6c32a7e9a5613..f7d56cfd19ce5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -903,6 +903,8 @@ OpenMP Support
- Added support for 'omp stripe' directive.
- Fixed a crashing bug with ``omp tile sizes`` if the argument to ``sizes`` was
an invalid expression. (#GH139073)
+- Fixed a crashing bug with ``omp distribute dist_schedule`` if the argument to
+ ``dist_schedule`` was not strictly positive. (#GH139266)
Improvements
^^^^^^^^^^^^
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 2534822b72f80..e1c63d582c615 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -22753,7 +22753,8 @@ OMPClause *SemaOpenMP::ActOnOpenMPDistScheduleClause(
ValExpr->getIntegerConstantExpr(getASTContext())) {
if (Result->isSigned() && !Result->isStrictlyPositive()) {
Diag(ChunkSizeLoc, diag::err_omp_negative_expression_in_clause)
- << "dist_schedule" << ChunkSize->getSourceRange();
+ << "dist_schedule" << /*strictly positive*/ 1
+ << ChunkSize->getSourceRange();
return nullptr;
}
} else if (getOpenMPCaptureRegionForClause(
diff --git a/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp b/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
index 22d2408d3f178..72d8e33173d71 100644
--- a/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
@@ -105,3 +105,11 @@ int main(int argc, char **argv) {
return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0])); // expected-note {{in instantiation of function template specialization 'tmain<int, 5>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<char, 1>' requested here}}
}
+
+namespace GH139266 {
+void f(void) {
+#pragma omp distribute dist_schedule(static, 0) // expected-error {[argument to 'dist_schedule' clause must be a strictly positive integer value}}
+ for (int i = 0; i < 10; i++)
+ ;
+}
+} // namespace GH139266
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/24756 Here is the relevant piece of the build log for the reference
|
|
||
namespace GH139266 { | ||
void f(void) { | ||
#pragma omp distribute dist_schedule(static, 0) // expected-error {[argument to 'dist_schedule' clause must be a strictly positive integer value}} |
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.
a {
is missing.
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.
Yup, already fixed it. :-)
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/5055 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/14789 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/174/builds/17515 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/46/builds/16524 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/56/builds/25482 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/60/builds/26998 Here is the relevant piece of the build log for the reference
|
We were failing to pass a required argument when emitting the diagnostic, so the source range was being used in place of an index. This caused a failed assertion due to the incorrect index.
Fixes #139266