Index: include/clang-c/Index.h =================================================================== --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -2282,7 +2282,11 @@ */ CXCursor_OMPTargetExitDataDirective = 262, - CXCursor_LastStmt = CXCursor_OMPTargetExitDataDirective, + /** \brief OpenMP target parallel directive. + */ + CXCursor_OMPTargetParallelDirective = 263, + + CXCursor_LastStmt = CXCursor_OMPTargetParallelDirective, /** * \brief Cursor that represents the translation unit itself. Index: include/clang/AST/RecursiveASTVisitor.h =================================================================== --- include/clang/AST/RecursiveASTVisitor.h +++ include/clang/AST/RecursiveASTVisitor.h @@ -2439,6 +2439,9 @@ DEF_TRAVERSE_STMT(OMPTargetExitDataDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPTargetParallelDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + DEF_TRAVERSE_STMT(OMPTeamsDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) Index: include/clang/AST/StmtOpenMP.h =================================================================== --- include/clang/AST/StmtOpenMP.h +++ include/clang/AST/StmtOpenMP.h @@ -2158,6 +2158,65 @@ } }; +/// \brief This represents '#pragma omp target parallel' directive. +/// +/// \code +/// #pragma omp target parallel if(a) +/// \endcode +/// In this example directive '#pragma omp target parallel' has clause 'if' with +/// condition 'a'. +/// +class OMPTargetParallelDirective : public OMPExecutableDirective { + friend class ASTStmtReader; + /// \brief 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 NumClauses Number of clauses. + /// + OMPTargetParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc, + unsigned NumClauses) + : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass, + OMPD_target_parallel, StartLoc, EndLoc, + NumClauses, /*NumChildren=*/1) {} + + /// \brief Build an empty directive. + /// + /// \param NumClauses Number of clauses. + /// + explicit OMPTargetParallelDirective(unsigned NumClauses) + : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass, + OMPD_target_parallel, SourceLocation(), + SourceLocation(), NumClauses, + /*NumChildren=*/1) {} + +public: + /// \brief 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 Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// + static OMPTargetParallelDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + ArrayRef Clauses, Stmt *AssociatedStmt); + + /// \brief Creates an empty directive with the place for \a NumClauses + /// clauses. + /// + /// \param C AST context. + /// \param NumClauses Number of clauses. + /// + static OMPTargetParallelDirective * + CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTargetParallelDirectiveClass; + } +}; + /// \brief This represents '#pragma omp teams' directive. /// /// \code Index: include/clang/Basic/OpenMPKinds.def =================================================================== --- include/clang/Basic/OpenMPKinds.def +++ include/clang/Basic/OpenMPKinds.def @@ -66,6 +66,9 @@ #ifndef OPENMP_TARGET_EXIT_DATA_CLAUSE #define OPENMP_TARGET_EXIT_DATA_CLAUSE(Name) #endif +#ifndef OPENMP_TARGET_PARALLEL_CLAUSE +# define OPENMP_TARGET_PARALLEL_CLAUSE(Name) +#endif #ifndef OPENMP_TEAMS_CLAUSE # define OPENMP_TEAMS_CLAUSE(Name) #endif @@ -142,6 +145,7 @@ OPENMP_DIRECTIVE_EXT(target_data, "target data") OPENMP_DIRECTIVE_EXT(target_enter_data, "target enter data") OPENMP_DIRECTIVE_EXT(target_exit_data, "target exit data") +OPENMP_DIRECTIVE_EXT(target_parallel, "target parallel") OPENMP_DIRECTIVE_EXT(parallel_for, "parallel for") OPENMP_DIRECTIVE_EXT(parallel_for_simd, "parallel for simd") OPENMP_DIRECTIVE_EXT(parallel_sections, "parallel sections") @@ -392,6 +396,22 @@ OPENMP_TARGET_EXIT_DATA_CLAUSE(nowait) OPENMP_TARGET_EXIT_DATA_CLAUSE(depend) +// Clauses allowed for OpenMP directive 'target parallel'. +// TODO: add target clauses 'is_device_ptr' +OPENMP_TARGET_PARALLEL_CLAUSE(if) +OPENMP_TARGET_PARALLEL_CLAUSE(device) +OPENMP_TARGET_PARALLEL_CLAUSE(map) +OPENMP_TARGET_PARALLEL_CLAUSE(private) +OPENMP_TARGET_PARALLEL_CLAUSE(firstprivate) +OPENMP_TARGET_PARALLEL_CLAUSE(nowait) +OPENMP_TARGET_PARALLEL_CLAUSE(depend) +OPENMP_TARGET_PARALLEL_CLAUSE(defaultmap) +OPENMP_TARGET_PARALLEL_CLAUSE(num_threads) +OPENMP_TARGET_PARALLEL_CLAUSE(default) +OPENMP_TARGET_PARALLEL_CLAUSE(proc_bind) +OPENMP_TARGET_PARALLEL_CLAUSE(shared) +OPENMP_TARGET_PARALLEL_CLAUSE(reduction) + // Clauses allowed for OpenMP directive 'teams'. // TODO More clauses for 'teams' directive. OPENMP_TEAMS_CLAUSE(default) @@ -492,6 +512,7 @@ #undef OPENMP_TARGET_DATA_CLAUSE #undef OPENMP_TARGET_ENTER_DATA_CLAUSE #undef OPENMP_TARGET_EXIT_DATA_CLAUSE +#undef OPENMP_TARGET_PARALLEL_CLAUSE #undef OPENMP_TEAMS_CLAUSE #undef OPENMP_SIMD_CLAUSE #undef OPENMP_FOR_CLAUSE Index: include/clang/Basic/StmtNodes.td =================================================================== --- include/clang/Basic/StmtNodes.td +++ include/clang/Basic/StmtNodes.td @@ -218,6 +218,7 @@ def OMPTargetDataDirective : DStmt; def OMPTargetEnterDataDirective : DStmt; def OMPTargetExitDataDirective : DStmt; +def OMPTargetParallelDirective : DStmt; def OMPTeamsDirective : DStmt; def OMPCancellationPointDirective : DStmt; def OMPCancelDirective : DStmt; Index: include/clang/Sema/Sema.h =================================================================== --- include/clang/Sema/Sema.h +++ include/clang/Sema/Sema.h @@ -7960,6 +7960,12 @@ StmtResult ActOnOpenMPTargetExitDataDirective(ArrayRef Clauses, SourceLocation StartLoc, SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp target parallel' after + /// parsing of the associated statement. + StmtResult ActOnOpenMPTargetParallelDirective(ArrayRef Clauses, + Stmt *AStmt, + SourceLocation StartLoc, + SourceLocation EndLoc); /// \brief Called on well-formed '\#pragma omp teams' after parsing of the /// associated statement. StmtResult ActOnOpenMPTeamsDirective(ArrayRef Clauses, Index: include/clang/Serialization/ASTBitCodes.h =================================================================== --- include/clang/Serialization/ASTBitCodes.h +++ include/clang/Serialization/ASTBitCodes.h @@ -1447,6 +1447,7 @@ STMT_OMP_TARGET_DATA_DIRECTIVE, STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE, STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE, + STMT_OMP_TARGET_PARALLEL_DIRECTIVE, STMT_OMP_TEAMS_DIRECTIVE, STMT_OMP_TASKGROUP_DIRECTIVE, STMT_OMP_CANCELLATION_POINT_DIRECTIVE, Index: lib/AST/StmtOpenMP.cpp =================================================================== --- lib/AST/StmtOpenMP.cpp +++ lib/AST/StmtOpenMP.cpp @@ -694,6 +694,30 @@ return new (Mem) OMPTargetDirective(NumClauses); } +OMPTargetParallelDirective *OMPTargetParallelDirective::Create( + const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + ArrayRef Clauses, Stmt *AssociatedStmt) { + unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelDirective), + llvm::alignOf()); + void *Mem = + C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); + OMPTargetParallelDirective *Dir = + new (Mem) OMPTargetParallelDirective(StartLoc, EndLoc, Clauses.size()); + Dir->setClauses(Clauses); + Dir->setAssociatedStmt(AssociatedStmt); + return Dir; +} + +OMPTargetParallelDirective * +OMPTargetParallelDirective::CreateEmpty(const ASTContext &C, + unsigned NumClauses, EmptyShell) { + unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelDirective), + llvm::alignOf()); + void *Mem = + C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); + return new (Mem) OMPTargetParallelDirective(NumClauses); +} + OMPTargetDataDirective *OMPTargetDataDirective::Create( const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef Clauses, Stmt *AssociatedStmt) { Index: lib/AST/StmtPrinter.cpp =================================================================== --- lib/AST/StmtPrinter.cpp +++ lib/AST/StmtPrinter.cpp @@ -1083,6 +1083,12 @@ PrintOMPExecutableDirective(Node); } +void StmtPrinter::VisitOMPTargetParallelDirective( + OMPTargetParallelDirective *Node) { + Indent() << "#pragma omp target parallel "; + PrintOMPExecutableDirective(Node); +} + void StmtPrinter::VisitOMPTeamsDirective(OMPTeamsDirective *Node) { Indent() << "#pragma omp teams "; PrintOMPExecutableDirective(Node); Index: lib/AST/StmtProfile.cpp =================================================================== --- lib/AST/StmtProfile.cpp +++ lib/AST/StmtProfile.cpp @@ -594,6 +594,11 @@ VisitOMPExecutableDirective(S); } +void StmtProfiler::VisitOMPTargetParallelDirective( + const OMPTargetParallelDirective *S) { + VisitOMPExecutableDirective(S); +} + void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) { VisitOMPExecutableDirective(S); } Index: lib/Basic/OpenMPKinds.cpp =================================================================== --- lib/Basic/OpenMPKinds.cpp +++ lib/Basic/OpenMPKinds.cpp @@ -455,6 +455,16 @@ break; } break; + case OMPD_target_parallel: + switch (CKind) { +#define OPENMP_TARGET_PARALLEL_CLAUSE(Name) \ + case OMPC_##Name: \ + return true; +#include "clang/Basic/OpenMPKinds.def" + default: + break; + } + break; case OMPD_teams: switch (CKind) { #define OPENMP_TEAMS_CLAUSE(Name) \ @@ -562,7 +572,8 @@ bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) { return DKind == OMPD_parallel || DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd || - DKind == OMPD_parallel_sections; // TODO add next directives. + DKind == OMPD_parallel_sections || DKind == OMPD_target_parallel; + // TODO add next directives. } bool clang::isOpenMPTargetDirective(OpenMPDirectiveKind DKind) { Index: lib/CodeGen/CGStmt.cpp =================================================================== --- lib/CodeGen/CGStmt.cpp +++ lib/CodeGen/CGStmt.cpp @@ -262,6 +262,9 @@ case Stmt::OMPTargetExitDataDirectiveClass: EmitOMPTargetExitDataDirective(cast(*S)); break; + case Stmt::OMPTargetParallelDirectiveClass: + EmitOMPTargetParallelDirective(cast(*S)); + break; case Stmt::OMPTaskLoopDirectiveClass: EmitOMPTaskLoopDirective(cast(*S)); break; Index: lib/CodeGen/CGStmtOpenMP.cpp =================================================================== --- lib/CodeGen/CGStmtOpenMP.cpp +++ lib/CodeGen/CGStmtOpenMP.cpp @@ -2672,6 +2672,11 @@ // TODO: codegen for target exit data. } +void CodeGenFunction::EmitOMPTargetParallelDirective( + const OMPTargetParallelDirective &S) { + // TODO: codegen for target parallel. +} + void CodeGenFunction::EmitOMPTaskLoopDirective(const OMPTaskLoopDirective &S) { // emit the code inside the construct for now auto CS = cast(S.getAssociatedStmt()); Index: lib/CodeGen/CodeGenFunction.h =================================================================== --- lib/CodeGen/CodeGenFunction.h +++ lib/CodeGen/CodeGenFunction.h @@ -2338,6 +2338,7 @@ void EmitOMPTargetDataDirective(const OMPTargetDataDirective &S); void EmitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective &S); void EmitOMPTargetExitDataDirective(const OMPTargetExitDataDirective &S); + void EmitOMPTargetParallelDirective(const OMPTargetParallelDirective &S); void EmitOMPTeamsDirective(const OMPTeamsDirective &S); void EmitOMPCancellationPointDirective(const OMPCancellationPointDirective &S); Index: lib/Parse/ParseOpenMP.cpp =================================================================== --- lib/Parse/ParseOpenMP.cpp +++ lib/Parse/ParseOpenMP.cpp @@ -44,7 +44,8 @@ {OMPD_parallel, OMPD_for, OMPD_parallel_for}, {OMPD_parallel_for, OMPD_simd, OMPD_parallel_for_simd}, {OMPD_parallel, OMPD_sections, OMPD_parallel_sections}, - {OMPD_taskloop, OMPD_simd, OMPD_taskloop_simd}}; + {OMPD_taskloop, OMPD_simd, OMPD_taskloop_simd}, + {OMPD_target, OMPD_parallel, OMPD_target_parallel}}; auto Tok = P.getCurToken(); auto DKind = Tok.isAnnotation() @@ -153,6 +154,7 @@ case OMPD_target_data: case OMPD_target_enter_data: case OMPD_target_exit_data: + case OMPD_target_parallel: case OMPD_taskloop: case OMPD_taskloop_simd: case OMPD_distribute: @@ -177,7 +179,8 @@ /// 'barrier' | 'taskwait' | 'flush' | 'ordered' | 'atomic' | /// 'for simd' | 'parallel for simd' | 'target' | 'target data' | /// 'taskgroup' | 'teams' | 'taskloop' | 'taskloop simd' {clause} | -/// 'distribute' | 'target enter data' | 'target exit data' +/// 'distribute' | 'target enter data' | 'target exit data' | +/// 'target parallel' /// annot_pragma_openmp_end /// StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( @@ -259,6 +262,7 @@ case OMPD_teams: case OMPD_taskgroup: case OMPD_target_data: + case OMPD_target_parallel: case OMPD_taskloop: case OMPD_taskloop_simd: case OMPD_distribute: { Index: lib/Sema/SemaOpenMP.cpp =================================================================== --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -1550,7 +1550,8 @@ break; } case OMPD_target_data: - case OMPD_target: { + case OMPD_target: + case OMPD_target_parallel: { Sema::CapturedParamNameType Params[] = { std::make_pair(StringRef(), QualType()) // __context with shared vars }; @@ -1726,6 +1727,7 @@ // | parallel | ordered | + | // | parallel | atomic | * | // | parallel | target | * | + // | parallel | target parallel | * | // | parallel | target enter | * | // | | data | | // | parallel | target exit | * | @@ -1759,6 +1761,7 @@ // | for | ordered | * (if construct is ordered) | // | for | atomic | * | // | for | target | * | + // | for | target parallel | * | // | for | target enter | * | // | | data | | // | for | target exit | * | @@ -1792,6 +1795,7 @@ // | master | ordered | + | // | master | atomic | * | // | master | target | * | + // | master | target parallel | * | // | master | target enter | * | // | | data | | // | master | target exit | * | @@ -1824,6 +1828,7 @@ // | critical | ordered | + | // | critical | atomic | * | // | critical | target | * | + // | critical | target parallel | * | // | critical | target enter | * | // | | data | | // | critical | target exit | * | @@ -1857,6 +1862,7 @@ // | simd | ordered | + (with simd clause) | // | simd | atomic | | // | simd | target | | + // | simd | target parallel | | // | simd | target enter | | // | | data | | // | simd | target exit | | @@ -1890,6 +1896,7 @@ // | for simd | ordered | + (with simd clause) | // | for simd | atomic | | // | for simd | target | | + // | for simd | target parallel | | // | for simd | target enter | | // | | data | | // | for simd | target exit | | @@ -1923,6 +1930,7 @@ // | parallel for simd| ordered | + (with simd clause) | // | parallel for simd| atomic | | // | parallel for simd| target | | + // | parallel for simd| target parallel | | // | parallel for simd| target enter | | // | | data | | // | parallel for simd| target exit | | @@ -1956,6 +1964,7 @@ // | sections | ordered | + | // | sections | atomic | * | // | sections | target | * | + // | sections | target parallel | * | // | sections | target enter | * | // | | data | | // | sections | target exit | * | @@ -1989,6 +1998,7 @@ // | section | ordered | + | // | section | atomic | * | // | section | target | * | + // | section | target parallel | * | // | section | target enter | * | // | | data | | // | section | target exit | * | @@ -2022,6 +2032,7 @@ // | single | ordered | + | // | single | atomic | * | // | single | target | * | + // | single | target parallel | * | // | single | target enter | * | // | | data | | // | single | target exit | * | @@ -2055,6 +2066,7 @@ // | parallel for | ordered | * (if construct is ordered) | // | parallel for | atomic | * | // | parallel for | target | * | + // | parallel for | target parallel | * | // | parallel for | target enter | * | // | | data | | // | parallel for | target exit | * | @@ -2088,6 +2100,7 @@ // | parallel sections| ordered | + | // | parallel sections| atomic | * | // | parallel sections| target | * | + // | parallel sections| target parallel | * | // | parallel sections| target enter | * | // | | data | | // | parallel sections| target exit | * | @@ -2121,6 +2134,7 @@ // | task | ordered | + | // | task | atomic | * | // | task | target | * | + // | task | target parallel | * | // | task | target enter | * | // | | data | | // | task | target exit | * | @@ -2154,6 +2168,7 @@ // | ordered | ordered | + | // | ordered | atomic | * | // | ordered | target | * | + // | ordered | target parallel | * | // | ordered | target enter | * | // | | data | | // | ordered | target exit | * | @@ -2187,6 +2202,7 @@ // | atomic | ordered | | // | atomic | atomic | | // | atomic | target | | + // | atomic | target parallel | | // | atomic | target enter | | // | | data | | // | atomic | target exit | | @@ -2220,6 +2236,7 @@ // | target | ordered | * | // | target | atomic | * | // | target | target | * | + // | target | target parallel | * | // | target | target enter | * | // | | data | | // | target | target exit | * | @@ -2232,6 +2249,40 @@ // | target | taskloop simd | * | // | target | distribute | | // +------------------+-----------------+------------------------------------+ + // | target parallel | parallel | * | + // | target parallel | for | * | + // | target parallel | for simd | * | + // | target parallel | master | * | + // | target parallel | critical | * | + // | target parallel | simd | * | + // | target parallel | sections | * | + // | target parallel | section | * | + // | target parallel | single | * | + // | target parallel | parallel for | * | + // | target parallel |parallel for simd| * | + // | target parallel |parallel sections| * | + // | target parallel | task | * | + // | target parallel | taskyield | * | + // | target parallel | barrier | * | + // | target parallel | taskwait | * | + // | target parallel | taskgroup | * | + // | target parallel | flush | * | + // | target parallel | ordered | * | + // | target parallel | atomic | * | + // | target parallel | target | * | + // | target parallel | target parallel | * | + // | target parallel | target enter | * | + // | | data | | + // | target parallel | target exit | * | + // | | data | | + // | target parallel | teams | | + // | target parallel | cancellation | | + // | | point | ! | + // | target parallel | cancel | ! | + // | target parallel | taskloop | * | + // | target parallel | taskloop simd | * | + // | target parallel | distribute | | + // +------------------+-----------------+------------------------------------+ // | teams | parallel | * | // | teams | for | + | // | teams | for simd | + | @@ -2253,6 +2304,7 @@ // | teams | ordered | + | // | teams | atomic | + | // | teams | target | + | + // | teams | target parallel | + | // | teams | target enter | + | // | | data | | // | teams | target exit | + | @@ -2286,6 +2338,7 @@ // | taskloop | ordered | + | // | taskloop | atomic | * | // | taskloop | target | * | + // | taskloop | target parallel | * | // | taskloop | target enter | * | // | | data | | // | taskloop | target exit | * | @@ -2318,6 +2371,7 @@ // | taskloop simd | ordered | + (with simd clause) | // | taskloop simd | atomic | | // | taskloop simd | target | | + // | taskloop simd | target parallel | | // | taskloop simd | target enter | | // | | data | | // | taskloop simd | target exit | | @@ -2351,6 +2405,7 @@ // | distribute | ordered | + | // | distribute | atomic | * | // | distribute | target | | + // | distribute | target parallel | | // | distribute | target enter | | // | | data | | // | distribute | target exit | | @@ -2421,7 +2476,9 @@ // OpenMP construct that matches the type specified in // construct-type-clause. NestingProhibited = - !((CancelRegion == OMPD_parallel && ParentRegion == OMPD_parallel) || + !((CancelRegion == OMPD_parallel && + (ParentRegion == OMPD_parallel || + ParentRegion == OMPD_target_parallel)) || (CancelRegion == OMPD_for && (ParentRegion == OMPD_for || ParentRegion == OMPD_parallel_for)) || (CancelRegion == OMPD_taskgroup && ParentRegion == OMPD_task) || @@ -2760,6 +2817,12 @@ EndLoc); AllowedNameModifiers.push_back(OMPD_target); break; + case OMPD_target_parallel: + Res = ActOnOpenMPTargetParallelDirective(ClausesWithImplicit, AStmt, + StartLoc, EndLoc); + AllowedNameModifiers.push_back(OMPD_target); + AllowedNameModifiers.push_back(OMPD_parallel); + break; case OMPD_cancellation_point: assert(ClausesWithImplicit.empty() && "No clauses are allowed for 'omp cancellation point' directive"); @@ -5525,6 +5588,27 @@ return OMPTargetDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt); } +StmtResult +Sema::ActOnOpenMPTargetParallelDirective(ArrayRef Clauses, + Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc) { + 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(); + + getCurFunction()->setHasBranchProtectedScope(); + + return OMPTargetParallelDirective::Create(Context, StartLoc, EndLoc, Clauses, + AStmt); +} + /// \brief Check for existence of a map clause in the list of clauses. static bool HasMapClause(ArrayRef Clauses) { for (ArrayRef::iterator I = Clauses.begin(), E = Clauses.end(); Index: lib/Sema/TreeTransform.h =================================================================== --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -7414,6 +7414,17 @@ } template +StmtResult TreeTransform::TransformOMPTargetParallelDirective( + OMPTargetParallelDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel, DirName, + nullptr, D->getLocStart()); + StmtResult Res = getDerived().TransformOMPExecutableDirective(D); + getDerived().getSema().EndOpenMPDSABlock(Res.get()); + return Res; +} + +template StmtResult TreeTransform::TransformOMPTeamsDirective(OMPTeamsDirective *D) { DeclarationNameInfo DirName; Index: lib/Serialization/ASTReaderStmt.cpp =================================================================== --- lib/Serialization/ASTReaderStmt.cpp +++ lib/Serialization/ASTReaderStmt.cpp @@ -2482,6 +2482,13 @@ VisitOMPExecutableDirective(D); } +void ASTStmtReader::VisitOMPTargetParallelDirective( + OMPTargetParallelDirective *D) { + VisitStmt(D); + ++Idx; + VisitOMPExecutableDirective(D); +} + void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) { VisitStmt(D); // The NumClauses field was read in ReadStmtFromStream. @@ -3135,6 +3142,11 @@ Context, Record[ASTStmtReader::NumStmtFields], Empty); break; + case STMT_OMP_TARGET_PARALLEL_DIRECTIVE: + S = OMPTargetParallelDirective::CreateEmpty( + Context, Record[ASTStmtReader::NumStmtFields], Empty); + break; + case STMT_OMP_TEAMS_DIRECTIVE: S = OMPTeamsDirective::CreateEmpty( Context, Record[ASTStmtReader::NumStmtFields], Empty); Index: lib/Serialization/ASTWriterStmt.cpp =================================================================== --- lib/Serialization/ASTWriterStmt.cpp +++ lib/Serialization/ASTWriterStmt.cpp @@ -2238,6 +2238,14 @@ Code = serialization::STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE; } +void ASTStmtWriter::VisitOMPTargetParallelDirective( + OMPTargetParallelDirective *D) { + VisitStmt(D); + Record.push_back(D->getNumClauses()); + VisitOMPExecutableDirective(D); + Code = serialization::STMT_OMP_TARGET_PARALLEL_DIRECTIVE; +} + void ASTStmtWriter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) { VisitStmt(D); VisitOMPExecutableDirective(D); Index: lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -832,6 +832,7 @@ case Stmt::OMPTargetDataDirectiveClass: case Stmt::OMPTargetEnterDataDirectiveClass: case Stmt::OMPTargetExitDataDirectiveClass: + case Stmt::OMPTargetParallelDirectiveClass: case Stmt::OMPTeamsDirectiveClass: case Stmt::OMPCancellationPointDirectiveClass: case Stmt::OMPCancelDirectiveClass: Index: test/OpenMP/nesting_of_regions.cpp =================================================================== --- test/OpenMP/nesting_of_regions.cpp +++ test/OpenMP/nesting_of_regions.cpp @@ -97,6 +97,11 @@ } #pragma omp parallel { +#pragma omp target parallel + ++a; + } +#pragma omp parallel + { #pragma omp target enter data map(to: a) ++a; } @@ -246,6 +251,11 @@ } #pragma omp 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 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; } @@ -418,6 +428,11 @@ } #pragma omp for for (int i = 0; i < 10; ++i) { +#pragma omp target parallel + ++a; + } +#pragma omp for + for (int i = 0; i < 10; ++i) { #pragma omp target enter data map(to: a) ++a; } @@ -567,6 +582,11 @@ } #pragma omp for 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 for 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; } @@ -746,6 +766,11 @@ } #pragma omp sections { +#pragma omp target parallel + ++a; + } +#pragma omp sections + { #pragma omp target enter data map(to: a) } #pragma omp sections @@ -959,6 +984,12 @@ #pragma omp sections { #pragma omp section +#pragma omp target parallel + ++a; + } +#pragma omp sections + { +#pragma omp section { #pragma omp target enter data map(to: a) ++a; @@ -1129,6 +1160,11 @@ } #pragma omp single { +#pragma omp target parallel + ++a; + } +#pragma omp single + { #pragma omp target enter data map(to: a) ++a; } @@ -1291,6 +1327,11 @@ } #pragma omp master { +#pragma omp target parallel + ++a; + } +#pragma omp master + { #pragma omp target enter data map(to: a) ++a; } @@ -1467,6 +1508,11 @@ } #pragma omp critical { +#pragma omp target parallel + ++a; + } +#pragma omp critical + { #pragma omp target enter data map(to: a) ++a; } @@ -1644,6 +1690,11 @@ } #pragma omp parallel for for (int i = 0; i < 10; ++i) { +#pragma omp target parallel + ++a; + } +#pragma omp parallel for + for (int i = 0; i < 10; ++i) { #pragma omp target enter data map(to: a) ++a; } @@ -1821,6 +1872,11 @@ } #pragma omp parallel for 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 parallel for 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; } @@ -1989,6 +2045,11 @@ } #pragma omp parallel sections { +#pragma omp target parallel + ++a; + } +#pragma omp parallel sections + { #pragma omp target enter data map(to: a) } #pragma omp parallel sections @@ -2101,6 +2162,11 @@ } #pragma omp task { +#pragma omp target parallel + ++a; + } +#pragma omp task + { #pragma omp target enter data map(to: a) ++a; } @@ -2273,6 +2339,11 @@ } #pragma omp ordered { +#pragma omp target parallel + ++a; + } +#pragma omp ordered + { #pragma omp target enter data map(to: a) ++a; } @@ -2464,6 +2535,13 @@ // 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 parallel // expected-error {{OpenMP constructs may not be nested inside an atomic region}} + ++a; + } +#pragma omp atomic + // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}} + // expected-note@+1 {{expected an expression statement}} + { #pragma omp target enter data map(to: a) // expected-error {{OpenMP constructs may not be nested inside an atomic region}} ++a; } @@ -2593,6 +2671,11 @@ } #pragma omp target { +#pragma omp target parallel + ++a; + } +#pragma omp target + { #pragma omp teams ++a; } @@ -2623,6 +2706,136 @@ #pragma omp target exit data map(from: a) } +// TARGET PARALLEL DIRECTIVE +#pragma omp target parallel +#pragma omp parallel + bar(); +#pragma omp target parallel +#pragma omp for + for (int i = 0; i < 10; ++i) + ; +#pragma omp target parallel +#pragma omp simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp target parallel +#pragma omp for simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp target parallel +#pragma omp sections + { + bar(); + } +#pragma omp target parallel +#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a target parallel region}} + { + bar(); + } +#pragma omp target parallel +#pragma omp single + bar(); + +#pragma omp target parallel +#pragma omp master + { + bar(); + } +#pragma omp target parallel +#pragma omp critical + { + bar(); + } +#pragma omp target parallel +#pragma omp parallel for + for (int i = 0; i < 10; ++i) + ; +#pragma omp target parallel +#pragma omp parallel for simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp target parallel +#pragma omp parallel sections + { + bar(); + } +#pragma omp target parallel +#pragma omp task + { + bar(); + } +#pragma omp target parallel + { +#pragma omp taskyield + bar(); + } +#pragma omp target parallel + { +#pragma omp barrier + bar(); + } +#pragma omp target parallel + { +#pragma omp taskwait + bar(); + } +#pragma omp target parallel + { +#pragma omp flush + bar(); + } +#pragma omp target parallel + { +#pragma omp ordered // expected-error {{region cannot be closely nested inside 'target 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 parallel + { +#pragma omp atomic + ++a; + } +#pragma omp target parallel + { +#pragma omp target + ++a; + } +#pragma omp target parallel + { +#pragma omp target parallel + ++a; + } +#pragma omp target parallel + { +#pragma omp teams // expected-error {{region cannot be closely nested inside 'target parallel' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} + ++a; + } +#pragma omp target parallel + { + ++a; +#pragma omp teams // expected-error {{region cannot be closely nested inside 'target parallel' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} + ++a; + } +#pragma omp target parallel + { +#pragma omp taskloop + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target parallel + { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'target parallel' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target parallel + { +#pragma omp target enter data map(to: a) + } +#pragma omp target parallel + { +#pragma omp target exit data map(from: a) + } + // TEAMS DIRECTIVE #pragma omp target #pragma omp teams @@ -2739,6 +2952,12 @@ #pragma omp target #pragma omp teams { +#pragma omp target parallel + ++a; + } +#pragma omp target +#pragma omp teams + { #pragma omp target enter data map(to: a) // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp target enter data' directive into a parallel region?}} ++a; } @@ -2916,6 +3135,11 @@ } #pragma omp taskloop for (int i = 0; i < 10; ++i) { +#pragma omp target parallel + ++a; + } +#pragma omp taskloop + for (int i = 0; i < 10; ++i) { #pragma omp target enter data map(to: a) ++a; } @@ -3120,6 +3344,13 @@ #pragma omp teams #pragma omp distribute for (int i = 0; i < 10; ++i) { +#pragma omp target parallel + ++a; + } +#pragma omp target +#pragma omp teams +#pragma omp distribute + for (int i = 0; i < 10; ++i) { #pragma omp target enter data map(to: a) ++a; } @@ -3233,6 +3464,11 @@ } #pragma omp parallel { +#pragma omp target parallel + ++a; + } +#pragma omp parallel + { #pragma omp target enter data map(to: a) ++a; } @@ -3375,6 +3611,11 @@ } #pragma omp 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 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; } @@ -3537,6 +3778,11 @@ } #pragma omp for for (int i = 0; i < 10; ++i) { +#pragma omp target parallel + ++a; + } +#pragma omp for + for (int i = 0; i < 10; ++i) { #pragma omp target enter data map(to: a) ++a; } @@ -3679,6 +3925,11 @@ } #pragma omp for 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 for 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; } @@ -3833,6 +4084,11 @@ } #pragma omp sections { +#pragma omp target parallel + ++a; + } +#pragma omp sections + { #pragma omp target enter data map(to: a) } #pragma omp sections @@ -4051,6 +4307,14 @@ { #pragma omp section { +#pragma omp target parallel + ++a; + } + } +#pragma omp sections + { +#pragma omp section + { #pragma omp target enter data map(to: a) ++a; } @@ -4214,6 +4478,11 @@ } #pragma omp single { +#pragma omp target parallel + ++a; + } +#pragma omp single + { #pragma omp target enter data map(to: a) ++a; } @@ -4376,6 +4645,11 @@ } #pragma omp master { +#pragma omp target parallel + ++a; + } +#pragma omp master + { #pragma omp target enter data map(to: a) ++a; } @@ -4557,6 +4831,11 @@ } #pragma omp critical { +#pragma omp target parallel + ++a; + } +#pragma omp critical + { #pragma omp target enter data map(to: a) ++a; } @@ -4734,6 +5013,11 @@ } #pragma omp parallel for for (int i = 0; i < 10; ++i) { +#pragma omp target parallel + ++a; + } +#pragma omp parallel for + for (int i = 0; i < 10; ++i) { #pragma omp target enter data map(to: a) ++a; } @@ -4911,6 +5195,11 @@ } #pragma omp parallel for 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 parallel for 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; } @@ -5075,6 +5364,11 @@ } #pragma omp parallel sections { +#pragma omp target parallel + ++a; + } +#pragma omp parallel sections + { #pragma omp target enter data map(to: a) } #pragma omp parallel sections @@ -5186,6 +5480,11 @@ } #pragma omp task { +#pragma omp target parallel + ++a; + } +#pragma omp task + { #pragma omp target enter data map(to: a) ++a; } @@ -5377,6 +5676,13 @@ // 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 parallel // expected-error {{OpenMP constructs may not be nested inside an atomic region}} + ++a; + } +#pragma omp atomic + // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}} + // expected-note@+1 {{expected an expression statement}} + { #pragma omp target enter data map(to: a) // expected-error {{OpenMP constructs may not be nested inside an atomic region}} ++a; } @@ -5506,6 +5812,11 @@ } #pragma omp target { +#pragma omp target parallel + ++a; + } +#pragma omp target + { #pragma omp target enter data map(to: a) } #pragma omp target @@ -5536,6 +5847,136 @@ ; } +// TARGET PARALLEL DIRECTIVE +#pragma omp target parallel +#pragma omp parallel + bar(); +#pragma omp target parallel +#pragma omp for + for (int i = 0; i < 10; ++i) + ; +#pragma omp target parallel +#pragma omp simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp target parallel +#pragma omp for simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp target parallel +#pragma omp sections + { + bar(); + } +#pragma omp target parallel +#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a target parallel region}} + { + bar(); + } +#pragma omp target parallel +#pragma omp single + bar(); + +#pragma omp target parallel +#pragma omp master + { + bar(); + } +#pragma omp target parallel +#pragma omp critical + { + bar(); + } +#pragma omp target parallel +#pragma omp parallel for + for (int i = 0; i < 10; ++i) + ; +#pragma omp target parallel +#pragma omp parallel for simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp target parallel +#pragma omp parallel sections + { + bar(); + } +#pragma omp target parallel +#pragma omp task + { + bar(); + } +#pragma omp target parallel + { +#pragma omp taskyield + bar(); + } +#pragma omp target parallel + { +#pragma omp barrier + bar(); + } +#pragma omp target parallel + { +#pragma omp taskwait + bar(); + } +#pragma omp target parallel + { +#pragma omp flush + bar(); + } +#pragma omp target parallel + { +#pragma omp ordered // expected-error {{region cannot be closely nested inside 'target 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 parallel + { +#pragma omp atomic + ++a; + } +#pragma omp target parallel + { +#pragma omp target + ++a; + } +#pragma omp target parallel + { +#pragma omp target parallel + ++a; + } +#pragma omp target parallel + { +#pragma omp teams // expected-error {{region cannot be closely nested inside 'target parallel' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} + ++a; + } +#pragma omp target parallel + { + ++a; +#pragma omp teams // expected-error {{region cannot be closely nested inside 'target parallel' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} + ++a; + } +#pragma omp target parallel + { +#pragma omp taskloop + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target parallel + { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'target parallel' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target parallel + { +#pragma omp target enter data map(to: a) + } +#pragma omp target parallel + { +#pragma omp target exit data map(from: a) + } + // TEAMS DIRECTIVE #pragma omp target #pragma omp teams @@ -5652,6 +6093,12 @@ #pragma omp target #pragma omp teams { +#pragma omp target parallel + ++a; + } +#pragma omp target +#pragma omp teams + { #pragma omp target enter data map(to: a) // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp target enter data' directive into a parallel region?}} } #pragma omp target @@ -5827,6 +6274,11 @@ } #pragma omp taskloop for (int i = 0; i < 10; ++i) { +#pragma omp target parallel + ++a; + } +#pragma omp taskloop + for (int i = 0; i < 10; ++i) { #pragma omp target enter data map(to: a) ++a; } @@ -6032,6 +6484,13 @@ #pragma omp teams #pragma omp distribute for (int i = 0; i < 10; ++i) { +#pragma omp target parallel + ++a; + } +#pragma omp target +#pragma omp teams +#pragma omp distribute + for (int i = 0; i < 10; ++i) { #pragma omp teams // expected-error {{region cannot be closely nested inside 'distribute' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} ++a; } Index: test/OpenMP/target_parallel_ast_print.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_ast_print.cpp @@ -0,0 +1,230 @@ +// 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() {} + +template +struct S { + operator T() {return T();} + static T TS; + #pragma omp threadprivate(TS) +}; + +// CHECK: template struct S { +// CHECK: static int TS; +// CHECK-NEXT: #pragma omp threadprivate(S::TS) +// CHECK-NEXT: } +// CHECK: template struct S { +// CHECK: static char TS; +// CHECK-NEXT: #pragma omp threadprivate(S::TS) +// CHECK-NEXT: } +// CHECK: template struct S { +// CHECK: static T TS; +// CHECK-NEXT: #pragma omp threadprivate(S::TS) +// CHECK: }; + +template +T tmain(T argc, T *argv) { + T b = argc, c, d, e, f, g; + static T h; + S s; + T arr[C][10], arr1[C]; + T i, j, a[20]; +#pragma omp target parallel + h=2; +#pragma omp target parallel default(none), private(argc,b) firstprivate(argv) shared (d) if (parallel:argc > 0) num_threads(C) proc_bind(master) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10]) + foo(); +#pragma omp target parallel if (C) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(&& : g) + foo(); +#pragma omp target parallel if (target:argc > 0) + foo(); +#pragma omp target parallel if (parallel:argc > 0) + foo(); +#pragma omp target parallel if (C) + foo(); +#pragma omp target parallel map(i) + foo(); +#pragma omp target parallel map(a[0:10], i) + foo(); +#pragma omp target parallel map(to: i) map(from: j) + foo(); +#pragma omp target parallel map(always,alloc: i) + foo(); +#pragma omp target parallel nowait + foo(); +#pragma omp target parallel depend(in : argc, argv[i:argc], a[:]) + foo(); +#pragma omp target parallel defaultmap(tofrom: scalar) + foo(); + return 0; +} + +// CHECK: template int tmain(int argc, int *argv) { +// CHECK-NEXT: int b = argc, c, d, e, f, g; +// CHECK-NEXT: static int h; +// CHECK-NEXT: S s; +// CHECK-NEXT: int arr[5][10], arr1[5]; +// CHECK-NEXT: int i, j, a[20] +// CHECK-NEXT: #pragma omp target parallel +// CHECK-NEXT: h = 2; +// CHECK-NEXT: #pragma omp target parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:5][0:10]) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel if(5) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:5][:argc]) reduction(&&: g) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel if(target: argc > 0) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel if(5) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel map(tofrom: i) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel map(always,alloc: i) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel nowait +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:]) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar) +// CHECK-NEXT: foo() +// CHECK: template char tmain(char argc, char *argv) { +// CHECK-NEXT: char b = argc, c, d, e, f, g; +// CHECK-NEXT: static char h; +// CHECK-NEXT: S s; +// CHECK-NEXT: char arr[1][10], arr1[1]; +// CHECK-NEXT: char i, j, a[20] +// CHECK-NEXT: #pragma omp target parallel +// CHECK-NEXT: h = 2; +// CHECK-NEXT: #pragma omp target parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:1][0:10]) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel if(1) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:1][:argc]) reduction(&&: g) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel if(target: argc > 0) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel if(1) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel map(tofrom: i) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel map(always,alloc: i) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel nowait +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:]) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar) +// CHECK-NEXT: foo() +// CHECK: template T tmain(T argc, T *argv) { +// CHECK-NEXT: T b = argc, c, d, e, f, g; +// CHECK-NEXT: static T h; +// CHECK-NEXT: S s; +// CHECK-NEXT: T arr[C][10], arr1[C]; +// CHECK-NEXT: T i, j, a[20] +// CHECK-NEXT: #pragma omp target parallel +// CHECK-NEXT: h = 2; +// CHECK-NEXT: #pragma omp target parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10]) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel if(C) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:C][:argc]) reduction(&&: g) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel if(target: argc > 0) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel if(C) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel map(tofrom: i) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel map(always,alloc: i) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel nowait +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:]) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar) +// CHECK-NEXT: foo() + +// CHECK-LABEL: int main(int argc, char **argv) { +int main (int argc, char **argv) { + int i, j, a[20]; +// CHECK-NEXT: int i, j, a[20] +#pragma omp target parallel +// CHECK-NEXT: #pragma omp target parallel + foo(); +// CHECK-NEXT: foo(); +#pragma omp target parallel if (argc > 0) +// CHECK-NEXT: #pragma omp target parallel if(argc > 0) + foo(); +// CHECK-NEXT: foo(); + +#pragma omp target parallel if (target: argc > 0) +// CHECK-NEXT: #pragma omp target parallel if(target: argc > 0) + foo(); +// CHECK-NEXT: foo(); + +#pragma omp target parallel if (parallel: argc > 0) +// CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0) + foo(); +// CHECK-NEXT: foo(); + +#pragma omp target parallel map(i) if(argc>0) +// CHECK-NEXT: #pragma omp target parallel map(tofrom: i) if(argc > 0) + foo(); +// CHECK-NEXT: foo(); + +#pragma omp target parallel map(i) +// CHECK-NEXT: #pragma omp target parallel map(tofrom: i) + foo(); +// CHECK-NEXT: foo(); + +#pragma omp target parallel map(a[0:10], i) +// CHECK-NEXT: #pragma omp target parallel map(tofrom: a[0:10],i) + foo(); +// CHECK-NEXT: foo(); + +#pragma omp target parallel map(to: i) map(from: j) +// CHECK-NEXT: #pragma omp target parallel map(to: i) map(from: j) + foo(); +// CHECK-NEXT: foo(); + +#pragma omp target parallel map(always,alloc: i) +// CHECK-NEXT: #pragma omp target parallel map(always,alloc: i) + foo(); +// CHECK-NEXT: foo(); + +#pragma omp target parallel nowait +// CHECK-NEXT: #pragma omp target parallel nowait + foo(); +// CHECK-NEXT: foo(); + +#pragma omp target parallel depend(in : argc, argv[i:argc], a[:]) +// CHECK-NEXT: #pragma omp target parallel depend(in : argc,argv[i:argc],a[:]) + foo(); +// CHECK-NEXT: foo(); + +#pragma omp target parallel defaultmap(tofrom: scalar) +// CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar) + foo(); +// CHECK-NEXT: foo(); + + return tmain(argc, &argc) + tmain(argv[0][0], argv[0]); +} + +#endif Index: test/OpenMP/target_parallel_default_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_default_messages.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s + +void foo(); + +int main(int argc, char **argv) { + #pragma omp target parallel default // expected-error {{expected '(' after 'default'}} + #pragma omp target parallel default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} + #pragma omp target parallel default (none // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel default (shared), default(shared) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'default' clause}} + #pragma omp target parallel default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} + foo(); + + #pragma omp target parallel default(none) + ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}} + + #pragma omp target parallel default(none) + #pragma omp target parallel default(shared) + ++argc; + return 0; +} Index: test/OpenMP/target_parallel_defaultmap_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_defaultmap_messages.cpp @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +template +T tmain(T argc, S **argv) { + #pragma omp target parallel defaultmap // expected-error {{expected '(' after 'defaultmap'}} + foo(); + #pragma omp target parallel defaultmap ( // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); + #pragma omp target parallel defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} + foo(); + #pragma omp target parallel 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'}} + foo(); + #pragma omp target parallel defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} + foo(); + #pragma omp target parallel defaultmap (tofrom) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} + foo(); + #pragma omp target parallel defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} + foo(); + #pragma omp target parallel 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 '('}} + foo(); + #pragma omp target parallel defaultmap (scalar: // expected-error {{expected ')'}} expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}} + foo(); + #pragma omp target parallel 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 '('}} + foo(); + + return argc; +} + +int main(int argc, char **argv) { + #pragma omp target parallel defaultmap // expected-error {{expected '(' after 'defaultmap'}} + foo(); + #pragma omp target parallel defaultmap ( // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); + #pragma omp target parallel defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} + foo(); + #pragma omp target parallel 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'}} + foo(); + #pragma omp target parallel defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} + foo(); + #pragma omp target parallel defaultmap (tofrom) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} + foo(); + #pragma omp target parallel defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} + foo(); + #pragma omp target parallel 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 '('}} + foo(); + #pragma omp target parallel defaultmap (scalar: // expected-error {{expected ')'}} expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}} + foo(); + #pragma omp target parallel 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 '('}} + foo(); + + return tmain(argc, argv); +} + Index: test/OpenMP/target_parallel_depend_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_depend_messages.cpp @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - -std=c++11 %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} + +class vector { + public: + int operator[](int index) { return 0; } +}; + +int main(int argc, char **argv, char *env[]) { + vector vec; + typedef float V __attribute__((vector_size(16))); + V a; + auto arr = x; // expected-error {{use of undeclared identifier 'x'}} + + #pragma omp target parallel depend // expected-error {{expected '(' after 'depend'}} + foo(); + #pragma omp target parallel 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}} + foo(); + #pragma omp target parallel depend () // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}} + foo(); + #pragma omp target parallel 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 '('}} + foo(); + #pragma omp target parallel depend (source : argc) // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} + foo(); + #pragma omp target parallel depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}} + foo(); + #pragma omp target parallel depend (in : argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); + #pragma omp target parallel depend (out: ) // expected-error {{expected expression}} + foo(); + #pragma omp target parallel 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}} + foo(); + #pragma omp target parallel depend (out :S1) // expected-error {{'S1' does not refer to a value}} + foo(); + #pragma omp target parallel depend(in : argv[1][1] = '2') // expected-error {{expected variable name, array element or array section}} + foo(); + #pragma omp target parallel depend (in : vec[1]) // expected-error {{expected variable name, array element or array section}} + foo(); + #pragma omp target parallel depend (in : argv[0]) + foo(); + #pragma omp target parallel depend (in : ) // expected-error {{expected expression}} + foo(); + #pragma omp target parallel depend (in : main) // expected-error {{expected variable name, array element or array section}} + foo(); + #pragma omp target parallel depend(in : a[0]) // expected-error{{expected variable name, array element or array section}} + foo(); + #pragma omp target parallel depend (in : vec[1:2]) // expected-error {{ value is not an array or pointer}} + foo(); + #pragma omp target parallel depend (in : argv[ // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}} + foo(); + #pragma omp target parallel depend (in : argv[: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}} + foo(); + #pragma omp target parallel 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 '('}} + foo(); + #pragma omp target parallel depend (in : argv[argc: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}} + foo(); + #pragma omp target parallel depend (in : argv[argc:argc] // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); + #pragma omp target parallel depend (in : argv[0:-1]) // expected-error {{section length is evaluated to a negative value -1}} + foo(); + #pragma omp target parallel depend (in : argv[-1:0]) // expected-error {{section lower bound is evaluated to a negative value -1}} + foo(); + #pragma omp target parallel depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} + foo(); + #pragma omp target parallel depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + foo(); + #pragma omp target parallel depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} + foo(); + #pragma omp target parallel depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}} + foo(); + #pragma omp target parallel depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} + foo(); + #pragma omp target parallel depend(in:env[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} + foo(); + #pragma omp target parallel depend(in : argv[ : argc][1 : argc - 1]) + foo(); + #pragma omp target parallel depend(in : arr[0]) + foo(); + + return 0; +} Index: test/OpenMP/target_parallel_device_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_device_messages.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} + +int main(int argc, char **argv) { + #pragma omp target parallel device // expected-error {{expected '(' after 'device'}} + #pragma omp target parallel device ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel device () // expected-error {{expected expression}} + #pragma omp target parallel device (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel device (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} +#pragma omp target parallel device (argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + #pragma omp target parallel device (argc + argc) + #pragma omp target parallel device (argc), device (argc+1) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'device' clause}} + #pragma omp target parallel device (S1) // expected-error {{'S1' does not refer to a value}} + #pragma omp target parallel device (-2) // expected-error {{argument to 'device' clause must be a non-negative integer value}} + #pragma omp target parallel device (-10u) + #pragma omp target parallel device (3.14) // expected-error {{expression must have integral or unscoped enumeration type, not 'double'}} + foo(); + + return 0; +} Index: test/OpenMP/target_parallel_firstprivate_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_firstprivate_messages.cpp @@ -0,0 +1,92 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}} +extern S1 a; +class S2 { + mutable int a; +public: + S2():a(0) { } + S2(const S2 &s2):a(s2.a) { } + static float S2s; + static const float S2sc; +}; +const float S2::S2sc = 0; +const S2 b; +const S2 ba[5]; +class S3 { + int a; +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 {{implicitly declared private here}} +public: + S4(int v):a(v) { } +}; +class S5 { + int a; + S5():a(0) {} + S5(const S5 &s5):a(s5.a) { } // expected-note {{implicitly declared private here}} +public: + S5(int v):a(v) { } +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} + +namespace A { +double x; +#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} +} +namespace B { +using A::x; +} + +int main(int argc, char **argv) { + const int d = 5; + const int da[5] = { 0 }; + S4 e(4); + S5 g(5); + int i; + int &j = i; + static int m; + #pragma omp target parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}} + #pragma omp target parallel firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel firstprivate () // expected-error {{expected expression}} + #pragma omp target parallel firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + #pragma omp target parallel firstprivate (argc) + #pragma omp target parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}} + #pragma omp target parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} + #pragma omp target parallel firstprivate (argv[1]) // expected-error {{expected variable name}} + #pragma omp target parallel firstprivate(ba) + #pragma omp target parallel firstprivate(ca) + #pragma omp target parallel firstprivate(da) + #pragma omp target parallel firstprivate(S2::S2s) + #pragma omp target parallel firstprivate(S2::S2sc) + #pragma omp target parallel firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} + #pragma omp target parallel firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}} + #pragma omp target parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}} + foo(); + #pragma omp target parallel shared(i) + #pragma omp target parallel firstprivate(i) + #pragma omp target parallel firstprivate(j) + #pragma omp target parallel firstprivate(m) + foo(); + + return 0; +} Index: test/OpenMP/target_parallel_if_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_if_messages.cpp @@ -0,0 +1,64 @@ +// 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) { + #pragma omp target parallel if // expected-error {{expected '(' after 'if'}} + #pragma omp target parallel if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if () // expected-error {{expected expression}} + #pragma omp target parallel if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + #pragma omp target parallel if (argc > 0 ? argv[1] : argv[2]) + #pragma omp target parallel if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause}} + #pragma omp target parallel if (S) // expected-error {{'S' does not refer to a value}} + #pragma omp target parallel if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if(argc) + #pragma omp target parallel if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if(target : argc) + #pragma omp target parallel if(parallel : argc) + #pragma omp target parallel if(target : argc) if(parallel : argc) + #pragma omp target parallel if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target parallel'}} + #pragma omp target parallel if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'target' name modifier}} + #pragma omp target parallel if(parallel : argc) if (parallel :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'parallel' name modifier}} + #pragma omp target parallel if(target : argc) if (argc) // expected-error {{expected 'parallel' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}} + #pragma omp target parallel if(target : argc) if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} expected-note {{previous clause with directive name modifier specified here}} + foo(); + + return 0; +} + +int main(int argc, char **argv) { + #pragma omp target parallel if // expected-error {{expected '(' after 'if'}} + #pragma omp target parallel if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if () // expected-error {{expected expression}} + #pragma omp target parallel if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + #pragma omp target parallel if (argc > 0 ? argv[1] : argv[2]) + #pragma omp target parallel if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause}} + #pragma omp target parallel if (S1) // expected-error {{'S1' does not refer to a value}} + #pragma omp target parallel if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel if(parallel : argc) + #pragma omp target parallel if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target parallel'}} + #pragma omp target parallel if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'target' name modifier}} + #pragma omp target parallel if(parallel : argc) if (parallel :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'parallel' name modifier}} + #pragma omp target parallel if(target : argc) if (argc) // expected-error {{expected 'parallel' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}} + #pragma omp target parallel if(target : argc) if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} expected-note {{previous clause with directive name modifier specified here}} + foo(); + + return tmain(argc, argv); +} Index: test/OpenMP/target_parallel_map_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_map_messages.cpp @@ -0,0 +1,207 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note 2 {{declared here}} +extern S1 a; +class S2 { + mutable int a; +public: + S2():a(0) { } + S2(S2 &s2):a(s2.a) { } + static float S2s; // expected-note 4 {{mappable type cannot contain static members}} + static const float S2sc; // expected-note 4 {{mappable type cannot contain static members}} +}; +const float S2::S2sc = 0; +const S2 b; +const S2 ba[5]; +class S3 { + int a; +public: + S3():a(0) { } + S3(S3 &s3):a(s3.a) { } +}; +const S3 c; +const S3 ca[5]; +extern const int f; +class S4 { + int a; + S4(); + S4(const S4 &s4); +public: + S4(int v):a(v) { } +}; +class S5 { + int a; + S5():a(0) {} + S5(const S5 &s5):a(s5.a) { } +public: + S5(int v):a(v) { } +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} + +typedef int from; + +template // expected-note {{declared here}} +T tmain(T argc) { + const T d = 5; + const T da[5] = { 0 }; + S4 e(4); + S5 g(5); + T i, t[20]; + T &j = i; + T *k = &j; + T x; + T y; + T to, tofrom, always; + const T (&l)[5] = da; + + +#pragma omp target parallel map // expected-error {{expected '(' after 'map'}} +#pragma omp target parallel map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} +#pragma omp target parallel map() // expected-error {{expected expression}} +#pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} +#pragma omp target parallel map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} +#pragma omp target parallel map(to:) // expected-error {{expected expression}} +#pragma omp target parallel map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +#pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} +#pragma omp target parallel map(x) + foo(); +#pragma omp target parallel map(tofrom: t[:I]) + foo(); +#pragma omp target parallel map(T: a) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} + foo(); +#pragma omp target parallel map(T) // expected-error {{'T' does not refer to a value}} + foo(); +#pragma omp target parallel map(I) // expected-error 2 {{expected variable name, array element or array section}} + foo(); +#pragma omp target parallel map(S2::S2s) + foo(); +#pragma omp target parallel map(S2::S2sc) + foo(); +#pragma omp target parallel map(x) + foo(); +#pragma omp target parallel map(to: x) + foo(); +#pragma omp target parallel map(to: to) + foo(); +#pragma omp target parallel map(to) + foo(); +#pragma omp target parallel map(to, x) + foo(); +#pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} +#pragma omp target parallel map(tofrom: argc > 0 ? x : y) // expected-error 2 {{expected variable name, array element or array section}} +#pragma omp target parallel map(argc) +#pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}} +#pragma omp target parallel 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}} +#pragma omp target parallel map(ba) // expected-error 2 {{type 'S2' is not mappable to target}} +#pragma omp target parallel map(ca) +#pragma omp target parallel map(da) +#pragma omp target parallel map(S2::S2s) +#pragma omp target parallel map(S2::S2sc) +#pragma omp target parallel map(e, g) +#pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in map clause}} +#pragma omp target parallel map(k), map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} +#pragma omp target parallel map(k), map(k[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} + foo(); +#pragma omp target parallel map(da) +#pragma omp target parallel map(da[:4]) + foo(); +#pragma omp target parallel map(k, j, l) // expected-note 4 {{used here}} +#pragma omp target parallel map(k[:4]) // expected-error 2 {{variable already marked as mapped in current construct}} +#pragma omp target parallel map(j) +#pragma omp target parallel map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} + foo(); +#pragma omp target parallel map(k[:4], j, l[:5]) // expected-note 4 {{used here}} +#pragma omp target parallel map(k) // expected-error 2 {{variable already marked as mapped in current construct}} +#pragma omp target parallel map(j) +#pragma omp target parallel map(l) // expected-error 2 {{variable already marked as mapped in current construct}} + foo(); + +#pragma omp target parallel map(always, tofrom: x) +#pragma omp target parallel map(always: x) // expected-error {{missing map type}} +#pragma omp target parallel 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'}} +#pragma omp target parallel map(always, tofrom: always, tofrom, x) +#pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} + 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 parallel map // expected-error {{expected '(' after 'map'}} +#pragma omp target parallel map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} +#pragma omp target parallel map() // expected-error {{expected expression}} +#pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} +#pragma omp target parallel map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} +#pragma omp target parallel map(to:) // expected-error {{expected expression}} +#pragma omp target parallel map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +#pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} +#pragma omp target parallel map(x) + foo(); +#pragma omp target parallel map(to: x) + foo(); +#pragma omp target parallel map(to: to) + foo(); +#pragma omp target parallel map(to) + foo(); +#pragma omp target parallel map(to, x) + foo(); +#pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} +#pragma omp target parallel map(tofrom: argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}} +#pragma omp target parallel map(argc) +#pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}} +#pragma omp target parallel 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}} +#pragma omp target parallel map(argv[1]) +#pragma omp target parallel map(ba) // expected-error 2 {{type 'S2' is not mappable to target}} +#pragma omp target parallel map(ca) +#pragma omp target parallel map(da) +#pragma omp target parallel map(S2::S2s) +#pragma omp target parallel map(S2::S2sc) +#pragma omp target parallel map(e, g) +#pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in map clause}} +#pragma omp target parallel map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} +#pragma omp target parallel map(k), map(k[:5]) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} + foo(); +#pragma omp target parallel map(da) +#pragma omp target parallel map(da[:4]) + foo(); +#pragma omp target parallel map(k, j, l) // expected-note 2 {{used here}} +#pragma omp target parallel map(k[:4]) // expected-error {{variable already marked as mapped in current construct}} +#pragma omp target parallel map(j) +#pragma omp target parallel map(l[:5]) // expected-error {{variable already marked as mapped in current construct}} + foo(); +#pragma omp target parallel map(k[:4], j, l[:5]) // expected-note 2 {{used here}} +#pragma omp target parallel map(k) // expected-error {{variable already marked as mapped in current construct}} +#pragma omp target parallel map(j) +#pragma omp target parallel map(l) // expected-error {{variable already marked as mapped in current construct}} + foo(); + +#pragma omp target parallel map(always, tofrom: x) +#pragma omp target parallel map(always: x) // expected-error {{missing map type}} +#pragma omp target parallel 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'}} +#pragma omp target parallel map(always, tofrom: always, tofrom, x) +#pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} + 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: test/OpenMP/target_parallel_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_messages.cpp @@ -0,0 +1,72 @@ +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - %s +// RUN: not %clang_cc1 -fopenmp -std=c++11 -omptargets=aaa-bbb-ccc-ddd -o - %s 2>&1 | FileCheck %s +// CHECK: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd' + +void foo() { +} + +static int pvt; +#pragma omp threadprivate(pvt) + +#pragma omp target parallel // expected-error {{unexpected OpenMP directive '#pragma omp target parallel'}} + +int main(int argc, char **argv) { + #pragma omp target parallel { // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); + #pragma omp target parallel ( // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); + #pragma omp target parallel [ // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); + #pragma omp target parallel ] // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); + #pragma omp target parallel ) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); + #pragma omp target parallel } // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); + #pragma omp target parallel + // expected-warning@+1 {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + #pragma omp target parallel unknown() + foo(); + L1: + foo(); + #pragma omp target parallel + ; + #pragma omp target parallel + { + goto L1; // expected-error {{use of undeclared label 'L1'}} + argc++; + } + + for (int i = 0; i < 10; ++i) { + switch(argc) { + case (0): + #pragma omp target parallel + { + foo(); + break; // expected-error {{'break' statement not in loop or switch statement}} + continue; // expected-error {{'continue' statement not in loop statement}} + } + default: + break; + } + } + + goto L2; // expected-error {{use of undeclared label 'L2'}} + #pragma omp target parallel + L2: + foo(); + #pragma omp target parallel + { + return 1; // expected-error {{cannot return from OpenMP region}} + } + + [[]] // expected-error {{an attribute list cannot appear here}} + #pragma omp target parallel + for (int n = 0; n < 100; ++n) {} + + #pragma omp target parallel copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp target parallel'}} + foo(); + + return 0; +} + Index: test/OpenMP/target_parallel_nowait_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_nowait_messages.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s + +void foo() { +} + +int main(int argc, char **argv) { + #pragma omp target parallel nowait( // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); + #pragma omp target parallel nowait (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); + #pragma omp target parallel nowait device (-10u) + foo(); + #pragma omp target parallel nowait (3.14) device (-10u) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); + + return 0; +} Index: test/OpenMP/target_parallel_num_threads_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_num_threads_messages.cpp @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} + +#define redef_num_threads(a, b) num_threads(a) + +template // expected-note {{declared here}} +T tmain(T argc, S **argv) { + #pragma omp target parallel num_threads // expected-error {{expected '(' after 'num_threads'}} + #pragma omp target parallel num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel num_threads () // expected-error {{expected expression}} + #pragma omp target parallel num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + #pragma omp target parallel num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}} + #pragma omp target parallel num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp target parallel' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}} + #pragma omp target parallel num_threads (S) // expected-error {{'S' does not refer to a value}} + #pragma omp target parallel num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}} + #pragma omp target parallel num_threads (argc) + #pragma omp target parallel num_threads (N) // expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}} + #pragma omp target parallel redef_num_threads (argc, argc) + foo(); + + return argc; +} + +int main(int argc, char **argv) { + #pragma omp target parallel num_threads // expected-error {{expected '(' after 'num_threads'}} + #pragma omp target parallel num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel num_threads () // expected-error {{expected expression}} + #pragma omp target parallel num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + #pragma omp target parallel num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }} + #pragma omp target parallel num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp target parallel' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}} + #pragma omp target parallel num_threads (S1) // expected-error {{'S1' does not refer to a value}} + #pragma omp target parallel num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + #pragma omp target parallel num_threads (num_threads(tmain(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} + #pragma omp target parallel redef_num_threads (argc, argc) + foo(); + + return tmain(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} +} Index: test/OpenMP/target_parallel_private_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_private_messages.cpp @@ -0,0 +1,180 @@ +// RUN: %clang_cc1 -verify -fopenmp %s + +void foo() { +} + +struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} expected-note 1 {{forward declaration of 'S1'}} expected-note {{forward declaration of 'S1'}} +extern S1 a; +class S2 { + mutable int a; + +public: + S2() : a(0) {} + static float S2s; // expected-note {{static data member is predetermined as shared}} expected-note 1 {{static data member is predetermined as shared}} +}; +const S2 b; +const S2 ba[5]; +class S3 { + int a; + +public: + S3() : a(0) {} +}; +const S3 c; // expected-note {{global variable is predetermined as shared}} expected-note 1 {{global variable is predetermined as shared}} +const S3 ca[5]; // expected-note {{global variable is predetermined as shared}} expected-note 1 {{global variable is predetermined as shared}} +extern const int f; // expected-note {{global variable is predetermined as shared}} expected-note 1 {{global variable is predetermined as shared}} + +int threadvar; +#pragma omp threadprivate(threadvar) // expected-note {{defined as threadprivate or thread local}} expected-note 1 {{defined as threadprivate or thread local}} + +class S4 { + int a; + S4(); // expected-note {{implicitly declared private here}} expected-note 1 {{implicitly declared private here}} + +public: + S4(int v) : a(v) {} +}; +class S5 { + int a; + S5() : a(0) {} // expected-note {{implicitly declared private here}} expected-note 1 {{implicitly declared private here}} + +public: + S5(int v) : a(v) {} +}; +namespace A { +double x; +#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} expected-note 1 {{defined as threadprivate or thread local}} expected-note 2 {{defined as threadprivate or thread local}} +} +namespace B { +using A::x; +} + +S3 h; +#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} + +template +int foomain(I argc, C **argv) { + const I d = 5; // expected-note {{constant variable is predetermined as shared}} + const I da[5] = { 0 }; // expected-note {{constant variable is predetermined as shared}} + D e(4); + E g[] = {5, 6}; + I i; + I &j = i; +#pragma omp target parallel private // expected-error {{expected '(' after 'private'}} +#pragma omp target parallel private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +#pragma omp target parallel private() // expected-error {{expected expression}} +#pragma omp target parallel private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} +#pragma omp target parallel private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +#pragma omp target parallel private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} +#pragma omp target parallel private(argc argv) // expected-error {{expected ',' or ')' in 'private' clause}} +#pragma omp target parallel private(argc) +#pragma omp target parallel private(S1) // expected-error {{'S1' does not refer to a value}} +#pragma omp target parallel private(a, b) // expected-error {{private variable with incomplete type 'S1'}} +#pragma omp target parallel private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}} +#pragma omp target parallel private(argv[1]) // expected-error {{expected variable name}} +#pragma omp target parallel private(ba) +#pragma omp target parallel private(ca) // expected-error {{shared variable cannot be private}} +#pragma omp target parallel private(da) // expected-error {{shared variable cannot be private}} +#pragma omp target parallel private(S2::S2s) // expected-error {{shared variable cannot be private}} +#pragma omp target parallel private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} + #pragma omp target parallel private(threadvar, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}} + #pragma omp target parallel shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}} + foo(); + #pragma omp target parallel firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}} + foo(); + #pragma omp target parallel private(i) + #pragma omp target parallel private(j) + foo(); + #pragma omp parallel firstprivate(i) + for (int k = 0; k < 10; ++k) { + #pragma omp target parallel private(i) + foo(); + } + static int m; + #pragma omp target parallel private(m) // OK + foo(); +#pragma omp target parallel private(h) // expected-error {{threadprivate or thread local variable cannot be private}} +#pragma omp target parallel private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}} +#pragma omp parallel + { + int v = 0; + int i; +#pragma omp target parallel private(i) + {} + } +#pragma omp target parallel shared(i) +#pragma omp target parallel private(i) +#pragma omp target parallel private(j) +#pragma omp target parallel private(i) + {} + static int si; +#pragma omp target parallel private(si) // OK + {} + return 0; +} + +void bar(S4 a[2]) { +#pragma omp parallel +#pragma omp target parallel private(a) + {} +} + +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, 6}; + int i; + int &j = i; +#pragma omp target parallel private // expected-error {{expected '(' after 'private'}} +#pragma omp target parallel private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +#pragma omp target parallel private() // expected-error {{expected expression}} +#pragma omp target parallel private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} +#pragma omp target parallel private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +#pragma omp target parallel private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} +#pragma omp target parallel private(argc argv) // expected-error {{expected ',' or ')' in 'private' clause}} +#pragma omp target parallel private(argc) +#pragma omp target parallel private(S1) // expected-error {{'S1' does not refer to a value}} +#pragma omp target parallel private(a, b) // expected-error {{private variable with incomplete type 'S1'}} +#pragma omp target parallel private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}} +#pragma omp target parallel private(argv[1]) // expected-error {{expected variable name}} +#pragma omp target parallel private(ba) +#pragma omp target parallel private(ca) // expected-error {{shared variable cannot be private}} +#pragma omp target parallel private(da) // expected-error {{shared variable cannot be private}} +#pragma omp target parallel private(S2::S2s) // expected-error {{shared variable cannot be private}} +#pragma omp target parallel private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} + #pragma omp target parallel private(threadvar, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}} + #pragma omp target parallel shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}} + foo(); + #pragma omp target parallel firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}} + foo(); + #pragma omp target parallel private(i) + #pragma omp target parallel private(j) + foo(); + #pragma omp parallel firstprivate(i) + for (int k = 0; k < 10; ++k) { + #pragma omp target parallel private(i) + foo(); + } + static int m; + #pragma omp target parallel private(m) // OK + foo(); +#pragma omp target parallel private(h) // expected-error {{threadprivate or thread local variable cannot be private}} +#pragma omp target parallel private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}} +#pragma omp parallel + { + int i; +#pragma omp target parallel private(i) + {} + } +#pragma omp target parallel shared(i) +#pragma omp target parallel private(i) +#pragma omp target parallel private(j) +#pragma omp target parallel private(i) + {} + static int si; +#pragma omp target parallel private(si) // OK + {} + return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}} +} + Index: test/OpenMP/target_parallel_proc_bind_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_proc_bind_messages.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s + +void foo(); + +int main(int argc, char **argv) { + #pragma omp target parallel proc_bind // expected-error {{expected '(' after 'proc_bind'}} + #pragma omp target parallel proc_bind ( // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel proc_bind () // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} + #pragma omp target parallel proc_bind (master // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel proc_bind (close), proc_bind(spread) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'proc_bind' clause}} + #pragma omp target parallel proc_bind (x) // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} + foo(); + + #pragma omp target parallel proc_bind(master) + ++argc; + + #pragma omp target parallel proc_bind(close) + #pragma omp target parallel proc_bind(spread) + ++argc; + return 0; +} Index: test/OpenMP/target_parallel_reduction_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_reduction_messages.cpp @@ -0,0 +1,257 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++98 -ferror-limit 100 -o - %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 -ferror-limit 100 -o - %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{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 4 {{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 2 {{'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 2 {{'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 2 {{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 2 {{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 parallel reduction // expected-error {{expected '(' after 'reduction'}} + foo(); +#pragma omp target parallel reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); +#pragma omp target parallel reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); +#pragma omp target parallel reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); +#pragma omp target parallel reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + foo(); +#pragma omp target parallel reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} + foo(); +#pragma omp target parallel reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + foo(); +#pragma omp target parallel reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}} + foo(); +#pragma omp target parallel reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}} + foo(); +#pragma omp target parallel reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}} + foo(); +#pragma omp target parallel reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}} + foo(); +#pragma omp target parallel reduction(&& : argc) + foo(); +#pragma omp target parallel reduction(^ : T) // expected-error {{'T' does not refer to a value}} + foo(); +#pragma omp target parallel 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 3 {{'operator+' is a private member of 'S2'}} + foo(); +#pragma omp target parallel 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 3 {{const-qualified list item cannot be reduction}} + foo(); +#pragma omp target parallel reduction(max : h.b) // expected-error {{expected variable name, array element or array section}} + foo(); +#pragma omp target parallel reduction(+ : ba) // expected-error {{a reduction list item with array type 'const S2 [5]'}} + foo(); +#pragma omp target parallel reduction(* : ca) // expected-error {{a reduction list item with array type 'const S3 [5]'}} + foo(); +#pragma omp target parallel reduction(- : da) // expected-error {{a reduction list item with array type 'const int [5]'}} expected-error {{a reduction list item with array type 'const float [5]'}} + foo(); +#pragma omp target parallel reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} + foo(); +#pragma omp target parallel reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} + foo(); +#pragma omp target parallel reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}} + foo(); +#pragma omp target parallel reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}} + foo(); +#pragma omp target parallel reduction(+ : o) // expected-error {{no viable overloaded '='}} + foo(); +#pragma omp target parallel private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + foo(); +#pragma omp target parallel private(k) +#pragma omp target parallel reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + foo(); +#pragma omp target parallel reduction(+ : p), reduction(+ : p) // expected-error 3 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 3 {{previously referenced here}} + foo(); +#pragma omp target parallel reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}} + foo(); +#pragma omp target parallel shared(i) +#pragma omp target parallel reduction(min : i) +#pragma omp target parallel reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + foo(); +#pragma omp target parallel +#pragma omp for private(fl) + for (int i = 0; i < 10; ++i) +#pragma omp target parallel reduction(+ : fl) + foo(); +#pragma omp target parallel +#pragma omp for reduction(- : fl) + for (int i = 0; i < 10; ++i) +#pragma omp target parallel reduction(+ : fl) + 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 parallel reduction // expected-error {{expected '(' after 'reduction'}} + foo(); +#pragma omp target parallel reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); +#pragma omp target parallel reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); +#pragma omp target parallel reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); +#pragma omp target parallel reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + foo(); +#pragma omp target parallel reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} + foo(); +#pragma omp target parallel reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} + foo(); +#pragma omp target parallel reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}} + foo(); +#pragma omp target parallel reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); +#pragma omp target parallel reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}} + foo(); +#pragma omp target parallel reduction(~ : argc) // expected-error {{expected unqualified-id}} + foo(); +#pragma omp target parallel reduction(&& : argc) + foo(); +#pragma omp target parallel reduction(^ : S1) // expected-error {{'S1' does not refer to a value}} + foo(); +#pragma omp target parallel 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'}} + foo(); +#pragma omp target parallel 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}} + foo(); +#pragma omp target parallel reduction(max : h.b) // expected-error {{expected variable name, array element or array section}} + foo(); +#pragma omp target parallel reduction(+ : ba) // expected-error {{a reduction list item with array type 'const S2 [5]'}} + foo(); +#pragma omp target parallel reduction(* : ca) // expected-error {{a reduction list item with array type 'const S3 [5]'}} + foo(); +#pragma omp target parallel reduction(- : da) // expected-error {{a reduction list item with array type 'const int [5]'}} + foo(); +#pragma omp target parallel reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} + foo(); +#pragma omp target parallel reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} + foo(); +#pragma omp target parallel reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}} + foo(); +#pragma omp target parallel reduction(& : e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{nvalid 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')}} + foo(); +#pragma omp target parallel reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}} + foo(); +#pragma omp target parallel reduction(+ : o) // expected-error {{no viable overloaded '='}} + foo(); +#pragma omp target parallel private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + foo(); +#pragma omp target parallel private(k) +#pragma omp target parallel reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + foo(); +#pragma omp target parallel reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}} + foo(); +#pragma omp target parallel reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}} + foo(); +#pragma omp target parallel shared(i) +#pragma omp target parallel reduction(min : i) +#pragma omp target parallel reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} + foo(); +#pragma omp target parallel +#pragma omp for private(fl) + for (int i = 0; i < 10; ++i) +#pragma omp target parallel reduction(+ : fl) + foo(); +#pragma omp target parallel +#pragma omp for reduction(- : fl) + for (int i = 0; i < 10; ++i) +#pragma omp target parallel reduction(+ : fl) + foo(); + static int m; +#pragma omp target parallel reduction(+ : m) // OK + 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: test/OpenMP/target_parallel_shared_messages.cpp =================================================================== --- /dev/null +++ test/OpenMP/target_parallel_shared_messages.cpp @@ -0,0 +1,91 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +void foo() { +} + +bool foobool(int argc) { + return argc; +} + +struct S1; // expected-note {{declared here}} +extern S1 a; +class S2 { + mutable int a; +public: + S2():a(0) { } + S2(S2 &s2):a(s2.a) { } +}; +const S2 b; +const S2 ba[5]; +class S3 { + int a; +public: + S3():a(0) { } + S3(S3 &s3):a(s3.a) { } +}; +const S3 c; +const S3 ca[5]; +extern const int f; +class S4 { + int a; + S4(); + S4(const S4 &s4); +public: + S4(int v):a(v) { } +}; +class S5 { + int a; + S5():a(0) {} + S5(const S5 &s5):a(s5.a) { } +public: + S5(int v):a(v) { } +}; + +S3 h; +#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} + +namespace A { +double x; +#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} +} +namespace B { +using A::x; +} + +int main(int argc, char **argv) { + const int d = 5; + const int da[5] = { 0 }; + S4 e(4); + S5 g(5); + int i; + int &j = i; + #pragma omp target parallel shared // expected-error {{expected '(' after 'shared'}} + #pragma omp target parallel shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel shared () // expected-error {{expected expression}} + #pragma omp target parallel shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + #pragma omp target parallel shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + #pragma omp target parallel shared (argc) + #pragma omp target parallel shared (S1) // expected-error {{'S1' does not refer to a value}} + #pragma omp target parallel shared (a, b, c, d, f) + #pragma omp target parallel shared (argv[1]) // expected-error {{expected variable name}} + #pragma omp target parallel shared(ba) + #pragma omp target parallel shared(ca) + #pragma omp target parallel shared(da) + #pragma omp target parallel shared(e, g) + #pragma omp target parallel shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}} + #pragma omp target parallel private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}} + foo(); + #pragma omp target parallel firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}} + foo(); + #pragma omp target parallel private(i) + #pragma omp target parallel shared(i) + #pragma omp target parallel shared(j) + foo(); + #pragma omp target parallel firstprivate(i) + #pragma omp target parallel shared(i) + #pragma omp target parallel shared(j) + foo(); + + return 0; +} Index: tools/libclang/CIndex.cpp =================================================================== --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -1955,6 +1955,7 @@ void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D); void VisitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective *D); void VisitOMPTargetExitDataDirective(const OMPTargetExitDataDirective *D); + void VisitOMPTargetParallelDirective(const OMPTargetParallelDirective *D); void VisitOMPTeamsDirective(const OMPTeamsDirective *D); void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D); void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D); @@ -2647,6 +2648,11 @@ VisitOMPExecutableDirective(D); } +void EnqueueVisitor::VisitOMPTargetParallelDirective( + const OMPTargetParallelDirective *D) { + VisitOMPExecutableDirective(D); +} + void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) { VisitOMPExecutableDirective(D); } @@ -4856,6 +4862,8 @@ return cxstring::createRef("OMPTargetEnterDataDirective"); case CXCursor_OMPTargetExitDataDirective: return cxstring::createRef("OMPTargetExitDataDirective"); + case CXCursor_OMPTargetParallelDirective: + return cxstring::createRef("OMPTargetParallelDirective"); case CXCursor_OMPTeamsDirective: return cxstring::createRef("OMPTeamsDirective"); case CXCursor_OMPCancellationPointDirective: Index: tools/libclang/CXCursor.cpp =================================================================== --- tools/libclang/CXCursor.cpp +++ tools/libclang/CXCursor.cpp @@ -606,6 +606,9 @@ case Stmt::OMPTargetExitDataDirectiveClass: K = CXCursor_OMPTargetExitDataDirective; break; + case Stmt::OMPTargetParallelDirectiveClass: + K = CXCursor_OMPTargetParallelDirective; + break; case Stmt::OMPTeamsDirectiveClass: K = CXCursor_OMPTeamsDirective; break;