Skip to content

[OpenMP] Fix a crash on invalid with unroll partial #139280

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

Merged
merged 3 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,8 @@ OpenMP Support
- Added support 'no_openmp_constructs' assumption clause.
- Added support for 'self_maps' in map and requirement clause.
- Added support for 'omp stripe' directive.
- Fixed a crashing bug with ``omp unroll partial`` if the argument to
``partial`` was an invalid expression. (#GH139267)
- 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
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14912,7 +14912,8 @@ StmtResult SemaOpenMP::ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses,
// Determine the unroll factor.
uint64_t Factor;
SourceLocation FactorLoc;
if (Expr *FactorVal = PartialClause->getFactor()) {
if (Expr *FactorVal = PartialClause->getFactor();
FactorVal && !FactorVal->containsErrors()) {
Factor = FactorVal->getIntegerConstantExpr(Context)->getZExtValue();
FactorLoc = FactorVal->getExprLoc();
} else {
Expand Down
9 changes: 9 additions & 0 deletions clang/test/OpenMP/unroll_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,12 @@ void template_inst(int n) {
// expected-note@+1 {{in instantiation of function template specialization 'templated_func<int, -1>' requested here}}
templated_func<int, -1>(n);
}

namespace GH139267 {
void f(void) {
// This would previously crash with follow-on recovery after issuing the error.
#pragma omp unroll partial(a) // expected-error {{use of undeclared identifier 'a'}}
for (int i = 0; i < 10; i++)
;
}
}