diff --git a/clang/include/clang/AST/OpenACCClause.h b/clang/include/clang/AST/OpenACCClause.h index 607a2b9d653678..28ff8c44bd2569 100644 --- a/clang/include/clang/AST/OpenACCClause.h +++ b/clang/include/clang/AST/OpenACCClause.h @@ -677,6 +677,35 @@ class OpenACCCreateClause final ArrayRef VarList, SourceLocation EndLoc); }; +class OpenACCReductionClause final + : public OpenACCClauseWithVarList, + public llvm::TrailingObjects { + OpenACCReductionOperator Op; + + OpenACCReductionClause(SourceLocation BeginLoc, SourceLocation LParenLoc, + OpenACCReductionOperator Operator, + ArrayRef VarList, SourceLocation EndLoc) + : OpenACCClauseWithVarList(OpenACCClauseKind::Reduction, BeginLoc, + LParenLoc, EndLoc), + Op(Operator) { + std::uninitialized_copy(VarList.begin(), VarList.end(), + getTrailingObjects()); + setExprs(MutableArrayRef(getTrailingObjects(), VarList.size())); + } + +public: + static bool classof(const OpenACCClause *C) { + return C->getClauseKind() == OpenACCClauseKind::Reduction; + } + + static OpenACCReductionClause * + Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, + OpenACCReductionOperator Operator, ArrayRef VarList, + SourceLocation EndLoc); + + OpenACCReductionOperator getReductionOp() const { return Op; } +}; + template class OpenACCClauseVisitor { Impl &getDerived() { return static_cast(*this); } diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index e3c65cba4886a8..c7dea1d54d0637 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12343,7 +12343,8 @@ def err_acc_num_gangs_num_args "provided}0">; def err_acc_not_a_var_ref : Error<"OpenACC variable is not a valid variable name, sub-array, array " - "element, or composite variable member">; + "element,%select{| member of a composite variable,}0 or composite " + "variable member">; def err_acc_typecheck_subarray_value : Error<"OpenACC sub-array subscripted value is not an array or pointer">; def err_acc_subarray_function_type @@ -12374,5 +12375,18 @@ def note_acc_expected_pointer_var : Note<"expected variable of pointer type">; def err_acc_clause_after_device_type : Error<"OpenACC clause '%0' may not follow a '%1' clause in a " "compute construct">; - +def err_acc_reduction_num_gangs_conflict + : Error< + "OpenACC 'reduction' clause may not appear on a 'parallel' construct " + "with a 'num_gangs' clause with more than 1 argument, have %0">; +def err_acc_reduction_type + : Error<"OpenACC 'reduction' variable must be of scalar type, sub-array, or a " + "composite of scalar types;%select{| sub-array base}1 type is %0">; +def err_acc_reduction_composite_type + : Error<"OpenACC 'reduction' variable must be a composite of scalar types; " + "%1 %select{is not a class or struct|is incomplete|is not an " + "aggregate}0">; +def err_acc_reduction_composite_member_type :Error< + "OpenACC 'reduction' composite variable must not have non-scalar field">; +def note_acc_reduction_composite_member_loc : Note<"invalid field is here">; } // end of sema component. diff --git a/clang/include/clang/Basic/OpenACCClauses.def b/clang/include/clang/Basic/OpenACCClauses.def index 7ecc51799468c1..3e464abaafd928 100644 --- a/clang/include/clang/Basic/OpenACCClauses.def +++ b/clang/include/clang/Basic/OpenACCClauses.def @@ -46,6 +46,7 @@ VISIT_CLAUSE(NumGangs) VISIT_CLAUSE(NumWorkers) VISIT_CLAUSE(Present) VISIT_CLAUSE(Private) +VISIT_CLAUSE(Reduction) VISIT_CLAUSE(Self) VISIT_CLAUSE(VectorLength) VISIT_CLAUSE(Wait) diff --git a/clang/include/clang/Basic/OpenACCKinds.h b/clang/include/clang/Basic/OpenACCKinds.h index 0e38a04e7164bb..7b9d619a8aec6d 100644 --- a/clang/include/clang/Basic/OpenACCKinds.h +++ b/clang/include/clang/Basic/OpenACCKinds.h @@ -514,6 +514,42 @@ enum class OpenACCReductionOperator { /// Invalid Reduction Clause Kind. Invalid, }; + +template +inline StreamTy &printOpenACCReductionOperator(StreamTy &Out, + OpenACCReductionOperator Op) { + switch (Op) { + case OpenACCReductionOperator::Addition: + return Out << "+"; + case OpenACCReductionOperator::Multiplication: + return Out << "*"; + case OpenACCReductionOperator::Max: + return Out << "max"; + case OpenACCReductionOperator::Min: + return Out << "min"; + case OpenACCReductionOperator::BitwiseAnd: + return Out << "&"; + case OpenACCReductionOperator::BitwiseOr: + return Out << "|"; + case OpenACCReductionOperator::BitwiseXOr: + return Out << "^"; + case OpenACCReductionOperator::And: + return Out << "&&"; + case OpenACCReductionOperator::Or: + return Out << "||"; + case OpenACCReductionOperator::Invalid: + return Out << ""; + } + llvm_unreachable("Unknown reduction operator kind"); +} +inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &Out, + OpenACCReductionOperator Op) { + return printOpenACCReductionOperator(Out, Op); +} +inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out, + OpenACCReductionOperator Op) { + return printOpenACCReductionOperator(Out, Op); +} } // namespace clang #endif // LLVM_CLANG_BASIC_OPENACCKINDS_H diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 5f04664141d29f..3c4ab649e3b4c1 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -3686,9 +3686,9 @@ class Parser : public CodeCompletionHandler { using OpenACCVarParseResult = std::pair; /// Parses a single variable in a variable list for OpenACC. - OpenACCVarParseResult ParseOpenACCVar(); + OpenACCVarParseResult ParseOpenACCVar(OpenACCClauseKind CK); /// Parses the variable list for the variety of places that take a var-list. - llvm::SmallVector ParseOpenACCVarList(); + llvm::SmallVector ParseOpenACCVarList(OpenACCClauseKind CK); /// Parses any parameters for an OpenACC Clause, including required/optional /// parens. OpenACCClauseParseResult diff --git a/clang/include/clang/Sema/SemaOpenACC.h b/clang/include/clang/Sema/SemaOpenACC.h index f838fa97d33a29..6f69fa08939b82 100644 --- a/clang/include/clang/Sema/SemaOpenACC.h +++ b/clang/include/clang/Sema/SemaOpenACC.h @@ -66,9 +66,14 @@ class SemaOpenACC : public SemaBase { struct DeviceTypeDetails { SmallVector Archs; }; + struct ReductionDetails { + OpenACCReductionOperator Op; + SmallVector VarList; + }; std::variant + IntExprDetails, VarListDetails, WaitDetails, DeviceTypeDetails, + ReductionDetails> Details = std::monostate{}; public: @@ -170,6 +175,10 @@ class SemaOpenACC : public SemaBase { return const_cast(this)->getIntExprs(); } + OpenACCReductionOperator getReductionOp() const { + return std::get(Details).Op; + } + ArrayRef getVarList() { assert((ClauseKind == OpenACCClauseKind::Private || ClauseKind == OpenACCClauseKind::NoCreate || @@ -188,8 +197,13 @@ class SemaOpenACC : public SemaBase { ClauseKind == OpenACCClauseKind::PresentOrCreate || ClauseKind == OpenACCClauseKind::Attach || ClauseKind == OpenACCClauseKind::DevicePtr || + ClauseKind == OpenACCClauseKind::Reduction || ClauseKind == OpenACCClauseKind::FirstPrivate) && "Parsed clause kind does not have a var-list"); + + if (ClauseKind == OpenACCClauseKind::Reduction) + return std::get(Details).VarList; + return std::get(Details).VarList; } @@ -334,6 +348,13 @@ class SemaOpenACC : public SemaBase { Details = VarListDetails{std::move(VarList), IsReadOnly, IsZero}; } + void setReductionDetails(OpenACCReductionOperator Op, + llvm::SmallVector &&VarList) { + assert(ClauseKind == OpenACCClauseKind::Reduction && + "reduction details only valid on reduction"); + Details = ReductionDetails{Op, std::move(VarList)}; + } + void setWaitDetails(Expr *DevNum, SourceLocation QueuesLoc, llvm::SmallVector &&IntExprs) { assert(ClauseKind == OpenACCClauseKind::Wait && @@ -394,7 +415,11 @@ class SemaOpenACC : public SemaBase { /// Called when encountering a 'var' for OpenACC, ensures it is actually a /// declaration reference to a variable of the correct type. - ExprResult ActOnVar(Expr *VarExpr); + ExprResult ActOnVar(OpenACCClauseKind CK, Expr *VarExpr); + + /// Called while semantically analyzing the reduction clause, ensuring the var + /// is the correct kind of reference. + ExprResult CheckReductionVar(Expr *VarExpr); /// Called to check the 'var' type is a variable of pointer type, necessary /// for 'deviceptr' and 'attach' clauses. Returns true on success. diff --git a/clang/lib/AST/OpenACCClause.cpp b/clang/lib/AST/OpenACCClause.cpp index 8ff6dabcbc48e8..cb2c7f98be75cb 100644 --- a/clang/lib/AST/OpenACCClause.cpp +++ b/clang/lib/AST/OpenACCClause.cpp @@ -35,7 +35,7 @@ bool OpenACCClauseWithVarList::classof(const OpenACCClause *C) { OpenACCAttachClause::classof(C) || OpenACCNoCreateClause::classof(C) || OpenACCPresentClause::classof(C) || OpenACCCopyClause::classof(C) || OpenACCCopyInClause::classof(C) || OpenACCCopyOutClause::classof(C) || - OpenACCCreateClause::classof(C); + OpenACCReductionClause::classof(C) || OpenACCCreateClause::classof(C); } bool OpenACCClauseWithCondition::classof(const OpenACCClause *C) { return OpenACCIfClause::classof(C) || OpenACCSelfClause::classof(C); @@ -310,6 +310,16 @@ OpenACCDeviceTypeClause *OpenACCDeviceTypeClause::Create( OpenACCDeviceTypeClause(K, BeginLoc, LParenLoc, Archs, EndLoc); } +OpenACCReductionClause *OpenACCReductionClause::Create( + const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, + OpenACCReductionOperator Operator, ArrayRef VarList, + SourceLocation EndLoc) { + void *Mem = C.Allocate( + OpenACCReductionClause::totalSizeToAlloc(VarList.size())); + return new (Mem) + OpenACCReductionClause(BeginLoc, LParenLoc, Operator, VarList, EndLoc); +} + //===----------------------------------------------------------------------===// // OpenACC clauses printing methods //===----------------------------------------------------------------------===// @@ -445,6 +455,14 @@ void OpenACCClausePrinter::VisitCreateClause(const OpenACCCreateClause &C) { OS << ")"; } +void OpenACCClausePrinter::VisitReductionClause( + const OpenACCReductionClause &C) { + OS << "reduction(" << C.getReductionOp() << ": "; + llvm::interleaveComma(C.getVarList(), OS, + [&](const Expr *E) { printExpr(E); }); + OS << ")"; +} + void OpenACCClausePrinter::VisitWaitClause(const OpenACCWaitClause &C) { OS << "wait"; if (!C.getLParenLoc().isInvalid()) { diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp index caab4ab0ef160a..00b8c43af035c7 100644 --- a/clang/lib/AST/StmtProfile.cpp +++ b/clang/lib/AST/StmtProfile.cpp @@ -2588,6 +2588,12 @@ void OpenACCClauseProfiler::VisitWaitClause(const OpenACCWaitClause &Clause) { /// Nothing to do here, there are no sub-statements. void OpenACCClauseProfiler::VisitDeviceTypeClause( const OpenACCDeviceTypeClause &Clause) {} + +void OpenACCClauseProfiler::VisitReductionClause( + const OpenACCReductionClause &Clause) { + for (auto *E : Clause.getVarList()) + Profiler.VisitStmt(E); +} } // namespace void StmtProfiler::VisitOpenACCComputeConstruct( diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index efcd74717a4e2c..4a1e94ffe283ba 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -457,6 +457,10 @@ void TextNodeDumper::Visit(const OpenACCClause *C) { }); OS << ")"; break; + case OpenACCClauseKind::Reduction: + OS << " clause Operator: " + << cast(C)->getReductionOp(); + break; default: // Nothing to do here. break; diff --git a/clang/lib/Parse/ParseOpenACC.cpp b/clang/lib/Parse/ParseOpenACC.cpp index 5db3036b000302..e9c60f76165b68 100644 --- a/clang/lib/Parse/ParseOpenACC.cpp +++ b/clang/lib/Parse/ParseOpenACC.cpp @@ -920,7 +920,8 @@ Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams( case OpenACCClauseKind::PresentOrCopyIn: { bool IsReadOnly = tryParseAndConsumeSpecialTokenKind( *this, OpenACCSpecialTokenKind::ReadOnly, ClauseKind); - ParsedClause.setVarListDetails(ParseOpenACCVarList(), IsReadOnly, + ParsedClause.setVarListDetails(ParseOpenACCVarList(ClauseKind), + IsReadOnly, /*IsZero=*/false); break; } @@ -932,16 +933,17 @@ Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams( case OpenACCClauseKind::PresentOrCopyOut: { bool IsZero = tryParseAndConsumeSpecialTokenKind( *this, OpenACCSpecialTokenKind::Zero, ClauseKind); - ParsedClause.setVarListDetails(ParseOpenACCVarList(), + ParsedClause.setVarListDetails(ParseOpenACCVarList(ClauseKind), /*IsReadOnly=*/false, IsZero); break; } - case OpenACCClauseKind::Reduction: + case OpenACCClauseKind::Reduction: { // If we're missing a clause-kind (or it is invalid), see if we can parse // the var-list anyway. - ParseReductionOperator(*this); - ParseOpenACCVarList(); + OpenACCReductionOperator Op = ParseReductionOperator(*this); + ParsedClause.setReductionDetails(Op, ParseOpenACCVarList(ClauseKind)); break; + } case OpenACCClauseKind::Self: // The 'self' clause is a var-list instead of a 'condition' in the case of // the 'update' clause, so we have to handle it here. U se an assert to @@ -955,11 +957,11 @@ Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams( case OpenACCClauseKind::Host: case OpenACCClauseKind::Link: case OpenACCClauseKind::UseDevice: - ParseOpenACCVarList(); + ParseOpenACCVarList(ClauseKind); break; case OpenACCClauseKind::Attach: case OpenACCClauseKind::DevicePtr: - ParsedClause.setVarListDetails(ParseOpenACCVarList(), + ParsedClause.setVarListDetails(ParseOpenACCVarList(ClauseKind), /*IsReadOnly=*/false, /*IsZero=*/false); break; case OpenACCClauseKind::Copy: @@ -969,7 +971,7 @@ Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams( case OpenACCClauseKind::NoCreate: case OpenACCClauseKind::Present: case OpenACCClauseKind::Private: - ParsedClause.setVarListDetails(ParseOpenACCVarList(), + ParsedClause.setVarListDetails(ParseOpenACCVarList(ClauseKind), /*IsReadOnly=*/false, /*IsZero=*/false); break; case OpenACCClauseKind::Collapse: { @@ -1278,7 +1280,7 @@ ExprResult Parser::ParseOpenACCBindClauseArgument() { /// - an array element /// - a member of a composite variable /// - a common block name between slashes (fortran only) -Parser::OpenACCVarParseResult Parser::ParseOpenACCVar() { +Parser::OpenACCVarParseResult Parser::ParseOpenACCVar(OpenACCClauseKind CK) { OpenACCArraySectionRAII ArraySections(*this); ExprResult Res = ParseAssignmentExpression(); @@ -1289,15 +1291,15 @@ Parser::OpenACCVarParseResult Parser::ParseOpenACCVar() { if (!Res.isUsable()) return {Res, OpenACCParseCanContinue::Can}; - Res = getActions().OpenACC().ActOnVar(Res.get()); + Res = getActions().OpenACC().ActOnVar(CK, Res.get()); return {Res, OpenACCParseCanContinue::Can}; } -llvm::SmallVector Parser::ParseOpenACCVarList() { +llvm::SmallVector Parser::ParseOpenACCVarList(OpenACCClauseKind CK) { llvm::SmallVector Vars; - auto [Res, CanContinue] = ParseOpenACCVar(); + auto [Res, CanContinue] = ParseOpenACCVar(CK); if (Res.isUsable()) { Vars.push_back(Res.get()); } else if (CanContinue == OpenACCParseCanContinue::Cannot) { @@ -1308,7 +1310,7 @@ llvm::SmallVector Parser::ParseOpenACCVarList() { while (!getCurToken().isOneOf(tok::r_paren, tok::annot_pragma_openacc_end)) { ExpectAndConsume(tok::comma); - auto [Res, CanContinue] = ParseOpenACCVar(); + auto [Res, CanContinue] = ParseOpenACCVar(CK); if (Res.isUsable()) { Vars.push_back(Res.get()); @@ -1342,7 +1344,7 @@ void Parser::ParseOpenACCCacheVarList() { // ParseOpenACCVarList should leave us before a r-paren, so no need to skip // anything here. - ParseOpenACCVarList(); + ParseOpenACCVarList(OpenACCClauseKind::Invalid); } Parser::OpenACCDirectiveParseInfo Parser::ParseOpenACCDirective() { diff --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp index f174b2fa63c6a5..09d91b31cfe5f9 100644 --- a/clang/lib/Sema/SemaOpenACC.cpp +++ b/clang/lib/Sema/SemaOpenACC.cpp @@ -233,6 +233,19 @@ bool doesClauseApplyToDirective(OpenACCDirectiveKind DirectiveKind, return false; } + case OpenACCClauseKind::Reduction: + switch (DirectiveKind) { + case OpenACCDirectiveKind::Parallel: + case OpenACCDirectiveKind::Serial: + case OpenACCDirectiveKind::Loop: + case OpenACCDirectiveKind::ParallelLoop: + case OpenACCDirectiveKind::SerialLoop: + case OpenACCDirectiveKind::KernelsLoop: + return true; + default: + return false; + } + default: // Do nothing so we can go to the 'unimplemented' diagnostic instead. return true; @@ -281,7 +294,6 @@ bool checkValidAfterDeviceType( return true; } } - } // namespace SemaOpenACC::SemaOpenACC(Sema &S) : SemaBase(S) {} @@ -426,6 +438,22 @@ SemaOpenACC::ActOnClause(ArrayRef ExistingClauses, << /*NoArgs=*/1 << Clause.getDirectiveKind() << MaxArgs << Clause.getIntExprs().size(); + // OpenACC 3.3 Section 2.5.4: + // A reduction clause may not appear on a parallel construct with a + // num_gangs clause that has more than one argument. + if (Clause.getDirectiveKind() == OpenACCDirectiveKind::Parallel && + Clause.getIntExprs().size() > 1) { + auto *Parallel = + llvm::find_if(ExistingClauses, llvm::IsaPred); + + if (Parallel != ExistingClauses.end()) { + Diag(Clause.getBeginLoc(), diag::err_acc_reduction_num_gangs_conflict) + << Clause.getIntExprs().size(); + Diag((*Parallel)->getBeginLoc(), diag::note_acc_previous_clause_here); + return nullptr; + } + } + // Create the AST node for the clause even if the number of expressions is // incorrect. return OpenACCNumGangsClause::Create( @@ -706,6 +734,46 @@ SemaOpenACC::ActOnClause(ArrayRef ExistingClauses, Clause.getLParenLoc(), Clause.getDeviceTypeArchitectures(), Clause.getEndLoc()); } + case OpenACCClauseKind::Reduction: { + // Restrictions only properly implemented on 'compute' constructs, and + // 'compute' constructs are the only construct that can do anything with + // this yet, so skip/treat as unimplemented in this case. + if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind())) + break; + + // OpenACC 3.3 Section 2.5.4: + // A reduction clause may not appear on a parallel construct with a + // num_gangs clause that has more than one argument. + if (Clause.getDirectiveKind() == OpenACCDirectiveKind::Parallel) { + auto NumGangsClauses = llvm::make_filter_range( + ExistingClauses, llvm::IsaPred); + + for (auto *NGC : NumGangsClauses) { + unsigned NumExprs = + cast(NGC)->getIntExprs().size(); + + if (NumExprs > 1) { + Diag(Clause.getBeginLoc(), diag::err_acc_reduction_num_gangs_conflict) + << NumExprs; + Diag(NGC->getBeginLoc(), diag::note_acc_previous_clause_here); + return nullptr; + } + } + } + + SmallVector ValidVars; + + for (Expr *Var : Clause.getVarList()) { + ExprResult Res = CheckReductionVar(Var); + + if (Res.isUsable()) + ValidVars.push_back(Res.get()); + } + + return OpenACCReductionClause::Create( + getASTContext(), Clause.getBeginLoc(), Clause.getLParenLoc(), + Clause.getReductionOp(), ValidVars, Clause.getEndLoc()); + } default: break; } @@ -715,6 +783,66 @@ SemaOpenACC::ActOnClause(ArrayRef 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(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 (const auto *CXXRD = dyn_cast(RD); + CXXRD && !CXXRD->isAggregate()) { + Diag(VarExpr->getExprLoc(), diag::err_acc_reduction_composite_type) + << /*aggregate*/ 2 << VarExpr->getType(); + return ExprError(); + } + + for (FieldDecl *FD : RD->fields()) { + if (!TypeIsValid(FD->getType())) { + Diag(VarExpr->getExprLoc(), + diag::err_acc_reduction_composite_member_type); + Diag(FD->getLocation(), diag::note_acc_reduction_composite_member_loc); + return ExprError(); + } + } + } else if (!TypeIsValid(VarExpr->getType())) { + Diag(VarExpr->getExprLoc(), diag::err_acc_reduction_type) + << VarExpr->getType() << /*Sub array base type*/ 0; + return ExprError(); + } + + return VarExpr; +} + void SemaOpenACC::ActOnConstruct(OpenACCDirectiveKind K, SourceLocation StartLoc) { switch (K) { @@ -864,9 +992,7 @@ bool SemaOpenACC::CheckVarIsPointerType(OpenACCClauseKind ClauseKind, return false; } -ExprResult SemaOpenACC::ActOnVar(Expr *VarExpr) { - // We still need to retain the array subscript/subarray exprs, so work on a - // copy. +ExprResult SemaOpenACC::ActOnVar(OpenACCClauseKind CK, Expr *VarExpr) { Expr *CurVarExpr = VarExpr->IgnoreParenImpCasts(); // Sub-arrays/subscript-exprs are fine as long as the base is a @@ -882,14 +1008,19 @@ ExprResult SemaOpenACC::ActOnVar(Expr *VarExpr) { // References to a VarDecl are fine. if (const auto *DRE = dyn_cast(CurVarExpr)) { if (isa( - DRE->getDecl()->getCanonicalDecl())) + DRE->getFoundDecl()->getCanonicalDecl())) return VarExpr; } + // If CK is a Reduction, this special cases for OpenACC3.3 2.5.15: "A var in a + // reduction clause must be a scalar variable name, an aggregate variable + // name, an array element, or a subarray. // A MemberExpr that references a Field is valid. - if (const auto *ME = dyn_cast(CurVarExpr)) { - if (isa(ME->getMemberDecl()->getCanonicalDecl())) - return VarExpr; + if (CK != OpenACCClauseKind::Reduction) { + if (const auto *ME = dyn_cast(CurVarExpr)) { + if (isa(ME->getMemberDecl()->getCanonicalDecl())) + return VarExpr; + } } // Referring to 'this' is always OK. @@ -898,7 +1029,9 @@ ExprResult SemaOpenACC::ActOnVar(Expr *VarExpr) { // Nothing really we can do here, as these are dependent. So just return they // are valid. - if (isa(CurVarExpr)) + if (isa(CurVarExpr) || + (CK != OpenACCClauseKind::Reduction && + isa(CurVarExpr))) return VarExpr; // There isn't really anything we can do in the case of a recovery expr, so @@ -906,7 +1039,8 @@ ExprResult SemaOpenACC::ActOnVar(Expr *VarExpr) { if (isa(CurVarExpr)) return ExprError(); - Diag(VarExpr->getExprLoc(), diag::err_acc_not_a_var_ref); + Diag(VarExpr->getExprLoc(), diag::err_acc_not_a_var_ref) + << (CK != OpenACCClauseKind::Reduction); return ExprError(); } diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index a9e4987eda2b52..6b53c2490cc492 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -11126,7 +11126,8 @@ class OpenACCClauseTransform final if (!Res.isUsable()) continue; - Res = Self.getSema().OpenACC().ActOnVar(Res.get()); + Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getClauseKind(), + Res.get()); if (Res.isUsable()) InstantiatedVarList.push_back(Res.get()); @@ -11486,6 +11487,24 @@ void OpenACCClauseTransform::VisitDeviceTypeClause( ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(), C.getArchitectures(), ParsedClause.getEndLoc()); } + +template +void OpenACCClauseTransform::VisitReductionClause( + const OpenACCReductionClause &C) { + SmallVector TransformedVars = VisitVarList(C.getVarList()); + SmallVector ValidVars; + + for (Expr *Var : TransformedVars) { + ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(Var); + if (Res.isUsable()) + ValidVars.push_back(Res.get()); + } + + NewClause = OpenACCReductionClause::Create( + Self.getSema().getASTContext(), ParsedClause.getBeginLoc(), + ParsedClause.getLParenLoc(), C.getReductionOp(), ValidVars, + ParsedClause.getEndLoc()); +} } // namespace template OpenACCClause *TreeTransform::TransformOpenACCClause( diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index f50f9569c0a5ee..d7fc6697eaf74c 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -11921,6 +11921,13 @@ OpenACCClause *ASTRecordReader::readOpenACCClause() { return OpenACCDeviceTypeClause::Create(getContext(), ClauseKind, BeginLoc, LParenLoc, Archs, EndLoc); } + case OpenACCClauseKind::Reduction: { + SourceLocation LParenLoc = readSourceLocation(); + OpenACCReductionOperator Op = readEnum(); + llvm::SmallVector VarList = readOpenACCVarList(); + return OpenACCReductionClause::Create(getContext(), BeginLoc, LParenLoc, Op, + VarList, EndLoc); + } case OpenACCClauseKind::Finalize: case OpenACCClauseKind::IfPresent: @@ -11937,7 +11944,6 @@ OpenACCClause *ASTRecordReader::readOpenACCClause() { case OpenACCClauseKind::DeviceResident: case OpenACCClauseKind::Host: case OpenACCClauseKind::Link: - case OpenACCClauseKind::Reduction: case OpenACCClauseKind::Collapse: case OpenACCClauseKind::Bind: case OpenACCClauseKind::DeviceNum: diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 1d6d96932ba2cf..00b0e48083217c 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -7959,6 +7959,13 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) { } return; } + case OpenACCClauseKind::Reduction: { + const auto *RC = cast(C); + writeSourceLocation(RC->getLParenLoc()); + writeEnum(RC->getReductionOp()); + writeOpenACCVarList(RC); + return; + } case OpenACCClauseKind::Finalize: case OpenACCClauseKind::IfPresent: @@ -7975,7 +7982,6 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) { case OpenACCClauseKind::DeviceResident: case OpenACCClauseKind::Host: case OpenACCClauseKind::Link: - case OpenACCClauseKind::Reduction: case OpenACCClauseKind::Collapse: case OpenACCClauseKind::Bind: case OpenACCClauseKind::DeviceNum: diff --git a/clang/test/AST/ast-print-openacc-compute-construct.cpp b/clang/test/AST/ast-print-openacc-compute-construct.cpp index 19965e7491414b..fe580c86ac8ea8 100644 --- a/clang/test/AST/ast-print-openacc-compute-construct.cpp +++ b/clang/test/AST/ast-print-openacc-compute-construct.cpp @@ -130,5 +130,33 @@ void foo() { //CHECK: #pragma acc parallel device_type(SomeStructImpl) #pragma acc parallel device_type (SomeStructImpl) while(true); + +//CHECK: #pragma acc parallel reduction(+: iPtr) +#pragma acc parallel reduction(+: iPtr) + while(true); +//CHECK: #pragma acc parallel reduction(*: i) +#pragma acc parallel reduction(*: i) + while(true); +//CHECK: #pragma acc parallel reduction(max: SomeB) +#pragma acc parallel reduction(max: SomeB) + while(true); +//CHECK: #pragma acc parallel reduction(min: iPtr) +#pragma acc parallel reduction(min: iPtr) + while(true); +//CHECK: #pragma acc parallel reduction(&: i) +#pragma acc parallel reduction(&: i) + while(true); +//CHECK: #pragma acc parallel reduction(|: SomeB) +#pragma acc parallel reduction(|: SomeB) + while(true); +//CHECK: #pragma acc parallel reduction(^: iPtr) +#pragma acc parallel reduction(^: iPtr) + while(true); +//CHECK: #pragma acc parallel reduction(&&: i) +#pragma acc parallel reduction(&&: i) + while(true); +//CHECK: #pragma acc parallel reduction(||: SomeB) +#pragma acc parallel reduction(||: SomeB) + while(true); } diff --git a/clang/test/ParserOpenACC/parse-clauses.c b/clang/test/ParserOpenACC/parse-clauses.c index 694f28b86ec9fa..49e749feb2ec7e 100644 --- a/clang/test/ParserOpenACC/parse-clauses.c +++ b/clang/test/ParserOpenACC/parse-clauses.c @@ -831,52 +831,38 @@ void ReductionClauseParsing() { // expected-error@+1{{expected '('}} #pragma acc serial reduction for(;;){} - // expected-error@+3{{missing reduction operator, expected '+', '*', 'max', 'min', '&', '|', '^', '&&', or '||', follwed by a ':'}} - // expected-error@+2{{expected expression}} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} + // expected-error@+2{{missing reduction operator, expected '+', '*', 'max', 'min', '&', '|', '^', '&&', or '||', follwed by a ':'}} + // expected-error@+1{{expected expression}} #pragma acc serial reduction() for(;;){} - // expected-error@+2{{missing reduction operator, expected '+', '*', 'max', 'min', '&', '|', '^', '&&', or '||', follwed by a ':'}} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} + // expected-error@+1{{missing reduction operator, expected '+', '*', 'max', 'min', '&', '|', '^', '&&', or '||', follwed by a ':'}} #pragma acc serial reduction(Begin) for(;;){} - // expected-error@+2{{missing reduction operator, expected '+', '*', 'max', 'min', '&', '|', '^', '&&', or '||', follwed by a ':'}} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} + // expected-error@+1{{missing reduction operator, expected '+', '*', 'max', 'min', '&', '|', '^', '&&', or '||', follwed by a ':'}} #pragma acc serial reduction(Begin, End) for(;;){} - // expected-error@+2{{missing reduction operator, expected '+', '*', 'max', 'min', '&', '|', '^', '&&', or '||', follwed by a ':'}} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} + // expected-error@+1{{missing reduction operator, expected '+', '*', 'max', 'min', '&', '|', '^', '&&', or '||', follwed by a ':'}} #pragma acc serial reduction(Begin, End) for(;;){} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} #pragma acc serial reduction(+:Begin) for(;;){} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} #pragma acc serial reduction(+:Begin, End) for(;;){} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} #pragma acc serial reduction(*: Begin, End) for(;;){} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} #pragma acc serial reduction(max : Begin, End) for(;;){} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} #pragma acc serial reduction(min: Begin, End) for(;;){} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} #pragma acc serial reduction(&: Begin, End) for(;;){} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} #pragma acc serial reduction(|: Begin, End) for(;;){} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} #pragma acc serial reduction(^: Begin, End) for(;;){} - // expected-warning@+2{{OpenACC clause 'seq' not yet implemented, clause ignored}} - // expected-warning@+1{{OpenACC clause 'reduction' not yet implemented, clause ignored}} + // expected-warning@+1{{OpenACC clause 'seq' not yet implemented, clause ignored}} #pragma acc serial seq, reduction(&&: Begin, End) for(;;){} - // expected-warning@+2{{OpenACC clause 'reduction' not yet implemented, clause ignored}} // expected-warning@+1{{OpenACC clause 'seq' not yet implemented, clause ignored}} #pragma acc serial reduction(||: Begin, End), seq for(;;){} diff --git a/clang/test/SemaOpenACC/compute-construct-attach-clause.c b/clang/test/SemaOpenACC/compute-construct-attach-clause.c index de735308528adb..deca99f5bae477 100644 --- a/clang/test/SemaOpenACC/compute-construct-attach-clause.c +++ b/clang/test/SemaOpenACC/compute-construct-attach-clause.c @@ -16,7 +16,7 @@ void uses() { #pragma acc parallel attach(LocalInt) while (1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel attach(&LocalInt) while (1); diff --git a/clang/test/SemaOpenACC/compute-construct-clause-ast.cpp b/clang/test/SemaOpenACC/compute-construct-clause-ast.cpp index 6d2efcf81eb6e4..69f65f4083ae7b 100644 --- a/clang/test/SemaOpenACC/compute-construct-clause-ast.cpp +++ b/clang/test/SemaOpenACC/compute-construct-clause-ast.cpp @@ -40,6 +40,89 @@ void NormalFunc(int i, float f) { // CHECK-NEXT: WhileStmt // CHECK-NEXT: CXXBoolLiteralExpr // CHECK-NEXT: NullStmt + +#pragma acc parallel reduction(+: i) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: + + // CHECK-NEXT: DeclRefExpr{{.*}} 'int' lvalue ParmVar{{.*}} 'i' 'int' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc serial reduction(*: f) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}serial + // CHECK-NEXT: reduction clause Operator: * + // CHECK-NEXT: DeclRefExpr{{.*}} 'float' lvalue ParmVar{{.*}} 'f' 'float' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc parallel reduction(max: i) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: max + // CHECK-NEXT: DeclRefExpr{{.*}} 'int' lvalue ParmVar{{.*}} 'i' 'int' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc serial reduction(min: f) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}serial + // CHECK-NEXT: reduction clause Operator: min + // CHECK-NEXT: DeclRefExpr{{.*}} 'float' lvalue ParmVar{{.*}} 'f' 'float' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc parallel reduction(&: i) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: & + // CHECK-NEXT: DeclRefExpr{{.*}} 'int' lvalue ParmVar{{.*}} 'i' 'int' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc serial reduction(|: f) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}serial + // CHECK-NEXT: reduction clause Operator: | + // CHECK-NEXT: DeclRefExpr{{.*}} 'float' lvalue ParmVar{{.*}} 'f' 'float' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + + +#pragma acc parallel reduction(^: i) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: ^ + // CHECK-NEXT: DeclRefExpr{{.*}} 'int' lvalue ParmVar{{.*}} 'i' 'int' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc serial reduction(&&: f) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}serial + // CHECK-NEXT: reduction clause Operator: && + // CHECK-NEXT: DeclRefExpr{{.*}} 'float' lvalue ParmVar{{.*}} 'f' 'float' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + + +#pragma acc parallel reduction(||: i) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: || + // CHECK-NEXT: DeclRefExpr{{.*}} 'int' lvalue ParmVar{{.*}} 'i' 'int' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt } template @@ -154,6 +237,98 @@ void TemplFunc() { // CHECK-NEXT: CXXBoolLiteralExpr // CHECK-NEXT: NullStmt + T t; + // CHECK-NEXT: DeclStmt + // CHECK-NEXT: VarDecl{{.*}} t 'T' + +#pragma acc parallel reduction(+: t) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: + + // CHECK-NEXT: DeclRefExpr{{.*}} 'T' lvalue Var{{.*}} 't' 'T' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc serial reduction(*: T::SomeFloat) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}serial + // CHECK-NEXT: reduction clause Operator: * + // CHECK-NEXT: DependentScopeDeclRefExpr{{.*}} '' lvalue + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'T' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + + typename T::IntTy i; + // CHECK-NEXT: DeclStmt + // CHECK-NEXT: VarDecl{{.*}} i 'typename T::IntTy' + +#pragma acc parallel reduction(max: i) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: max + // CHECK-NEXT: DeclRefExpr{{.*}} 'typename T::IntTy' lvalue Var{{.*}} 'i' 'typename T::IntTy' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc serial reduction(min: t) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}serial + // CHECK-NEXT: reduction clause Operator: min + // CHECK-NEXT: DeclRefExpr{{.*}} 'T' lvalue Var{{.*}} 't' 'T' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc parallel reduction(&: T::SomeFloat) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: & + // CHECK-NEXT: DependentScopeDeclRefExpr{{.*}} '' lvalue + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'T' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc serial reduction(|: i) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}serial + // CHECK-NEXT: reduction clause Operator: | + // CHECK-NEXT: DeclRefExpr{{.*}} 'typename T::IntTy' lvalue Var{{.*}} 'i' 'typename T::IntTy' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc parallel reduction(^: t) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: ^ + // CHECK-NEXT: DeclRefExpr{{.*}} 'T' lvalue Var{{.*}} 't' 'T' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc serial reduction(&&: T::SomeFloat) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}serial + // CHECK-NEXT: reduction clause Operator: && + // CHECK-NEXT: DependentScopeDeclRefExpr{{.*}} '' lvalue + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'T' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + +#pragma acc parallel reduction(||: i) + while(true); + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: || + // CHECK-NEXT: DeclRefExpr{{.*}} 'typename T::IntTy' lvalue Var{{.*}} 'i' 'typename T::IntTy' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + // Match the instantiation: // CHECK: FunctionDecl{{.*}}TemplFunc{{.*}}implicit_instantiation // CHECK-NEXT: TemplateArgument type 'InstTy' @@ -262,6 +437,79 @@ void TemplFunc() { // CHECK-NEXT: CXXBoolLiteralExpr // CHECK-NEXT: NullStmt + // CHECK-NEXT: DeclStmt + // CHECK-NEXT: VarDecl{{.*}} t 'InstTy' + // CHECK-NEXT: CXXConstructExpr + + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: + + // CHECK-NEXT: DeclRefExpr{{.*}} 'InstTy' lvalue Var{{.*}} 't' 'InstTy' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}serial + // CHECK-NEXT: reduction clause Operator: * + // CHECK-NEXT: DeclRefExpr{{.*}} 'const float' lvalue Var{{.*}} 'SomeFloat' 'const float' + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'InstTy' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + + // CHECK-NEXT: DeclStmt + // CHECK-NEXT: VarDecl{{.*}} i 'typename InstTy::IntTy':'int' + + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: max + // CHECK-NEXT: DeclRefExpr{{.*}} 'typename InstTy::IntTy':'int' lvalue Var{{.*}} 'i' 'typename InstTy::IntTy':'int' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}serial + // CHECK-NEXT: reduction clause Operator: min + // CHECK-NEXT: DeclRefExpr{{.*}} 'InstTy' lvalue Var{{.*}} 't' 'InstTy' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: & + // CHECK-NEXT: DeclRefExpr{{.*}} 'const float' lvalue Var{{.*}} 'SomeFloat' 'const float' + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'InstTy' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}serial + // CHECK-NEXT: reduction clause Operator: | + // CHECK-NEXT: DeclRefExpr{{.*}} 'typename InstTy::IntTy':'int' lvalue Var{{.*}} 'i' 'typename InstTy::IntTy':'int' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: ^ + // CHECK-NEXT: DeclRefExpr{{.*}} 'InstTy' lvalue Var{{.*}} 't' 'InstTy' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}serial + // CHECK-NEXT: reduction clause Operator: && + // CHECK-NEXT: DeclRefExpr{{.*}} 'const float' lvalue Var{{.*}} 'SomeFloat' 'const float' + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'InstTy' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + + // CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel + // CHECK-NEXT: reduction clause Operator: || + // CHECK-NEXT: DeclRefExpr{{.*}} 'typename InstTy::IntTy':'int' lvalue Var{{.*}} 'i' 'typename InstTy::IntTy':'int' + // CHECK-NEXT: WhileStmt + // CHECK-NEXT: CXXBoolLiteralExpr + // CHECK-NEXT: NullStmt + } struct BoolConversion{ operator bool() const;}; diff --git a/clang/test/SemaOpenACC/compute-construct-copy-clause.c b/clang/test/SemaOpenACC/compute-construct-copy-clause.c index accbe43cea406f..2b43480be8b4fe 100644 --- a/clang/test/SemaOpenACC/compute-construct-copy-clause.c +++ b/clang/test/SemaOpenACC/compute-construct-copy-clause.c @@ -36,11 +36,11 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo #pragma acc parallel copy(LocalComposite.ScalarMember, LocalComposite.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copy(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copy(+IntParam) while(1); @@ -53,10 +53,10 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copy((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copy((float)ArrayParam[2]) while(1); } diff --git a/clang/test/SemaOpenACC/compute-construct-copy-clause.cpp b/clang/test/SemaOpenACC/compute-construct-copy-clause.cpp index 16e78a43026a9f..2797927e6e56b8 100644 --- a/clang/test/SemaOpenACC/compute-construct-copy-clause.cpp +++ b/clang/test/SemaOpenACC/compute-construct-copy-clause.cpp @@ -31,11 +31,11 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos #pragma acc parallel copy(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copy(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copy(+IntParam) while(1); @@ -48,27 +48,27 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copy((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copy((float)ArrayParam[2]) while(1); } template void TemplUses(T t, T (&arrayT)[I], V TemplComp) { - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copy(+t) while(true); // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#TEMPL_USES_INST{{in instantiation of}} #pragma acc parallel copy(I) while(true); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copy(t, I) while(true); @@ -93,7 +93,7 @@ void TemplUses(T t, T (&arrayT)[I], V TemplComp) { template void NTTP() { // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#NTTP_INST{{in instantiation of}} #pragma acc parallel copy(I) while(true); diff --git a/clang/test/SemaOpenACC/compute-construct-copyin-clause.c b/clang/test/SemaOpenACC/compute-construct-copyin-clause.c index 6f200b357f52b2..5ea4db9e5fae94 100644 --- a/clang/test/SemaOpenACC/compute-construct-copyin-clause.c +++ b/clang/test/SemaOpenACC/compute-construct-copyin-clause.c @@ -38,11 +38,11 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo #pragma acc parallel copyin(LocalComposite.ScalarMember, LocalComposite.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyin(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyin(+IntParam) while(1); @@ -55,14 +55,14 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyin((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyin((float)ArrayParam[2]) while(1); // expected-error@+2{{invalid tag 'invalid' on 'copyin' clause}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyin(invalid:(float)ArrayParam[2]) while(1); } diff --git a/clang/test/SemaOpenACC/compute-construct-copyin-clause.cpp b/clang/test/SemaOpenACC/compute-construct-copyin-clause.cpp index 79275e701161b3..74ce74a1368d1c 100644 --- a/clang/test/SemaOpenACC/compute-construct-copyin-clause.cpp +++ b/clang/test/SemaOpenACC/compute-construct-copyin-clause.cpp @@ -31,11 +31,11 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos #pragma acc parallel copyin(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyin(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyin(+IntParam) while(1); @@ -48,27 +48,27 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyin((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyin((float)ArrayParam[2]) while(1); } template void TemplUses(T t, T (&arrayT)[I], V TemplComp) { - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyin(+t) while(true); // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#TEMPL_USES_INST{{in instantiation of}} #pragma acc parallel copyin(I) while(true); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyin(t, I) while(true); @@ -93,7 +93,7 @@ void TemplUses(T t, T (&arrayT)[I], V TemplComp) { template void NTTP() { // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#NTTP_INST{{in instantiation of}} #pragma acc parallel copyin(I) while(true); diff --git a/clang/test/SemaOpenACC/compute-construct-copyout-clause.c b/clang/test/SemaOpenACC/compute-construct-copyout-clause.c index 38a50f8373e8d0..a035ab3242e3a8 100644 --- a/clang/test/SemaOpenACC/compute-construct-copyout-clause.c +++ b/clang/test/SemaOpenACC/compute-construct-copyout-clause.c @@ -38,11 +38,11 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo #pragma acc parallel copyout(LocalComposite.ScalarMember, LocalComposite.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyout(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyout(+IntParam) while(1); @@ -55,14 +55,14 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyout((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyout((float)ArrayParam[2]) while(1); // expected-error@+2{{invalid tag 'invalid' on 'copyout' clause}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyout(invalid:(float)ArrayParam[2]) while(1); } diff --git a/clang/test/SemaOpenACC/compute-construct-copyout-clause.cpp b/clang/test/SemaOpenACC/compute-construct-copyout-clause.cpp index 3d05a5670092e1..c01dc1a39963bd 100644 --- a/clang/test/SemaOpenACC/compute-construct-copyout-clause.cpp +++ b/clang/test/SemaOpenACC/compute-construct-copyout-clause.cpp @@ -31,11 +31,11 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos #pragma acc parallel copyout(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyout(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyout(+IntParam) while(1); @@ -48,27 +48,27 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyout((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyout((float)ArrayParam[2]) while(1); } template void TemplUses(T t, T (&arrayT)[I], V TemplComp) { - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyout(+t) while(true); // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#TEMPL_USES_INST{{in instantiation of}} #pragma acc parallel copyout(I) while(true); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel copyout(t, I) while(true); @@ -93,7 +93,7 @@ void TemplUses(T t, T (&arrayT)[I], V TemplComp) { template void NTTP() { // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#NTTP_INST{{in instantiation of}} #pragma acc parallel copyout(I) while(true); diff --git a/clang/test/SemaOpenACC/compute-construct-create-clause.c b/clang/test/SemaOpenACC/compute-construct-create-clause.c index 9c94e3a1a40739..5cfa9b0c5cc3c0 100644 --- a/clang/test/SemaOpenACC/compute-construct-create-clause.c +++ b/clang/test/SemaOpenACC/compute-construct-create-clause.c @@ -39,11 +39,11 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo #pragma acc parallel create(LocalComposite.ScalarMember, LocalComposite.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel create(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel create(+IntParam) while(1); @@ -56,14 +56,14 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel create((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel create((float)ArrayParam[2]) while(1); // expected-error@+2{{invalid tag 'invalid' on 'create' clause}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel create(invalid:(float)ArrayParam[2]) while(1); } diff --git a/clang/test/SemaOpenACC/compute-construct-create-clause.cpp b/clang/test/SemaOpenACC/compute-construct-create-clause.cpp index d0323620b8f70d..3ed1e1e9f700d0 100644 --- a/clang/test/SemaOpenACC/compute-construct-create-clause.cpp +++ b/clang/test/SemaOpenACC/compute-construct-create-clause.cpp @@ -31,11 +31,11 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos #pragma acc parallel create(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel create(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel create(+IntParam) while(1); @@ -48,27 +48,27 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel create((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel create((float)ArrayParam[2]) while(1); } template void TemplUses(T t, T (&arrayT)[I], V TemplComp) { - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel create(+t) while(true); // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#TEMPL_USES_INST{{in instantiation of}} #pragma acc parallel create(I) while(true); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel create(t, I) while(true); @@ -93,7 +93,7 @@ void TemplUses(T t, T (&arrayT)[I], V TemplComp) { template void NTTP() { // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#NTTP_INST{{in instantiation of}} #pragma acc parallel create(I) while(true); diff --git a/clang/test/SemaOpenACC/compute-construct-device_type-clause.c b/clang/test/SemaOpenACC/compute-construct-device_type-clause.c index 15c9cf396c80c0..bf2a00a0f73604 100644 --- a/clang/test/SemaOpenACC/compute-construct-device_type-clause.c +++ b/clang/test/SemaOpenACC/compute-construct-device_type-clause.c @@ -182,7 +182,7 @@ void uses() { while(1); // expected-error@+2{{OpenACC clause 'reduction' may not follow a 'device_type' clause in a compute construct}} // expected-note@+1{{previous clause is here}} -#pragma acc kernels device_type(*) reduction(+:Var) +#pragma acc serial device_type(*) reduction(+:Var) while(1); // expected-error@+2{{OpenACC clause 'collapse' may not follow a 'device_type' clause in a compute construct}} // expected-note@+1{{previous clause is here}} diff --git a/clang/test/SemaOpenACC/compute-construct-deviceptr-clause.c b/clang/test/SemaOpenACC/compute-construct-deviceptr-clause.c index e5d328eb0b28bc..ae8269b9779a4a 100644 --- a/clang/test/SemaOpenACC/compute-construct-deviceptr-clause.c +++ b/clang/test/SemaOpenACC/compute-construct-deviceptr-clause.c @@ -16,7 +16,7 @@ void uses() { #pragma acc parallel deviceptr(LocalInt) while (1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel deviceptr(&LocalInt) while (1); diff --git a/clang/test/SemaOpenACC/compute-construct-firstprivate-clause.c b/clang/test/SemaOpenACC/compute-construct-firstprivate-clause.c index 4e057bf32c2d6d..eacda7bbbbba20 100644 --- a/clang/test/SemaOpenACC/compute-construct-firstprivate-clause.c +++ b/clang/test/SemaOpenACC/compute-construct-firstprivate-clause.c @@ -29,11 +29,11 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo #pragma acc parallel firstprivate(LocalComposite.ScalarMember, LocalComposite.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel firstprivate(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel firstprivate(+IntParam) while(1); @@ -46,10 +46,10 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel firstprivate((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel firstprivate((float)ArrayParam[2]) while(1); } diff --git a/clang/test/SemaOpenACC/compute-construct-firstprivate-clause.cpp b/clang/test/SemaOpenACC/compute-construct-firstprivate-clause.cpp index 2fbb80f7b2fbd6..161e4012c08d56 100644 --- a/clang/test/SemaOpenACC/compute-construct-firstprivate-clause.cpp +++ b/clang/test/SemaOpenACC/compute-construct-firstprivate-clause.cpp @@ -32,11 +32,11 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos #pragma acc parallel firstprivate(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel firstprivate(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel firstprivate(+IntParam) while(1); @@ -49,27 +49,27 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel firstprivate((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel firstprivate((float)ArrayParam[2]) while(1); } template void TemplUses(T t, T (&arrayT)[I], V TemplComp) { - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private(+t) while(true); // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#TEMPL_USES_INST{{in instantiation of}} #pragma acc parallel private(I) while(true); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private(t, I) while(true); @@ -94,7 +94,7 @@ void TemplUses(T t, T (&arrayT)[I], V TemplComp) { template void NTTP() { // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#NTTP_INST{{in instantiation of}} #pragma acc parallel private(I) while(true); diff --git a/clang/test/SemaOpenACC/compute-construct-no_create-clause.c b/clang/test/SemaOpenACC/compute-construct-no_create-clause.c index 07a60b73c34f84..4ff06eaf132b04 100644 --- a/clang/test/SemaOpenACC/compute-construct-no_create-clause.c +++ b/clang/test/SemaOpenACC/compute-construct-no_create-clause.c @@ -28,11 +28,11 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo #pragma acc parallel no_create(LocalComposite.ScalarMember, LocalComposite.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel no_create(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel no_create(+IntParam) while(1); @@ -45,10 +45,10 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel no_create((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel no_create((float)ArrayParam[2]) while(1); } diff --git a/clang/test/SemaOpenACC/compute-construct-no_create-clause.cpp b/clang/test/SemaOpenACC/compute-construct-no_create-clause.cpp index 3820d5e3999d56..fa84b1fbeda077 100644 --- a/clang/test/SemaOpenACC/compute-construct-no_create-clause.cpp +++ b/clang/test/SemaOpenACC/compute-construct-no_create-clause.cpp @@ -31,11 +31,11 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos #pragma acc parallel no_create(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel no_create(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel no_create(+IntParam) while(1); @@ -48,27 +48,27 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel no_create((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel no_create((float)ArrayParam[2]) while(1); } template void TemplUses(T t, T (&arrayT)[I], V TemplComp) { - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel no_create(+t) while(true); // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#TEMPL_USES_INST{{in instantiation of}} #pragma acc parallel no_create(I) while(true); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel no_create(t, I) while(true); @@ -93,7 +93,7 @@ void TemplUses(T t, T (&arrayT)[I], V TemplComp) { template void NTTP() { // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#NTTP_INST{{in instantiation of}} #pragma acc parallel no_create(I) while(true); diff --git a/clang/test/SemaOpenACC/compute-construct-present-clause.c b/clang/test/SemaOpenACC/compute-construct-present-clause.c index 99c4b1dcd19b47..1d50a6b1275b82 100644 --- a/clang/test/SemaOpenACC/compute-construct-present-clause.c +++ b/clang/test/SemaOpenACC/compute-construct-present-clause.c @@ -28,11 +28,11 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo #pragma acc parallel present(LocalComposite.ScalarMember, LocalComposite.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel present(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel present(+IntParam) while(1); @@ -45,10 +45,10 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel present((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel present((float)ArrayParam[2]) while(1); } diff --git a/clang/test/SemaOpenACC/compute-construct-present-clause.cpp b/clang/test/SemaOpenACC/compute-construct-present-clause.cpp index 62e481dea3e24a..db230d0b1d9da5 100644 --- a/clang/test/SemaOpenACC/compute-construct-present-clause.cpp +++ b/clang/test/SemaOpenACC/compute-construct-present-clause.cpp @@ -31,11 +31,11 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos #pragma acc parallel present(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel present(1 + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel present(+IntParam) while(1); @@ -48,27 +48,27 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel present((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel present((float)ArrayParam[2]) while(1); } template void TemplUses(T t, T (&arrayT)[I], V TemplComp) { - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel present(+t) while(true); // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#TEMPL_USES_INST{{in instantiation of}} #pragma acc parallel present(I) while(true); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel present(t, I) while(true); @@ -93,7 +93,7 @@ void TemplUses(T t, T (&arrayT)[I], V TemplComp) { template void NTTP() { // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#NTTP_INST{{in instantiation of}} #pragma acc parallel present(I) while(true); diff --git a/clang/test/SemaOpenACC/compute-construct-private-clause.c b/clang/test/SemaOpenACC/compute-construct-private-clause.c index d2615c384cdb1c..3e6dbaafbc6fa0 100644 --- a/clang/test/SemaOpenACC/compute-construct-private-clause.c +++ b/clang/test/SemaOpenACC/compute-construct-private-clause.c @@ -89,13 +89,13 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo // Invalid cases, arbitrary expressions. struct Incomplete *I; - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private(*I) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private(GlobalInt + IntParam) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private(+GlobalInt) while(1); @@ -128,10 +128,10 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo while(1); // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private((float*)ArrayParam[2:5]) while(1); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private((float)ArrayParam[2]) while(1); } diff --git a/clang/test/SemaOpenACC/compute-construct-private-clause.cpp b/clang/test/SemaOpenACC/compute-construct-private-clause.cpp index a776b16f0feb27..fb9e89a21accba 100644 --- a/clang/test/SemaOpenACC/compute-construct-private-clause.cpp +++ b/clang/test/SemaOpenACC/compute-construct-private-clause.cpp @@ -64,34 +64,34 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos // Invalid cases, arbitrary expressions. Incomplete *I; - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private(*I) while(true); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private(GlobalInt + IntParam) while(true); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private(+GlobalInt) while(true); } template void TemplUses(T t, T (&arrayT)[I], V TemplComp) { - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private(+t) while(true); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private(+I) while(true); // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#TEMPL_USES_INST{{in instantiation of}} #pragma acc parallel private(I) while(true); - // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} #pragma acc parallel private(t, I) while(true); @@ -120,7 +120,7 @@ void TemplUses(T t, T (&arrayT)[I], V TemplComp) { template void NTTP() { // NTTP's are only valid if it is a reference to something. - // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} + // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} // expected-note@#NTTP_INST{{in instantiation of}} #pragma acc parallel private(I) while(true); diff --git a/clang/test/SemaOpenACC/compute-construct-reduction-clause.c b/clang/test/SemaOpenACC/compute-construct-reduction-clause.c new file mode 100644 index 00000000000000..9c0debd3450316 --- /dev/null +++ b/clang/test/SemaOpenACC/compute-construct-reduction-clause.c @@ -0,0 +1,107 @@ +// RUN: %clang_cc1 %s -fopenacc -verify + +struct CompositeOfScalars { + int I; + float F; + short J; + char C; + double D; + _Complex float CF; + _Complex double CD; +}; + +struct CompositeHasComposite { + int I; + float F; + short J; + char C; + double D; + _Complex float CF; + _Complex double CD; + struct CompositeOfScalars COS; // #COS_FIELD +}; + +void uses(unsigned Parm) { + float Var; + int IVar; + +#pragma acc parallel reduction(+:Parm) + while (1); +#pragma acc serial reduction(+:Parm) + while (1); + // expected-error@+1{{OpenACC 'reduction' clause is not valid on 'kernels' directive}} +#pragma acc kernels reduction(+:Parm) + while (1); + + // On a 'parallel', 'num_gangs' cannot have >1 args. num_gangs not valid on + // 'serial', but 'reduction' not valid on 'kernels', other combos cannot be + // tested. +#pragma acc parallel reduction(+:Parm) num_gangs(IVar) + while (1); +#pragma acc parallel num_gangs(IVar) reduction(+:IVar) + while (1); + + // expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel' construct with a 'num_gangs' clause with more than 1 argument, have 2}} + // expected-note@+1{{previous clause is here}} +#pragma acc parallel reduction(+:Parm) num_gangs(Parm, IVar) + while (1); + + // expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel' construct with a 'num_gangs' clause with more than 1 argument, have 2}} + // expected-note@+1{{previous clause is here}} +#pragma acc parallel num_gangs(Parm, IVar) reduction(+:Var) + while (1); + + struct CompositeOfScalars CoS; + struct CompositeOfScalars *CoSPtr; + struct CompositeHasComposite ChC; + struct CompositeHasComposite *ChCPtr; + + int I; + float F; + int Array[5]; + + // Vars in a reduction must be a scalar or a composite of scalars. +#pragma acc parallel reduction(&: CoS, I, F) + while (1); + // expected-error@+2{{OpenACC 'reduction' composite variable must not have non-scalar field}} + // expected-note@#COS_FIELD{{invalid field is here}} +#pragma acc parallel reduction(&: ChC) + while (1); + + // expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}} +#pragma acc parallel reduction(&: Array) + while (1); + +#pragma acc parallel reduction(&: CoS, Array[I], Array[0:I]) + while (1); + + struct CompositeHasComposite ChCArray[5]; + // expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; sub-array base type is 'struct CompositeHasComposite'}} +#pragma acc parallel reduction(&: CoS, Array[I], ChCArray[0:I]) + while (1); + + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&: CoS.I) + while (1); + + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&: CoSPtr->I) + + while (1); + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&: ChC.COS) + while (1); + + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&: ChCPtr->COS) + while (1); + +#pragma acc parallel reduction(&: I) reduction(&:I) + while (1); + + struct HasArray { int array[5]; } HA; + + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&:HA.array[1:2]) + while (1); +} diff --git a/clang/test/SemaOpenACC/compute-construct-reduction-clause.cpp b/clang/test/SemaOpenACC/compute-construct-reduction-clause.cpp new file mode 100644 index 00000000000000..532dbb23871652 --- /dev/null +++ b/clang/test/SemaOpenACC/compute-construct-reduction-clause.cpp @@ -0,0 +1,175 @@ +// RUN: %clang_cc1 %s -fopenacc -verify + +struct CompositeOfScalars { + int I; + float F; + short J; + char C; + double D; + _Complex float CF; + _Complex double CD; +}; + +struct CompositeHasComposite { + int I; + float F; + short J; + char C; + double D; + _Complex float CF; + _Complex double CD; + struct CompositeOfScalars COS; // #COS_FIELD +}; + +void uses(unsigned Parm) { + float Var; + int IVar; + +#pragma acc parallel reduction(+:Parm) + while (1); +#pragma acc serial reduction(+:Parm) + while (1); + // expected-error@+1{{OpenACC 'reduction' clause is not valid on 'kernels' directive}} +#pragma acc kernels reduction(+:Parm) + while (1); + + // On a 'parallel', 'num_gangs' cannot have >1 args. num_gangs not valid on + // 'serial', but 'reduction' not valid on 'kernels', other combos cannot be + // tested. +#pragma acc parallel reduction(+:Parm) num_gangs(IVar) + while (1); +#pragma acc parallel num_gangs(IVar) reduction(+:Var) + while (1); + + // expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel' construct with a 'num_gangs' clause with more than 1 argument, have 2}} + // expected-note@+1{{previous clause is here}} +#pragma acc parallel reduction(+:Parm) num_gangs(Parm, IVar) + while (1); + + // expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel' construct with a 'num_gangs' clause with more than 1 argument, have 2}} + // expected-note@+1{{previous clause is here}} +#pragma acc parallel num_gangs(Parm, IVar) reduction(+:Var) + while (1); + +#pragma acc parallel reduction(+:Parm) reduction(+:Parm) + while (1); + + struct CompositeOfScalars CoS; + struct CompositeOfScalars *CoSPtr; + struct CompositeHasComposite ChC; + struct CompositeHasComposite *ChCPtr; + + int I; + float F; + int Array[5]; + + // Vars in a reduction must be a scalar or a composite of scalars. +#pragma acc parallel reduction(&: CoS, I, F) + while (1); + // expected-error@+2{{OpenACC 'reduction' composite variable must not have non-scalar field}} + // expected-note@#COS_FIELD{{invalid field is here}} +#pragma acc parallel reduction(&: ChC) + while (1); + // expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}} +#pragma acc parallel reduction(&: Array) + while (1); + +#pragma acc parallel reduction(&: CoS, Array[I], Array[0:I]) + while (1); + + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&: CoS.I) + while (1); + + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&: CoSPtr->I) + + while (1); + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&: ChC.COS) + while (1); + + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&: ChCPtr->COS) + while (1); +} + +template +void TemplUses(T Parm, U CoS, V ChC) { + T Var; + U *CoSPtr; + V *ChCPtr; + +#pragma acc parallel reduction(+:Parm) + while (1); +#pragma acc serial reduction(+:Parm) + while (1); + // expected-error@+1{{OpenACC 'reduction' clause is not valid on 'kernels' directive}} +#pragma acc kernels reduction(+:Parm) + while (1); + + // On a 'parallel', 'num_gangs' cannot have >1 args. num_gangs not valid on + // 'serial', but 'reduction' not valid on 'kernels', other combos cannot be + // tested. +#pragma acc parallel reduction(+:Parm) num_gangs(Var) + while (1); +#pragma acc parallel num_gangs(Var) reduction(+:Var) + while (1); + + // expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel' construct with a 'num_gangs' clause with more than 1 argument, have 2}} + // expected-note@+1{{previous clause is here}} +#pragma acc parallel reduction(+:Parm) num_gangs(Parm, Var) + while (1); + + // expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel' construct with a 'num_gangs' clause with more than 1 argument, have 2}} + // expected-note@+1{{previous clause is here}} +#pragma acc parallel num_gangs(Parm, Var) reduction(+:Var) + while (1); + +#pragma acc parallel reduction(+:Parm) reduction(+:Parm) + while (1); + + int NonDep; + int NonDepArray[5]; + T Array[5]; + + // Vars in a reduction must be a scalar or a composite of scalars. +#pragma acc parallel reduction(&: CoS, Var, Parm) + while (1); + // expected-error@+2{{OpenACC 'reduction' composite variable must not have non-scalar field}} + // expected-note@#COS_FIELD{{invalid field is here}} +#pragma acc parallel reduction(&: ChC) + while (1); + // expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}} +#pragma acc parallel reduction(&: Array) + while (1); + // expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}} +#pragma acc parallel reduction(&: NonDepArray) + while (1); + +#pragma acc parallel reduction(&: CoS, Array[Var], Array[0:Var]) + while (1); + + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&: CoS.I) + while (1); + + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&: CoSPtr->I) + + while (1); + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&: ChC.COS) + while (1); + + // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} +#pragma acc parallel reduction(&: ChCPtr->COS) + while (1); +} + +void inst() { + CompositeOfScalars CoS; + CompositeHasComposite ChC; + // expected-note@+1{{in instantiation of function template specialization}} + TemplUses(5, CoS, ChC); +} diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index bfbdb5be9ff2ff..f00ba9e3acfc84 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -2855,6 +2855,10 @@ void OpenACCClauseEnqueue::VisitWaitClause(const OpenACCWaitClause &C) { } void OpenACCClauseEnqueue::VisitDeviceTypeClause( const OpenACCDeviceTypeClause &C) {} +void OpenACCClauseEnqueue::VisitReductionClause( + const OpenACCReductionClause &C) { + VisitVarList(C); +} } // namespace void EnqueueVisitor::EnqueueChildren(const OpenACCClause *C) {