aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorJennifer Yu <jennifer.yu@intel.com>2022-11-10 18:12:35 -0800
committerJennifer Yu <jennifer.yu@intel.com>2022-11-15 14:06:50 -0800
commit628fdc3f57adeab111ff43306f44542728e65a07 (patch)
tree874bfe151129ebaa5716e6effed5c747e2e5a5ec /clang/lib/Sema/SemaOpenMP.cpp
parent05ec16d90deb747414c8534f98617d25d90bb714 (diff)
downloadllvm-628fdc3f57adeab111ff43306f44542728e65a07.zip
llvm-628fdc3f57adeab111ff43306f44542728e65a07.tar.gz
llvm-628fdc3f57adeab111ff43306f44542728e65a07.tar.bz2
[OPENMP]Initial support for at clause
Error directive is allowed in both declared and executable contexts. The function ActOnOpenMPAtClause is called in both places during the parsers. Adding a param "bool InExContext" to identify context which is used to emit error massage. Differential Revision: https://reviews.llvm.org/D137851
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp44
1 files changed, 42 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 2772ac6..8070f10 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -6308,7 +6308,7 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
break;
case OMPD_error:
assert(AStmt == nullptr &&
- "No associated statement allowed for 'omp taskyield' directive");
+ "No associated statement allowed for 'omp error' directive");
Res = ActOnOpenMPErrorDirective(ClausesWithImplicit, StartLoc, EndLoc);
break;
case OMPD_barrier:
@@ -6719,6 +6719,7 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
case OMPC_device_type:
case OMPC_match:
case OMPC_when:
+ case OMPC_at:
default:
llvm_unreachable("Unexpected clause");
}
@@ -11028,7 +11029,21 @@ StmtResult Sema::ActOnOpenMPBarrierDirective(SourceLocation StartLoc,
StmtResult Sema::ActOnOpenMPErrorDirective(ArrayRef<OMPClause *> Clauses,
SourceLocation StartLoc,
- SourceLocation EndLoc) {
+ SourceLocation EndLoc,
+ bool InExContext) {
+ auto AtClauses =
+ OMPExecutableDirective::getClausesOfKind<OMPAtClause>(Clauses);
+ const OMPAtClause *AtC = AtClauses.empty() ? nullptr : (*AtClauses.begin());
+
+ if (AtC && !InExContext && AtC->getAtKind() == OMPC_AT_execution) {
+ Diag(AtC->getAtKindKwLoc(), diag::err_omp_unexpected_execution_modifier);
+ return StmtError();
+ }
+ if (!AtC || AtC->getAtKind() == OMPC_AT_compilation) {
+ Diag(AtC ? AtC->getBeginLoc() : StartLoc, diag::err_diagnose_if_succeeded)
+ << "ERROR";
+ return StmtError();
+ }
return OMPErrorDirective::Create(Context, StartLoc, EndLoc, Clauses);
}
@@ -15171,6 +15186,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
case OMPC_match:
case OMPC_nontemporal:
case OMPC_order:
+ case OMPC_at:
case OMPC_destroy:
case OMPC_inclusive:
case OMPC_exclusive:
@@ -16096,6 +16112,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
case OMPC_match:
case OMPC_nontemporal:
case OMPC_order:
+ case OMPC_at:
case OMPC_destroy:
case OMPC_detach:
case OMPC_inclusive:
@@ -16498,6 +16515,10 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
Res = ActOnOpenMPBindClause(static_cast<OpenMPBindClauseKind>(Argument),
ArgumentLoc, StartLoc, LParenLoc, EndLoc);
break;
+ case OMPC_at:
+ Res = ActOnOpenMPAtClause(static_cast<OpenMPAtClauseKind>(Argument),
+ ArgumentLoc, StartLoc, LParenLoc, EndLoc);
+ break;
case OMPC_if:
case OMPC_final:
case OMPC_num_threads:
@@ -16676,6 +16697,22 @@ OMPClause *Sema::ActOnOpenMPAtomicDefaultMemOrderClause(
LParenLoc, EndLoc);
}
+OMPClause *Sema::ActOnOpenMPAtClause(OpenMPAtClauseKind Kind,
+ SourceLocation KindKwLoc,
+ SourceLocation StartLoc,
+ SourceLocation LParenLoc,
+ SourceLocation EndLoc) {
+ if (Kind == OMPC_AT_unknown) {
+ Diag(KindKwLoc, diag::err_omp_unexpected_clause_value)
+ << getListOfPossibleValues(OMPC_at, /*First=*/0,
+ /*Last=*/OMPC_AT_unknown)
+ << getOpenMPClauseName(OMPC_at);
+ return nullptr;
+ }
+ return new (Context)
+ OMPAtClause(Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
+}
+
OMPClause *Sema::ActOnOpenMPOrderClause(OpenMPOrderClauseKind Kind,
SourceLocation KindKwLoc,
SourceLocation StartLoc,
@@ -16875,6 +16912,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause(
case OMPC_match:
case OMPC_nontemporal:
case OMPC_order:
+ case OMPC_at:
case OMPC_destroy:
case OMPC_novariants:
case OMPC_nocontext:
@@ -17131,6 +17169,7 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
case OMPC_match:
case OMPC_nontemporal:
case OMPC_order:
+ case OMPC_at:
case OMPC_novariants:
case OMPC_nocontext:
case OMPC_detach:
@@ -17685,6 +17724,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause(OpenMPClauseKind Kind,
case OMPC_device_type:
case OMPC_match:
case OMPC_order:
+ case OMPC_at:
case OMPC_destroy:
case OMPC_novariants:
case OMPC_nocontext: