@@ -471,6 +471,22 @@ bool doesClauseApplyToDirective(OpenACCDirectiveKind DirectiveKind,
471471 return false ;
472472 }
473473 }
474+ case OpenACCClauseKind::Device: {
475+ switch (DirectiveKind) {
476+ case OpenACCDirectiveKind::Update:
477+ return true ;
478+ default :
479+ return false ;
480+ }
481+ }
482+ case OpenACCClauseKind::Host: {
483+ switch (DirectiveKind) {
484+ case OpenACCDirectiveKind::Update:
485+ return true ;
486+ default :
487+ return false ;
488+ }
489+ }
474490 }
475491
476492 default :
@@ -1040,6 +1056,28 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitPresentClause(
10401056 Clause.getVarList (), Clause.getEndLoc ());
10411057}
10421058
1059+ OpenACCClause *SemaOpenACCClauseVisitor::VisitHostClause (
1060+ SemaOpenACC::OpenACCParsedClause &Clause) {
1061+ // ActOnVar ensured that everything is a valid variable reference, so there
1062+ // really isn't anything to do here. GCC does some duplicate-finding, though
1063+ // it isn't apparent in the standard where this is justified.
1064+
1065+ return OpenACCHostClause::Create (Ctx, Clause.getBeginLoc (),
1066+ Clause.getLParenLoc (), Clause.getVarList (),
1067+ Clause.getEndLoc ());
1068+ }
1069+
1070+ OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceClause (
1071+ SemaOpenACC::OpenACCParsedClause &Clause) {
1072+ // ActOnVar ensured that everything is a valid variable reference, so there
1073+ // really isn't anything to do here. GCC does some duplicate-finding, though
1074+ // it isn't apparent in the standard where this is justified.
1075+
1076+ return OpenACCDeviceClause::Create (Ctx, Clause.getBeginLoc (),
1077+ Clause.getLParenLoc (), Clause.getVarList (),
1078+ Clause.getEndLoc ());
1079+ }
1080+
10431081OpenACCClause *SemaOpenACCClauseVisitor::VisitCopyClause (
10441082 SemaOpenACC::OpenACCParsedClause &Clause) {
10451083 // Restrictions only properly implemented on 'compute'/'combined'/'data'
@@ -3694,8 +3732,17 @@ bool SemaOpenACC::ActOnStartStmtDirective(
36943732 OpenACCClauseKind::DeviceType,
36953733 OpenACCClauseKind::If});
36963734
3697- // TODO: OpenACC: 'Update' construct needs to have one of 'self', 'host', or
3698- // 'device'. Implement here.
3735+ // OpenACC3.3 2.14.4: At least one self, host, or device clause must appear on
3736+ // an update directive.
3737+ if (K == OpenACCDirectiveKind::Update &&
3738+ llvm::find_if (Clauses, llvm::IsaPred<OpenACCSelfClause, OpenACCHostClause,
3739+ OpenACCDeviceClause>) ==
3740+ Clauses.end ())
3741+ return Diag (StartLoc, diag::err_acc_construct_one_clause_of)
3742+ << K
3743+ << GetListOfClauses ({OpenACCClauseKind::Self,
3744+ OpenACCClauseKind::Host,
3745+ OpenACCClauseKind::Device});
36993746
37003747 return diagnoseConstructAppertainment (*this , K, StartLoc, /* IsStmt=*/ true );
37013748}
0 commit comments