Skip to content

Commit b249b49

Browse files
authored
[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
1 parent 6b7e65a commit b249b49

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,8 @@ OpenMP Support
903903
- Added support for 'omp stripe' directive.
904904
- Fixed a crashing bug with ``omp tile sizes`` if the argument to ``sizes`` was
905905
an invalid expression. (#GH139073)
906+
- Fixed a crashing bug with ``omp distribute dist_schedule`` if the argument to
907+
``dist_schedule`` was not strictly positive. (#GH139266)
906908

907909
Improvements
908910
^^^^^^^^^^^^

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22789,7 +22789,8 @@ OMPClause *SemaOpenMP::ActOnOpenMPDistScheduleClause(
2278922789
ValExpr->getIntegerConstantExpr(getASTContext())) {
2279022790
if (Result->isSigned() && !Result->isStrictlyPositive()) {
2279122791
Diag(ChunkSizeLoc, diag::err_omp_negative_expression_in_clause)
22792-
<< "dist_schedule" << ChunkSize->getSourceRange();
22792+
<< "dist_schedule" << /*strictly positive*/ 1
22793+
<< ChunkSize->getSourceRange();
2279322794
return nullptr;
2279422795
}
2279522796
} else if (getOpenMPCaptureRegionForClause(

clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,11 @@ int main(int argc, char **argv) {
105105

106106
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}}
107107
}
108+
109+
namespace GH139266 {
110+
void f(void) {
111+
#pragma omp distribute dist_schedule(static, 0) // expected-error {[argument to 'dist_schedule' clause must be a strictly positive integer value}}
112+
for (int i = 0; i < 10; i++)
113+
;
114+
}
115+
} // namespace GH139266

0 commit comments

Comments
 (0)