Index: cfe/trunk/include/clang-c/Index.h =================================================================== --- cfe/trunk/include/clang-c/Index.h +++ cfe/trunk/include/clang-c/Index.h @@ -2358,7 +2358,11 @@ */ CXCursor_OMPTargetTeamsDirective = 275, - CXCursor_LastStmt = CXCursor_OMPTargetTeamsDirective, + /** \brief OpenMP target teams distribute directive. + */ + CXCursor_OMPTargetTeamsDistributeDirective = 276, + + CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeDirective, /** * \brief Cursor that represents the translation unit itself. Index: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h =================================================================== --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h @@ -2663,6 +2663,9 @@ DEF_TRAVERSE_STMT(OMPTargetTeamsDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + // OpenMP clauses. template bool RecursiveASTVisitor::TraverseOMPClause(OMPClause *C) { Index: cfe/trunk/include/clang/AST/StmtOpenMP.h =================================================================== --- cfe/trunk/include/clang/AST/StmtOpenMP.h +++ cfe/trunk/include/clang/AST/StmtOpenMP.h @@ -3498,6 +3498,73 @@ } }; +/// This represents '#pragma omp target teams distribute' combined directive. +/// +/// \code +/// #pragma omp target teams distribute private(x) +/// \endcode +/// In this example directive '#pragma omp target teams distribute' has clause +/// 'private' with the variables 'x' +/// +class OMPTargetTeamsDistributeDirective final : public OMPLoopDirective { + friend class ASTStmtReader; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + OMPTargetTeamsDistributeDirective(SourceLocation StartLoc, + SourceLocation EndLoc, + unsigned CollapsedNum, unsigned NumClauses) + : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass, + OMPD_target_teams_distribute, StartLoc, EndLoc, + CollapsedNum, NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPTargetTeamsDistributeDirective(unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass, + OMPD_target_teams_distribute, SourceLocation(), + SourceLocation(), CollapsedNum, NumClauses) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPTargetTeamsDistributeDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with the place for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + static OMPTargetTeamsDistributeDirective * + CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTargetTeamsDistributeDirectiveClass; + } +}; + } // end namespace clang #endif Index: cfe/trunk/include/clang/Basic/OpenMPKinds.def =================================================================== --- cfe/trunk/include/clang/Basic/OpenMPKinds.def +++ cfe/trunk/include/clang/Basic/OpenMPKinds.def @@ -156,6 +156,9 @@ #ifndef OPENMP_TARGET_TEAMS_CLAUSE #define OPENMP_TARGET_TEAMS_CLAUSE(Name) #endif +#ifndef OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE +#define OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(Name) +#endif // OpenMP directives. OPENMP_DIRECTIVE(threadprivate) @@ -206,6 +209,7 @@ OPENMP_DIRECTIVE_EXT(teams_distribute_parallel_for_simd, "teams distribute parallel for simd") OPENMP_DIRECTIVE_EXT(teams_distribute_parallel_for, "teams distribute parallel for") OPENMP_DIRECTIVE_EXT(target_teams, "target teams") +OPENMP_DIRECTIVE_EXT(target_teams_distribute, "target teams distribute") // OpenMP clauses. OPENMP_CLAUSE(if, OMPIfClause) @@ -743,6 +747,25 @@ OPENMP_TARGET_TEAMS_CLAUSE(num_teams) OPENMP_TARGET_TEAMS_CLAUSE(thread_limit) +// Clauses allowed for OpenMP directive 'target teams distribute'. +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(if) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(device) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(map) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(private) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(nowait) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(depend) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(defaultmap) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(firstprivate) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(is_device_ptr) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(default) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(shared) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(reduction) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(num_teams) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(thread_limit) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(lastprivate) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(collapse) +OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(dist_schedule) + #undef OPENMP_TASKLOOP_SIMD_CLAUSE #undef OPENMP_TASKLOOP_CLAUSE #undef OPENMP_LINEAR_KIND @@ -791,3 +814,4 @@ #undef OPENMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE #undef OPENMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_CLAUSE #undef OPENMP_TARGET_TEAMS_CLAUSE +#undef OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE Index: cfe/trunk/include/clang/Basic/StmtNodes.td =================================================================== --- cfe/trunk/include/clang/Basic/StmtNodes.td +++ cfe/trunk/include/clang/Basic/StmtNodes.td @@ -241,3 +241,4 @@ def OMPTeamsDistributeParallelForSimdDirective : DStmt; def OMPTeamsDistributeParallelForDirective : DStmt; def OMPTargetTeamsDirective : DStmt; +def OMPTargetTeamsDistributeDirective : DStmt; Index: cfe/trunk/include/clang/Sema/Sema.h =================================================================== --- cfe/trunk/include/clang/Sema/Sema.h +++ cfe/trunk/include/clang/Sema/Sema.h @@ -8471,6 +8471,12 @@ Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc); + /// Called on well-formed '\#pragma omp target teams distribute' after parsing + /// of the associated statement. + StmtResult ActOnOpenMPTargetTeamsDistributeDirective( + ArrayRef Clauses, Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc, + llvm::DenseMap &VarsWithImplicitDSA); /// Checks correctness of linear modifiers. bool CheckOpenMPLinearModifier(OpenMPLinearClauseKind LinKind, Index: cfe/trunk/include/clang/Serialization/ASTBitCodes.h =================================================================== --- cfe/trunk/include/clang/Serialization/ASTBitCodes.h +++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h @@ -1514,6 +1514,7 @@ STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE, STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE, STMT_OMP_TARGET_TEAMS_DIRECTIVE, + STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE, EXPR_OMP_ARRAY_SECTION, // ARC Index: cfe/trunk/lib/AST/StmtOpenMP.cpp =================================================================== --- cfe/trunk/lib/AST/StmtOpenMP.cpp +++ cfe/trunk/lib/AST/StmtOpenMP.cpp @@ -1543,3 +1543,58 @@ C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); return new (Mem) OMPTargetTeamsDirective(NumClauses); } + +OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create( + const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, Stmt *AssociatedStmt, + const HelperExprs &Exprs) { + auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective), + alignof(OMPClause *)); + void *Mem = C.Allocate( + Size + sizeof(OMPClause *) * Clauses.size() + + sizeof(Stmt *) * + numLoopChildren(CollapsedNum, OMPD_target_teams_distribute)); + OMPTargetTeamsDistributeDirective *Dir = + new (Mem) OMPTargetTeamsDistributeDirective(StartLoc, EndLoc, CollapsedNum, + Clauses.size()); + Dir->setClauses(Clauses); + Dir->setAssociatedStmt(AssociatedStmt); + Dir->setIterationVariable(Exprs.IterationVarRef); + Dir->setLastIteration(Exprs.LastIteration); + Dir->setCalcLastIteration(Exprs.CalcLastIteration); + Dir->setPreCond(Exprs.PreCond); + Dir->setCond(Exprs.Cond); + Dir->setInit(Exprs.Init); + Dir->setInc(Exprs.Inc); + Dir->setIsLastIterVariable(Exprs.IL); + Dir->setLowerBoundVariable(Exprs.LB); + Dir->setUpperBoundVariable(Exprs.UB); + Dir->setStrideVariable(Exprs.ST); + Dir->setEnsureUpperBound(Exprs.EUB); + Dir->setNextLowerBound(Exprs.NLB); + Dir->setNextUpperBound(Exprs.NUB); + Dir->setNumIterations(Exprs.NumIterations); + Dir->setPrevLowerBoundVariable(Exprs.PrevLB); + Dir->setPrevUpperBoundVariable(Exprs.PrevUB); + Dir->setCounters(Exprs.Counters); + Dir->setPrivateCounters(Exprs.PrivateCounters); + Dir->setInits(Exprs.Inits); + Dir->setUpdates(Exprs.Updates); + Dir->setFinals(Exprs.Finals); + Dir->setPreInits(Exprs.PreInits); + return Dir; +} + +OMPTargetTeamsDistributeDirective * +OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C, + unsigned NumClauses, + unsigned CollapsedNum, + EmptyShell) { + auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective), + alignof(OMPClause *)); + void *Mem = C.Allocate( + Size + sizeof(OMPClause *) * NumClauses + + sizeof(Stmt *) * + numLoopChildren(CollapsedNum, OMPD_target_teams_distribute)); + return new (Mem) OMPTargetTeamsDistributeDirective(CollapsedNum, NumClauses); +} Index: cfe/trunk/lib/AST/StmtPrinter.cpp =================================================================== --- cfe/trunk/lib/AST/StmtPrinter.cpp +++ cfe/trunk/lib/AST/StmtPrinter.cpp @@ -1232,6 +1232,12 @@ PrintOMPExecutableDirective(Node); } +void StmtPrinter::VisitOMPTargetTeamsDistributeDirective( + OMPTargetTeamsDistributeDirective *Node) { + Indent() << "#pragma omp target teams distribute "; + PrintOMPExecutableDirective(Node); +} + //===----------------------------------------------------------------------===// // Expr printing methods. //===----------------------------------------------------------------------===// Index: cfe/trunk/lib/AST/StmtProfile.cpp =================================================================== --- cfe/trunk/lib/AST/StmtProfile.cpp +++ cfe/trunk/lib/AST/StmtProfile.cpp @@ -753,6 +753,11 @@ VisitOMPExecutableDirective(S); } +void StmtProfiler::VisitOMPTargetTeamsDistributeDirective( + const OMPTargetTeamsDistributeDirective *S) { + VisitOMPLoopDirective(S); +} + void StmtProfiler::VisitExpr(const Expr *S) { VisitStmt(S); } Index: cfe/trunk/lib/Basic/OpenMPKinds.cpp =================================================================== --- cfe/trunk/lib/Basic/OpenMPKinds.cpp +++ cfe/trunk/lib/Basic/OpenMPKinds.cpp @@ -670,6 +670,16 @@ break; } break; + case OMPD_target_teams_distribute: + switch (CKind) { +#define OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(Name) \ + case OMPC_##Name: \ + return true; +#include "clang/Basic/OpenMPKinds.def" + default: + break; + } + break; case OMPD_declare_target: case OMPD_end_declare_target: case OMPD_unknown: @@ -699,8 +709,8 @@ DKind == OMPD_teams_distribute || DKind == OMPD_teams_distribute_simd || DKind == OMPD_teams_distribute_parallel_for_simd || - DKind == OMPD_teams_distribute_parallel_for; - // TODO add next directives. + DKind == OMPD_teams_distribute_parallel_for || + DKind == OMPD_target_teams_distribute; } bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) { @@ -737,7 +747,7 @@ return DKind == OMPD_target || DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for || DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd || - DKind == OMPD_target_teams; + DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute; } bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) { @@ -754,7 +764,7 @@ bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) { return isOpenMPNestingTeamsDirective(DKind) || - DKind == OMPD_target_teams; + DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute; } bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) { @@ -778,8 +788,8 @@ return isOpenMPNestingDistributeDirective(Kind) || Kind == OMPD_teams_distribute || Kind == OMPD_teams_distribute_simd || Kind == OMPD_teams_distribute_parallel_for_simd || - Kind == OMPD_teams_distribute_parallel_for; - // TODO add next directives. + Kind == OMPD_teams_distribute_parallel_for || + Kind == OMPD_target_teams_distribute; } bool clang::isOpenMPPrivate(OpenMPClauseKind Kind) { @@ -802,5 +812,6 @@ Kind == OMPD_distribute_simd || Kind == OMPD_teams_distribute || Kind == OMPD_teams_distribute_simd || Kind == OMPD_teams_distribute_parallel_for_simd || - Kind == OMPD_teams_distribute_parallel_for; + Kind == OMPD_teams_distribute_parallel_for || + Kind == OMPD_target_teams_distribute; } Index: cfe/trunk/lib/CodeGen/CGStmt.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGStmt.cpp +++ cfe/trunk/lib/CodeGen/CGStmt.cpp @@ -318,6 +318,10 @@ case Stmt::OMPTargetTeamsDirectiveClass: EmitOMPTargetTeamsDirective(cast(*S)); break; + case Stmt::OMPTargetTeamsDistributeDirectiveClass: + EmitOMPTargetTeamsDistributeDirective( + cast(*S)); + break; } } Index: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp @@ -2011,6 +2011,14 @@ }); } +void CodeGenFunction::EmitOMPTargetTeamsDistributeDirective( + const OMPTargetTeamsDistributeDirective &S) { + CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_target_teams_distribute, + [&S](CodeGenFunction &CGF, PrePostActionTy &) { + CGF.EmitStmt(cast(S.getAssociatedStmt())->getCapturedStmt()); + }); +} + /// \brief Emit a helper variable and return corresponding lvalue. static LValue EmitOMPHelperVar(CodeGenFunction &CGF, const DeclRefExpr *Helper) { Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h =================================================================== --- cfe/trunk/lib/CodeGen/CodeGenFunction.h +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h @@ -2695,6 +2695,8 @@ void EmitOMPTeamsDistributeParallelForDirective( const OMPTeamsDistributeParallelForDirective &S); void EmitOMPTargetTeamsDirective(const OMPTargetTeamsDirective &S); + void EmitOMPTargetTeamsDistributeDirective( + const OMPTargetTeamsDistributeDirective &S); /// Emit outlined function for the target directive. static std::pair Clauses, Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc, + llvm::DenseMap &VarsWithImplicitDSA) { + if (!AStmt) + return StmtError(); + + CapturedStmt *CS = cast(AStmt); + // 1.2.2 OpenMP Language Terminology + // Structured block - An executable statement with a single entry at the + // top and a single exit at the bottom. + // The point of exit cannot be a branch out of the structured block. + // longjmp() and throw() must not violate the entry/exit criteria. + CS->getCapturedDecl()->setNothrow(); + + OMPLoopDirective::HelperExprs B; + // In presence of clause 'collapse' with number of loops, it will + // define the nested loops number. + auto NestedLoopCount = CheckOpenMPLoop( + OMPD_target_teams_distribute, + getCollapseNumberExpr(Clauses), + nullptr /*ordered not a clause on distribute*/, AStmt, *this, *DSAStack, + VarsWithImplicitDSA, B); + if (NestedLoopCount == 0) + return StmtError(); + + assert((CurContext->isDependentContext() || B.builtAll()) && + "omp target teams distribute loop exprs were not built"); + + getCurFunction()->setHasBranchProtectedScope(); + return OMPTargetTeamsDistributeDirective::Create( + Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B); +} + OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, SourceLocation StartLoc, SourceLocation LParenLoc, @@ -7303,7 +7343,8 @@ // A list item cannot appear in both a map clause and a data-sharing // attribute clause on the same construct if (CurrDir == OMPD_target || CurrDir == OMPD_target_parallel || - CurrDir == OMPD_target_teams) { + CurrDir == OMPD_target_teams || + CurrDir == OMPD_target_teams_distribute) { OpenMPClauseKind ConflictKind; if (DSAStack->checkMappableExprComponentListsForDecl( VD, /*CurrentRegionOnly=*/true, @@ -7561,7 +7602,8 @@ // A list item cannot appear in both a map clause and a data-sharing // attribute clause on the same construct if (CurrDir == OMPD_target || CurrDir == OMPD_target_parallel || - CurrDir == OMPD_target_teams) { + CurrDir == OMPD_target_teams || + CurrDir == OMPD_target_teams_distribute) { OpenMPClauseKind ConflictKind; if (DSAStack->checkMappableExprComponentListsForDecl( VD, /*CurrentRegionOnly=*/true, @@ -10077,7 +10119,8 @@ // OpenMP 4.5 [2.15.5.1, Restrictions, p.3] // A list item cannot appear in both a map clause and a data-sharing // attribute clause on the same construct - if ((DKind == OMPD_target || DKind == OMPD_target_teams) && VD) { + if ((DKind == OMPD_target || DKind == OMPD_target_teams || + DKind == OMPD_target_teams) && VD) { auto DVar = DSAS->getTopDSA(VD, false); if (isOpenMPPrivate(DVar.CKind)) { SemaRef.Diag(ELoc, diag::err_omp_variable_in_given_clause_and_dsa) Index: cfe/trunk/lib/Sema/TreeTransform.h =================================================================== --- cfe/trunk/lib/Sema/TreeTransform.h +++ cfe/trunk/lib/Sema/TreeTransform.h @@ -7742,6 +7742,17 @@ return Res; } +template +StmtResult TreeTransform::TransformOMPTargetTeamsDistributeDirective( + OMPTargetTeamsDistributeDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_target_teams_distribute, + DirName, nullptr, D->getLocStart()); + auto Res = getDerived().TransformOMPExecutableDirective(D); + getDerived().getSema().EndOpenMPDSABlock(Res.get()); + return Res; +} + //===----------------------------------------------------------------------===// // OpenMP clause transformation //===----------------------------------------------------------------------===// Index: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp =================================================================== --- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp +++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp @@ -2850,6 +2850,11 @@ VisitOMPExecutableDirective(D); } +void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective( + OMPTargetTeamsDistributeDirective *D) { + VisitOMPLoopDirective(D); +} + //===----------------------------------------------------------------------===// // ASTReader Implementation //===----------------------------------------------------------------------===// @@ -3574,7 +3579,7 @@ break; } - case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: { + case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: { auto NumClauses = Record[ASTStmtReader::NumStmtFields]; auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses, @@ -3611,7 +3616,15 @@ Context, Record[ASTStmtReader::NumStmtFields], Empty); break; } - + + case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: { + auto NumClauses = Record[ASTStmtReader::NumStmtFields]; + auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; + S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses, + CollapsedNum, Empty); + break; + } + case EXPR_CXX_OPERATOR_CALL: S = new (Context) CXXOperatorCallExpr(Context, Empty); break; Index: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp =================================================================== --- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp +++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp @@ -2544,6 +2544,12 @@ Code = serialization::STMT_OMP_TARGET_TEAMS_DIRECTIVE; } +void ASTStmtWriter::VisitOMPTargetTeamsDistributeDirective( + OMPTargetTeamsDistributeDirective *D) { + VisitOMPLoopDirective(D); + Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE; +} + //===----------------------------------------------------------------------===// // ASTWriter Implementation //===----------------------------------------------------------------------===// Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -867,6 +867,7 @@ case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass: case Stmt::OMPTeamsDistributeParallelForDirectiveClass: case Stmt::OMPTargetTeamsDirectiveClass: + case Stmt::OMPTargetTeamsDistributeDirectiveClass: llvm_unreachable("Stmt should not be in analyzer evaluation loop"); case Stmt::ObjCSubscriptRefExprClass: Index: cfe/trunk/test/OpenMP/nesting_of_regions.cpp =================================================================== --- cfe/trunk/test/OpenMP/nesting_of_regions.cpp +++ cfe/trunk/test/OpenMP/nesting_of_regions.cpp @@ -190,6 +190,12 @@ #pragma omp target teams // OK ++a; } +#pragma omp parallel + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // SIMD DIRECTIVE #pragma omp simd @@ -417,7 +423,13 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } - +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } + // FOR DIRECTIVE #pragma omp for for (int i = 0; i < 10; ++i) { @@ -657,6 +669,12 @@ #pragma omp target teams // OK ++a; } +#pragma omp for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // OK + for (int j = 0; j < 10; ++j) + ; + } // FOR SIMD DIRECTIVE #pragma omp for simd @@ -885,6 +903,12 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} a++; } +#pragma omp for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // SECTIONS DIRECTIVE #pragma omp sections @@ -1130,6 +1154,12 @@ #pragma omp target teams // OK ++a; } +#pragma omp sections + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // SECTION DIRECTIVE #pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}} @@ -1438,6 +1468,13 @@ #pragma omp target teams // OK ++a; } +#pragma omp sections + { +#pragma omp section +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // SINGLE DIRECTIVE #pragma omp single @@ -1669,6 +1706,12 @@ #pragma omp target teams // OK ++a; } +#pragma omp single + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // MASTER DIRECTIVE #pragma omp master @@ -1900,6 +1943,12 @@ #pragma omp target teams // OK a++; } +#pragma omp master + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // CRITICAL DIRECTIVE #pragma omp critical @@ -2145,6 +2194,12 @@ #pragma omp target teams // OK a++; } +#pragma omp critical + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // PARALLEL FOR DIRECTIVE #pragma omp parallel for @@ -2390,6 +2445,12 @@ #pragma omp target teams // OK a++; } +#pragma omp parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // OK + for (int j = 0; j < 10; ++j) + ; + } // PARALLEL FOR SIMD DIRECTIVE #pragma omp parallel for simd @@ -2636,6 +2697,12 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} a++; } +#pragma omp parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // PARALLEL SECTIONS DIRECTIVE #pragma omp parallel sections @@ -2870,6 +2937,12 @@ #pragma omp target teams // OK a++; } +#pragma omp parallel sections + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // TASK DIRECTIVE #pragma omp task @@ -3051,6 +3124,12 @@ #pragma omp target teams // OK a++; } +#pragma omp task + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // ORDERED DIRECTIVE #pragma omp ordered @@ -3303,6 +3382,12 @@ #pragma omp target teams // OK a++; } +#pragma omp ordered + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // ATOMIC DIRECTIVE #pragma omp atomic @@ -3595,6 +3680,14 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside an atomic region}} a++; } +#pragma omp atomic + // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}} + // expected-note@+1 {{expected an expression statement}} + { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside an atomic region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET DIRECTIVE #pragma omp target @@ -3793,6 +3886,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp target + { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET PARALLEL DIRECTIVE #pragma omp target parallel @@ -3984,6 +4083,12 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target parallel' region}} a++; } +#pragma omp target parallel + { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target parallel' region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET PARALLEL FOR DIRECTIVE #pragma omp target parallel for @@ -4229,6 +4334,12 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target parallel for' region}} a++; } +#pragma omp target parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target parallel for' region}} + for (int j = 0; j < 10; ++j) + ; + } // TEAMS DIRECTIVE #pragma omp teams // expected-error {{orphaned 'omp teams' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -4470,6 +4581,13 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target' region}} a++; } +#pragma omp target +#pragma omp teams + { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ; + } // TASKLOOP DIRECTIVE #pragma omp taskloop @@ -4706,6 +4824,12 @@ #pragma omp target teams // OK ++a; } +#pragma omp taskloop + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // OK + for (int j = 0; j < 10; ++j) + ++a; + } // DISTRIBUTE DIRECTIVE #pragma omp target @@ -4978,6 +5102,14 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target' region}} a++; } +#pragma omp target +#pragma omp teams +#pragma omp distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target' region}} + for (int j = 0; j < 10; ++j) + ; + } // DISTRIBUTE PARALLEL FOR DIRECTIVE #pragma omp target @@ -5258,6 +5390,14 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target' region}} a++; } +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ; + } // DISTRIBUTE PARALLEL FOR SIMD DIRECTIVE #pragma omp target @@ -5546,6 +5686,14 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } // TARGET SIMD DIRECTIVE #pragma omp target simd @@ -5752,7 +5900,7 @@ ++a; } - // TEAMS DISTRIBUTE DIRECTIVE +// TEAMS DISTRIBUTE DIRECTIVE #pragma omp teams distribute // expected-error {{orphaned 'omp teams distribute' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} for (int i = 0; i < 10; ++i) ; @@ -5994,7 +6142,7 @@ ++a; } - // TEAMS DISTRIBUTE DIRECTIVE +// TEAMS DISTRIBUTE DIRECTIVE #pragma omp teams distribute // expected-error {{orphaned 'omp teams distribute' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} for (int i = 0; i < 10; ++i) ; @@ -6248,6 +6396,13 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target' region}} ++a; } +#pragma omp target +#pragma omp teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ++a; + } // TEAMS DISTRIBUTE SIMD DIRECTIVE #pragma omp teams distribute simd // expected-error {{orphaned 'omp teams distribute simd' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -6503,6 +6658,13 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } +#pragma omp target +#pragma omp teams distribute simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } // TEAMS DISTRIBUTE PARALLEL FOR SIMD DIRECTIVE #pragma omp teams distribute parallel for simd // expected-error {{orphaned 'omp teams distribute parallel for simd' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -6758,6 +6920,13 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } +#pragma omp target +#pragma omp teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } // TEAMS DISTRIBUTE PARALLEL FOR DIRECTIVE #pragma omp teams distribute parallel for // expected-error {{orphaned 'omp teams distribute parallel for' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -7013,6 +7182,13 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target' region}} ++a; } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ++a; + } // TARGET TEAMS DIRECTIVE #pragma omp target teams @@ -7210,92 +7386,323 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target teams' region}} a++; } - -} - -void foo() { - int a = 0; -// PARALLEL DIRECTIVE -#pragma omp parallel -#pragma omp for - for (int i = 0; i < 10; ++i) - ; -#pragma omp parallel -#pragma omp simd - for (int i = 0; i < 10; ++i) - ; -#pragma omp parallel -#pragma omp for simd - for (int i = 0; i < 10; ++i) - ; -#pragma omp parallel -#pragma omp sections - { - bar(); - } -#pragma omp parallel -#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel region}} - { - bar(); - } -#pragma omp parallel -#pragma omp sections +#pragma omp target teams { - bar(); - } -#pragma omp parallel -#pragma omp single - bar(); -#pragma omp parallel -#pragma omp master - bar(); -#pragma omp parallel -#pragma omp critical - bar(); -#pragma omp parallel -#pragma omp parallel for +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target teams' region}} for (int i = 0; i < 10; ++i) ; -#pragma omp parallel -#pragma omp parallel for simd + } + +// TARGET TEAMS DISTRIBUTE DIRECTIVE +#pragma omp target teams distribute // OK for (int i = 0; i < 10; ++i) ; -#pragma omp parallel -#pragma omp parallel sections - { - bar(); +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp distribute parallel for simd // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp distribute parallel for simd' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; } -#pragma omp parallel -#pragma omp task - { - bar(); +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; } -#pragma omp parallel - { -#pragma omp taskyield - bar(); +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp for // OK + for (int i = 0; i < 10; ++i) + ; } -#pragma omp parallel - { -#pragma omp barrier - bar(); +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp simd // OK + for (int i = 0; i < 10; ++i) + ; } -#pragma omp parallel - { -#pragma omp taskwait - bar(); +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp for simd // OK + for (int i = 0; i < 10; ++i) + ; } -#pragma omp parallel - { -#pragma omp flush - bar(); +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // OK + for (int i = 0; i < 10; ++i) + ; } -#pragma omp parallel - { -#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} - bar(); +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp sections // OK + { + bar(); + } } -#pragma omp parallel +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a target teams distribute region}} + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp single // OK + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp master // OK + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp critical // OK + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // OK + { +#pragma omp single + { + bar(); + } + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for simd // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp parallel sections // OK + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp task // OK + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp taskyield // OK + bar(); + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp barrier // OK + bar(); + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp taskwait // OK + bar(); + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp flush // OK + bar(); + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp ordered // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} + bar(); + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp atomic // OK + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target // expected-error {{region cannot be nested inside 'target teams distribute' region}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target parallel // expected-error {{region cannot be nested inside 'target teams distribute' region}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target parallel for // expected-error {{region cannot be nested inside 'target teams distribute' region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target enter data map(to: a) // expected-error {{region cannot be nested inside 'target teams distribute' region}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target exit data map(from: a) // expected-error {{region cannot be nested inside 'target teams distribute' region}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target update to(a) // expected-error {{region cannot be nested inside 'target teams distribute' region}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp distribute simd // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp distribute simd' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{region cannot be nested inside 'target teams distribute' region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp teams distribute' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute simd // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp teams distribute simd' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for simd // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp teams distribute parallel for simd' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target teams // expected-error {{region cannot be nested inside 'target teams distribute' region}} + a++; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target teams distribute' region}} + for (int i = 0; i < 10; ++i) + ; + } + +} + +void foo() { + int a = 0; +// PARALLEL DIRECTIVE +#pragma omp parallel +#pragma omp for + for (int i = 0; i < 10; ++i) + ; +#pragma omp parallel +#pragma omp simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp parallel +#pragma omp for simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp parallel +#pragma omp sections + { + bar(); + } +#pragma omp parallel +#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel region}} + { + bar(); + } +#pragma omp parallel +#pragma omp sections + { + bar(); + } +#pragma omp parallel +#pragma omp single + bar(); +#pragma omp parallel +#pragma omp master + bar(); +#pragma omp parallel +#pragma omp critical + bar(); +#pragma omp parallel +#pragma omp parallel for + for (int i = 0; i < 10; ++i) + ; +#pragma omp parallel +#pragma omp parallel for simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp parallel +#pragma omp parallel sections + { + bar(); + } +#pragma omp parallel +#pragma omp task + { + bar(); + } +#pragma omp parallel + { +#pragma omp taskyield + bar(); + } +#pragma omp parallel + { +#pragma omp barrier + bar(); + } +#pragma omp parallel + { +#pragma omp taskwait + bar(); + } +#pragma omp parallel + { +#pragma omp flush + bar(); + } +#pragma omp parallel + { +#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} + bar(); + } +#pragma omp parallel { #pragma omp atomic ++a; @@ -7399,6 +7806,12 @@ #pragma omp target teams // OK a++; } +#pragma omp parallel + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // SIMD DIRECTIVE #pragma omp simd @@ -7610,6 +8023,12 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} a++; } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // FOR DIRECTIVE #pragma omp for @@ -7841,6 +8260,12 @@ #pragma omp target teams // OK a++; } +#pragma omp for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // OK + for (int j = 0; j < 10; ++j) + ; + } // FOR SIMD DIRECTIVE #pragma omp for simd @@ -8052,6 +8477,12 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} a++; } +#pragma omp for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // SECTIONS DIRECTIVE #pragma omp sections @@ -8272,6 +8703,12 @@ #pragma omp target teams // OK a++; } +#pragma omp sections + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // SECTION DIRECTIVE #pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}} @@ -8590,6 +9027,13 @@ #pragma omp target teams // OK a++; } +#pragma omp sections + { +#pragma omp section +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // SINGLE DIRECTIVE #pragma omp single @@ -8811,6 +9255,12 @@ #pragma omp target teams // oK a++; } +#pragma omp single + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // MASTER DIRECTIVE #pragma omp master @@ -9042,6 +9492,12 @@ #pragma omp target teams // OK a++; } +#pragma omp master + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // CRITICAL DIRECTIVE #pragma omp critical @@ -9292,6 +9748,12 @@ #pragma omp target teams // OK a++; } +#pragma omp critical + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // PARALLEL FOR DIRECTIVE #pragma omp parallel for @@ -9538,6 +10000,12 @@ #pragma omp target teams // OK a++; } +#pragma omp parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // OK + for (int j = 0; j < 10; ++j) + ; + } // PARALLEL FOR SIMD DIRECTIVE #pragma omp parallel for simd @@ -9784,6 +10252,12 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} a++; } +#pragma omp parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // PARALLEL SECTIONS DIRECTIVE #pragma omp parallel sections @@ -10014,6 +10488,12 @@ #pragma omp target teams // OK a++; } +#pragma omp parallel sections + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // TASK DIRECTIVE #pragma omp task @@ -10194,6 +10674,12 @@ #pragma omp target teams // OK a++; } +#pragma omp task + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // ATOMIC DIRECTIVE #pragma omp atomic @@ -10485,6 +10971,14 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside an atomic region}} a++; } +#pragma omp atomic + // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}} + // expected-note@+1 {{expected an expression statement}} + { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside an atomic region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET DIRECTIVE #pragma omp target @@ -10679,6 +11173,12 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target' region}} a++; } +#pragma omp target + { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET PARALLEL DIRECTIVE #pragma omp target parallel @@ -10870,6 +11370,12 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target parallel' region}} a++; } +#pragma omp target parallel + { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target parallel' region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET PARALLEL FOR DIRECTIVE #pragma omp target parallel for @@ -11116,6 +11622,12 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target parallel for' region}} a++; } +#pragma omp target parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target parallel for' region}} + for (int j = 0; j < 10; ++j) + ; + } // TEAMS DIRECTIVE #pragma omp target @@ -11359,6 +11871,13 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target' region}} a++; } +#pragma omp target +#pragma omp teams + { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ; + } // TASKLOOP DIRECTIVE #pragma omp taskloop @@ -11595,6 +12114,12 @@ #pragma omp target teams // OK a++; } +#pragma omp taskloop + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } // DISTRIBUTE DIRECTIVE #pragma omp target @@ -11876,6 +12401,14 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp target +#pragma omp teams +#pragma omp distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ++a; + } // DISTRIBUTE PARALLEL FOR DIRECTIVE #pragma omp target @@ -12165,6 +12698,14 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target' region}} ++a; } +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ++a; + } // DISTRIBUTE PARALLEL FOR SIMD DIRECTIVE #pragma omp target @@ -12445,6 +12986,14 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} a++; } +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } // DISTRIBUTE SIMD DIRECTIVE #pragma omp target @@ -12725,6 +13274,14 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} a++; } +#pragma omp target +#pragma omp teams +#pragma omp distribute simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET SIMD DIRECTIVE #pragma omp target simd @@ -12935,6 +13492,12 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} a++; } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } // TEAMS DISTRIBUTE DIRECTIVE #pragma omp teams distribute // expected-error {{orphaned 'omp teams distribute' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -13190,6 +13753,13 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target' region}} ++a; } +#pragma omp target +#pragma omp teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ++a; + } // TEAMS DISTRIBUTE SIMD DIRECTIVE #pragma omp teams distribute simd // expected-error {{orphaned 'omp teams distribute simd' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -13445,6 +14015,13 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } +#pragma omp target +#pragma omp teams distribute simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } // TEAMS DISTRIBUTE PARALLEL FOR SIMD DIRECTIVE #pragma omp teams distribute parallel for simd // expected-error {{orphaned 'omp teams distribute parallel for simd' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -13700,6 +14277,13 @@ #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } +#pragma omp target +#pragma omp teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } // TEAMS DISTRIBUTE PARALLEL FOR DIRECTIVE #pragma omp teams distribute parallel for // expected-error {{orphaned 'omp teams distribute parallel for' directives are prohibited; perhaps you forget to enclose the directive into a target region?}} @@ -13955,6 +14539,13 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target' region}} ++a; } +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ++a; + } // TARGET TEAMS DIRECTIVE #pragma omp target teams @@ -14152,6 +14743,237 @@ #pragma omp target teams // expected-error {{region cannot be nested inside 'target teams' region}} a++; } +#pragma omp target teams + { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target teams' region}} + for (int i = 0; i < 10; ++i) + ; + } + +// TARGET TEAMS DISTRIBUTE DIRECTIVE +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp distribute parallel for simd // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp distribute parallel for simd' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp for // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp simd // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp for simd // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp sections // OK + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a target teams distribute region}} + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp single // OK + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp master // OK + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp critical // OK + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // OK + { +#pragma omp single + { + bar(); + } + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for simd // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp parallel sections // OK + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp task // OK + { + bar(); + } + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp taskyield // OK + bar(); + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp barrier // OK + bar(); + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp taskwait // OK + bar(); + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp flush // OK + bar(); + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp ordered // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} + bar(); + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp atomic // OK + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target // expected-error {{region cannot be nested inside 'target teams distribute' region}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target parallel // expected-error {{region cannot be nested inside 'target teams distribute' region}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target parallel for // expected-error {{region cannot be nested inside 'target teams distribute' region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target enter data map(to: a) // expected-error {{region cannot be nested inside 'target teams distribute' region}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target exit data map(from: a) // expected-error {{region cannot be nested inside 'target teams distribute' region}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target update to(a) // expected-error {{region cannot be nested inside 'target teams distribute' region}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp distribute simd // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp distribute simd' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{region cannot be nested inside 'target teams distribute' region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp teams distribute' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute simd // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp teams distribute simd' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for simd // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp teams distribute parallel for simd' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'target teams distribute' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target teams // expected-error {{region cannot be nested inside 'target teams distribute' region}} + ++a; + } +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target teams distribute' region}} + for (int i = 0; i < 10; ++i) + ++a; + } return foo(); } Index: cfe/trunk/test/OpenMP/target_teams_distribute_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_ast_print.cpp @@ -0,0 +1,150 @@ +// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s +// expected-no-diagnostics + +#ifndef HEADER +#define HEADER + +void foo() {} + +struct S { + S(): a(0) {} + S(int v) : a(v) {} + int a; + typedef int type; +}; + +template +class S7 : public T { +protected: + T a; + S7() : a(0) {} + +public: + S7(typename T::type v) : a(v) { +#pragma omp target teams distribute private(a) private(this->a) private(T::a) + for (int k = 0; k < a.a; ++k) + ++this->a.a; + } + S7 &operator=(S7 &s) { +#pragma omp target teams distribute private(a) private(this->a) + for (int k = 0; k < s.a.a; ++k) + ++s.a.a; + return *this; + } + + void foo() { + int b, argv, d, c, e, f; +#pragma omp target teams distribute default(none), private(b) firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d) + for (int k = 0; k < a.a; ++k) + ++a.a; + } +}; +// CHECK: #pragma omp target teams distribute private(this->a) private(this->a) private(T::a) +// CHECK: #pragma omp target teams distribute private(this->a) private(this->a) +// CHECK: #pragma omp target teams distribute default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d) +// CHECK: #pragma omp target teams distribute private(this->a) private(this->a) private(this->S::a) + +class S8 : public S7 { + S8() {} + +public: + S8(int v) : S7(v){ +#pragma omp target teams distribute private(a) private(this->a) private(S7::a) + for (int k = 0; k < a.a; ++k) + ++this->a.a; + } + S8 &operator=(S8 &s) { +#pragma omp target teams distribute private(a) private(this->a) + for (int k = 0; k < s.a.a; ++k) + ++s.a.a; + return *this; + } + + void bar() { + int b, argv, d, c, e, f; +#pragma omp target teams distribute default(none), private(b) firstprivate(argv) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d) + for (int k = 0; k < a.a; ++k) + ++a.a; + } +}; +// CHECK: #pragma omp target teams distribute private(this->a) private(this->a) private(this->S7::a) +// CHECK: #pragma omp target teams distribute private(this->a) private(this->a) +// CHECK: #pragma omp target teams distribute default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d) + +template +T tmain(T argc) { + T b = argc, c, d, e, f, g; + static T a; +// CHECK: static T a; +#pragma omp target teams distribute + for (int i=0; i < 2; ++i) + a = 2; +// CHECK: #pragma omp target teams distribute +// CHECK-NEXT: for (int i = 0; i < 2; ++i) +// CHECK-NEXT: a = 2; +#pragma omp target teams distribute private(argc, b), firstprivate(c, d), collapse(2) + for (int i = 0; i < 10; ++i) + for (int j = 0; j < 10; ++j) + foo(); +// CHECK: #pragma omp target teams distribute private(argc,b) firstprivate(c,d) collapse(2) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) +// CHECK-NEXT: for (int j = 0; j < 10; ++j) +// CHECK-NEXT: foo(); + for (int i = 0; i < 10; ++i) + foo(); +// CHECK: for (int i = 0; i < 10; ++i) +// CHECK-NEXT: foo(); +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) + foo(); +// CHECK: #pragma omp target teams distribute +// CHECK-NEXT: for (int i = 0; i < 10; ++i) +// CHECK-NEXT: foo(); +#pragma omp target teams distribute default(none), private(b) firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d) + for (int k = 0; k < 10; ++k) + e += d + argc; +// CHECK: #pragma omp target teams distribute default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d) +// CHECK-NEXT: for (int k = 0; k < 10; ++k) +// CHECK-NEXT: e += d + argc; + return T(); +} + +int main (int argc, char **argv) { + int b = argc, c, d, e, f, g; + static int a; +// CHECK: static int a; +#pragma omp target teams distribute + for (int i=0; i < 2; ++i) + a = 2; +// CHECK: #pragma omp target teams distribute +// CHECK-NEXT: for (int i = 0; i < 2; ++i) +// CHECK-NEXT: a = 2; +#pragma omp target teams distribute private(argc,b),firstprivate(argv, c), collapse(2) + for (int i = 0; i < 10; ++i) + for (int j = 0; j < 10; ++j) + foo(); +// CHECK: #pragma omp target teams distribute private(argc,b) firstprivate(argv,c) collapse(2) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) +// CHECK-NEXT: for (int j = 0; j < 10; ++j) +// CHECK-NEXT: foo(); + for (int i = 0; i < 10; ++i) + foo(); +// CHECK: for (int i = 0; i < 10; ++i) +// CHECK-NEXT: foo(); +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i)foo(); +// CHECK: #pragma omp target teams distribute +// CHECK-NEXT: for (int i = 0; i < 10; ++i) +// CHECK-NEXT: foo(); +#pragma omp target teams distribute default(none), private(b) firstprivate(argc) shared(d) reduction(+:c) reduction(max:e) num_teams(f) thread_limit(d) + for (int k = 0; k < 10; ++k) + e += d + argc; +// CHECK: #pragma omp target teams distribute default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d) +// CHECK-NEXT: for (int k = 0; k < 10; ++k) +// CHECK-NEXT: e += d + argc; + return (0); +} + +#endif Index: cfe/trunk/test/OpenMP/target_teams_distribute_collapse_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_collapse_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_collapse_messages.cpp @@ -0,0 +1,127 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} + +template // expected-note {{declared here}} +T tmain(T argc, S **argv) { //expected-note 2 {{declared here}} +#pragma omp target teams distribute collapse // expected-error {{expected '(' after 'collapse'}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target teams distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = ST; i < N; i++) + + argv[0][i] = argv[0][i] - argv[0][i-ST]; +#pragma omp target teams distribute collapse () // expected-error {{expected expression}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +// expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}} +// expected-error@+2 2 {{expression is not an integral constant expression}} +// expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} +#pragma omp target teams distribute collapse (argc + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +// expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}} +#pragma omp target teams distribute collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target teams distribute collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target teams distribute collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp target teams distribute', but found only 1}} + +// expected-error@+3 2 {{directive '#pragma omp target teams distribute' cannot contain more than one 'collapse' clause}} +// expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}} +// expected-error@+1 2 {{expression is not an integral constant expression}} +#pragma omp target teams distribute collapse (foobool(argc)), collapse (true), collapse (-5) + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target teams distribute collapse (S) // expected-error {{'S' does not refer to a value}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +// expected-error@+1 2 {{expression is not an integral constant expression}} +#pragma omp target teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target teams distribute collapse (1) + for (int i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target teams distribute collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}} + for (T i = ST; i < N; i++) + argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}} + foo(); // expected-error {{expected 2 for loops after '#pragma omp target teams distribute'}} + return argc; +} + +int main(int argc, char **argv) { +#pragma omp target teams distribute collapse // expected-error {{expected '(' after 'collapse'}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target teams distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target teams distribute collapse () // expected-error {{expected expression}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target teams distribute collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} + +#pragma omp target teams distribute collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} expected-note {{as specified in 'collapse' clause}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} + +#pragma omp target teams distribute collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +// expected-error@+3 {{expression is not an integral constant expression}} +// expected-error@+2 2 {{directive '#pragma omp target teams distribute' cannot contain more than one 'collapse' clause}} +// expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}} +#pragma omp target teams distribute collapse (foobool(argc)), collapse (true), collapse (-5) + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target teams distribute collapse (S1) // expected-error {{'S1' does not refer to a value}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +// expected-error@+1 {{expression is not an integral constant expression}} +#pragma omp target teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 4; i < 12; i++) + argv[0][i] = argv[0][i] - argv[0][i-4]; + +// expected-error@+3 {{statement after '#pragma omp target teams distribute' must be a for loop}} +// expected-note@+1 {{in instantiation of function template specialization 'tmain' requested here}} +#pragma omp target teams distribute collapse(collapse(tmain(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} + foo(); + +#pragma omp target teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}} + foo(); // expected-error {{expected 2 for loops after '#pragma omp target teams distribute'}} + +// expected-note@+1 {{in instantiation of function template specialization 'tmain' requested here}} + return tmain(argc, argv); +} + Index: cfe/trunk/test/OpenMP/target_teams_distribute_default_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_default_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_default_messages.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo(); + +int main(int argc, char **argv) { + #pragma omp target teams distribute default // expected-error {{expected '(' after 'default'}} + for (int i=0; i<200; i++) foo(); + #pragma omp target teams distribute default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i=0; i<200; i++) foo(); + #pragma omp target teams distribute default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} + for (int i=0; i<200; i++) foo(); + #pragma omp target teams distribute default (none // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i=0; i<200; i++) foo(); + #pragma omp target teams distribute default (shared), default(shared) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'default' clause}} + for (int i=0; i<200; i++) foo(); + #pragma omp target teams distribute default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} + for (int i=0; i<200; i++) foo(); + + #pragma omp target teams distribute default(none) + for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}} + + return 0; +} Index: cfe/trunk/test/OpenMP/target_teams_distribute_defaultmap_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_defaultmap_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_defaultmap_messages.cpp @@ -0,0 +1,58 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +template +T tmain(T argc, S **argv) { + int i; +#pragma omp target teams distribute defaultmap // expected-error {{expected '(' after 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap ( // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (tofrom // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (tofrom) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (tofrom, // expected-error {{expected ')'}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (scalar: // expected-error {{expected ')'}} expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (tofrom, scalar // expected-error {{expected ')'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + + return argc; +} + +int main(int argc, char **argv) { + int i; +#pragma omp target teams distribute defaultmap // expected-error {{expected '(' after 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap ( // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (tofrom // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (tofrom) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (tofrom, // expected-error {{expected ')'}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (scalar: // expected-error {{expected ')'}} expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute defaultmap (tofrom, scalar // expected-error {{expected ')'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + + return tmain(argc, argv); +} + Index: cfe/trunk/test/OpenMP/target_teams_distribute_depend_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_depend_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_depend_messages.cpp @@ -0,0 +1,90 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - -std=c++11 %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} + +class vector { + public: + int operator[](int index) { return 0; } +}; + +int main(int argc, char **argv, char *env[]) { + vector vec; + typedef float V __attribute__((vector_size(16))); + V a; + auto arr = x; // expected-error {{use of undeclared identifier 'x'}} + int i; + +#pragma omp target teams distribute depend // expected-error {{expected '(' after 'depend'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend ( // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend () // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (argc // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (source : argc) // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : argc)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (out: ) // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (inout : foobool(argc)), depend (in, argc) // expected-error {{expected variable name, array element or array section}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (out :S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend(in : argv[1][1] = '2') // expected-error {{expected variable name, array element or array section}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : vec[1]) // expected-error {{expected variable name, array element or array section}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : argv[0]) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : ) // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : main) // expected-error {{expected variable name, array element or array section}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend(in : a[0]) // expected-error{{expected variable name, array element or array section}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : vec[1:2]) // expected-error {{ value is not an array or pointer}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : argv[ // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : argv[: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : argv[:] // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : argv[argc: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : argv[argc:argc] // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : argv[0:-1]) // expected-error {{section length is evaluated to a negative value -1}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : argv[-1:0]) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend(in:env[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend(in : argv[ : argc][1 : argc - 1]) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute depend(in : arr[0]) + for (i = 0; i < argc; ++i) foo(); + + return 0; +} Index: cfe/trunk/test/OpenMP/target_teams_distribute_device_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_device_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_device_messages.cpp @@ -0,0 +1,40 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} + +int main(int argc, char **argv) { + int i; +#pragma omp target teams distribute device // expected-error {{expected '(' after 'device'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute device ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute device () // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute device (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute device (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute device (argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute device (argc + argc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute device (argc), device (argc+1) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'device' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute device (S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute device (-2) // expected-error {{argument to 'device' clause must be a non-negative integer value}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute device (-10u) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute device (3.14) // expected-error {{expression must have integral or unscoped enumeration type, not 'double'}} + for (i = 0; i < argc; ++i) foo(); + + return 0; +} Index: cfe/trunk/test/OpenMP/target_teams_distribute_dist_schedule_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_dist_schedule_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_dist_schedule_messages.cpp @@ -0,0 +1,84 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} expected-note {{declared here}} + +template +T tmain(T argc) { + T b = argc, c, d, e, f, g; + char ** argv; + static T a; +// CHECK: static T a; + +#pragma omp target teams distribute dist_schedule // expected-error {{expected '(' after 'dist_schedule'}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule ( // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule () // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (static // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (static, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (argc)) // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (static, argc > 0 ? argv[1] : argv[2]) // expected-error2 {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (static), dist_schedule (static, 1) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'dist_schedule' clause}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (static, S1) // expected-error {{'S1' does not refer to a value}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (static, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error3 {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (int i = 0; i < 10; ++i) foo(); + + return T(); +} + +int main(int argc, char **argv) { +#pragma omp target teams distribute dist_schedule // expected-error {{expected '(' after 'dist_schedule'}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule ( // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule () // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (static // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (static, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (argc)) // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (static, argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (static), dist_schedule (static, 1) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'dist_schedule' clause}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (static, S1) // expected-error {{'S1' does not refer to a value}} + for (int i = 0; i < 10; ++i) foo(); + +#pragma omp target teams distribute dist_schedule (static, argv[1]=2) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) foo(); + + return (tmain(argc) + tmain(argv[0][0])); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} +} Index: cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_messages.cpp @@ -0,0 +1,132 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}} +extern S1 a; +class S2 { + mutable int a; + +public: + S2() : a(0) {} + S2(const S2 &s2) : a(s2.a) {} + static float S2s; + static const float S2sc; +}; +const float S2::S2sc = 0; +const S2 b; +const S2 ba[5]; +class S3 { + int a; + S3 &operator=(const S3 &s3); + +public: + S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}} + S3(S3 &s3) : a(s3.a) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}} +}; +const S3 c; +const S3 ca[5]; +extern const int f; +class S4 { + int a; + S4(); + S4(const S4 &s4); +public: + S4(int v):a(v) { } +}; +class S5 { + int a; + S5():a(0) {} + S5(const S5 &s5):a(s5.a) { } +public: + S5(int v):a(v) { } +}; +class S6 { + int a; +public: + S6() : a(0) { } +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} + +int main(int argc, char **argv) { + const int d = 5; + const int da[5] = { 0 }; + S4 e(4); + S5 g(5); + S6 p; + int i; + int &j = i; + +#pragma omp target teams distribute firstprivate // expected-error {{expected '(' after 'firstprivate'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate () // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate (argc) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate (S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{no matching constructor for initialization of 'S3'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate (argv[1]) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate(ba) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target +#pragma omp teams distribute firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate(da) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate(S2::S2s) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate(S2::S2sc) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate(i) + for (j = 0; j < argc; ++j) foo(); + +#pragma omp target teams distribute firstprivate(i) // expected-note {{defined as firstprivate}} + for (i = 0; i < argc; ++i) foo(); // expected-error {{loop iteration variable in the associated loop of 'omp target teams distribute' directive may not be firstprivate, predetermined as private}} + +#pragma omp target teams distribute firstprivate(j) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(argc), firstprivate(argc) // OK + for (i = 0; i < argc; ++i) foo(); + + return 0; +} Index: cfe/trunk/test/OpenMP/target_teams_distribute_if_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_if_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_if_messages.cpp @@ -0,0 +1,150 @@ +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} + +template // expected-note {{declared here}} +int tmain(T argc, S **argv) { + int i; +#pragma omp target teams distribute if // expected-error {{expected '(' after 'if'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if () // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (argc > 0 ? argv[1] : argv[2]) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'if' clause}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (S) // expected-error {{'S' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(argc) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(target : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(target : argc) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(teams: argc) // expected-error {{directive name modifier 'teams' is not allowed for '#pragma omp target teams distribute'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(distribute: argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp target teams distribute'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(argc) if(teams: argc) // expected-note {{previous clause with directive name modifier specified here}} expected-error {{directive name modifier 'teams' is not allowed for '#pragma omp target teams distribute'}} expected-error {{no more 'if' clause is allowed}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(argc) if(distribute: argc) // expected-note {{previous clause with directive name modifier specified here}} expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp target teams distribute'}} expected-error {{no more 'if' clause is allowed}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(distribute: argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target teams distribute'}} expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp target teams distribute'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'if' clause with 'target' name modifier}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(target : argc) if (argc) // expected-note {{previous clause with directive name modifier specified here}} expected-error {{no more 'if' clause is allowed}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(target : argc) if(distribute: argc) if (argc) // expected-note 2 {{previous clause with directive name modifier specified here}} expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp target teams distribute'}} expected-error {{expected one of directive name modifiers}} + for (i = 0; i < argc; ++i) foo(); + + return 0; +} + +int main(int argc, char **argv) { + int i; +#pragma omp target teams distribute if // expected-error {{expected '(' after 'if'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if () // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (argc > 0 ? argv[1] : argv[2]) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'if' clause}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(target : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(teams : argc) // expected-error {{directive name modifier 'teams' is not allowed for '#pragma omp target teams distribute'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp target teams distribute'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(target : argc) if (distribute :argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp target teams distribute'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'if' clause with 'target' name modifier}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(target : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(argc) if(teams: argc) // expected-note {{previous clause with directive name modifier specified here}} expected-error {{directive name modifier 'teams' is not allowed for '#pragma omp target teams distribute'}} expected-error {{no more 'if' clause is allowed}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute if(argc) if(distribute: argc) // expected-note {{previous clause with directive name modifier specified here}} expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp target teams distribute'}} expected-error {{no more 'if' clause is allowed}} + for (i = 0; i < argc; ++i) foo(); + + return tmain(argc, argv); +} Index: cfe/trunk/test/OpenMP/target_teams_distribute_lastprivate_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_lastprivate_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_lastprivate_messages.cpp @@ -0,0 +1,229 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} +extern S1 a; +class S2 { + mutable int a; + +public: + S2() : a(0) {} + S2(S2 &s2) : a(s2.a) {} + const S2 &operator =(const S2&) const; + S2 &operator =(const S2&); + static float S2s; // expected-note {{static data member is predetermined as shared}} + static const float S2sc; +}; +const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}} +const S2 b; +const S2 ba[5]; +class S3 { + int a; + S3 &operator=(const S3 &s3); // expected-note 2 {{implicitly declared private here}} + +public: + S3() : a(0) {} + S3(S3 &s3) : a(s3.a) {} +}; +const S3 c; // expected-note {{global variable is predetermined as shared}} +const S3 ca[5]; // expected-note {{global variable is predetermined as shared}} +extern const int f; // expected-note {{global variable is predetermined as shared}} +class S4 { + int a; + S4(); // expected-note 3 {{implicitly declared private here}} + S4(const S4 &s4); + +public: + S4(int v) : a(v) {} +}; +class S5 { + int a; + S5() : a(0) {} // expected-note {{implicitly declared private here}} + +public: + S5(const S5 &s5) : a(s5.a) {} + S5(int v) : a(v) {} +}; +class S6 { + int a; + S6() : a(0) {} + +public: + S6(const S6 &s6) : a(s6.a) {} + S6(int v) : a(v) {} +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} + +template +int foomain(int argc, char **argv) { + I e(4); + I g(5); + int i; + int &j = i; +#pragma omp target teams distribute lastprivate // expected-error {{expected '(' after 'lastprivate'}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute lastprivate() // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute lastprivate(argc) + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute lastprivate(S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute lastprivate(argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} + for (int k = 0; k < argc; ++k) ++k; + + int v = 0; +#pragma omp target teams distribute lastprivate(i) + for (int k = 0; k < argc; ++k) { + i = k; + v += i; + } + +#pragma omp target teams distribute lastprivate(j) private(i) + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute lastprivate(i) + for (int k = 0; k < argc; ++k) ++k; + + return 0; +} + +void bar(S4 a[2]) { +#pragma omp target teams distribute lastprivate(a) + for (int i = 0; i < 2; ++i) foo(); +} + +namespace A { +double x; +#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} +} +namespace B { +using A::x; +} + +int main(int argc, char **argv) { + const int d = 5; // expected-note {{constant variable is predetermined as shared}} + const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}} + S4 e(4); + S5 g(5); + S3 m; + S6 n(2); + int i; + int &j = i; +#pragma omp target teams distribute lastprivate // expected-error {{expected '(' after 'lastprivate'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate() // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(argc) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(argv[1]) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(2 * 2) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(ba) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(da) // expected-error {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + + int xa; +#pragma omp target teams distribute lastprivate(xa) // OK + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(xa) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(j) + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} + for (i = 0; i < argc; ++i) foo(); + +#pragma omp target teams distribute lastprivate(n) firstprivate(n) // OK + for (i = 0; i < argc; ++i) foo(); + + static int si; +#pragma omp target teams distribute lastprivate(si) // OK + for (i = 0; i < argc; ++i) si = i + 1; + + return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}} +} Index: cfe/trunk/test/OpenMP/target_teams_distribute_loop_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_loop_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_loop_messages.cpp @@ -0,0 +1,620 @@ +// RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s + +class S { + int a; + S() : a(0) {} + +public: + S(int v) : a(v) {} + S(const S &s) : a(s.a) {} +}; + +static int sii; +// expected-note@+1 {{defined as threadprivate or thread local}} +#pragma omp threadprivate(sii) +static int globalii; + +int test_iteration_spaces() { + const int N = 100; + float a[N], b[N], c[N]; + int ii, jj, kk; + float fii; + double dii; +#pragma omp target teams distribute + for (int i = 0; i < 10; i += 1) { + c[i] = a[i] + b[i]; + } +#pragma omp target teams distribute + for (char i = 0; i < 10; i++) { + c[i] = a[i] + b[i]; + } +#pragma omp target teams distribute + for (char i = 0; i < 10; i += '\1') { + c[i] = a[i] + b[i]; + } +#pragma omp target teams distribute + for (long long i = 0; i < 10; i++) { + c[i] = a[i] + b[i]; + } +#pragma omp target teams distribute +// expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'double'}} + for (long long i = 0; i < 10; i += 1.5) { + c[i] = a[i] + b[i]; + } +#pragma omp target teams distribute + for (long long i = 0; i < 'z'; i += 1u) { + c[i] = a[i] + b[i]; + } +#pragma omp target teams distribute +// expected-error@+1 {{variable must be of integer or random access iterator type}} + for (float fi = 0; fi < 10.0; fi++) { + c[(int)fi] = a[(int)fi] + b[(int)fi]; + } +#pragma omp target teams distribute +// expected-error@+1 {{variable must be of integer or random access iterator type}} + for (double fi = 0; fi < 10.0; fi++) { + c[(int)fi] = a[(int)fi] + b[(int)fi]; + } +#pragma omp target teams distribute +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (int &ref = ii; ref < 10; ref++) { + } +#pragma omp target teams distribute +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (int i; i < 10; i++) + c[i] = a[i]; + +#pragma omp target teams distribute +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (int i = 0, j = 0; i < 10; ++i) + c[i] = a[i]; + +#pragma omp target teams distribute +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (; ii < 10; ++ii) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-warning@+2 {{expression result unused}} +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (ii + 1; ii < 10; ++ii) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (c[ii] = 0; ii < 10; ++ii) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// Ok to skip parenthesises. + for (((ii)) = 0; ii < 10; ++ii) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} + for (int i = 0; i; i++) + c[i] = a[i]; + +#pragma omp target teams distribute +// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}} + for (int i = 0; jj < kk; ii++) + c[i] = a[i]; + +#pragma omp target teams distribute +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} + for (int i = 0; !!i; i++) + c[i] = a[i]; + +#pragma omp target teams distribute +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} + for (int i = 0; i != 1; i++) + c[i] = a[i]; + +#pragma omp target teams distribute +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} + for (int i = 0;; i++) + c[i] = a[i]; + +// Ok. +#pragma omp target teams distribute + for (int i = 11; i > 10; i--) + c[i] = a[i]; + +// Ok. +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) + c[i] = a[i]; + +// Ok. +#pragma omp target teams distribute + for (ii = 0; ii < 10; ++ii) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10; ++jj) + c[ii] = a[jj]; + +#pragma omp target teams distribute +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10; ++++ii) + c[ii] = a[ii]; + +// Ok but undefined behavior (in general, cannot check that incr +// is really loop-invariant). +#pragma omp target teams distribute + for (ii = 0; ii < 10; ii = ii + ii) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'float'}} + for (ii = 0; ii < 10; ii = ii + 1.0f) + c[ii] = a[ii]; + +// Ok - step was converted to integer type. +#pragma omp target teams distribute + for (ii = 0; ii < 10; ii = ii + (int)1.1f) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10; jj = ii + 2) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-warning@+2 {{relational comparison result unused}} +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii<10; jj> kk + 2) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10;) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-warning@+2 {{expression result unused}} +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10; !ii) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10; ii ? ++ii : ++jj) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} + for (ii = 0; ii < 10; ii = ii < 10) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} + for (ii = 0; ii < 10; ii = ii + 0) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} + for (ii = 0; ii < 10; ii = ii + (int)(0.8 - 0.45)) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} + for (ii = 0; (ii) < 10; ii -= 25) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} + for (ii = 0; (ii < 10); ii -= 0) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}} + for (ii = 0; ii > 10; (ii += 0)) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} + for (ii = 0; ii < 10; (ii) = (1 - 1) + (ii)) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}} + for ((ii = 0); ii > 10; (ii -= 0)) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} + for (ii = 0; (ii < 10); (ii -= 0)) + c[ii] = a[ii]; + +#pragma omp target teams distribute firstprivate(ii) // expected-note {{defined as firstprivate}} +// expected-error@+1 {{loop iteration variable in the associated loop of 'omp target teams distribute' directive may not be firstprivate, predetermined as private}} + for (ii = 0; ii < 10; ii++) + c[ii] = a[ii]; + +#pragma omp target teams distribute private(ii) +// OK + for (ii = 0; ii < 10; ii++) + c[ii] = a[ii]; + +#pragma omp target teams distribute lastprivate(ii) +// OK + for (ii = 0; ii < 10; ii++) + c[ii] = a[ii]; + +#pragma omp target teams distribute +// expected-error@+1 {{loop iteration variable in the associated loop of 'omp target teams distribute' directive may not be threadprivate or thread local, predetermined as private}} + for (sii = 0; sii < 10; sii++) + c[sii] = a[sii]; + + { +#pragma omp target teams distribute collapse(2) + for (ii = 0; ii < 10; ii += 1) + for (globalii = 0; globalii < 10; globalii += 1) + c[globalii] += a[globalii] + ii; + } + +#pragma omp target teams distribute +// expected-error@+1 {{statement after '#pragma omp target teams distribute' must be a for loop}} + for (auto &item : a) { + item = item + 1; + } + +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}} + for (unsigned i = 9; i < 10; i--) { + c[i] = a[i] + b[i]; + } + + int(*lb)[4] = nullptr; +#pragma omp target teams distribute + for (int(*p)[4] = lb; p < lb + 8; ++p) { + } + +#pragma omp target teams distribute +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (int a{0}; a < 10; ++a) { + } + + return 0; +} + +// Iterators allowed in openmp for-loops. +namespace std { +struct random_access_iterator_tag {}; +template +struct iterator_traits { + typedef typename Iter::difference_type difference_type; + typedef typename Iter::iterator_category iterator_category; +}; +template +typename iterator_traits::difference_type +distance(Iter first, Iter last) { return first - last; } +} +class Iter0 { +public: + Iter0() {} + Iter0(const Iter0 &) {} + Iter0 operator++() { return *this; } + Iter0 operator--() { return *this; } + bool operator<(Iter0 a) { return true; } +}; +// expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}} +// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}} +int operator-(Iter0 a, Iter0 b) { return 0; } +class Iter1 { +public: + Iter1(float f = 0.0f, double d = 0.0) {} + Iter1(const Iter1 &) {} + Iter1 operator++() { return *this; } + Iter1 operator--() { return *this; } + bool operator<(Iter1 a) { return true; } + bool operator>=(Iter1 a) { return false; } +}; +class GoodIter { +public: + GoodIter() {} + GoodIter(const GoodIter &) {} + GoodIter(int fst, int snd) {} + GoodIter &operator=(const GoodIter &that) { return *this; } + GoodIter &operator=(const Iter0 &that) { return *this; } + GoodIter &operator+=(int x) { return *this; } + explicit GoodIter(void *) {} + GoodIter operator++() { return *this; } + GoodIter operator--() { return *this; } + bool operator!() { return true; } + bool operator<(GoodIter a) { return true; } + bool operator<=(GoodIter a) { return true; } + bool operator>=(GoodIter a) { return false; } + typedef int difference_type; + typedef std::random_access_iterator_tag iterator_category; +}; +// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}} +// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}} +int operator-(GoodIter a, GoodIter b) { return 0; } +// expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}} +GoodIter operator-(GoodIter a) { return a; } +// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}} +// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}} +GoodIter operator-(GoodIter a, int v) { return GoodIter(); } +// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}} +GoodIter operator+(GoodIter a, int v) { return GoodIter(); } +// expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}} +// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}} +GoodIter operator-(int v, GoodIter a) { return GoodIter(); } +// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}} +GoodIter operator+(int v, GoodIter a) { return GoodIter(); } + +int test_with_random_access_iterator() { + GoodIter begin, end; + Iter0 begin0, end0; +#pragma omp target teams distribute + for (GoodIter I = begin; I < end; ++I) + ++I; +#pragma omp target teams distribute +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (GoodIter &I = begin; I < end; ++I) + ++I; +#pragma omp target teams distribute + for (GoodIter I = begin; I >= end; --I) + ++I; +#pragma omp target teams distribute +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (GoodIter I(begin); I < end; ++I) + ++I; +#pragma omp target teams distribute +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (GoodIter I(nullptr); I < end; ++I) + ++I; +#pragma omp target teams distribute +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (GoodIter I(0); I < end; ++I) + ++I; +#pragma omp target teams distribute +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (GoodIter I(1, 2); I < end; ++I) + ++I; +#pragma omp target teams distribute + for (begin = GoodIter(0); begin < end; ++begin) + ++begin; +#pragma omp target teams distribute +// expected-error@+2 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}} +// expected-error@+1 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}} + for (begin = begin0; begin < end; ++begin) + ++begin; +#pragma omp target teams distribute +// expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (++begin; begin < end; ++begin) + ++begin; +#pragma omp target teams distribute + for (begin = end; begin < end; ++begin) + ++begin; +#pragma omp target teams distribute +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} + for (GoodIter I = begin; I - I; ++I) + ++I; +#pragma omp target teams distribute +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} + for (GoodIter I = begin; begin < end; ++I) + ++I; +#pragma omp target teams distribute +// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} + for (GoodIter I = begin; !I; ++I) + ++I; +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} + for (GoodIter I = begin; I >= end; I = I + 1) + ++I; +#pragma omp target teams distribute + for (GoodIter I = begin; I >= end; I = I - 1) + ++I; +#pragma omp target teams distribute +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}} + for (GoodIter I = begin; I >= end; I = -I) + ++I; +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} + for (GoodIter I = begin; I >= end; I = 2 + I) + ++I; +#pragma omp target teams distribute +// expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}} + for (GoodIter I = begin; I >= end; I = 2 - I) + ++I; +#pragma omp target teams distribute +// expected-error@+1 {{invalid operands to binary expression ('Iter0' and 'int')}} + for (Iter0 I = begin0; I < end0; ++I) + ++I; +#pragma omp target teams distribute +// Initializer is constructor without params. +// expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}} +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (Iter0 I; I < end0; ++I) + ++I; + Iter1 begin1, end1; +#pragma omp target teams distribute +// expected-error@+2 {{invalid operands to binary expression ('Iter1' and 'Iter1')}} +// expected-error@+1 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}} + for (Iter1 I = begin1; I < end1; ++I) + ++I; +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} + for (Iter1 I = begin1; I >= end1; ++I) + ++I; +#pragma omp target teams distribute +// expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'float')}} +// expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}} +// Initializer is constructor with all default params. +// expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} + for (Iter1 I; I < end1; ++I) { + } + return 0; +} + +template +class TC { +public: + int dotest_lt(IT begin, IT end) { +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}} + for (IT I = begin; I < end; I = I + ST) { + ++I; + } +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be positive due to this condition}} +// expected-error@+1 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}} + for (IT I = begin; I <= end; I += ST) { + ++I; + } +#pragma omp target teams distribute + for (IT I = begin; I < end; ++I) { + ++I; + } + } + + static IT step() { + return IT(ST); + } +}; +template +int dotest_gt(IT begin, IT end) { +#pragma omp target teams distribute +// expected-note@+2 2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} + for (IT I = begin; I >= end; I = I + ST) { + ++I; + } +#pragma omp target teams distribute +// expected-note@+2 2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} + for (IT I = begin; I >= end; I += ST) { + ++I; + } + +#pragma omp target teams distribute +// expected-note@+2 {{loop step is expected to be negative due to this condition}} +// expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} + for (IT I = begin; I >= end; ++I) { + ++I; + } + +#pragma omp target teams distribute + for (IT I = begin; I < end; I += TC::step()) { + ++I; + } +} + +void test_with_template() { + GoodIter begin, end; + TC t1; + TC t2; + t1.dotest_lt(begin, end); + t2.dotest_lt(begin, end); // expected-note {{in instantiation of member function 'TC::dotest_lt' requested here}} + dotest_gt(begin, end); // expected-note {{in instantiation of function template specialization 'dotest_gt' requested here}} + dotest_gt(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt' requested here}} +} + +void test_loop_break() { + const int N = 100; + float a[N], b[N], c[N]; +#pragma omp target teams distribute + for (int i = 0; i < 10; i++) { + c[i] = a[i] + b[i]; + for (int j = 0; j < 10; ++j) { + if (a[i] > b[j]) + break; // OK in nested loop + } + switch (i) { + case 1: + b[i]++; + break; + default: + break; + } + if (c[i] > 10) + break; // expected-error {{'break' statement cannot be used in OpenMP for loop}} + + if (c[i] > 11) + break; // expected-error {{'break' statement cannot be used in OpenMP for loop}} + } + +#pragma omp target teams distribute + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + c[i] = a[i] + b[i]; + if (c[i] > 10) { + if (c[i] < 20) { + break; // OK + } + } + } + } +} + +void test_loop_eh() { + const int N = 100; + float a[N], b[N], c[N]; +#pragma omp target teams distribute + for (int i = 0; i < 10; i++) { + c[i] = a[i] + b[i]; + try { // OK + for (int j = 0; j < 10; ++j) { + if (a[i] > b[j]) + throw a[i]; // OK + } + throw a[i]; // OK + } catch (float f) { + if (f > 0.1) + throw a[i]; // OK + return; // expected-error {{cannot return from OpenMP region}} + } + switch (i) { + case 1: + b[i]++; + break; + default: + break; + } + for (int j = 0; j < 10; j++) { + if (c[i] > 10) + throw c[i]; // OK + } + } + if (c[9] > 10) + throw c[9]; // OK + +#pragma omp target teams distribute + for (int i = 0; i < 10; ++i) { + struct S { + void g() { throw 0; } + }; + } +} + +void test_loop_firstprivate_lastprivate() { + S s(4); +#pragma omp target teams distribute lastprivate(s) firstprivate(s) + for (int i = 0; i < 16; ++i) + ; +} + +void test_ordered() { +#pragma omp target teams distribute ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp target teams distribute'}} + for (int i = 0; i < 16; ++i) + ; +} + Index: cfe/trunk/test/OpenMP/target_teams_distribute_map_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_map_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_map_messages.cpp @@ -0,0 +1,281 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note 2 {{declared here}} +extern S1 a; +class S2 { + mutable int a; +public: + S2():a(0) { } + S2(S2 &s2):a(s2.a) { } + static float S2s; // expected-note 4 {{mappable type cannot contain static members}} + static const float S2sc; // expected-note 4 {{mappable type cannot contain static members}} +}; +const float S2::S2sc = 0; +const S2 b; +const S2 ba[5]; +class S3 { + int a; +public: + S3():a(0) { } + S3(S3 &s3):a(s3.a) { } +}; +const S3 c; +const S3 ca[5]; +extern const int f; +class S4 { + int a; + S4(); + S4(const S4 &s4); +public: + S4(int v):a(v) { } +}; +class S5 { + int a; + S5():a(0) {} + S5(const S5 &s5):a(s5.a) { } +public: + S5(int v):a(v) { } +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} + +typedef int from; + +template // expected-note {{declared here}} +T tmain(T argc) { + const T d = 5; + const T da[5] = { 0 }; + S4 e(4); + S5 g(5); + T i, t[20]; + T &j = i; + T *k = &j; + T x; + T y; + T to, tofrom, always; + const T (&l)[5] = da; + + +#pragma omp target teams distribute map // expected-error {{expected '(' after 'map'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map() // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to:) // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(l[-1:]) // expected-error 2 {{array section must be a subset of the original array}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(l[:-1]) // expected-error 2 {{section length is evaluated to a negative value -1}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(tofrom: t[:I]) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(T: a) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} expected-error {{incomplete type 'S1' where a complete type is required}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(T) // expected-error {{'T' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(S2::S2s) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(S2::S2sc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to: x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to: to) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to, x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(tofrom: argc > 0 ? x : y) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(argc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(ba) // expected-error 2 {{type 'S2' is not mappable to target}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(ca) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(da) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(S2::S2s) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(S2::S2sc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(e, g) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(k), map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(k), map(k[:5]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} expected-note 2 {{used here}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(da) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(da[:4]) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target data map(k, j, l) // expected-note 2 {{used here}} +#pragma omp target teams distribute map(k[:4]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(j) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}} +{ +#pragma omp target teams distribute map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(j) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(l) + for (i = 0; i < argc; ++i) foo(); +} + +#pragma omp target teams distribute map(always, tofrom: x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(always: x) // expected-error {{missing map type}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always'}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(always, tofrom: always, tofrom, x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} + for (i = 0; i < argc; ++i) foo(); + + return 0; +} + +int main(int argc, char **argv) { + const int d = 5; + const int da[5] = { 0 }; + S4 e(4); + S5 g(5); + int i; + int &j = i; + int *k = &j; + int x; + int y; + int to, tofrom, always; + const int (&l)[5] = da; + +#pragma omp target teams distribute map // expected-error {{expected '(' after 'map'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map() // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to:) // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(l[-1:]) // expected-error {{array section must be a subset of the original array}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(l[:-1]) // expected-error {{section length is evaluated to a negative value -1}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to: x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to: to) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to, x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(tofrom: argc > 0 ? argv[1] : argv[2]) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(argc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(argv[1]) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(ba) // expected-error 2 {{type 'S2' is not mappable to target}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(ca) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(da) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(S2::S2s) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(S2::S2sc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(e, g) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(k), map(k[:5]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(da) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(da[:4]) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target data map(k, j, l) // expected-note {{used here}} +#pragma omp target teams distribute map(k[:4]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(j) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}} +{ +#pragma omp target teams distribute map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(j) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(l) + for (i = 0; i < argc; ++i) foo(); +} + +#pragma omp target teams distribute map(always, tofrom: x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(always: x) // expected-error {{missing map type}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always'}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(always, tofrom: always, tofrom, x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} + for (i = 0; i < argc; ++i) foo(); + + return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} +} + Index: cfe/trunk/test/OpenMP/target_teams_distribute_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_messages.cpp @@ -0,0 +1,92 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s + +void foo() { +} + +static int pvt; +#pragma omp threadprivate(pvt) + +#pragma omp target teams distribute // expected-error {{unexpected OpenMP directive '#pragma omp target teams distribute'}} + +int main(int argc, char **argv) { +#pragma omp target teams distribute { // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target teams distribute ( // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target teams distribute[ // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target teams distribute] // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target teams distribute) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target teams distribute } // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target teams distribute + for (int i = 0; i < argc; ++i) + foo(); +// expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} +#pragma omp target teams distribute unknown() + for (int i = 0; i < argc; ++i) + foo(); +L1: + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target teams distribute + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target teams distribute + for (int i = 0; i < argc; ++i) { + goto L1; // expected-error {{use of undeclared label 'L1'}} + argc++; + } + + for (int i = 0; i < 10; ++i) { + switch (argc) { + case (0): +#pragma omp target teams distribute + for (int i = 0; i < argc; ++i) { + foo(); + break; // expected-error {{'break' statement cannot be used in OpenMP for loop}} + continue; + } + default: + break; + } + } +#pragma omp target teams distribute default(none) + for (int i = 0; i < 10; ++i) + ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}} + + goto L2; // expected-error {{use of undeclared label 'L2'}} +#pragma omp target teams distribute + for (int i = 0; i < argc; ++i) + L2: + foo(); +#pragma omp target teams distribute + for (int i = 0; i < argc; ++i) { + return 1; // expected-error {{cannot return from OpenMP region}} + } + + [[]] // expected-error {{an attribute list cannot appear here}} +#pragma omp target teams distribute + for (int n = 0; n < 100; ++n) { + } + +#pragma omp target teams distribute copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp target teams distribute'}} + for (int n = 0; n < 100; ++n) {} + + return 0; +} + +void test_ordered() { +#pragma omp target teams distribute ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp target teams distribute'}} + for (int i = 0; i < 16; ++i) + ; +} + Index: cfe/trunk/test/OpenMP/target_teams_distribute_misc_messages.c =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_misc_messages.c +++ cfe/trunk/test/OpenMP/target_teams_distribute_misc_messages.c @@ -0,0 +1,312 @@ +// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s + +// expected-error@+1 {{unexpected OpenMP directive '#pragma omp target teams distribute'}} +#pragma omp target teams distribute + +// expected-error@+1 {{unexpected OpenMP directive '#pragma omp target teams distribute'}} +#pragma omp target teams distribute foo + +void test_no_clause() { + int i; +#pragma omp target teams distribute + for (i = 0; i < 16; ++i) + ; + +// expected-error@+2 {{statement after '#pragma omp target teams distribute' must be a for loop}} +#pragma omp target teams distribute + ++i; +} + +void test_branch_protected_scope() { + int i = 0; +L1: + ++i; + + int x[24]; + +#pragma omp target teams distribute + for (i = 0; i < 16; ++i) { + if (i == 5) + goto L1; // expected-error {{use of undeclared label 'L1'}} + else if (i == 6) + return; // expected-error {{cannot return from OpenMP region}} + else if (i == 7) + goto L2; + else if (i == 8) { + L2: + x[i]++; + } + } + + if (x[0] == 0) + goto L2; // expected-error {{use of undeclared label 'L2'}} + else if (x[1] == 1) + goto L1; +} + +void test_invalid_clause() { + int i; +// expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} +#pragma omp target teams distribute foo bar + for (i = 0; i < 16; ++i) + ; +} + +void test_non_identifiers() { + int i, x; + +// expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} +#pragma omp target teams distribute; + for (i = 0; i < 16; ++i) + ; + +// expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} +#pragma omp target teams distribute private(x); + for (i = 0; i < 16; ++i) + ; + +// expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} +#pragma omp target teams distribute, private(x); + for (i = 0; i < 16; ++i) + ; +} + +extern int foo(); + +void test_collapse() { + int i; +// expected-error@+1 {{expected '('}} +#pragma omp target teams distribute collapse + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} +#pragma omp target teams distribute collapse( + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target teams distribute collapse() + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} +#pragma omp target teams distribute collapse(, + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} +#pragma omp target teams distribute collapse(, ) + for (i = 0; i < 16; ++i) + ; +// expected-warning@+2 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} +// expected-error@+1 {{expected '('}} +#pragma omp target teams distribute collapse 4) + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} +#pragma omp target teams distribute collapse(4 + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} +#pragma omp target teams distribute collapse(4, + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} +#pragma omp target teams distribute collapse(4, ) + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} +// expected-note@+1 {{as specified in 'collapse' clause}} +#pragma omp target teams distribute collapse(4) + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} +#pragma omp target teams distribute collapse(4 4) + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} +#pragma omp target teams distribute collapse(4, , 4) + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} +#pragma omp target teams distribute collapse(4) + for (int i1 = 0; i1 < 16; ++i1) + for (int i2 = 0; i2 < 16; ++i2) + for (int i3 = 0; i3 < 16; ++i3) + for (int i4 = 0; i4 < 16; ++i4) + foo(); +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} +#pragma omp target teams distribute collapse(4, 8) + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} +// expected-error@+1 {{expression is not an integer constant expression}} +#pragma omp target teams distribute collapse(2.5) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expression is not an integer constant expression}} +#pragma omp target teams distribute collapse(foo()) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} +#pragma omp target teams distribute collapse(-5) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} +#pragma omp target teams distribute collapse(0) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} +#pragma omp target teams distribute collapse(5 - 5) + for (i = 0; i < 16; ++i) + ; +// expected-error@+3 {{loop iteration variable in the associated loop of 'omp target teams distribute' directive may not be firstprivate, predetermined as private}} +// expected-note@+1 {{defined as firstprivate}} +#pragma omp target teams distribute collapse(2) firstprivate(i) + for (i = 0; i < 16; ++i) + for (int j = 0; j < 16; ++j) +#pragma omp parallel for reduction(+ : i, j) + for (int k = 0; k < 16; ++k) + i += j; +} + +void test_private() { + int i; +// expected-error@+2 {{expected expression}} +// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} +#pragma omp target teams distribute private( + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} +// expected-error@+1 2 {{expected expression}} +#pragma omp target teams distribute private(, + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 2 {{expected expression}} +#pragma omp target teams distribute private(, ) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target teams distribute private() + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target teams distribute private(int) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected variable name}} +#pragma omp target teams distribute private(0) + for (i = 0; i < 16; ++i) + ; + + int x, y, z; +#pragma omp target teams distribute private(x) + for (i = 0; i < 16; ++i) + ; +#pragma omp target teams distribute private(x, y) + for (i = 0; i < 16; ++i) + ; +#pragma omp target teams distribute private(x, y, z) + for (i = 0; i < 16; ++i) { + x = y * i + z; + } +} + +void test_lastprivate() { + int i; +// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} +// expected-error@+1 {{expected expression}} +#pragma omp target teams distribute lastprivate( + for (i = 0; i < 16; ++i) + ; + +// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} +// expected-error@+1 2 {{expected expression}} +#pragma omp target teams distribute lastprivate(, + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 2 {{expected expression}} +#pragma omp target teams distribute lastprivate(, ) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target teams distribute lastprivate() + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target teams distribute lastprivate(int) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected variable name}} +#pragma omp target teams distribute lastprivate(0) + for (i = 0; i < 16; ++i) + ; + + int x, y, z; +#pragma omp target teams distribute lastprivate(x) + for (i = 0; i < 16; ++i) + ; +#pragma omp target teams distribute lastprivate(x, y) + for (i = 0; i < 16; ++i) + ; +#pragma omp target teams distribute lastprivate(x, y, z) + for (i = 0; i < 16; ++i) + ; +} + +void test_firstprivate() { + int i; +// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} +// expected-error@+1 {{expected expression}} +#pragma omp target teams distribute firstprivate( + for (i = 0; i < 16; ++i) + ; + +// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} +// expected-error@+1 2 {{expected expression}} +#pragma omp target teams distribute firstprivate(, + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 2 {{expected expression}} +#pragma omp target teams distribute firstprivate(, ) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target teams distribute firstprivate() + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target teams distribute firstprivate(int) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected variable name}} +#pragma omp target teams distribute firstprivate(0) + for (i = 0; i < 16; ++i) + ; + + int x, y, z; +#pragma omp target teams distribute lastprivate(x) firstprivate(x) + for (i = 0; i < 16; ++i) + ; +#pragma omp target teams distribute lastprivate(x, y) firstprivate(x, y) + for (i = 0; i < 16; ++i) + ; +#pragma omp target teams distribute lastprivate(x, y, z) firstprivate(x, y, z) + for (i = 0; i < 16; ++i) + ; +} + +void test_loop_messages() { + float a[100], b[100], c[100]; +// expected-error@+2 {{variable must be of integer or pointer type}} +#pragma omp target teams distribute + for (float fi = 0; fi < 10.0; fi++) { + c[(int)fi] = a[(int)fi] + b[(int)fi]; + } +// expected-error@+2 {{variable must be of integer or pointer type}} +#pragma omp target teams distribute + for (double fi = 0; fi < 10.0; fi++) { + c[(int)fi] = a[(int)fi] + b[(int)fi]; + } +} + Index: cfe/trunk/test/OpenMP/target_teams_distribute_nowait_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_nowait_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_nowait_messages.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -verify -fopenmp -o - %s + +void foo() { +} + +int main(int argc, char **argv) { + int i; +#pragma omp target teams distribute nowait( // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute nowait (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute nowait device (-10u) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute nowait (3.14) device (-10u) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (i = 0; i < argc; ++i) foo(); + + return 0; +} Index: cfe/trunk/test/OpenMP/target_teams_distribute_num_teams_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_num_teams_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_num_teams_messages.cpp @@ -0,0 +1,85 @@ +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 -ferror-limit 100 -o - %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note 2 {{declared here}} + +template // expected-note {{declared here}} +T tmain(T argc) { + char **a; +#pragma omp target teams distribute num_teams(C) + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams(T) // expected-error {{'T' does not refer to a value}} + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams // expected-error {{expected '(' after 'num_teams'}} + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams() // expected-error {{expected expression}} + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams(argc)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams(argc > 0 ? a[1] : a[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams(argc + argc) + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams(argc), num_teams (argc+1) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'num_teams' clause}} + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams(S1) // expected-error {{'S1' does not refer to a value}} + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams(-2) // expected-error {{argument to 'num_teams' clause must be a strictly positive integer value}} + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams(-10u) + for (int i=0; i<100; i++) foo(); +#pragma omp target teams distribute num_teams(3.14) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'double'}} + for (int i=0; i<100; i++) foo(); + + return 0; +} + +int main(int argc, char **argv) { +#pragma omp target teams distribute num_teams // expected-error {{expected '(' after 'num_teams'}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target teams distribute num_teams ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target teams distribute num_teams () // expected-error {{expected expression}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target teams distribute num_teams (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target teams distribute num_teams (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target teams distribute num_teams (argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target teams distribute num_teams (argc + argc) + for (int i=0; i<100; i++) foo(); + +#pragma omp target teams distribute num_teams (argc), num_teams (argc+1) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'num_teams' clause}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target teams distribute num_teams (S1) // expected-error {{'S1' does not refer to a value}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target teams distribute num_teams (-2) // expected-error {{argument to 'num_teams' clause must be a strictly positive integer value}} + for (int i=0; i<100; i++) foo(); + +#pragma omp target teams distribute num_teams (-10u) + for (int i=0; i<100; i++) foo(); + +#pragma omp target teams distribute num_teams (3.14) // expected-error {{expression must have integral or unscoped enumeration type, not 'double'}} + for (int i=0; i<100; i++) foo(); + + return tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} +} Index: cfe/trunk/test/OpenMP/target_teams_distribute_private_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_private_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_private_messages.cpp @@ -0,0 +1,111 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} expected-note {{forward declaration of 'S1'}} +extern S1 a; +class S2 { + mutable int a; +public: + S2():a(0) { } + static float S2s; // expected-note {{predetermined as shared}} +}; +const S2 b; +const S2 ba[5]; +class S3 { + int a; +public: + S3():a(0) { } +}; +const S3 c; // expected-note {{predetermined as shared}} +const S3 ca[5]; // expected-note {{predetermined as shared}} +extern const int f; // expected-note {{predetermined as shared}} +class S4 { + int a; + S4(); // expected-note {{implicitly declared private here}} +public: + S4(int v):a(v) { } +}; +class S5 { + int a; + S5():a(0) {} // expected-note {{implicitly declared private here}} +public: + S5(int v):a(v) { } +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} + + +int main(int argc, char **argv) { + const int d = 5; // expected-note {{predetermined as shared}} + const int da[5] = { 0 }; // expected-note {{predetermined as shared}} + S4 e(4); + S5 g(5); + int i; + int &j = i; + +#pragma omp target teams distribute private // expected-error {{expected '(' after 'private'}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private () // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private (argc) + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private (S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private (a, b, c, d, f) // expected-error {{private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private (argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private(ba) + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private(ca) // expected-error {{shared variable cannot be private}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private(da) // expected-error {{shared variable cannot be private}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private(S2::S2s) // expected-error {{shared variable cannot be private}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private(h) // expected-error {{threadprivate or thread local variable cannot be private}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute shared(i) + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute firstprivate(i), private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}} + for (int k = 0; k < argc; ++k) ++k; + +#pragma omp target teams distribute private(j) + for (int k = 0; k < argc; ++k) ++k; + + return 0; +} Index: cfe/trunk/test/OpenMP/target_teams_distribute_reduction_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_reduction_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_reduction_messages.cpp @@ -0,0 +1,246 @@ +// RUN: %clang_cc1 -verify -fopenmp %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +void foobar(int &ref) { +#pragma omp target teams distribute reduction(+:ref) + for (int j=0; j<100; j++) foo(); +} + +struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}} +extern S1 a; +class S2 { + mutable int a; + S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}} + +public: + S2() : a(0) {} + S2(S2 &s2) : a(s2.a) {} + static float S2s; // expected-note 2 {{static data member is predetermined as shared}} + static const float S2sc; +}; +const float S2::S2sc = 0; // expected-note 2 {{'S2sc' defined here}} +S2 b; // expected-note 3 {{'b' defined here}} +const S2 ba[5]; // expected-note 2 {{'ba' defined here}} +class S3 { + int a; + +public: + int b; + S3() : a(0) {} + S3(const S3 &s3) : a(s3.a) {} + S3 operator+(const S3 &arg1) { return arg1; } +}; +int operator+(const S3 &arg1, const S3 &arg2) { return 5; } +S3 c; // expected-note 3 {{'c' defined here}} +const S3 ca[5]; // expected-note 2 {{'ca' defined here}} +extern const int f; // expected-note 4 {{'f' declared here}} +class S4 { + int a; + S4(); // expected-note {{implicitly declared private here}} + S4(const S4 &s4); + S4 &operator+(const S4 &arg) { return (*this); } + +public: + S4(int v) : a(v) {} +}; +S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; } +class S5 { + int a; + S5() : a(0) {} // expected-note {{implicitly declared private here}} + S5(const S5 &s5) : a(s5.a) {} + S5 &operator+(const S5 &arg); + +public: + S5(int v) : a(v) {} +}; +class S6 { // expected-note 3 {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'int' to 'const S6' for 1st argument}} +#if __cplusplus >= 201103L // C++11 or later +// expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}} +#endif + int a; + +public: + S6() : a(6) {} + operator int() { return 6; } +} o; + +S3 h, k; +#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} + +template // expected-note {{declared here}} +T tmain(T argc) { + const T d = T(); // expected-note 4 {{'d' defined here}} + const T da[5] = {T()}; // expected-note 2 {{'da' defined here}} + T qa[5] = {T()}; + T i; + T &j = i; // expected-note 4 {{'j' defined here}} + S3 &p = k; // expected-note 2 {{'p' defined here}} + const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}} + T &q = qa[(int)i]; // expected-note 2 {{'q' defined here}} + T fl; +#pragma omp target teams distribute reduction // expected-error {{expected '(' after 'reduction'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(&& : argc) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(^ : T) // expected-error {{'T' does not refer to a value}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 3 {{const-qualified list item cannot be reduction}} expected-error 2 {{'operator+' is a private member of 'S2'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 4 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(max : h.b) // expected-error {{expected variable name, array element or array section}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : o) // expected-error 2 {{no viable overloaded '='}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int j=0; j<100; j++) foo(); +#pragma omp parallel private(k) +#pragma omp target teams distribute reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp parallel shared(i) +#pragma omp parallel reduction(min : i) +#pragma omp target teams distribute reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : fl) + for (int j=0; j<100; j++) foo(); + + return T(); +} + +namespace A { +double x; +#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} +} +namespace B { +using A::x; +} + +int main(int argc, char **argv) { + const int d = 5; // expected-note 2 {{'d' defined here}} + const int da[5] = {0}; // expected-note {{'da' defined here}} + int qa[5] = {0}; + S4 e(4); + S5 g(5); + int i; + int &j = i; // expected-note 2 {{'j' defined here}} + S3 &p = k; // expected-note 2 {{'p' defined here}} + const int &r = da[i]; // expected-note {{'r' defined here}} + int &q = qa[i]; // expected-note {{'q' defined here}} + float fl; +#pragma omp target teams distribute reduction // expected-error {{expected '(' after 'reduction'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(~ : argc) // expected-error {{expected unqualified-id}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(&& : argc) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(^ : S1) // expected-error {{'S1' does not refer to a value}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{const-qualified list item cannot be reduction}} expected-error {{'operator+' is a private member of 'S2'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(max : h.b) // expected-error {{expected variable name, array element or array section}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(& : e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{invalid operands to binary expression ('S4' and 'S4')}} expected-error {{calling a private constructor of class 'S5'}} expected-error {{invalid operands to binary expression ('S5' and 'S5')}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : o) // expected-error {{no viable overloaded '='}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int j=0; j<100; j++) foo(); +#pragma omp parallel private(k) +#pragma omp target teams distribute reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}} + for (int j=0; j<100; j++) foo(); +#pragma omp parallel shared(i) +#pragma omp parallel reduction(min : i) +#pragma omp target teams distribute reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute reduction(+ : fl) + for (int j=0; j<100; j++) foo(); + static int m; +#pragma omp target teams distribute reduction(+ : m) // OK + for (int j=0; j<100; j++) foo(); + + return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} +} Index: cfe/trunk/test/OpenMP/target_teams_distribute_shared_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_teams_distribute_shared_messages.cpp +++ cfe/trunk/test/OpenMP/target_teams_distribute_shared_messages.cpp @@ -0,0 +1,110 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} +extern S1 a; +class S2 { + mutable int a; +public: + S2():a(0) { } + S2(S2 &s2):a(s2.a) { } +}; +const S2 b; +const S2 ba[5]; +class S3 { + int a; +public: + S3():a(0) { } + S3(S3 &s3):a(s3.a) { } +}; +const S3 c; +const S3 ca[5]; +extern const int f; +class S4 { + int a; + S4(); + S4(const S4 &s4); +public: + S4(int v):a(v) { } +}; +class S5 { + int a; + S5():a(0) {} + S5(const S5 &s5):a(s5.a) { } +public: + S5(int v):a(v) { } +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} + +namespace A { +double x; +#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} +} +namespace B { +using A::x; +} + +int main(int argc, char **argv) { + const int d = 5; + const int da[5] = { 0 }; + S4 e(4); + S5 g(5); + int i; + int &j = i; +#pragma omp target teams distribute shared // expected-error {{expected '(' after 'shared'}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared () // expected-error {{expected expression}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared (argc) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared (S1) // expected-error {{'S1' does not refer to a value}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared (a, b, c, d, f) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared (argv[1]) // expected-error {{expected variable name}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared(ba) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared(ca) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared(da) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared(e, g) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}} + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute private(i) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared(i) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared(j) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute firstprivate(i) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared(i) + for (int j=0; j<100; j++) foo(); +#pragma omp target teams distribute shared(j) + for (int j=0; j<100; j++) foo(); + + return 0; +} Index: cfe/trunk/tools/libclang/CIndex.cpp =================================================================== --- cfe/trunk/tools/libclang/CIndex.cpp +++ cfe/trunk/tools/libclang/CIndex.cpp @@ -2009,6 +2009,8 @@ void VisitOMPTeamsDistributeParallelForDirective( const OMPTeamsDistributeParallelForDirective *D); void VisitOMPTargetTeamsDirective(const OMPTargetTeamsDirective *D); + void VisitOMPTargetTeamsDistributeDirective( + const OMPTargetTeamsDistributeDirective *D); private: void AddDeclarationNameInfo(const Stmt *S); @@ -2818,6 +2820,11 @@ VisitOMPExecutableDirective(D); } +void EnqueueVisitor::VisitOMPTargetTeamsDistributeDirective( + const OMPTargetTeamsDistributeDirective *D) { + VisitOMPLoopDirective(D); +} + void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, const Stmt *S) { EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S); } @@ -4982,6 +4989,8 @@ return cxstring::createRef("OMPTeamsDistributeParallelForDirective"); case CXCursor_OMPTargetTeamsDirective: return cxstring::createRef("OMPTargetTeamsDirective"); + case CXCursor_OMPTargetTeamsDistributeDirective: + return cxstring::createRef("OMPTargetTeamsDistributeDirective"); case CXCursor_OverloadCandidate: return cxstring::createRef("OverloadCandidate"); case CXCursor_TypeAliasTemplateDecl: Index: cfe/trunk/tools/libclang/CXCursor.cpp =================================================================== --- cfe/trunk/tools/libclang/CXCursor.cpp +++ cfe/trunk/tools/libclang/CXCursor.cpp @@ -670,6 +670,9 @@ case Stmt::OMPTargetTeamsDirectiveClass: K = CXCursor_OMPTargetTeamsDirective; break; + case Stmt::OMPTargetTeamsDistributeDirectiveClass: + K = CXCursor_OMPTargetTeamsDistributeDirective; + break; } CXCursor C = { K, 0, { Parent, S, TU } };