summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorKelvin Li <kkwli0@gmail.com>2020-01-03 11:55:37 -0500
committerKelvin Li <kkwli0@gmail.com>2020-01-03 11:55:37 -0500
commit427ffa2cdbbc7337d903ba71823a7830fa92568d (patch)
tree41e84011459e232d710fabc71c519df074247477 /clang/lib/Sema/SemaOpenMP.cpp
parentd2d2fb19f7ea3b192247ca2d6995e66229366cec (diff)
downloadbcm5719-llvm-427ffa2cdbbc7337d903ba71823a7830fa92568d.tar.gz
bcm5719-llvm-427ffa2cdbbc7337d903ba71823a7830fa92568d.zip
[OpenMP] diagnose zero-length array section in the depend clause
The OpenMP specification disallows having zero-length array sections in the depend clause (OpenMP 5.0 2.17.11). Differential Revision: https://reviews.llvm.org/D71969
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 23cd6f04a93..5a4254f11a8 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15020,6 +15020,22 @@ Sema::ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind,
}
OpsOffs.emplace_back(RHS, OOK);
} else {
+ // OpenMP 5.0 [2.17.11, Restrictions]
+ // List items used in depend clauses cannot be zero-length array sections.
+ const auto *OASE = dyn_cast<OMPArraySectionExpr>(SimpleExpr);
+ if (OASE) {
+ const Expr *Length = OASE->getLength();
+ Expr::EvalResult Result;
+ if (Length && !Length->isValueDependent() &&
+ Length->EvaluateAsInt(Result, Context) &&
+ Result.Val.getInt().isNullValue()) {
+ Diag(ELoc,
+ diag::err_omp_depend_zero_length_array_section_not_allowed)
+ << SimpleExpr->getSourceRange();
+ continue;
+ }
+ }
+
auto *ASE = dyn_cast<ArraySubscriptExpr>(SimpleExpr);
if (!RefExpr->IgnoreParenImpCasts()->isLValue() ||
(ASE &&
OpenPOWER on IntegriCloud