Index: cfe/trunk/include/clang-c/Index.h =================================================================== --- cfe/trunk/include/clang-c/Index.h +++ cfe/trunk/include/clang-c/Index.h @@ -2325,7 +2325,11 @@ */ CXCursor_OMPTargetParallelForSimdDirective = 269, - CXCursor_LastStmt = CXCursor_OMPTargetParallelForSimdDirective, + /** \brief OpenMP target simd directive. + */ + CXCursor_OMPTargetSimdDirective = 270, + + CXCursor_LastStmt = CXCursor_OMPTargetSimdDirective, /** * \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 @@ -2574,6 +2574,9 @@ DEF_TRAVERSE_STMT(OMPTargetParallelForSimdDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPTargetSimdDirective, + { 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 @@ -773,7 +773,8 @@ T->getStmtClass() == OMPDistributeParallelForDirectiveClass || T->getStmtClass() == OMPDistributeParallelForSimdDirectiveClass || T->getStmtClass() == OMPDistributeSimdDirectiveClass || - T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass; + T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass || + T->getStmtClass() == OMPTargetSimdDirectiveClass; } }; @@ -3090,6 +3091,73 @@ } }; +/// This represents '#pragma omp target simd' directive. +/// +/// \code +/// #pragma omp target simd private(a) map(b) safelen(c) +/// \endcode +/// In this example directive '#pragma omp target simd' has clauses 'private' +/// with the variable 'a', 'map' with the variable 'b' and 'safelen' with +/// the variable 'c'. +/// +class OMPTargetSimdDirective 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. + /// + OMPTargetSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, unsigned NumClauses) + : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, + OMPD_target_simd, StartLoc, EndLoc, CollapsedNum, + NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPTargetSimdDirective(unsigned CollapsedNum, unsigned NumClauses) + : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, OMPD_target_simd, + 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 OMPTargetSimdDirective * + 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 OMPTargetSimdDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, + unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTargetSimdDirectiveClass; + } +}; + } // 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 @@ -138,6 +138,9 @@ #ifndef OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE #define OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(Name) #endif +#ifndef OPENMP_TARGET_SIMD_CLAUSE +#define OPENMP_TARGET_SIMD_CLAUSE(Name) +#endif // OpenMP directives. OPENMP_DIRECTIVE(threadprivate) @@ -182,6 +185,7 @@ OPENMP_DIRECTIVE_EXT(distribute_parallel_for_simd, "distribute parallel for simd") OPENMP_DIRECTIVE_EXT(distribute_simd, "distribute simd") OPENMP_DIRECTIVE_EXT(target_parallel_for_simd, "target parallel for simd") +OPENMP_DIRECTIVE_EXT(target_simd, "target simd") // OpenMP clauses. OPENMP_CLAUSE(if, OMPIfClause) @@ -620,6 +624,24 @@ OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(simdlen) OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(aligned) +// Clauses allowed for OpenMP directive 'target simd'. +OPENMP_TARGET_SIMD_CLAUSE(if) +OPENMP_TARGET_SIMD_CLAUSE(device) +OPENMP_TARGET_SIMD_CLAUSE(map) +OPENMP_TARGET_SIMD_CLAUSE(private) +OPENMP_TARGET_SIMD_CLAUSE(nowait) +OPENMP_TARGET_SIMD_CLAUSE(depend) +OPENMP_TARGET_SIMD_CLAUSE(defaultmap) +OPENMP_TARGET_SIMD_CLAUSE(firstprivate) +OPENMP_TARGET_SIMD_CLAUSE(is_device_ptr) +OPENMP_TARGET_SIMD_CLAUSE(lastprivate) +OPENMP_TARGET_SIMD_CLAUSE(linear) +OPENMP_TARGET_SIMD_CLAUSE(aligned) +OPENMP_TARGET_SIMD_CLAUSE(safelen) +OPENMP_TARGET_SIMD_CLAUSE(simdlen) +OPENMP_TARGET_SIMD_CLAUSE(collapse) +OPENMP_TARGET_SIMD_CLAUSE(reduction) + #undef OPENMP_TASKLOOP_SIMD_CLAUSE #undef OPENMP_TASKLOOP_CLAUSE #undef OPENMP_LINEAR_KIND @@ -662,3 +684,4 @@ #undef OPENMP_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE #undef OPENMP_DISTRIBUTE_SIMD_CLAUSE #undef OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE +#undef OPENMP_TARGET_SIMD_CLAUSE Index: cfe/trunk/include/clang/Basic/StmtNodes.td =================================================================== --- cfe/trunk/include/clang/Basic/StmtNodes.td +++ cfe/trunk/include/clang/Basic/StmtNodes.td @@ -233,3 +233,4 @@ def OMPDistributeParallelForSimdDirective : DStmt; def OMPDistributeSimdDirective : DStmt; def OMPTargetParallelForSimdDirective : DStmt; +def OMPTargetSimdDirective : DStmt; Index: cfe/trunk/include/clang/Sema/Sema.h =================================================================== --- cfe/trunk/include/clang/Sema/Sema.h +++ cfe/trunk/include/clang/Sema/Sema.h @@ -8240,6 +8240,12 @@ ArrayRef Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc, llvm::DenseMap &VarsWithImplicitDSA); + /// \brief Called on well-formed '\#pragma omp target simd' after parsing of + /// the associated statement. + StmtResult ActOnOpenMPTargetSimdDirective( + 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 @@ -1484,6 +1484,7 @@ STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE, STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE, STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE, + STMT_OMP_TARGET_SIMD_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 @@ -1270,3 +1270,44 @@ numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd)); return new (Mem) OMPTargetParallelForSimdDirective(CollapsedNum, NumClauses); } + +OMPTargetSimdDirective * +OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc, + SourceLocation EndLoc, unsigned CollapsedNum, + ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs) { + unsigned Size = llvm::alignTo(sizeof(OMPTargetSimdDirective), + llvm::alignOf()); + void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + + sizeof(Stmt *) * + numLoopChildren(CollapsedNum, OMPD_target_simd)); + OMPTargetSimdDirective *Dir = new (Mem) + OMPTargetSimdDirective(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->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; +} + +OMPTargetSimdDirective * +OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, + unsigned CollapsedNum, EmptyShell) { + unsigned Size = llvm::alignTo(sizeof(OMPTargetSimdDirective), + llvm::alignOf()); + void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses + + sizeof(Stmt *) * + numLoopChildren(CollapsedNum, OMPD_target_simd)); + return new (Mem) OMPTargetSimdDirective(CollapsedNum, NumClauses); +} Index: cfe/trunk/lib/AST/StmtPrinter.cpp =================================================================== --- cfe/trunk/lib/AST/StmtPrinter.cpp +++ cfe/trunk/lib/AST/StmtPrinter.cpp @@ -1198,6 +1198,11 @@ PrintOMPExecutableDirective(Node); } +void StmtPrinter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *Node) { + Indent() << "#pragma omp target simd "; + PrintOMPExecutableDirective(Node); +} + //===----------------------------------------------------------------------===// // Expr printing methods. //===----------------------------------------------------------------------===// Index: cfe/trunk/lib/AST/StmtProfile.cpp =================================================================== --- cfe/trunk/lib/AST/StmtProfile.cpp +++ cfe/trunk/lib/AST/StmtProfile.cpp @@ -727,6 +727,11 @@ VisitOMPLoopDirective(S); } +void StmtProfiler::VisitOMPTargetSimdDirective( + const OMPTargetSimdDirective *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 @@ -610,6 +610,16 @@ break; } break; + case OMPD_target_simd: + switch (CKind) { +#define OPENMP_TARGET_SIMD_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: @@ -635,7 +645,7 @@ DKind == OMPD_distribute_parallel_for || DKind == OMPD_distribute_parallel_for_simd || DKind == OMPD_distribute_simd || - DKind == OMPD_target_parallel_for_simd; + DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd; // TODO add next directives. } @@ -669,7 +679,7 @@ // TODO add next directives. return DKind == OMPD_target || DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for || - DKind == OMPD_target_parallel_for_simd; + DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd; } bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) { @@ -685,7 +695,7 @@ return DKind == OMPD_simd || DKind == OMPD_for_simd || DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd || DKind == OMPD_distribute_parallel_for_simd || - DKind == OMPD_distribute_simd; + DKind == OMPD_distribute_simd || DKind == OMPD_target_simd; // TODO add next directives. } Index: cfe/trunk/lib/CodeGen/CGStmt.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGStmt.cpp +++ cfe/trunk/lib/CodeGen/CGStmt.cpp @@ -295,6 +295,9 @@ EmitOMPTargetParallelForSimdDirective( cast(*S)); break; + case Stmt::OMPTargetSimdDirectiveClass: + EmitOMPTargetSimdDirective(cast(*S)); + break; } } Index: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp @@ -1913,6 +1913,17 @@ }); } +void CodeGenFunction::EmitOMPTargetSimdDirective( + const OMPTargetSimdDirective &S) { + OMPLexicalScope Scope(*this, S, /*AsInlined=*/true); + CGM.getOpenMPRuntime().emitInlinedDirective( + *this, OMPD_target_simd, [&S](CodeGenFunction &CGF, PrePostActionTy &) { + OMPLoopScope PreInitScope(CGF, S); + 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 @@ -2508,6 +2508,7 @@ void EmitOMPDistributeSimdDirective(const OMPDistributeSimdDirective &S); void EmitOMPTargetParallelForSimdDirective( const OMPTargetParallelForSimdDirective &S); + void EmitOMPTargetSimdDirective(const OMPTargetSimdDirective &S); /// Emit outlined function for the target directive. static std::pairgetCurScope()) { auto ParentRegion = Stack->getParentDirective(); @@ -3596,6 +3671,11 @@ AllowedNameModifiers.push_back(OMPD_target); AllowedNameModifiers.push_back(OMPD_parallel); break; + case OMPD_target_simd: + Res = ActOnOpenMPTargetSimdDirective(ClausesWithImplicit, AStmt, StartLoc, + EndLoc, VarsWithInheritedDSA); + AllowedNameModifiers.push_back(OMPD_target); + break; case OMPD_declare_target: case OMPD_end_declare_target: case OMPD_threadprivate: @@ -7201,6 +7281,53 @@ Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B); } +StmtResult Sema::ActOnOpenMPTargetSimdDirective( + ArrayRef 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. + unsigned NestedLoopCount = + CheckOpenMPLoop(OMPD_target_simd, getCollapseNumberExpr(Clauses), + getOrderedNumberExpr(Clauses), AStmt, *this, *DSAStack, + VarsWithImplicitDSA, B); + if (NestedLoopCount == 0) + return StmtError(); + + assert((CurContext->isDependentContext() || B.builtAll()) && + "omp target simd loop exprs were not built"); + + if (!CurContext->isDependentContext()) { + // Finalize the clauses that need pre-built expressions for CodeGen. + for (auto C : Clauses) { + if (auto LC = dyn_cast(C)) + if (FinishOpenMPLinearClause(*LC, cast(B.IterationVarRef), + B.NumIterations, *this, CurScope, + DSAStack)) + return StmtError(); + } + } + + if (checkSimdlenSafelenSpecified(*this, Clauses)) + return StmtError(); + + getCurFunction()->setHasBranchProtectedScope(); + return OMPTargetSimdDirective::Create(Context, StartLoc, EndLoc, + NestedLoopCount, Clauses, AStmt, B); +} + OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, SourceLocation StartLoc, SourceLocation LParenLoc, Index: cfe/trunk/lib/Sema/TreeTransform.h =================================================================== --- cfe/trunk/lib/Sema/TreeTransform.h +++ cfe/trunk/lib/Sema/TreeTransform.h @@ -7626,6 +7626,17 @@ return Res; } +template +StmtResult TreeTransform::TransformOMPTargetSimdDirective( + OMPTargetSimdDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_target_simd, DirName, nullptr, + D->getLocStart()); + StmtResult 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 @@ -2773,6 +2773,10 @@ VisitOMPLoopDirective(D); } +void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) { + VisitOMPLoopDirective(D); +} + //===----------------------------------------------------------------------===// // ASTReader Implementation //===----------------------------------------------------------------------===// @@ -3484,6 +3488,14 @@ break; } + case STMT_OMP_TARGET_SIMD_DIRECTIVE: { + auto NumClauses = Record[ASTStmtReader::NumStmtFields]; + auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; + S = OMPTargetSimdDirective::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 @@ -2479,6 +2479,11 @@ Code = serialization::STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE; } +void ASTStmtWriter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) { + VisitOMPLoopDirective(D); + Code = serialization::STMT_OMP_TARGET_SIMD_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 @@ -846,6 +846,7 @@ case Stmt::OMPDistributeParallelForSimdDirectiveClass: case Stmt::OMPDistributeSimdDirectiveClass: case Stmt::OMPTargetParallelForSimdDirectiveClass: + case Stmt::OMPTargetSimdDirectiveClass: 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 @@ -155,6 +155,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp parallel + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // SIMD DIRECTIVE #pragma omp simd @@ -347,6 +353,12 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // FOR DIRECTIVE #pragma omp for @@ -552,6 +564,12 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp for + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // OK + for (int j = 0; j < 10; ++j) + ; + } // FOR SIMD DIRECTIVE #pragma omp for simd @@ -745,6 +763,12 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // SECTIONS DIRECTIVE #pragma omp sections @@ -955,6 +979,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp sections + { +#pragma omp target simd // 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}} @@ -1222,6 +1252,13 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp sections + { +#pragma omp section +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // SINGLE DIRECTIVE #pragma omp single @@ -1418,6 +1455,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp single + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // MASTER DIRECTIVE #pragma omp master @@ -1614,6 +1657,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp master + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // CRITICAL DIRECTIVE #pragma omp critical @@ -1824,6 +1873,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp critical + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // PARALLEL FOR DIRECTIVE #pragma omp parallel for @@ -2034,6 +2089,12 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // OK + for (int j = 0; j < 10; ++j) + ; + } // PARALLEL FOR SIMD DIRECTIVE #pragma omp parallel for simd @@ -2245,6 +2306,12 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // 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 @@ -2444,6 +2511,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp parallel sections + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // TASK DIRECTIVE #pragma omp task @@ -2590,6 +2663,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp task + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // ORDERED DIRECTIVE #pragma omp ordered @@ -2807,6 +2886,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp ordered + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // ATOMIC DIRECTIVE #pragma omp atomic @@ -3052,6 +3137,14 @@ for (int i = 0; i < 10; ++i) ; } +#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 simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET DIRECTIVE #pragma omp target @@ -3214,6 +3307,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp target + { +#pragma omp target simd // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET PARALLEL DIRECTIVE #pragma omp target parallel @@ -3370,6 +3469,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp target parallel + { +#pragma omp target simd // 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 @@ -3580,6 +3685,12 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp target parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{region cannot be nested inside 'target parallel for' region}} + for (int j = 0; j < 10; ++j) + ; + } // TEAMS DIRECTIVE #pragma omp target @@ -3778,6 +3889,13 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp target +#pragma omp teams + { +#pragma omp target simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp target simd' directive into a parallel region?}} + for (int i = 0; i < 10; ++i) + ; + } // TASKLOOP DIRECTIVE #pragma omp taskloop @@ -3979,6 +4097,12 @@ for (int j = 0; j < 10; ++j) ++a; } +#pragma omp taskloop + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // OK + for (int j = 0; j < 10; ++j) + ++a; + } // DISTRIBUTE DIRECTIVE #pragma omp target @@ -4204,6 +4328,14 @@ #pragma omp target update to(a) // 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 simd // expected-error {{region cannot be nested inside 'target' region}} + for (int j = 0; j < 10; ++j) + ; + } // DISTRIBUTE PARALLEL FOR DIRECTIVE #pragma omp target @@ -4686,99 +4818,294 @@ for (int i = 0; i < 10; ++i) ++a; } -} +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++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(); +// TARGET SIMD DIRECTIVE +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp distribute parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; } -#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 target simd + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; } -#pragma omp parallel -#pragma omp sections - { - bar(); +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; } -#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 target simd + for (int i = 0; i < 10; ++i) { +#pragma omp simd // expected-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}} + for (int i = 0; i < 10; ++i) + ; } -#pragma omp parallel -#pragma omp task - { - bar(); +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; } -#pragma omp parallel - { -#pragma omp taskyield - bar(); +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; } -#pragma omp parallel - { -#pragma omp barrier - bar(); +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } } -#pragma omp parallel - { -#pragma omp taskwait - bar(); +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } } -#pragma omp parallel - { -#pragma omp flush - bar(); +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + 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 target simd + for (int i = 0; i < 10; ++i) { +#pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } } -#pragma omp parallel - { -#pragma omp atomic - ++a; +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } } -#pragma omp parallel - { -#pragma omp target - ++a; +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { +#pragma omp single + { + bar(); + } + } + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp atomic // 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 // 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 parallel // 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 parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp target enter data map(to: a) // 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 exit data map(from: a) // 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 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 update to(a) // 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 distribute simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++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 + { + 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; + } +#pragma omp parallel + { +#pragma omp target + ++a; } #pragma omp parallel { @@ -4839,6 +5166,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp parallel + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // SIMD DIRECTIVE #pragma omp simd @@ -5015,6 +5348,12 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // FOR DIRECTIVE #pragma omp for @@ -5211,6 +5550,12 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp for + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // OK + for (int j = 0; j < 10; ++j) + ; + } // FOR SIMD DIRECTIVE #pragma omp for simd @@ -5387,6 +5732,12 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int j = 0; j < 10; ++j) + ; + } // SECTIONS DIRECTIVE #pragma omp sections @@ -5572,6 +5923,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp sections + { +#pragma omp target simd // 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}} @@ -5849,6 +6206,13 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp sections + { +#pragma omp section +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // SINGLE DIRECTIVE #pragma omp single @@ -6035,6 +6399,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp single + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // MASTER DIRECTIVE #pragma omp master @@ -6231,6 +6601,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp master + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // CRITICAL DIRECTIVE #pragma omp critical @@ -6446,6 +6822,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp critical + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // PARALLEL FOR DIRECTIVE #pragma omp parallel for @@ -6657,6 +7039,12 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // OK + for (int j = 0; j < 10; ++j) + ; + } // PARALLEL FOR SIMD DIRECTIVE #pragma omp parallel for simd @@ -6868,6 +7256,12 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // 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 @@ -7063,6 +7457,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp parallel sections + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // TASK DIRECTIVE #pragma omp task @@ -7208,6 +7608,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp task + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // ATOMIC DIRECTIVE #pragma omp atomic @@ -7452,6 +7858,14 @@ for (int i = 0; i < 10; ++i) ; } +#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 simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET DIRECTIVE #pragma omp target @@ -7611,6 +8025,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp target + { +#pragma omp target simd // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET PARALLEL DIRECTIVE #pragma omp target parallel @@ -7767,6 +8187,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp target parallel + { +#pragma omp target simd // expected-error {{region cannot be nested inside 'target parallel' regio}} + for (int i = 0; i < 10; ++i) + ; + } // TARGET PARALLEL FOR DIRECTIVE #pragma omp target parallel for @@ -7978,6 +8404,12 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp target parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{region cannot be nested inside 'target parallel for' region}} + for (int j = 0; j < 10; ++j) + ; + } // TEAMS DIRECTIVE #pragma omp target @@ -8180,6 +8612,13 @@ for (int j = 0; j < 10; ++j) ; } +#pragma omp target +#pragma omp teams + { +#pragma omp target simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp target simd' directive into a parallel region?}} + for (int i = 0; i < 10; ++i) + ; + } // TASKLOOP DIRECTIVE #pragma omp taskloop @@ -8381,6 +8820,12 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp taskloop + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } // DISTRIBUTE DIRECTIVE #pragma omp target @@ -8631,6 +9076,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 simd // expected-error {{region cannot be nested inside 'target' region}} + for (int i = 0; i < 10; ++i) + ++a; + } // DISTRIBUTE PARALLEL FOR DIRECTIVE #pragma omp target @@ -8874,6 +9327,14 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // 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 @@ -9108,6 +9569,14 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // 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 @@ -9342,4 +9811,194 @@ for (int i = 0; i < 10; ++i) ; } +#pragma omp target +#pragma omp teams +#pragma omp distribute simd + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // 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 + for (int i = 0; i < 10; ++i) { +#pragma omp distribute parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp simd // expected-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { +#pragma omp single + { + bar(); + } + } + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp atomic // 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 // 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 parallel // 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 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 enter data map(to: a) // 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 exit data map(from: a) // 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 update to(a) // 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 distribute simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } + return foo(); } Index: cfe/trunk/test/OpenMP/target_simd_aligned_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_aligned_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_aligned_messages.cpp @@ -0,0 +1,203 @@ +// RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp %s + +struct B { + static int ib[20]; // expected-note 0 {{'B::ib' declared here}} + static constexpr int bfoo() { return 8; } +}; +namespace X { + B x; // expected-note {{'x' defined here}} +}; +constexpr int bfoo() { return 4; } + +int **z; +const int C1 = 1; +const int C2 = 2; +void test_aligned_colons(int *&rp) +{ + int *B = 0; + #pragma omp target simd aligned(B:bfoo()) + for (int i = 0; i < 10; ++i) ; + // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}} + #pragma omp target simd aligned(B::ib:B:bfoo()) + for (int i = 0; i < 10; ++i) ; + #pragma omp target simd aligned(B:B::bfoo()) + for (int i = 0; i < 10; ++i) ; + // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}} + #pragma omp target simd aligned(z:B:bfoo()) + for (int i = 0; i < 10; ++i) ; + #pragma omp target simd aligned(B:B::bfoo()) + for (int i = 0; i < 10; ++i) ; + // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'int **'}} + // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'B'}} + #pragma omp target simd aligned(X::x : ::z) + for (int i = 0; i < 10; ++i) ; + // expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'B'}} + #pragma omp target simd aligned(B,rp,::z: X::x) + for (int i = 0; i < 10; ++i) ; + #pragma omp target simd aligned(::z) + for (int i = 0; i < 10; ++i) ; + // expected-error@+1 {{expected variable name}} + #pragma omp target simd aligned(B::bfoo()) + for (int i = 0; i < 10; ++i) ; + // expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}} + #pragma omp target simd aligned(B::ib,B:C1+C2) + for (int i = 0; i < 10; ++i) ; +} + +// expected-note@+1 {{'num' defined here}} +template T test_template(T* arr, N num) { + N i; + T sum = (T)0; + T ind2 = - num * L; + // Negative number is passed as L. + // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}} + #pragma omp target simd aligned(arr:L) + for (i = 0; i < num; ++i) { + T cur = arr[(int)ind2]; + ind2 += L; + sum += cur; + } + // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} + #pragma omp target simd aligned(num:4) + for (i = 0; i < num; ++i); + return T(); +} + +template int test_warn() { + int *ind2 = 0; + // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}} + #pragma omp target simd aligned(ind2:LEN) + for (int i = 0; i < 100; i++) { + ind2 += LEN; + } + return 0; +} + +struct S1; // expected-note 2 {{declared here}} +extern S1 a; // expected-note {{'a' declared here}} +class S2 { + mutable int a; +public: + S2():a(0) { } +}; +const S2 b; // expected-note 1 {{'b' defined here}} +const S2 ba[5]; +class S3 { + int a; +public: + S3():a(0) { } +}; +const S3 ca[5]; +class S4 { + int a; + S4(); +public: + S4(int v):a(v) { } +}; +class S5 { + int a; + S5():a(0) {} +public: + S5(int v):a(v) { } +}; + +S3 h; // expected-note 2 {{'h' defined here}} +#pragma omp threadprivate(h) + +template int foomain(I argc, C **argv) { + I e(argc); + I g(argc); + int i; // expected-note {{declared here}} expected-note {{'i' defined here}} + // expected-note@+2 {{declared here}} + // expected-note@+1 {{reference to 'i' is not a constant expression}} + int &j = i; + #pragma omp target simd aligned // expected-error {{expected '(' after 'aligned'}} + for (I k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (I k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned () // expected-error {{expected expression}} + for (I k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (I k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (I k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (I k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned (argc : 5) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}} + for (I k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned (S1) // expected-error {{'S1' does not refer to a value}} + for (I k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned (argv[1]) // expected-error {{expected variable name}} + for (I k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned(e, g) + for (I k = 0; k < argc; ++k) ++k; + // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}} + #pragma omp target simd aligned(h) + for (I k = 0; k < argc; ++k) ++k; + // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} + #pragma omp target simd aligned(i) + for (I k = 0; k < argc; ++k) ++k; + #pragma omp parallel + { + int *v = 0; + I i; + #pragma omp target simd aligned(v:16) + for (I k = 0; k < argc; ++k) { i = k; v += 2; } + } + float *f; + #pragma omp target simd aligned(f) + for (I k = 0; k < argc; ++k) ++k; + int v = 0; + // expected-note@+2 {{initializer of 'j' is not a constant expression}} + // expected-error@+1 {{expression is not an integral constant expression}} + #pragma omp target simd aligned(f:j) + for (I k = 0; k < argc; ++k) { ++k; v += j; } + #pragma omp target simd aligned(f) + for (I k = 0; k < argc; ++k) ++k; + return 0; +} + +// expected-note@+1 2 {{'argc' defined here}} +int main(int argc, char **argv) { + double darr[100]; + // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}} + test_template<-4>(darr, 4); + test_warn<4>(); // ok + // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}} + test_warn<0>(); + + int i; + int &j = i; + #pragma omp target simd aligned // expected-error {{expected '(' after 'aligned'}} + for (int k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned () // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned (argv // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} + #pragma omp target simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} + #pragma omp target simd aligned (argc) + for (int k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned (S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) ++k; + // expected-error@+2 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S1'}} + // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S2'}} + #pragma omp target simd aligned (a, b) + for (int k = 0; k < argc; ++k) ++k; + #pragma omp target simd aligned (argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) ++k; + // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}} + #pragma omp target simd aligned(h) + for (int k = 0; k < argc; ++k) ++k; + int *pargc = &argc; + // expected-note@+1 {{in instantiation of function template specialization 'foomain' requested here}} + foomain(pargc,argv); + return 0; +} + Index: cfe/trunk/test/OpenMP/target_simd_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_simd_ast_print.cpp @@ -0,0 +1,310 @@ +// 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 simd 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 simd private(a) private(this->a) + for (int k = 0; k < s.a.a; ++k) + ++s.a.a; + return *this; + } +}; + +// CHECK: #pragma omp target simd private(this->a) private(this->a) private(this->S::a) +// CHECK: #pragma omp target simd private(this->a) private(this->a) private(T::a) +// CHECK: #pragma omp target simd private(this->a) private(this->a) + +class S8 : public S7 { + S8() {} + +public: + S8(int v) : S7(v){ +#pragma omp target simd 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 simd private(a) private(this->a) + for (int k = 0; k < s.a.a; ++k) + ++s.a.a; + return *this; + } +}; + +// CHECK: #pragma omp target simd private(this->a) private(this->a) private(this->S7::a) +// CHECK: #pragma omp target simd private(this->a) private(this->a) + +template +T tmain(T argc, T *argv) { + T b = argc, c, d, e, f, h; + T arr[N][10], arr1[N]; + T i, j; + T s; + static T a; +// CHECK: static T a; + static T g; + const T clen = 5; +// CHECK: T clen = 5; + T *p; +#pragma omp threadprivate(g) +#pragma omp target simd linear(a) + // CHECK: #pragma omp target simd linear(a) + for (T i = 0; i < 2; ++i) + a = 2; +// CHECK-NEXT: for (T i = 0; i < 2; ++i) +// CHECK-NEXT: a = 2; +#pragma omp target simd private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) if (target :argc) reduction(+ : h) + for (int i = 0; i < 2; ++i) + for (int j = 0; j < 2; ++j) + for (int j = 0; j < 2; ++j) + for (int j = 0; j < 2; ++j) + for (int j = 0; j < 2; ++j) + foo(); + // CHECK-NEXT: #pragma omp target simd private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) if(target: argc) reduction(+: h) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) + // CHECK-NEXT: for (int j = 0; j < 2; ++j) + // CHECK-NEXT: for (int j = 0; j < 2; ++j) + // CHECK-NEXT: for (int j = 0; j < 2; ++j) + // CHECK-NEXT: for (int j = 0; j < 2; ++j) + // CHECK-NEXT: foo(); + +#pragma omp target simd private(argc,b) firstprivate(argv) if(target:argc > 0) reduction(+:c, arr1[argc]) reduction(max:e, arr[:N][0:10]) + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd private(argc,b) firstprivate(argv) if(target: argc > 0) reduction(+: c,arr1[argc]) reduction(max: e,arr[:N][0:10]) + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd if(N) reduction(^:e, f, arr[0:N][:argc]) reduction(&& : h) + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd if(N) reduction(^: e,f,arr[0:N][:argc]) reduction(&&: h) + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd if(target:argc > 0) + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd if(target: argc > 0) + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd if(N) + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd if(N) + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd map(i) + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd map(tofrom: i) + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd map(arr1[0:10], i) + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd map(tofrom: arr1[0:10],i) + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd map(to: i) map(from: j) + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd map(to: i) map(from: j) + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd map(always,alloc: i) + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd map(always,alloc: i) + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd nowait + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd nowait + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd depend(in : argc, arr[i:argc], arr1[:]) + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd depend(in : argc,arr[i:argc],arr1[:]) + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd defaultmap(tofrom: scalar) + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd defaultmap(tofrom: scalar) + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd safelen(clen-1) + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd safelen(clen - 1) + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd simdlen(clen-1) + for (T i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd simdlen(clen - 1) + // CHECK-NEXT: for (T i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd aligned(arr1:N-1) + for (T i = 0; i < N; ++i) {} + // CHECK: #pragma omp target simd aligned(arr1: N - 1) + // CHECK-NEXT: for (T i = 0; i < N; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd is_device_ptr(p) + for (T i = 0; i < N; ++i) {} + // CHECK: #pragma omp target simd is_device_ptr(p) + // CHECK-NEXT: for (T i = 0; i < N; ++i) { + // CHECK-NEXT: } + + return T(); +} + +int main(int argc, char **argv) { + int b = argc, c, d, e, f, h; + int arr[5][10], arr1[5]; + int i, j; + int s; + static int a; +// CHECK: static int a; + const int clen = 5; +// CHECK: int clen = 5; + static float g; +#pragma omp threadprivate(g) + int *p; +#pragma omp target simd linear(a) + // CHECK: #pragma omp target simd linear(a) + for (int i = 0; i < 2; ++i) + a = 2; +// CHECK-NEXT: for (int i = 0; i < 2; ++i) +// CHECK-NEXT: a = 2; + +#pragma omp target simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) if (target: argc) reduction(+ : h) linear(a:-5) + for (int i = 0; i < 10; ++i) + for (int j = 0; j < 10; ++j) + foo(); + // CHECK: #pragma omp target simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) if(target: argc) reduction(+: h) linear(a: -5) + // CHECK-NEXT: for (int i = 0; i < 10; ++i) + // CHECK-NEXT: for (int j = 0; j < 10; ++j) + // CHECK-NEXT: foo(); + +#pragma omp target simd private(argc,b) firstprivate(argv) if (argc > 0) reduction(+:c, arr1[argc]) reduction(max:e, arr[:5][0:10]) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd private(argc,b) firstprivate(argv) if(argc > 0) reduction(+: c,arr1[argc]) reduction(max: e,arr[:5][0:10]) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd if (5) reduction(^:e, f, arr[0:5][:argc]) reduction(&& : h) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd if(5) reduction(^: e,f,arr[0:5][:argc]) reduction(&&: h) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd if (target:argc > 0) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd if(target: argc > 0) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd if (5) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd if(5) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd map(i) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd map(tofrom: i) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd map(arr1[0:10], i) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd map(tofrom: arr1[0:10],i) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd map(to: i) map(from: j) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd map(to: i) map(from: j) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd map(always,alloc: i) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd map(always,alloc: i) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd nowait + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd nowait + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd depend(in : argc, arr[i:argc], arr1[:]) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd depend(in : argc,arr[i:argc],arr1[:]) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd defaultmap(tofrom: scalar) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd defaultmap(tofrom: scalar) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd safelen(clen-1) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd safelen(clen - 1) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd simdlen(clen-1) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd simdlen(clen - 1) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd aligned(arr1:4) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd aligned(arr1: 4) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + +#pragma omp target simd is_device_ptr(p) + for (int i = 0; i < 2; ++i) {} + // CHECK: #pragma omp target simd is_device_ptr(p) + // CHECK-NEXT: for (int i = 0; i < 2; ++i) { + // CHECK-NEXT: } + + return (tmain(argc, &argc)); +} + +#endif Index: cfe/trunk/test/OpenMP/target_simd_collapse_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_collapse_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_collapse_messages.cpp @@ -0,0 +1,100 @@ +// RUN: %clang_cc1 -verify -fopenmp %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s + +void foo() { +} + +#if __cplusplus >= 201103L +// expected-note@+2 4 {{declared here}} +#endif +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}} + int j; // expected-note {{declared here}} + #pragma omp target simd 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 simd 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 simd 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 simd 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 simd 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 simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + #pragma omp target simd 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 simd', but found only 1}} +#if __cplusplus >= 201103L + // expected-note@+5 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif + // expected-error@+3 2 {{directive '#pragma omp target simd' 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 simd 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 simd 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-note@+2 {{read of non-const variable 'j' is not allowed in a constant expression}} + // expected-error@+1 {{expression is not an integral constant expression}} + #pragma omp target simd collapse (j=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 simd collapse (1) + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + #pragma omp target simd 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 simd collapse (2) // expected-note {{as specified in 'collapse' clause}} + foo(); // expected-error {{expected 2 for loops after '#pragma omp target simd'}} + return argc; +} + +int main(int argc, char **argv) { + int j; // expected-note {{declared here}} + #pragma omp target simd 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 simd 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 simd 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 simd 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 simd', but found only 1}} + #pragma omp target simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' 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 simd', but found only 1}} +#if __cplusplus >= 201103L + // expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif + #pragma omp target simd 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]; +#if __cplusplus >= 201103L + // expected-note@+5 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif + // expected-error@+3 {{expression is not an integral constant expression}} + // expected-error@+2 2 {{directive '#pragma omp target simd' 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 simd 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 simd 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-note@+2 {{read of non-const variable 'j' is not allowed in a constant expression}} + // expected-error@+1 {{expression is not an integral constant expression}} + #pragma omp target simd collapse (j=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 simd' must be a for loop}} + // expected-note@+1 {{in instantiation of function template specialization 'tmain' requested here}} + #pragma omp target simd collapse(collapse(tmain(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} + foo(); + #pragma omp target simd collapse (2) // expected-note {{as specified in 'collapse' clause}} + foo(); // expected-error {{expected 2 for loops after '#pragma omp target simd'}} + // expected-note@+1 {{in instantiation of function template specialization 'tmain' requested here}} + return tmain(argc, argv); +} + Index: cfe/trunk/test/OpenMP/target_simd_defaultmap_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_defaultmap_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_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 simd defaultmap // expected-error {{expected '(' after 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd 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 simd 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 simd defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd 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 simd 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 simd defaultmap // expected-error {{expected '(' after 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd 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 simd 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 simd defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd 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 simd 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_simd_depend_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_depend_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_depend_messages.cpp @@ -0,0 +1,90 @@ +// RUN: %clang_cc1 -verify -fopenmp -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 simd depend // expected-error {{expected '(' after 'depend'}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd 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 simd 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 simd depend (source : argc) // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd depend (in : argc)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd depend (out: ) // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd depend (out :S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd depend (in : vec[1]) // expected-error {{expected variable name, array element or array section}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd depend (in : argv[0]) + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd depend (in : ) // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd depend (in : main) // expected-error {{expected variable name, array element or array section}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd depend(in : a[0]) // expected-error{{expected variable name, array element or array section}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd depend (in : vec[1:2]) // expected-error {{ value is not an array or pointer}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd 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 simd 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 simd 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 simd depend (in : argv[argc:argc] // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd depend (in : argv[-1:0]) // OK + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd 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 simd 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 simd 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 simd depend(in : argv[ : argc][1 : argc - 1]) + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd depend(in : arr[0]) + for (i = 0; i < argc; ++i) foo(); + + return 0; +} Index: cfe/trunk/test/OpenMP/target_simd_device_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_device_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_device_messages.cpp @@ -0,0 +1,40 @@ +// RUN: %clang_cc1 -verify -fopenmp %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 simd device // expected-error {{expected '(' after 'device'}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd device ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd device () // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd device (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd device (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd device (argc + argc) + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd device (argc), device (argc+1) // expected-error {{directive '#pragma omp target simd' cannot contain more than one 'device' clause}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd device (S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd device (-10u) + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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_simd_firstprivate_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_firstprivate_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_firstprivate_messages.cpp @@ -0,0 +1,261 @@ +// 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(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) {} + S3(const 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); // expected-note 2 {{implicitly declared private here}} + +public: + S4(int v) : a(v) {} +}; +class S5 { + int a; + S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}} + +public: + S5() : a(0) {} + 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); + C g(5); + int i; + int &j = i; +#pragma omp target simd firstprivate // expected-error {{expected '(' after 'firstprivate'}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd firstprivate() // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd firstprivate(argc) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd firstprivate(argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd firstprivate(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 simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp parallel + { + int v = 0; + int i; +#pragma omp target simd firstprivate(i) + for (int k = 0; k < argc; ++k) { + i = k; + v += i; + } + } +#pragma omp parallel shared(i) +#pragma omp parallel private(i) +#pragma omp target simd firstprivate(j) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd firstprivate(i) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp parallel private(i) +#pragma omp target simd firstprivate(i) // expected-note {{defined as firstprivate}} + for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}} + foo(); +#pragma omp parallel reduction(+ : i) +#pragma omp target simd firstprivate(i) // expected-note {{defined as firstprivate}} + for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}} + foo(); + return 0; +} + +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); + S3 m; + S6 n(2); + int i; + int &j = i; +#pragma omp target simd firstprivate // expected-error {{expected '(' after 'firstprivate'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate() // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(argc) + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(argv[1]) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(2 * 2) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(ba) // OK + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(ca) // OK + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(da) // OK + for (i = 0; i < argc; ++i) + foo(); + int xa; +#pragma omp target simd firstprivate(xa) // OK + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(S2::S2s) // OK + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(S2::S2sc) // OK + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd safelen(5) // OK + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(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 simd firstprivate(m) // OK + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(i) // expected-note {{defined as firstprivate}} + for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}} + foo(); +#pragma omp parallel shared(xa) +#pragma omp target simd firstprivate(xa) // OK: may be firstprivate + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(j) + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(n) firstprivate(n) // OK + for (i = 0; i < argc; ++i) + foo(); +#pragma omp parallel + { + int v = 0; + int i; +#pragma omp target simd firstprivate(i) + for (int k = 0; k < argc; ++k) { + i = k; + v += i; + } + } +#pragma omp parallel private(i) +#pragma omp target simd firstprivate(i) // expected-note {{defined as firstprivate}} + for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}} + foo(); +#pragma omp parallel reduction(+ : i) +#pragma omp target simd firstprivate(i) // expected-note {{defined as firstprivate}} + for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}} + foo(); + static int si; +#pragma omp target simd firstprivate(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_simd_if_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_if_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_if_messages.cpp @@ -0,0 +1,91 @@ +// 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}} +int tmain(T argc, S **argv) { + int i; + #pragma omp target simd if // expected-error {{expected '(' after 'if'}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if () // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (argc > 0 ? argv[1] : argv[2]) + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target simd' cannot contain more than one 'if' clause}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (S) // expected-error {{'S' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if(argc) + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if(target : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if(target : argc) + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if(target : argc) if (simd:argc) // expected-error {{directive name modifier 'simd' is not allowed for '#pragma omp target simd'}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target simd' cannot contain more than one 'if' clause with 'target' name modifier}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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(); + + return 0; +} + +int main(int argc, char **argv) { + int i; + #pragma omp target simd if // expected-error {{expected '(' after 'if'}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if () // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (argc > 0 ? argv[1] : argv[2]) + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target simd' cannot contain more than one 'if' clause}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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 simd if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if(target : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if(target : argc) if (simd:argc) // expected-error {{directive name modifier 'simd' is not allowed for '#pragma omp target simd'}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target simd' cannot contain more than one 'if' clause with 'target' name modifier}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd 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(); + + return tmain(argc, argv); +} Index: cfe/trunk/test/OpenMP/target_simd_is_device_ptr_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_is_device_ptr_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_is_device_ptr_messages.cpp @@ -0,0 +1,288 @@ +// RUN: %clang_cc1 -std=c++11 -verify -fopenmp %s + +struct ST { + int *a; +}; +typedef int arr[10]; +typedef ST STarr[10]; +struct SA { + const int d = 5; + const int da[5] = { 0 }; + ST e; + ST g[10]; + STarr &rg = g; + int i; + int &j = i; + int *k = &j; + int *&z = k; + int aa[10]; + arr &raa = aa; + void func(int arg) { +#pragma omp target simd is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}} + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr() // expected-error {{expected expression}} + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}} + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(k) // OK + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(z) // OK + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(aa) // OK + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(raa) // OK + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(g) // OK + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(rg) // OK + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int ii=0; ii<10; ii++) + ; +#pragma omp target simd is_device_ptr(da) // OK + for (int ii=0; ii<10; ii++) + ; + return; + } +}; +struct SB { + unsigned A; + unsigned B; + float Arr[100]; + float *Ptr; + float *foo() { + return &Arr[0]; + } +}; + +struct SC { + unsigned A : 2; + unsigned B : 3; + unsigned C; + unsigned D; + float Arr[100]; + SB S; + SB ArrS[100]; + SB *PtrS; + SB *&RPtrS; + float *Ptr; + + SC(SB *&_RPtrS) : RPtrS(_RPtrS) {} +}; + +union SD { + unsigned A; + float B; +}; + +struct S1; +extern S1 a; +class S2 { + mutable int a; +public: + S2():a(0) { } + S2(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; +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) + +typedef struct { + int a; +} S6; + +template +T tmain(T argc) { + const T d = 5; + const T da[5] = { 0 }; + S4 e(4); + S5 g(5); + S6 h[10]; + auto &rh = h; + T i; + T &j = i; + T *k = &j; + T *&z = k; + T aa[10]; + auto &raa = aa; +#pragma omp target simd is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr() // expected-error {{expected expression}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(k) // OK + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(z) // OK + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(aa) // OK + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(raa) // OK + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(h) // OK + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(rh) // OK + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(da) // OK + for (int kk=0; kk<20; kk++) + ; + return 0; +} + +int main(int argc, char **argv) { + const int d = 5; + const int da[5] = { 0 }; + S4 e(4); + S5 g(5); + S6 h[10]; + auto &rh = h; + int i; + int &j = i; + int *k = &j; + int *&z = k; + int aa[10]; + auto &raa = aa; +#pragma omp target simd is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr() // expected-error {{expected expression}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(k) // OK + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(z) // OK + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(aa) // OK + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(raa) // OK + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(h) // OK + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(rh) // OK + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}} + for (int kk=0; kk<20; kk++) + ; +#pragma omp target simd is_device_ptr(da) // OK + for (int kk=0; kk<20; kk++) + ; + return tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} +} Index: cfe/trunk/test/OpenMP/target_simd_lastprivate_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_lastprivate_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_lastprivate_messages.cpp @@ -0,0 +1,238 @@ +// 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) {} + S2 &operator=(const S2 &); + const S2 &operator=(const S2 &) const; + 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 simd lastprivate // expected-error {{expected '(' after 'lastprivate'}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd lastprivate() // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd 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 simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd lastprivate(argc) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd lastprivate(argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp parallel + { + int v = 0; + int i; +#pragma omp target simd lastprivate(i) + for (int k = 0; k < argc; ++k) { + i = k; + v += i; + } + } +#pragma omp parallel shared(i) +#pragma omp parallel private(i) +#pragma omp target simd lastprivate(j) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd lastprivate(i) + for (int k = 0; k < argc; ++k) + ++k; + return 0; +} + +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 simd lastprivate // expected-error {{expected '(' after 'lastprivate'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate() // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(argc) + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd 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 simd lastprivate(argv[1]) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(2 * 2) // expected-error {{expected variable name}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(ba) + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(da) // expected-error {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) + foo(); + int xa; +#pragma omp target simd lastprivate(xa) // OK + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd safelen(5) // OK + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd 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 simd lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be lastprivate}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd 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 simd lastprivate(i) // expected-note {{defined as lastprivate}} + for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target simd' directive may not be lastprivate, predetermined as linear}} + foo(); +#pragma omp parallel private(xa) +#pragma omp target simd lastprivate(xa) + for (i = 0; i < argc; ++i) + foo(); +#pragma omp parallel reduction(+ : xa) +#pragma omp target simd lastprivate(xa) + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(j) + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd lastprivate(n) firstprivate(n) // OK + for (i = 0; i < argc; ++i) + foo(); + static int si; +#pragma omp target simd lastprivate(si) // OK + for (i = 0; i < argc; ++i) + si = i + 2; + + return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}} +} Index: cfe/trunk/test/OpenMP/target_simd_linear_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_linear_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_linear_messages.cpp @@ -0,0 +1,269 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +namespace X { +int x; +}; + +struct B { + static int ib; // expected-note {{'B::ib' declared here}} + static int bfoo() { return 8; } +}; + +int bfoo() { return 4; } + +int z; +const int C1 = 1; +const int C2 = 2; +void test_linear_colons() { + int B = 0; +#pragma omp target simd linear(B : bfoo()) + for (int i = 0; i < 10; ++i) + ; +// expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}} +#pragma omp target simd linear(B::ib : B : bfoo()) + for (int i = 0; i < 10; ++i) + ; +// expected-error@+1 {{use of undeclared identifier 'ib'; did you mean 'B::ib'}} +#pragma omp target simd linear(B : ib) + for (int i = 0; i < 10; ++i) + ; +// expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}} +#pragma omp target simd linear(z : B : ib) + for (int i = 0; i < 10; ++i) + ; +#pragma omp target simd linear(B : B::bfoo()) + for (int i = 0; i < 10; ++i) + ; +#pragma omp target simd linear(X::x : ::z) + for (int i = 0; i < 10; ++i) + ; +#pragma omp target simd linear(B, ::z, X::x) + for (int i = 0; i < 10; ++i) + ; +#pragma omp target simd linear(::z) + for (int i = 0; i < 10; ++i) + ; +// expected-error@+1 {{expected variable name}} +#pragma omp target simd linear(B::bfoo()) + for (int i = 0; i < 10; ++i) + ; +#pragma omp target simd linear(B::ib, B : C1 + C2) + for (int i = 0; i < 10; ++i) + ; +} + +template +T test_template(T *arr, N num) { + N i; + T sum = (T)0; + T ind2 = -num * L; // expected-note {{'ind2' defined here}} +// expected-error@+1 {{argument of a linear clause should be of integral or pointer type}} +#pragma omp target simd linear(ind2 : L) + for (i = 0; i < num; ++i) { + T cur = arr[(int)ind2]; + ind2 += L; + sum += cur; + } + return T(); +} + +template +int test_warn() { + int ind2 = 0; +// expected-warning@+1 {{zero linear step (ind2 should probably be const)}} +#pragma omp target simd linear(ind2 : LEN) + for (int i = 0; i < 100; i++) { + ind2 += LEN; + } + return ind2; +} + +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) {} +}; +const S2 b; // expected-note 2 {{'b' defined here}} +const S2 ba[5]; +class S3 { + int a; + +public: + S3() : a(0) {} +}; +const S3 ca[5]; +class S4 { + int a; + S4(); + +public: + S4(int v) : a(v) {} +}; +class S5 { + int a; + S5() : a(0) {} + +public: + S5(int v) : a(v) {} +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} + +template +int foomain(I argc, C **argv) { + I e(4); + I g(5); + int i; + int &j = i; +#pragma omp target simd linear // expected-error {{expected '(' after 'linear'}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear() // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(argc : 5) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) + ++k; +// expected-error@+2 {{linear variable with incomplete type 'S1'}} +// expected-error@+1 {{const-qualified variable cannot be linear}} +#pragma omp target simd linear(a, b : B::ib) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(e, g) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(i) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp parallel + { + int v = 0; + int i; +#pragma omp target simd linear(v : i) + for (int k = 0; k < argc; ++k) { + i = k; + v += i; + } + } +#pragma omp target simd linear(j) + for (int k = 0; k < argc; ++k) + ++k; + int v = 0; +#pragma omp target simd linear(v : j) + for (int k = 0; k < argc; ++k) { + ++k; + v += j; + } +#pragma omp target simd linear(i) + for (int k = 0; k < argc; ++k) + ++k; + return 0; +} + +namespace A { +double x; +#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} +} +namespace C { +using A::x; +} + +int main(int argc, char **argv) { + double darr[100]; + // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}} + test_template<-4>(darr, 4); + // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}} + test_warn<0>(); + + S4 e(4); // expected-note {{'e' defined here}} + S5 g(5); // expected-note {{'g' defined here}} + int i; + int &j = i; +#pragma omp target simd linear // expected-error {{expected '(' after 'linear'}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear() // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(argc) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) + ++k; +// expected-error@+2 {{linear variable with incomplete type 'S1'}} +// expected-error@+1 {{const-qualified variable cannot be linear}} +#pragma omp target simd linear(a, b) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) + ++k; +// expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}} +// expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}} +#pragma omp target simd linear(e, g) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp parallel + { + int i; +#pragma omp target simd linear(i) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(i : 4) + for (int k = 0; k < argc; ++k) { + ++k; + i += 4; + } + } +#pragma omp target simd linear(j) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd linear(i) + for (int k = 0; k < argc; ++k) + ++k; + + foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}} + return 0; +} + Index: cfe/trunk/test/OpenMP/target_simd_loop_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_loop_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_loop_messages.cpp @@ -0,0 +1,629 @@ +// 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 simd + for (int i = 0; i < 10; i += 1) { + c[i] = a[i] + b[i]; + } +#pragma omp target simd + for (char i = 0; i < 10; i++) { + c[i] = a[i] + b[i]; + } +#pragma omp target simd + for (char i = 0; i < 10; i += '\1') { + c[i] = a[i] + b[i]; + } +#pragma omp target simd + for (long long i = 0; i < 10; i++) { + c[i] = a[i] + b[i]; + } +// expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'double'}} +#pragma omp target simd + for (long long i = 0; i < 10; i += 1.5) { + c[i] = a[i] + b[i]; + } +#pragma omp target simd + for (long long i = 0; i < 'z'; i += 1u) { + c[i] = a[i] + b[i]; + } +// expected-error@+2 {{variable must be of integer or random access iterator type}} +#pragma omp target simd + 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 random access iterator type}} +#pragma omp target simd + for (double fi = 0; fi < 10.0; fi++) { + c[(int)fi] = a[(int)fi] + b[(int)fi]; + } +// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (int &ref = ii; ref < 10; ref++) { + } +// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (int i; i < 10; i++) + c[i] = a[i]; + +// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (int i = 0, j = 0; i < 10; ++i) + c[i] = a[i]; + +// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (; ii < 10; ++ii) + c[ii] = a[ii]; + +// expected-warning@+3 {{expression result unused}} +// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (ii + 1; ii < 10; ++ii) + c[ii] = a[ii]; + +// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (c[ii] = 0; ii < 10; ++ii) + c[ii] = a[ii]; + +// Ok to skip parenthesises. +#pragma omp target simd + for (((ii)) = 0; ii < 10; ++ii) + c[ii] = a[ii]; + +// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} +#pragma omp target simd + for (int i = 0; i; i++) + c[i] = a[i]; + +// expected-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} +// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}} +#pragma omp target simd + for (int i = 0; jj < kk; ii++) + c[i] = a[i]; + +// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} +#pragma omp target simd + for (int i = 0; !!i; i++) + c[i] = a[i]; + +// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} +#pragma omp target simd + for (int i = 0; i != 1; i++) + c[i] = a[i]; + +// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} +#pragma omp target simd + for (int i = 0;; i++) + c[i] = a[i]; + +// Ok. +#pragma omp target simd + for (int i = 11; i > 10; i--) + c[i] = a[i]; + +// Ok. +#pragma omp target simd + for (int i = 0; i < 10; ++i) + c[i] = a[i]; + +// Ok. +#pragma omp target simd + for (ii = 0; ii < 10; ++ii) + c[ii] = a[ii]; + +// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} +#pragma omp target simd + for (ii = 0; ii < 10; ++jj) + c[ii] = a[jj]; + +// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} +#pragma omp target simd + 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 simd + for (ii = 0; ii < 10; ii = ii + ii) + c[ii] = a[ii]; + +// expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'float'}} +#pragma omp target simd + for (ii = 0; ii < 10; ii = ii + 1.0f) + c[ii] = a[ii]; + +// Ok - step was converted to integer type. +#pragma omp target simd + for (ii = 0; ii < 10; ii = ii + (int)1.1f) + c[ii] = a[ii]; + +// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} +#pragma omp target simd + for (ii = 0; ii < 10; jj = ii + 2) + c[ii] = a[ii]; + +// expected-warning@+3 {{relational comparison result unused}} +// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} +#pragma omp target simd + for (ii = 0; ii<10; jj> kk + 2) + c[ii] = a[ii]; + +// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} +#pragma omp target simd + for (ii = 0; ii < 10;) + c[ii] = a[ii]; + +// expected-warning@+3 {{expression result unused}} +// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} +#pragma omp target simd + for (ii = 0; ii < 10; !ii) + c[ii] = a[ii]; + +// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} +#pragma omp target simd + for (ii = 0; ii < 10; ii ? ++ii : ++jj) + c[ii] = a[ii]; + +// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}} +#pragma omp target simd + for (ii = 0; ii < 10; ii = ii < 10) + c[ii] = a[ii]; + +// expected-note@+3 {{loop step is expected to be positive due to this condition}} +// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} +#pragma omp target simd + for (ii = 0; ii < 10; ii = ii + 0) + c[ii] = a[ii]; + +// expected-note@+3 {{loop step is expected to be positive due to this condition}} +// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} +#pragma omp target simd + for (ii = 0; ii < 10; ii = ii + (int)(0.8 - 0.45)) + c[ii] = a[ii]; + +// expected-note@+3 {{loop step is expected to be positive due to this condition}} +// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} +#pragma omp target simd + for (ii = 0; (ii) < 10; ii -= 25) + c[ii] = a[ii]; + +// expected-note@+3 {{loop step is expected to be positive due to this condition}} +// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} +#pragma omp target simd + for (ii = 0; (ii < 10); ii -= 0) + c[ii] = a[ii]; + +// expected-note@+3 {{loop step is expected to be negative due to this condition}} +// expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}} +#pragma omp target simd + for (ii = 0; ii > 10; (ii += 0)) + c[ii] = a[ii]; + +// expected-note@+3 {{loop step is expected to be positive due to this condition}} +// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} +#pragma omp target simd + for (ii = 0; ii < 10; (ii) = (1 - 1) + (ii)) + c[ii] = a[ii]; + +// expected-note@+3 {{loop step is expected to be negative due to this condition}} +// expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}} +#pragma omp target simd + for ((ii = 0); ii > 10; (ii -= 0)) + c[ii] = a[ii]; + +// expected-note@+3 {{loop step is expected to be positive due to this condition}} +// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}} +#pragma omp target simd + for (ii = 0; (ii < 10); (ii -= 0)) + c[ii] = a[ii]; + +// expected-note@+2 {{defined as firstprivate}} +// expected-error@+2 {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}} +#pragma omp target simd firstprivate(ii) + for (ii = 0; ii < 10; ii++) + c[ii] = a[ii]; + +#pragma omp target simd linear(ii) + for (ii = 0; ii < 10; ii++) + c[ii] = a[ii]; + +// expected-note@+2 {{defined as private}} +// expected-error@+2 {{loop iteration variable in the associated loop of 'omp target simd' directive may not be private, predetermined as linear}} +#pragma omp target simd private(ii) + for (ii = 0; ii < 10; ii++) + c[ii] = a[ii]; + +// expected-note@+2 {{defined as lastprivate}} +// expected-error@+2 {{loop iteration variable in the associated loop of 'omp target simd' directive may not be lastprivate, predetermined as linear}} +#pragma omp target simd lastprivate(ii) + for (ii = 0; ii < 10; ii++) + c[ii] = a[ii]; + + { +// expected-error@+2 {{loop iteration variable in the associated loop of 'omp target simd' directive may not be threadprivate or thread local, predetermined as linear}} +#pragma omp target simd + for (sii = 0; sii < 10; sii += 1) + c[sii] = a[sii]; + } + + { +#pragma omp target simd + for (globalii = 0; globalii < 10; globalii += 1) + c[globalii] = a[globalii]; + } + + { +#pragma omp target simd collapse(2) + for (ii = 0; ii < 10; ii += 1) + for (globalii = 0; globalii < 10; globalii += 1) + c[globalii] += a[globalii] + ii; + } + +// expected-error@+2 {{statement after '#pragma omp target simd' must be a for loop}} +#pragma omp target simd + for (auto &item : a) { + item = item + 1; + } + +// expected-note@+3 {{loop step is expected to be positive due to this condition}} +// expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}} +#pragma omp target simd + for (unsigned i = 9; i < 10; i--) { + c[i] = a[i] + b[i]; + } + + int(*lb)[4] = nullptr; +#pragma omp target simd + for (int(*p)[4] = lb; p < lb + 8; ++p) { + } + +// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + 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; } + 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 simd + for (GoodIter I = begin; I < end; ++I) + ++I; +// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (GoodIter &I = begin; I < end; ++I) + ++I; +#pragma omp target simd + for (GoodIter I = begin; I >= end; --I) + ++I; +// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (GoodIter I(begin); I < end; ++I) + ++I; +// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (GoodIter I(nullptr); I < end; ++I) + ++I; +// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (GoodIter I(0); I < end; ++I) + ++I; +// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (GoodIter I(1, 2); I < end; ++I) + ++I; +#pragma omp target simd + for (begin = GoodIter(0); begin < end; ++begin) + ++begin; +// expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}} +// expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}} +#pragma omp target simd + for (begin = begin0; begin < end; ++begin) + ++begin; +// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (++begin; begin < end; ++begin) + ++begin; +#pragma omp target simd + for (begin = end; begin < end; ++begin) + ++begin; +// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} +#pragma omp target simd + for (GoodIter I = begin; I - I; ++I) + ++I; +// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} +#pragma omp target simd + for (GoodIter I = begin; begin < end; ++I) + ++I; +// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} +#pragma omp target simd + for (GoodIter I = begin; !I; ++I) + ++I; +// expected-note@+3 {{loop step is expected to be negative due to this condition}} +// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} +#pragma omp target simd + for (GoodIter I = begin; I >= end; I = I + 1) + ++I; +#pragma omp target simd + for (GoodIter I = begin; I >= end; I = I - 1) + ++I; +// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}} +#pragma omp target simd + for (GoodIter I = begin; I >= end; I = -I) + ++I; +// expected-note@+3 {{loop step is expected to be negative due to this condition}} +// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} +#pragma omp target simd + for (GoodIter I = begin; I >= end; I = 2 + I) + ++I; +// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}} +#pragma omp target simd + for (GoodIter I = begin; I >= end; I = 2 - I) + ++I; +// expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}} +#pragma omp target simd + for (Iter0 I = begin0; I < end0; ++I) + ++I; +// Initializer is constructor without params. +// expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}} +// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (Iter0 I; I < end0; ++I) + ++I; + Iter1 begin1, end1; +// expected-error@+3 {{invalid operands to binary expression ('Iter1' and 'Iter1')}} +// expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}} +#pragma omp target simd + for (Iter1 I = begin1; I < end1; ++I) + ++I; +// expected-note@+3 {{loop step is expected to be negative due to this condition}} +// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} +#pragma omp target simd + for (Iter1 I = begin1; I >= end1; ++I) + ++I; +// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}} +// expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}} +// Initializer is constructor with all default params. +// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}} +#pragma omp target simd + for (Iter1 I; I < end1; ++I) { + } + return 0; +} + +template +class TC { +public: + int dotest_lt(IT begin, IT end) { +// expected-note@+3 {{loop step is expected to be positive due to this condition}} +// expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}} +#pragma omp target simd + for (IT I = begin; I < end; I = I + ST) { + ++I; + } +// expected-note@+3 {{loop step is expected to be positive due to this condition}} +// expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}} +#pragma omp target simd + for (IT I = begin; I <= end; I += ST) { + ++I; + } +#pragma omp target simd + for (IT I = begin; I < end; ++I) { + ++I; + } + } + + static IT step() { + return IT(ST); + } +}; +template +int dotest_gt(IT begin, IT end) { +// expected-note@+3 2 {{loop step is expected to be negative due to this condition}} +// expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} +#pragma omp target simd + for (IT I = begin; I >= end; I = I + ST) { + ++I; + } +// expected-note@+3 2 {{loop step is expected to be negative due to this condition}} +// expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} +#pragma omp target simd + for (IT I = begin; I >= end; I += ST) { + ++I; + } + +// expected-note@+3 {{loop step is expected to be negative due to this condition}} +// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}} +#pragma omp target simd + for (IT I = begin; I >= end; ++I) { + ++I; + } + +#pragma omp target simd + 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 simd + 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 simd + 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 simd + for (int i = 0; i < 10; i++) { + c[i] = a[i] + b[i]; + try { // expected-error {{'try' statement cannot be used in OpenMP simd region}} + for (int j = 0; j < 10; ++j) { + if (a[i] > b[j]) + throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}} + } + throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}} + } catch (float f) { + if (f > 0.1) + throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}} + 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]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}} + } + } + if (c[9] > 10) + throw c[9]; // OK + +#pragma omp target simd + for (int i = 0; i < 10; ++i) { + struct S { + void g() { throw 0; } + }; + } +} + +void test_loop_firstprivate_lastprivate() { + S s(4); +#pragma omp target simd lastprivate(s) firstprivate(s) + for (int i = 0; i < 16; ++i) + ; +} Index: cfe/trunk/test/OpenMP/target_simd_map_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_map_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_map_messages.cpp @@ -0,0 +1,273 @@ +// RUN: %clang_cc1 -verify -fopenmp %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 simd map // expected-error {{expected '(' after 'map'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map() // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd map(to:) // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd 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 simd map(x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(tofrom: t[:I]) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd map(T) // expected-error {{'T' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd map(S2::S2s) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(S2::S2sc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(to: x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(to: to) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(to) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(to, x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd map(argc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd map(ba) // expected-error 2 {{type 'S2' is not mappable to target}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(ca) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(da) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(S2::S2s) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(S2::S2sc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(e, g) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd 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 simd map(da) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd 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 simd map(j) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd 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 simd map(j) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(l) // OK + for (i = 0; i < argc; ++i) foo(); +} + +#pragma omp target simd map(always, tofrom: x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(always: x) // expected-error {{missing map type}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd map(always, tofrom: always, tofrom, x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd map // expected-error {{expected '(' after 'map'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map() // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd map(to:) // expected-error {{expected expression}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd 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 simd map(x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(to: x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(to: to) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(to) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(to, x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd map(argc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(S1) // expected-error {{'S1' does not refer to a value}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd map(argv[1]) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(ba) // expected-error 2 {{type 'S2' is not mappable to target}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(ca) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(da) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(S2::S2s) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(S2::S2sc) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(e, g) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd 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 simd map(da) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd 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 simd map(j) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 1 {{used here}} +{ +#pragma omp target simd 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 simd map(j) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(l) // + for (i = 0; i < argc; ++i) foo(); +} + +#pragma omp target simd map(always, tofrom: x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(always: x) // expected-error {{missing map type}} + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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 simd map(always, tofrom: always, tofrom, x) + for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd 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_simd_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_messages.cpp @@ -0,0 +1,92 @@ +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s + +void foo() { +} + +static int pvt; +#pragma omp threadprivate(pvt) + +#pragma omp target simd // expected-error {{unexpected OpenMP directive '#pragma omp target simd'}} + +int main(int argc, char **argv) { +#pragma omp target simd { // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target simd ( // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target simd[ // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target simd] // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target simd) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target simd } // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target simd + for (int i = 0; i < argc; ++i) + foo(); +// expected-warning@+1 {{extra tokens at the end of '#pragma omp target simd' are ignored}} +#pragma omp target simd unknown() + for (int i = 0; i < argc; ++i) + foo(); +L1: + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target simd + for (int i = 0; i < argc; ++i) + foo(); +#pragma omp target simd + 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 simd + 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 simd default(none) // expected-error {{unexpected OpenMP clause 'default' in directive '#pragma omp target simd'}} + for (int i = 0; i < 10; ++i) + ++argc; + + goto L2; // expected-error {{use of undeclared label 'L2'}} +#pragma omp target simd + for (int i = 0; i < argc; ++i) + L2: + foo(); +#pragma omp target simd + 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 simd + for (int n = 0; n < 100; ++n) { + } + +#pragma omp target simd copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp target simd'}} + for (int n = 0; n < 100; ++n) {} + + return 0; +} + +void test_ordered() { +#pragma omp target simd ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp target simd'}} + for (int i = 0; i < 16; ++i) + ; +} + Index: cfe/trunk/test/OpenMP/target_simd_misc_messages.c =================================================================== --- cfe/trunk/test/OpenMP/target_simd_misc_messages.c +++ cfe/trunk/test/OpenMP/target_simd_misc_messages.c @@ -0,0 +1,485 @@ +// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s + +// expected-error@+1 {{unexpected OpenMP directive '#pragma omp target simd'}} +#pragma omp target simd + +// expected-error@+1 {{unexpected OpenMP directive '#pragma omp target simd'}} +#pragma omp target simd foo + +void test_no_clause() { + int i; +#pragma omp target simd + for (i = 0; i < 16; ++i) + ; + +// expected-error@+2 {{statement after '#pragma omp target simd' must be a for loop}} +#pragma omp target simd + ++i; +} + +void test_branch_protected_scope() { + int i = 0; +L1: + ++i; + + int x[24]; + +#pragma omp target simd + 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 simd' are ignored}} +#pragma omp target simd 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 simd' are ignored}} +#pragma omp target simd; + for (i = 0; i < 16; ++i) + ; + +// expected-warning@+1 {{extra tokens at the end of '#pragma omp target simd' are ignored}} +#pragma omp target simd private(x); + for (i = 0; i < 16; ++i) + ; + +// expected-warning@+1 {{extra tokens at the end of '#pragma omp target simd' are ignored}} +#pragma omp target simd, private(x); + for (i = 0; i < 16; ++i) + ; +} + +extern int foo(); + +void test_collapse() { + int i; +// expected-error@+1 {{expected '('}} +#pragma omp target simd 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 simd collapse( + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target simd 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 simd 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 simd collapse(, ) + for (i = 0; i < 16; ++i) + ; +// expected-warning@+2 {{extra tokens at the end of '#pragma omp target simd' are ignored}} +// expected-error@+1 {{expected '('}} +#pragma omp target simd 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 simd collapse(4 + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target simd', 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 simd collapse(4, + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target simd', 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 simd collapse(4, ) + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target simd', but found only 1}} +// expected-note@+1 {{as specified in 'collapse' clause}} +#pragma omp target simd collapse(4) + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target simd', 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 simd collapse(4 4) + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target simd', 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 simd collapse(4, , 4) + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target simd', but found only 1}} +#pragma omp target simd 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 simd collapse(4, 8) + for (i = 0; i < 16; ++i) + ; // expected-error {{expected 4 for loops after '#pragma omp target simd', but found only 1}} +// expected-error@+1 {{expression is not an integer constant expression}} +#pragma omp target simd collapse(2.5) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expression is not an integer constant expression}} +#pragma omp target simd 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 simd 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 simd 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 simd collapse(5 - 5) + for (i = 0; i < 16; ++i) + ; +} + +void test_private() { + int i; +// expected-error@+2 {{expected expression}} +// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} +#pragma omp target simd 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 simd private(, + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 2 {{expected expression}} +#pragma omp target simd private(, ) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target simd private() + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target simd private(int) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected variable name}} +#pragma omp target simd private(0) + for (i = 0; i < 16; ++i) + ; + + int x, y, z; +#pragma omp target simd private(x) + for (i = 0; i < 16; ++i) + ; +#pragma omp target simd private(x, y) + for (i = 0; i < 16; ++i) + ; +#pragma omp target simd 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 simd 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 simd lastprivate(, + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 2 {{expected expression}} +#pragma omp target simd lastprivate(, ) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target simd lastprivate() + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target simd lastprivate(int) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected variable name}} +#pragma omp target simd lastprivate(0) + for (i = 0; i < 16; ++i) + ; + + int x, y, z; +#pragma omp target simd lastprivate(x) + for (i = 0; i < 16; ++i) + ; +#pragma omp target simd lastprivate(x, y) + for (i = 0; i < 16; ++i) + ; +#pragma omp target simd 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 simd 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 simd firstprivate(, + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 2 {{expected expression}} +#pragma omp target simd firstprivate(, ) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target simd firstprivate() + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target simd firstprivate(int) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected variable name}} +#pragma omp target simd firstprivate(0) + for (i = 0; i < 16; ++i) + ; + + int x, y, z; +#pragma omp target simd lastprivate(x) firstprivate(x) + for (i = 0; i < 16; ++i) + ; +#pragma omp target simd lastprivate(x, y) firstprivate(x, y) + for (i = 0; i < 16; ++i) + ; +#pragma omp target simd 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 simd + 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 simd + for (double fi = 0; fi < 10.0; fi++) { + c[(int)fi] = a[(int)fi] + b[(int)fi]; + } +} + +void test_safelen() { + int i; +// expected-error@+1 {{expected '('}} +#pragma omp target simd safelen + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} +#pragma omp target simd safelen( + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target simd safelen() + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} +#pragma omp target simd safelen(, + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} +#pragma omp target simd safelen(, ) + for (i = 0; i < 16; ++i) + ; +// expected-warning@+2 {{extra tokens at the end of '#pragma omp target simd' are ignored}} +// expected-error@+1 {{expected '('}} +#pragma omp target simd safelen 4) + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} +#pragma omp target simd safelen(4 + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} +#pragma omp target simd safelen(4, + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} +#pragma omp target simd safelen(4, ) + for (i = 0; i < 16; ++i) + ; +#pragma omp target simd safelen(4) + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} +#pragma omp target simd safelen(4 4) + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} +#pragma omp target simd safelen(4, , 4) + for (i = 0; i < 16; ++i) + ; +#pragma omp target simd safelen(4) + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} +#pragma omp target simd safelen(4, 8) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expression is not an integer constant expression}} +#pragma omp target simd safelen(2.5) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expression is not an integer constant expression}} +#pragma omp target simd safelen(foo()) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}} +#pragma omp target simd safelen(-5) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}} +#pragma omp target simd safelen(0) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}} +#pragma omp target simd safelen(5 - 5) + for (i = 0; i < 16; ++i) + ; +} + +void test_simdlen() { + int i; +// expected-error@+1 {{expected '('}} +#pragma omp target simd simdlen + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} +#pragma omp target simd simdlen( + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} +#pragma omp target simd simdlen() + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} +#pragma omp target simd simdlen(, + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} +#pragma omp target simd simdlen(, ) + for (i = 0; i < 16; ++i) + ; +// expected-warning@+2 {{extra tokens at the end of '#pragma omp target simd' are ignored}} +// expected-error@+1 {{expected '('}} +#pragma omp target simd simdlen 4) + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} +#pragma omp target simd simdlen(4 + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} +#pragma omp target simd simdlen(4, + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} +#pragma omp target simd simdlen(4, ) + for (i = 0; i < 16; ++i) + ; +#pragma omp target simd simdlen(4) + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} +#pragma omp target simd simdlen(4 4) + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} +#pragma omp target simd simdlen(4, , 4) + for (i = 0; i < 16; ++i) + ; +#pragma omp target simd simdlen(4) + for (i = 0; i < 16; ++i) + ; +// expected-error@+2 {{expected ')'}} +// expected-note@+1 {{to match this '('}} +#pragma omp target simd simdlen(4, 8) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expression is not an integer constant expression}} +#pragma omp target simd simdlen(2.5) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{expression is not an integer constant expression}} +#pragma omp target simd simdlen(foo()) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}} +#pragma omp target simd simdlen(-5) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}} +#pragma omp target simd simdlen(0) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}} +#pragma omp target simd simdlen(5 - 5) + for (i = 0; i < 16; ++i) + ; +} + +void test_safelen_simdlen() { + int i; +// expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}} +#pragma omp target simd simdlen(6) safelen(5) + for (i = 0; i < 16; ++i) + ; +// expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}} +#pragma omp target simd safelen(5) simdlen(6) + for (i = 0; i < 16; ++i) + ; +} Index: cfe/trunk/test/OpenMP/target_simd_nowait_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_nowait_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_nowait_messages.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +int main(int argc, char **argv) { + int i; + #pragma omp target simd nowait( // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd nowait (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd nowait device (-10u) + for (i = 0; i < argc; ++i) foo(); + #pragma omp target simd nowait (3.14) device (-10u) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (i = 0; i < argc; ++i) foo(); + + return 0; +} Index: cfe/trunk/test/OpenMP/target_simd_private_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_private_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_private_messages.cpp @@ -0,0 +1,231 @@ +// 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) {} +}; +const S2 b; +const S2 ba[5]; +class S3 { + int a; + +public: + S3() : a(0) {} +}; +const S3 ca[5]; +class S4 { + int a; + S4(); // expected-note {{implicitly declared private here}} + +public: + S4(int v) : a(v) { +#pragma omp target simd private(a) private(this->a) + for (int k = 0; k < v; ++k) + ++this->a; + } +}; +class S5 { + int a; + S5() : a(0) {} // expected-note {{implicitly declared private here}} + +public: + S5(int v) : a(v) {} + S5 &operator=(S5 &s) { +#pragma omp target simd private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}} + for (int k = 0; k < s.a; ++k) + ++s.a; + return *this; + } +}; + +template +class S6 { +public: + T a; + + S6() : a(0) {} + S6(T v) : a(v) { +#pragma omp target simd private(a) private(this->a) + for (int k = 0; k < v; ++k) + ++this->a; + } + S6 &operator=(S6 &s) { +#pragma omp target simd private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}} + for (int k = 0; k < s.a; ++k) + ++s.a; + return *this; + } +}; + +template +class S7 : public T { + T a; + S7() : a(0) {} + +public: + S7(T v) : a(v) { +#pragma omp target simd 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 simd private(a) private(this->a) private(s.a) private(s.T::a) // expected-error 2 {{expected variable name or data member of current class}} + for (int k = 0; k < s.a.a; ++k) + ++s.a.a; + return *this; + } +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} + +template +int foomain(I argc, C **argv) { + I e(4); + I g(5); + int i; + int &j = i; +#pragma omp target simd private // expected-error {{expected '(' after 'private'}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private() // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd 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 simd private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(argc) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(a, b) // expected-error {{private variable with incomplete type 'S1'}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(e, g) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp parallel + { + int v = 0; + int i; +#pragma omp target simd private(i) + for (int k = 0; k < argc; ++k) { + i = k; + v += i; + } + } +#pragma omp parallel shared(i) +#pragma omp parallel private(i) +#pragma omp target simd private(j) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(i) + for (int k = 0; k < argc; ++k) + ++k; + return 0; +} + +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) { + S4 e(4); + S5 g(5); + S6 s6(0.0) , s6_0(1.0); + S7 > s7(0.0) , s7_0(1.0); + int i; + int &j = i; +#pragma omp target simd private // expected-error {{expected '(' after 'private'}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private() // expected-error {{expected expression}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd 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 simd private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(argc) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(S1) // expected-error {{'S1' does not refer to a value}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(a, b) // expected-error {{private variable with incomplete type 'S1'}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(argv[1]) // expected-error {{expected variable name}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd 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 simd private(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}} + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp parallel + { + int i; +#pragma omp target simd private(i) + for (int k = 0; k < argc; ++k) + ++k; + } +#pragma omp parallel shared(i) +#pragma omp parallel private(i) +#pragma omp target simd private(j) + for (int k = 0; k < argc; ++k) + ++k; +#pragma omp target simd private(i) + for (int k = 0; k < argc; ++k) + ++k; + static int m; +#pragma omp target simd private(m) + for (int k = 0; k < argc; ++k) + m = k + 2; + + s6 = s6_0; // expected-note {{in instantiation of member function 'S6::operator=' requested here}} + s7 = s7_0; // expected-note {{in instantiation of member function 'S7 >::operator=' requested here}} + return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}} +} + Index: cfe/trunk/test/OpenMP/target_simd_reduction_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_reduction_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_reduction_messages.cpp @@ -0,0 +1,313 @@ +// 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; +} + +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 simd reduction // expected-error {{expected '(' after 'reduction'}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd 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 i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd 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 i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(&& : argc) + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(^ : T) // expected-error {{'T' does not refer to a value}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd 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 i = 0; i < 10; ++i) + foo(); +#pragma omp target simd 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 i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(+ : o) // expected-error 2 {{no viable overloaded '='}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp parallel private(k) +#pragma omp target simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp parallel shared(i) +#pragma omp parallel reduction(min : i) +#pragma omp target simd reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp parallel private(fl) +#pragma omp target simd reduction(+ : fl) + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp parallel reduction(* : fl) +#pragma omp target simd reduction(+ : fl) + for (int i = 0; i < 10; ++i) + 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 simd reduction // expected-error {{expected '(' after 'reduction'}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(~ : argc) // expected-error {{expected unqualified-id}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(&& : argc) + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(^ : S1) // expected-error {{'S1' does not refer to a value}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd 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 i = 0; i < 10; ++i) + foo(); +#pragma omp target simd 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 i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd 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 i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(+ : o) // expected-error {{no viable overloaded '='}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp parallel private(k) +#pragma omp target simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp target simd reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp parallel shared(i) +#pragma omp parallel reduction(min : i) +#pragma omp target simd reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp parallel private(fl) +#pragma omp target simd reduction(+ : fl) + for (int i = 0; i < 10; ++i) + foo(); +#pragma omp parallel reduction(* : fl) +#pragma omp target simd reduction(+ : fl) + for (int i = 0; i < 10; ++i) + foo(); + static int m; +#pragma omp target simd reduction(+ : m) // OK + for (int i = 0; i < 10; ++i) + m++; + + 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_simd_safelen_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_safelen_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_safelen_messages.cpp @@ -0,0 +1,102 @@ +// 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() { +} + +#if __cplusplus >= 201103L +// expected-note@+2 4 {{declared here}} +#endif +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 simd safelen // expected-error {{expected '(' after 'safelen'}} + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + #pragma omp target simd safelen ( // 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 simd safelen () // 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 simd safelen (argc + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + // expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}} + #pragma omp target simd safelen (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 simd safelen (1)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + #pragma omp target simd safelen ((ST > 0) ? 1 + ST : 2) + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + // expected-error@+6 2 {{directive '#pragma omp target simd' cannot contain more than one 'safelen' clause}} + // expected-error@+5 2 {{argument to 'safelen' clause must be a strictly positive integer value}} + // expected-error@+4 2 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-note@+2 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif + #pragma omp target simd safelen (foobool(argc)), safelen (true), safelen (-5) + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + #pragma omp target simd safelen (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]; +#if __cplusplus <= 199711L + // expected-error@+4 2 {{expression is not an integral constant expression}} +#else + // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#endif + #pragma omp target simd safelen (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 simd safelen (4) + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + #pragma omp target simd safelen (N) // expected-error {{argument to 'safelen' 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]; + return argc; +} + +int main(int argc, char **argv) { + #pragma omp target simd safelen // expected-error {{expected '(' after 'safelen'}} + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + #pragma omp target simd safelen ( // 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 simd safelen () // expected-error {{expected expression}} + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + #pragma omp target simd safelen (4 // 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 simd safelen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + // expected-error@+4 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif + #pragma omp target simd safelen (foobool(1) > 0 ? 1 : 2) + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + // expected-error@+6 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-note@+4 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif + // expected-error@+2 2 {{directive '#pragma omp target simd' cannot contain more than one 'safelen' clause}} + // expected-error@+1 2 {{argument to 'safelen' clause must be a strictly positive integer value}} + #pragma omp target simd safelen (foobool(argc)), safelen (true), safelen (-5) + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + #pragma omp target simd safelen (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]; +#if __cplusplus <= 199711L + // expected-error@+4 {{expression is not an integral constant expression}} +#else + // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#endif + #pragma omp target simd safelen (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 simd' must be a for loop}} + // expected-note@+1 {{in instantiation of function template specialization 'tmain' requested here}} + #pragma omp target simd safelen(safelen(tmain(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} + foo(); + // expected-note@+1 {{in instantiation of function template specialization 'tmain' requested here}} + return tmain(argc, argv); +} + Index: cfe/trunk/test/OpenMP/target_simd_simdlen_messages.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_simdlen_messages.cpp +++ cfe/trunk/test/OpenMP/target_simd_simdlen_messages.cpp @@ -0,0 +1,142 @@ +// 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() { +} + +#if __cplusplus >= 201103L +// expected-note@+2 4 {{declared here}} +#endif +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 simd simdlen // expected-error {{expected '(' after 'simdlen'}} + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target simd simdlen ( // 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 simd simdlen () // 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 simd simdlen (argc + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + +// expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}} +#pragma omp target simd simdlen (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 simd simdlen (1)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target simd simdlen ((ST > 0) ? 1 + ST : 2) + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + + // expected-error@+6 2 {{directive '#pragma omp target simd' cannot contain more than one 'simdlen' clause}} + // expected-error@+5 2 {{argument to 'simdlen' clause must be a strictly positive integer value}} + // expected-error@+4 2 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-note@+2 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif +#pragma omp target simd simdlen (foobool(argc)), simdlen (true), simdlen (-5) + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target simd simdlen (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]; + +#if __cplusplus <= 199711L + // expected-error@+4 2 {{expression is not an integral constant expression}} +#else + // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#endif +#pragma omp target simd simdlen (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 simd simdlen (4) + for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + + #pragma omp target simd simdlen (N) // expected-error {{argument to 'simdlen' 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 simd simdlen (2), safelen (4) // OK + for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target simd simdlen (4), safelen (4) // OK + for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + +#pragma omp target simd simdlen (8), safelen (4) // expected-error{{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}} + for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; + + return argc; +} + +int main(int argc, char **argv) { +#pragma omp target simd simdlen // expected-error {{expected '(' after 'simdlen'}} + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target simd simdlen ( // 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 simd simdlen () // expected-error {{expected expression}} + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target simd simdlen (4 // 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 simd simdlen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + + // expected-error@+4 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif +#pragma omp target simd simdlen (foobool(1) > 0 ? 1 : 2) + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + + // expected-error@+6 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-note@+4 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif +// expected-error@+2 2 {{directive '#pragma omp target simd' cannot contain more than one 'simdlen' clause}} +// expected-error@+1 2 {{argument to 'simdlen' clause must be a strictly positive integer value}} +#pragma omp target simd simdlen (foobool(argc)), simdlen (true), simdlen (-5) + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target simd simdlen (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]; + +#if __cplusplus <= 199711L + // expected-error@+4 {{expression is not an integral constant expression}} +#else + // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#endif +#pragma omp target simd simdlen (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 simd' must be a for loop}} +// expected-note@+1 {{in instantiation of function template specialization 'tmain' requested here}} +#pragma omp target simd simdlen(simdlen(tmain(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} + foo(); + +#pragma omp target simd simdlen (2), safelen (4) // OK + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target simd simdlen (4), safelen (4) // OK + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + +#pragma omp target simd simdlen (8), safelen (4) // expected-error{{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}} + for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; + + // expected-note@+1 {{in instantiation of function template specialization 'tmain' requested here}} + return tmain(argc, argv); +} + Index: cfe/trunk/tools/libclang/CIndex.cpp =================================================================== --- cfe/trunk/tools/libclang/CIndex.cpp +++ cfe/trunk/tools/libclang/CIndex.cpp @@ -1976,6 +1976,7 @@ void VisitOMPDistributeSimdDirective(const OMPDistributeSimdDirective *D); void VisitOMPTargetParallelForSimdDirective( const OMPTargetParallelForSimdDirective *D); + void VisitOMPTargetSimdDirective(const OMPTargetSimdDirective *D); private: void AddDeclarationNameInfo(const Stmt *S); @@ -2755,6 +2756,11 @@ VisitOMPLoopDirective(D); } +void EnqueueVisitor::VisitOMPTargetSimdDirective( + const OMPTargetSimdDirective *D) { + VisitOMPLoopDirective(D); +} + void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, const Stmt *S) { EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S); } @@ -4879,6 +4885,8 @@ return cxstring::createRef("OMPDistributeSimdDirective"); case CXCursor_OMPTargetParallelForSimdDirective: return cxstring::createRef("OMPTargetParallelForSimdDirective"); + case CXCursor_OMPTargetSimdDirective: + return cxstring::createRef("OMPTargetSimdDirective"); 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 @@ -650,6 +650,9 @@ case Stmt::OMPTargetParallelForSimdDirectiveClass: K = CXCursor_OMPTargetParallelForSimdDirective; break; + case Stmt::OMPTargetSimdDirectiveClass: + K = CXCursor_OMPTargetSimdDirective; + break; } CXCursor C = { K, 0, { Parent, S, TU } };