[OpenMP] Fix a crash on invalid with unroll partial (#139280)
You cannot get the integer constant expression's value if the expression contains errors. Fixes https://github.com/llvm/llvm-project/issues/139267
This commit is contained in:
@@ -905,6 +905,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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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++)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user