@@ -68,6 +68,7 @@ class SemaOpenACC : public SemaBase {
6868 // / used to diagnose if there are multiple 'for' loops at any one level.
6969 LLVM_PREFERRED_TYPE (bool )
7070 unsigned CurLevelHasLoopAlready : 1 ;
71+
7172 } LoopInfo{/* TopLevelLoopSeen=*/ false , /* CurLevelHasLoopAlready=*/ false };
7273
7374 // / The 'collapse' clause requires quite a bit of checking while
@@ -109,6 +110,14 @@ class SemaOpenACC : public SemaBase {
109110 bool TileDepthSatisfied = true ;
110111 } TileInfo;
111112
113+ // / A list of the active reduction clauses, which allows us to check that all
114+ // / vars on nested constructs for the same reduction var have the same
115+ // / reduction operator. Currently this is enforced against all constructs
116+ // / despite the rule being in the 'loop' section. By current reading, this
117+ // / should apply to all anyway, but we may need to make this more like the
118+ // / 'loop' clause enforcement, where this is 'blocked' by a compute construct.
119+ llvm::SmallVector<OpenACCReductionClause *> ActiveReductionClauses;
120+
112121public:
113122 ComputeConstructInfo &getActiveComputeConstructInfo () {
114123 return ActiveComputeConstructInfo;
@@ -615,7 +624,9 @@ class SemaOpenACC : public SemaBase {
615624
616625 // / Called while semantically analyzing the reduction clause, ensuring the var
617626 // / is the correct kind of reference.
618- ExprResult CheckReductionVar (Expr *VarExpr);
627+ ExprResult CheckReductionVar (OpenACCDirectiveKind DirectiveKind,
628+ OpenACCReductionOperator ReductionOp,
629+ Expr *VarExpr);
619630
620631 // / Called to check the 'var' type is a variable of pointer type, necessary
621632 // / for 'deviceptr' and 'attach' clauses. Returns true on success.
@@ -634,6 +645,22 @@ class SemaOpenACC : public SemaBase {
634645 // Check a single expression on a gang clause.
635646 ExprResult CheckGangExpr (OpenACCGangKind GK, Expr *E);
636647
648+ // Does the checking for a 'gang' clause that needs to be done in dependent
649+ // and not dependent cases.
650+ OpenACCClause *
651+ CheckGangClause (ArrayRef<const OpenACCClause *> ExistingClauses,
652+ SourceLocation BeginLoc, SourceLocation LParenLoc,
653+ ArrayRef<OpenACCGangKind> GangKinds,
654+ ArrayRef<Expr *> IntExprs, SourceLocation EndLoc);
655+ // Does the checking for a 'reduction ' clause that needs to be done in
656+ // dependent and not dependent cases.
657+ OpenACCClause *
658+ CheckReductionClause (ArrayRef<const OpenACCClause *> ExistingClauses,
659+ OpenACCDirectiveKind DirectiveKind,
660+ SourceLocation BeginLoc, SourceLocation LParenLoc,
661+ OpenACCReductionOperator ReductionOp,
662+ ArrayRef<Expr *> Vars, SourceLocation EndLoc);
663+
637664 ExprResult BuildOpenACCAsteriskSizeExpr (SourceLocation AsteriskLoc);
638665 ExprResult ActOnOpenACCAsteriskSizeExpr (SourceLocation AsteriskLoc);
639666
@@ -686,6 +713,7 @@ class SemaOpenACC : public SemaBase {
686713 SourceLocation OldLoopWorkerClauseLoc;
687714 SourceLocation OldLoopVectorClauseLoc;
688715 llvm::SmallVector<OpenACCLoopConstruct *> ParentlessLoopConstructs;
716+ llvm::SmallVector<OpenACCReductionClause *> ActiveReductionClauses;
689717 LoopInConstructRAII LoopRAII;
690718
691719 public:
0 commit comments