aboutsummaryrefslogtreecommitdiff
path: root/clang
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2025-05-09 11:12:19 -0400
committerGitHub <noreply@github.com>2025-05-09 11:12:19 -0400
commitb249b49c133d0b4e1e2505dfd0a53f4da50d2a7a (patch)
tree4e430793175377abad00cd356d39ee10a323df23 /clang
parent6b7e65a1115bbeb4d881d2ac0a3adaa86d47d598 (diff)
downloadllvm-b249b49c133d0b4e1e2505dfd0a53f4da50d2a7a.zip
llvm-b249b49c133d0b4e1e2505dfd0a53f4da50d2a7a.tar.gz
llvm-b249b49c133d0b4e1e2505dfd0a53f4da50d2a7a.tar.bz2
[OpenMP] Fix crash when diagnosing dist_schedule (#139277)
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
Diffstat (limited to 'clang')
-rw-r--r--clang/docs/ReleaseNotes.rst2
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp3
-rw-r--r--clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp8
3 files changed, 12 insertions, 1 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6c32a7e..f7d56cf 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 90437fc..50211c5 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -22789,7 +22789,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 22d2408..72d8e33 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