================ @@ -715,6 +787,65 @@ SemaOpenACC::ActOnClause(ArrayRef<const OpenACCClause *> ExistingClauses, return nullptr; } +/// OpenACC 3.3 section 2.5.15: +/// At a mininmum, the supported data types include ... the numerical data types +/// in C, C++, and Fortran. +/// +/// If the reduction var is a composite variable, each +/// member of the composite variable must be a supported datatype for the +/// reduction operation. +ExprResult SemaOpenACC::CheckReductionVar(Expr *VarExpr) { + VarExpr = VarExpr->IgnoreParenCasts(); + + auto TypeIsValid = [](QualType Ty) { + return Ty->isDependentType() || Ty->isScalarType(); + }; + + if (isa<ArraySectionExpr>(VarExpr)) { + Expr *ASExpr = VarExpr; + QualType BaseTy = ArraySectionExpr::getBaseOriginalType(ASExpr); + QualType EltTy = getASTContext().getBaseElementType(BaseTy); + + if (!TypeIsValid(EltTy)) { + Diag(VarExpr->getExprLoc(), diag::err_acc_reduction_type) + << EltTy << /*Sub array base type*/ 1; + return ExprError(); + } + } else if (auto *RD = VarExpr->getType()->getAsRecordDecl()) { + if (!RD->isStruct() && !RD->isClass()) { + Diag(VarExpr->getExprLoc(), diag::err_acc_reduction_composite_type) + << /*not class or struct*/ 0 << VarExpr->getType(); + return ExprError(); + } + + if (!RD->isCompleteDefinition()) { + Diag(VarExpr->getExprLoc(), diag::err_acc_reduction_composite_type) + << /*incomplete*/ 1 << VarExpr->getType(); + return ExprError(); + } + if (isa<CXXRecordDecl>(RD) && !cast<CXXRecordDecl>(RD)->isAggregate()) { ---------------- erichkeane wrote:
Yep, better. https://github.com/llvm/llvm-project/pull/92808 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits