Index: clang/docs/OpenMPSupport.rst =================================================================== --- clang/docs/OpenMPSupport.rst +++ clang/docs/OpenMPSupport.rst @@ -321,7 +321,7 @@ +------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+ | misc | error directive | :none:`unclaimed` | | +------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+ -| misc | scope construct | :none:`unclaimed` | | +| misc | scope construct | :none:`worked on` | D157933 | +------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+ | misc | routines for controlling and querying team regions | :none:`unclaimed` | | +------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+ Index: clang/include/clang-c/Index.h =================================================================== --- clang/include/clang-c/Index.h +++ clang/include/clang-c/Index.h @@ -2136,7 +2136,11 @@ */ CXCursor_OMPErrorDirective = 305, - CXCursor_LastStmt = CXCursor_OMPErrorDirective, + /** OpenMP scope directive. + */ + CXCursor_OMPScopeDirective = 306, + + CXCursor_LastStmt = CXCursor_OMPScopeDirective, /** * Cursor that represents the translation unit itself. Index: clang/include/clang/AST/RecursiveASTVisitor.h =================================================================== --- clang/include/clang/AST/RecursiveASTVisitor.h +++ clang/include/clang/AST/RecursiveASTVisitor.h @@ -2980,6 +2980,9 @@ DEF_TRAVERSE_STMT(OMPSectionDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPScopeDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + DEF_TRAVERSE_STMT(OMPSingleDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) Index: clang/include/clang/AST/StmtOpenMP.h =================================================================== --- clang/include/clang/AST/StmtOpenMP.h +++ clang/include/clang/AST/StmtOpenMP.h @@ -1914,6 +1914,57 @@ } }; +/// This represents '#pragma omp scope' directive. +/// \code +/// #pragma omp scope private(a,b) nowait +/// \endcode +/// In this example directive '#pragma omp scope' has clauses 'private' with +/// the variables 'a' and 'b' and nowait. +/// +class OMPScopeDirective final : public OMPExecutableDirective { + friend class ASTStmtReader; + friend class OMPExecutableDirective; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// + OMPScopeDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPScopeDirectiveClass, llvm::omp::OMPD_scope, + StartLoc, EndLoc) {} + + /// Build an empty directive. + /// + explicit OMPScopeDirective() + : OMPExecutableDirective(OMPScopeDirectiveClass, llvm::omp::OMPD_scope, + SourceLocation(), SourceLocation()) {} + +public: + /// Creates directive. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param AssociatedStmt Statement, associated with the directive. + /// + static OMPScopeDirective *Create(const ASTContext &C, SourceLocation StartLoc, + SourceLocation EndLoc, + ArrayRef Clauses, + Stmt *AssociatedStmt); + + /// Creates an empty directive. + /// + /// \param C AST context. + /// + static OMPScopeDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPScopeDirectiveClass; + } +}; + /// This represents '#pragma omp single' directive. /// /// \code Index: clang/include/clang/Basic/StmtNodes.td =================================================================== --- clang/include/clang/Basic/StmtNodes.td +++ clang/include/clang/Basic/StmtNodes.td @@ -259,6 +259,7 @@ def OMPTeamsDirective : StmtNode; def OMPCancellationPointDirective : StmtNode; def OMPCancelDirective : StmtNode; +def OMPScopeDirective : StmtNode; def OMPTaskLoopDirective : StmtNode; def OMPTaskLoopSimdDirective : StmtNode; def OMPMasterTaskLoopDirective : StmtNode; Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -11526,6 +11526,11 @@ /// associated statement. StmtResult ActOnOpenMPSectionDirective(Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc); + /// Called on well-formed '\#pragma omp scope' after parsing of the + /// associated statement. + StmtResult ActOnOpenMPScopeDirective(ArrayRef Clauses, + Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc); /// Called on well-formed '\#pragma omp single' after parsing of the /// associated statement. StmtResult ActOnOpenMPSingleDirective(ArrayRef Clauses, Index: clang/include/clang/Serialization/ASTBitCodes.h =================================================================== --- clang/include/clang/Serialization/ASTBitCodes.h +++ clang/include/clang/Serialization/ASTBitCodes.h @@ -1995,6 +1995,7 @@ STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE, STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE, STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE, + STMT_OMP_SCOPE_DIRECTIVE, STMT_OMP_INTEROP_DIRECTIVE, STMT_OMP_DISPATCH_DIRECTIVE, STMT_OMP_MASKED_DIRECTIVE, Index: clang/lib/AST/StmtOpenMP.cpp =================================================================== --- clang/lib/AST/StmtOpenMP.cpp +++ clang/lib/AST/StmtOpenMP.cpp @@ -529,6 +529,23 @@ /*HasAssociatedStmt=*/true); } +OMPScopeDirective *OMPScopeDirective::Create(const ASTContext &C, + SourceLocation StartLoc, + SourceLocation EndLoc, + ArrayRef Clauses, + Stmt *AssociatedStmt) { + return createDirective(C, Clauses, AssociatedStmt, + /*NumChildren=*/0, StartLoc, + EndLoc); +} + +OMPScopeDirective *OMPScopeDirective::CreateEmpty(const ASTContext &C, + unsigned NumClauses, + EmptyShell) { + return createEmptyDirective(C, NumClauses, + /*HasAssociatedStmt=*/true); +} + OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, Index: clang/lib/AST/StmtPrinter.cpp =================================================================== --- clang/lib/AST/StmtPrinter.cpp +++ clang/lib/AST/StmtPrinter.cpp @@ -777,6 +777,11 @@ PrintOMPExecutableDirective(Node); } +void StmtPrinter::VisitOMPScopeDirective(OMPScopeDirective *Node) { + Indent() << "#pragma omp scope"; + PrintOMPExecutableDirective(Node); +} + void StmtPrinter::VisitOMPSingleDirective(OMPSingleDirective *Node) { Indent() << "#pragma omp single"; PrintOMPExecutableDirective(Node); Index: clang/lib/AST/StmtProfile.cpp =================================================================== --- clang/lib/AST/StmtProfile.cpp +++ clang/lib/AST/StmtProfile.cpp @@ -996,6 +996,10 @@ VisitOMPExecutableDirective(S); } +void StmtProfiler::VisitOMPScopeDirective(const OMPScopeDirective *S) { + VisitOMPExecutableDirective(S); +} + void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) { VisitOMPExecutableDirective(S); } Index: clang/lib/Basic/OpenMPKinds.cpp =================================================================== --- clang/lib/Basic/OpenMPKinds.cpp +++ clang/lib/Basic/OpenMPKinds.cpp @@ -848,6 +848,7 @@ case OMPD_atomic: case OMPD_target_data: case OMPD_distribute_simd: + case OMPD_scope: case OMPD_dispatch: CaptureRegions.push_back(OMPD_unknown); break; Index: clang/lib/CodeGen/CGStmt.cpp =================================================================== --- clang/lib/CodeGen/CGStmt.cpp +++ clang/lib/CodeGen/CGStmt.cpp @@ -409,6 +409,8 @@ case Stmt::OMPDispatchDirectiveClass: llvm_unreachable("Dispatch directive not supported yet."); break; + case Stmt::OMPScopeDirectiveClass: + llvm_unreachable("scope not supported with FE outlining"); case Stmt::OMPMaskedDirectiveClass: EmitOMPMaskedDirective(cast(*S)); break; Index: clang/lib/Parse/ParseOpenMP.cpp =================================================================== --- clang/lib/Parse/ParseOpenMP.cpp +++ clang/lib/Parse/ParseOpenMP.cpp @@ -2418,6 +2418,7 @@ case OMPD_distribute_simd: case OMPD_target_parallel_for_simd: case OMPD_target_simd: + case OMPD_scope: case OMPD_teams_distribute: case OMPD_teams_distribute_simd: case OMPD_teams_distribute_parallel_for_simd: @@ -2810,6 +2811,7 @@ case OMPD_target_teams_loop: case OMPD_parallel_loop: case OMPD_target_parallel_loop: + case OMPD_scope: case OMPD_taskloop: case OMPD_taskloop_simd: case OMPD_master_taskloop: Index: clang/lib/Sema/SemaExceptionSpec.cpp =================================================================== --- clang/lib/Sema/SemaExceptionSpec.cpp +++ clang/lib/Sema/SemaExceptionSpec.cpp @@ -1496,6 +1496,7 @@ case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass: case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass: case Stmt::OMPTargetUpdateDirectiveClass: + case Stmt::OMPScopeDirectiveClass: case Stmt::OMPTaskDirectiveClass: case Stmt::OMPTaskgroupDirectiveClass: case Stmt::OMPTaskLoopDirectiveClass: Index: clang/lib/Sema/SemaOpenMP.cpp =================================================================== --- clang/lib/Sema/SemaOpenMP.cpp +++ clang/lib/Sema/SemaOpenMP.cpp @@ -3687,6 +3687,7 @@ S->getDirectiveKind() == OMPD_section || S->getDirectiveKind() == OMPD_master || S->getDirectiveKind() == OMPD_masked || + S->getDirectiveKind() == OMPD_scope || isOpenMPLoopTransformationDirective(S->getDirectiveKind())) { Visit(S->getAssociatedStmt()); return; @@ -4297,6 +4298,7 @@ case OMPD_distribute: case OMPD_distribute_simd: case OMPD_ordered: + case OMPD_scope: case OMPD_target_data: case OMPD_dispatch: { Sema::CapturedParamNameType Params[] = { @@ -5108,7 +5110,10 @@ diag::note_omp_previous_critical_region); return true; } - } else if (CurrentRegion == OMPD_barrier) { + } else if (CurrentRegion == OMPD_barrier || CurrentRegion == OMPD_scope) { + // OpenMP 5.1 [2.22, Nesting of Regions] + // A scope region may not be closely nested inside a worksharing, loop, + // task, taskloop, critical, ordered, atomic, or masked region. // OpenMP 5.1 [2.22, Nesting of Regions] // A barrier region may not be closely nested inside a worksharing, loop, // task, taskloop, critical, ordered, atomic, or masked region. @@ -6330,6 +6335,10 @@ if (LangOpts.OpenMP >= 50) AllowedNameModifiers.push_back(OMPD_simd); break; + case OMPD_scope: + Res = + ActOnOpenMPScopeDirective(ClausesWithImplicit, AStmt, StartLoc, EndLoc); + break; case OMPD_parallel_master: Res = ActOnOpenMPParallelMasterDirective(ClausesWithImplicit, AStmt, StartLoc, EndLoc); @@ -23749,6 +23758,17 @@ Vars); } +StmtResult Sema::ActOnOpenMPScopeDirective(ArrayRef Clauses, + Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc) { + if (!AStmt) + return StmtError(); + + setFunctionHasBranchProtectedScope(); + + return OMPScopeDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt); +} + OMPClause *Sema::ActOnOpenMPInclusiveClause(ArrayRef VarList, SourceLocation StartLoc, SourceLocation LParenLoc, Index: clang/lib/Sema/TreeTransform.h =================================================================== --- clang/lib/Sema/TreeTransform.h +++ clang/lib/Sema/TreeTransform.h @@ -8919,6 +8919,17 @@ return Res; } +template +StmtResult +TreeTransform::TransformOMPScopeDirective(OMPScopeDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_scope, DirName, nullptr, + D->getBeginLoc()); + StmtResult Res = getDerived().TransformOMPExecutableDirective(D); + getDerived().getSema().EndOpenMPDSABlock(Res.get()); + return Res; +} + template StmtResult TreeTransform::TransformOMPSingleDirective(OMPSingleDirective *D) { Index: clang/lib/Serialization/ASTReaderStmt.cpp =================================================================== --- clang/lib/Serialization/ASTReaderStmt.cpp +++ clang/lib/Serialization/ASTReaderStmt.cpp @@ -2390,6 +2390,11 @@ D->setHasCancel(Record.readBool()); } +void ASTStmtReader::VisitOMPScopeDirective(OMPScopeDirective *D) { + VisitStmt(D); + VisitOMPExecutableDirective(D); +} + void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) { VisitStmt(D); VisitOMPExecutableDirective(D); @@ -3351,6 +3356,11 @@ S = OMPSectionDirective::CreateEmpty(Context, Empty); break; + case STMT_OMP_SCOPE_DIRECTIVE: + S = OMPScopeDirective::CreateEmpty( + Context, Record[ASTStmtReader::NumStmtFields], Empty); + break; + case STMT_OMP_SINGLE_DIRECTIVE: S = OMPSingleDirective::CreateEmpty( Context, Record[ASTStmtReader::NumStmtFields], Empty); Index: clang/lib/Serialization/ASTWriterStmt.cpp =================================================================== --- clang/lib/Serialization/ASTWriterStmt.cpp +++ clang/lib/Serialization/ASTWriterStmt.cpp @@ -2307,6 +2307,12 @@ Code = serialization::STMT_OMP_SECTION_DIRECTIVE; } +void ASTStmtWriter::VisitOMPScopeDirective(OMPScopeDirective *D) { + VisitStmt(D); + VisitOMPExecutableDirective(D); + Code = serialization::STMT_OMP_SCOPE_DIRECTIVE; +} + void ASTStmtWriter::VisitOMPSingleDirective(OMPSingleDirective *D) { VisitStmt(D); VisitOMPExecutableDirective(D); Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1746,6 +1746,7 @@ case Stmt::OMPForSimdDirectiveClass: case Stmt::OMPSectionsDirectiveClass: case Stmt::OMPSectionDirectiveClass: + case Stmt::OMPScopeDirectiveClass: case Stmt::OMPSingleDirectiveClass: case Stmt::OMPMasterDirectiveClass: case Stmt::OMPCriticalDirectiveClass: Index: clang/test/OpenMP/nesting_of_regions.cpp =================================================================== --- clang/test/OpenMP/nesting_of_regions.cpp +++ clang/test/OpenMP/nesting_of_regions.cpp @@ -3,9 +3,11 @@ // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-extensions -verify=expected,omp50 %s // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -verify=expected,omp45,omp -fno-openmp-extensions -Wno-openmp %s // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -verify=expected,omp45,omp -fno-openmp-extensions -Wno-source-uses-openmp %s +// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=51 -verify=expected,omp51,omp -fno-openmp-extensions -Wno-source-uses-openmp %s // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 -fno-openmp-extensions -verify=expected,omp45,omp45warn,omp %s // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify=expected,omp50,omp -fno-openmp-extensions %s +// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=51 -verify=expected,omp51,omp -fno-openmp-extensions %s // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} void bar(); @@ -241,7 +243,7 @@ // SIMD DIRECTIVE #pragma omp simd for (int i = 0; i < 10; ++i) { -#pragma omp for // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{OpenMP constructs may not be nested inside a simd region except for ordered simd, simd, scan, or atomic directive}} +#pragma omp for // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{OpenMP constructs may not be nested inside a simd region except for ordered simd, simd, scan, or atomic directive}} omp51-error {{OpenMP constructs may not be nested inside a simd region except for ordered simd, simd, scan, or atomic directive}} for (int i = 0; i < 10; ++i) ; } @@ -350,7 +352,7 @@ } #pragma omp simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} omp51-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} bar(); } #pragma omp simd @@ -638,7 +640,7 @@ } #pragma omp for for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} +#pragma omp scan // omp45-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} omp51-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} bar(); } #pragma omp for @@ -903,7 +905,7 @@ } #pragma omp for simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} omp51-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} bar(); } #pragma omp for simd @@ -2676,7 +2678,7 @@ } #pragma omp parallel for for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{region cannot be closely nested inside 'parallel for' region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} +#pragma omp scan // omp45-error {{region cannot be closely nested inside 'parallel for' region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} omp51-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} bar(); } #pragma omp parallel for @@ -2950,7 +2952,7 @@ } #pragma omp parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} omp51-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} bar(); } #pragma omp parallel for simd @@ -6861,7 +6863,7 @@ #pragma omp teams #pragma omp distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } #pragma omp target @@ -7150,7 +7152,7 @@ } #pragma omp target simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'target simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'target simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'target simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } #pragma omp target simd @@ -7958,7 +7960,7 @@ #pragma omp target #pragma omp teams distribute simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'teams distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'teams distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'teams distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } #pragma omp target @@ -8247,7 +8249,7 @@ #pragma omp target #pragma omp teams distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'teams distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'teams distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'teams distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } #pragma omp target @@ -9528,7 +9530,7 @@ } #pragma omp target teams distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'target teams distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'target teams distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'target teams distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } #pragma omp target teams distribute parallel for simd @@ -9776,7 +9778,7 @@ } #pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'target teams distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'target teams distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'target teams distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } #pragma omp target teams distribute simd @@ -9901,338 +9903,734 @@ ; } -} - -void foo() { - int a = 0; -// PARALLEL DIRECTIVE -#pragma omp parallel + // SCOPE DIRECTIVE +#pragma omp scope +#pragma omp parallel // OK + bar(); +#pragma omp scope +#pragma omp parallel for // OK + for(int i = 0; i < 10; i++) + ; +#pragma omp scope +#pragma omp parallel for simd // OK + for(int i = 0; i < 10; i++) + ; +#pragma omp scope #pragma omp for for (int i = 0; i < 10; ++i) ; -#pragma omp parallel +#pragma omp scope #pragma omp simd for (int i = 0; i < 10; ++i) ; -#pragma omp parallel +#pragma omp scope #pragma omp for simd for (int i = 0; i < 10; ++i) ; -#pragma omp parallel +#pragma omp scope #pragma omp sections { bar(); } -#pragma omp parallel -#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel region}} - { - bar(); - } -#pragma omp parallel -#pragma omp sections +#pragma omp scope +#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a scope region}} { bar(); } -#pragma omp parallel +#pragma omp scope #pragma omp single bar(); -#pragma omp parallel + +#pragma omp scope #pragma omp master - bar(); -#pragma omp parallel master - bar(); -#pragma omp parallel masked - bar(); -#pragma omp parallel + { + bar(); + } +#pragma omp scope #pragma omp critical - bar(); -#pragma omp parallel -#pragma omp parallel for - for (int i = 0; i < 10; ++i) - ; -#pragma omp parallel -#pragma omp parallel for simd - for (int i = 0; i < 10; ++i) - ; -#pragma omp parallel + { + bar(); + } +#pragma omp scope #pragma omp parallel sections { bar(); } -#pragma omp parallel +#pragma omp scope +#pragma omp parallel master + { + bar(); + } +#pragma omp scope +#pragma omp parallel masked + { + bar(); + } +#pragma omp scope #pragma omp task { bar(); } -#pragma omp parallel +#pragma omp scope { #pragma omp taskyield bar(); } -#pragma omp parallel +#pragma omp scope { #pragma omp barrier bar(); } -#pragma omp parallel +#pragma omp scope { -#pragma omp scan // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } -#pragma omp parallel +#pragma omp scope { #pragma omp taskwait bar(); } -#pragma omp parallel +#pragma omp scope { #pragma omp flush bar(); } -#pragma omp parallel +#pragma omp scope { -#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} +#pragma omp ordered // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} bar(); } -#pragma omp parallel +#pragma omp scope { #pragma omp atomic ++a; } -#pragma omp parallel - { -#pragma omp target - ++a; - } -#pragma omp parallel +#pragma omp scope { #pragma omp target parallel ++a; } -#pragma omp parallel +#pragma omp scope + { #pragma omp target parallel for for (int i = 0; i < 10; ++i) ; -#pragma omp parallel + } +#pragma omp scope { #pragma omp target enter data map(to: a) ++a; } -#pragma omp parallel +#pragma omp scope { #pragma omp target exit data map(from: a) ++a; } -#pragma omp parallel - { -#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} - ++a; - } -#pragma omp parallel +#pragma omp scope { #pragma omp taskloop for (int i = 0; i < 10; ++i) ++a; } -#pragma omp parallel +#pragma omp scope { -#pragma omp distribute // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} - for (int i = 0; i < 10; ++i) - ; +#pragma omp target // OK + a++; } -#pragma omp parallel +#pragma omp scope { -#pragma omp target update to(a) +#pragma omp teams // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} a++; } -#pragma omp parallel +#pragma omp scope { -#pragma omp distribute parallel for // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp distribute parallel for' directive into a teams region?}} - for (int i = 0; i < 10; ++i) - ; +#pragma omp target teams // OK + a++; } -#pragma omp parallel +#pragma omp scope { -#pragma omp distribute parallel for simd // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp distribute parallel for simd' directive into a teams region?}} +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} for (int i = 0; i < 10; ++i) ; } -#pragma omp parallel + #pragma omp scope + { + #pragma omp distribute parallel for simd // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp distribute parallel for simd' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp scope { -#pragma omp distribute simd // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp distribute simd' directive into a teams region?}} +#pragma omp distribute simd // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp distribute simd' directive into a teams region?}} for (int i = 0; i < 10; ++i) ; } -#pragma omp parallel +#pragma omp scope { #pragma omp target simd // OK for (int i = 0; i < 10; ++i) ; } -#pragma omp parallel - { -#pragma omp teams distribute // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams distribute' directive into a target region?}} - for (int i = 0; i < 10; ++i) - ; - } -#pragma omp parallel +#pragma omp scope + { + #pragma omp teams distribute // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp teams distribute' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp scope { -#pragma omp teams distribute simd // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams distribute simd' directive into a target region?}} +#pragma omp teams distribute simd // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp teams distribute simd' directive into a target region?}} for (int i = 0; i < 10; ++i) ; } -#pragma omp parallel +#pragma omp scope { -#pragma omp teams distribute parallel for simd // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams distribute parallel for simd' directive into a target region?}} +#pragma omp teams distribute parallel for simd // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp teams distribute parallel for simd' directive into a target region?}} for (int i = 0; i < 10; ++i) ; } -#pragma omp parallel +#pragma omp scope { -#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} for (int i = 0; i < 10; ++i) ; } -#pragma omp parallel +#pragma omp scope { #pragma omp target teams // OK - a++; + ++a; } -#pragma omp parallel +#pragma omp scope { #pragma omp target teams distribute // OK for (int i = 0; i < 10; ++i) ; } -#pragma omp parallel +#pragma omp scope { #pragma omp target teams distribute parallel for // OK for (int i = 0; i < 10; ++i) ; } -#pragma omp parallel +#pragma omp scope { #pragma omp target teams distribute parallel for simd // OK for (int i = 0; i < 10; ++i) ; } -#pragma omp parallel +#pragma omp scope { #pragma omp target teams distribute simd // OK for (int i = 0; i < 10; ++i) ; } - -// SIMD DIRECTIVE -#pragma omp simd - for (int i = 0; i < 10; ++i) { -#pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; - } -#pragma omp simd +#pragma omp for for (int i = 0; i < 10; ++i) { -#pragma omp simd // omp45warn-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}} - for (int i = 0; i < 10; ++i) - ; +#pragma omp scope // expected-error {{region cannot be closely nested inside 'for' region}} + bar(); } -#pragma omp simd + +#pragma omp for simd for (int i = 0; i < 10; ++i) { -#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); } -#pragma omp simd - for (int i = 0; i < 10; ++i) { -#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; + +#pragma omp sections + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'sections' region}} + bar(); } -#pragma omp simd - for (int i = 0; i < 10; ++i) { -#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} + +#pragma omp sections + { +#pragma omp section { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'section' region}} bar(); } } -#pragma omp simd - for (int i = 0; i < 10; ++i) { -#pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} - { - bar(); - } + +#pragma omp single + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'single' region}} + bar(); } -#pragma omp simd - for (int i = 0; i < 10; ++i) { -#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} + +#pragma omp master + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'master' region}} bar(); -#pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} + } + +#pragma omp critical + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'critical' region}} bar(); } -#pragma omp simd + +#pragma omp parallel for for (int i = 0; i < 10; ++i) { -#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} - bar(); -#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} +#pragma omp scope // expected-error {{region cannot be closely nested inside 'parallel for' region}} bar(); } -#pragma omp simd + +#pragma omp parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); } -#pragma omp simd - for (int i = 0; i < 10; ++i) { -#pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; + +#pragma omp parallel master + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'parallel master' region}} + bar(); } -#pragma omp simd - for (int i = 0; i < 10; ++i) { -#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} - { - bar(); - } + +#pragma omp parallel sections + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'parallel sections' region}} + bar(); } -#pragma omp simd - for (int i = 0; i < 10; ++i) { -#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} - { - bar(); - } + +#pragma omp task + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'task' region}} + bar(); } -#pragma omp simd - for (int i = 0; i < 10; ++i) { -#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} + +#pragma omp ordered + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'ordered' region}} bar(); } -#pragma omp simd - for (int i = 0; i < 10; ++i) { -#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} + +#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 lvalue expression with scalar type}} + // expected-note@+1 {{expected an expression statement}} + { +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside an atomic region}} bar(); } -#pragma omp simd - for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} + +#pragma omp target +#pragma omp teams + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp scope' directive into a parallel region?}} bar(); } -#pragma omp simd + +#pragma omp taskloop for (int i = 0; i < 10; ++i) { -#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} +#pragma omp scope // expected-error {{region cannot be closely nested inside 'taskloop' region}} bar(); } -#pragma omp simd + +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for for (int i = 0; i < 10; ++i) { -#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} +#pragma omp scope // expected-error {{region cannot be closely nested inside 'distribute parallel for' region}} bar(); } -#pragma omp simd + +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} bar(); } -#pragma omp simd + +#pragma omp target simd + for (int i = 0; i < 10; ++i) { +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } + +#pragma omp target +#pragma omp teams distribute simd + for (int i = 0; i < 10; ++i) { +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } + +#pragma omp target +#pragma omp teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } + +#pragma omp target +#pragma omp teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region}} + bar(); + } + +#pragma omp target teams + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'target teams' region; perhaps you forget to enclose 'omp scope' directive into a parallel region?}} + bar(); + } + +#pragma omp target teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'target teams distribute parallel for' region}} + bar(); + } + +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } + +#pragma omp target teams distribute simd + for (int i = 0; i < 10; ++i) { +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } + +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +} + +void foo() { + int a = 0; +// PARALLEL DIRECTIVE +#pragma omp parallel +#pragma omp for + for (int i = 0; i < 10; ++i) + ; +#pragma omp parallel +#pragma omp simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp parallel +#pragma omp for simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp parallel +#pragma omp sections + { + bar(); + } +#pragma omp parallel +#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel region}} + { + bar(); + } +#pragma omp parallel +#pragma omp sections + { + bar(); + } +#pragma omp parallel +#pragma omp single + bar(); +#pragma omp parallel +#pragma omp master + bar(); +#pragma omp parallel master + bar(); +#pragma omp parallel masked + bar(); +#pragma omp parallel +#pragma omp critical + bar(); +#pragma omp parallel +#pragma omp parallel for + for (int i = 0; i < 10; ++i) + ; +#pragma omp parallel +#pragma omp parallel for simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp parallel +#pragma omp parallel sections + { + bar(); + } +#pragma omp parallel +#pragma omp task + { + bar(); + } +#pragma omp parallel + { +#pragma omp taskyield + bar(); + } +#pragma omp parallel + { +#pragma omp barrier + bar(); + } +#pragma omp parallel + { +#pragma omp scan // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} + bar(); + } +#pragma omp parallel + { +#pragma omp taskwait + bar(); + } +#pragma omp parallel + { +#pragma omp flush + bar(); + } +#pragma omp parallel + { +#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} + bar(); + } +#pragma omp parallel + { +#pragma omp atomic + ++a; + } +#pragma omp parallel + { +#pragma omp target + ++a; + } +#pragma omp parallel + { +#pragma omp target parallel + ++a; + } +#pragma omp parallel +#pragma omp target parallel for + for (int i = 0; i < 10; ++i) + ; +#pragma omp parallel + { +#pragma omp target enter data map(to: a) + ++a; + } +#pragma omp parallel + { +#pragma omp target exit data map(from: a) + ++a; + } +#pragma omp parallel + { +#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} + ++a; + } +#pragma omp parallel + { +#pragma omp taskloop + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp parallel + { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp parallel + { +#pragma omp target update to(a) + a++; + } +#pragma omp parallel + { +#pragma omp distribute parallel for // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp distribute parallel for' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp parallel + { +#pragma omp distribute parallel for simd // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp distribute parallel for simd' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp parallel + { +#pragma omp distribute simd // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp distribute simd' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp parallel + { +#pragma omp target simd // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp parallel + { +#pragma omp teams distribute // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams distribute' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp parallel + { +#pragma omp teams distribute simd // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams distribute simd' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp parallel + { +#pragma omp teams distribute parallel for simd // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams distribute parallel for simd' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp parallel + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp parallel + { +#pragma omp target teams // OK + a++; + } +#pragma omp parallel + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp parallel + { +#pragma omp target teams distribute parallel for // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp parallel + { +#pragma omp target teams distribute parallel for simd // OK + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp parallel + { +#pragma omp target teams distribute simd // OK + for (int i = 0; i < 10; ++i) + ; + } + +// SIMD DIRECTIVE +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp simd // omp45warn-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); +#pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); +#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} omp51-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} + bar(); + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp simd for (int i = 0; i < 10; ++i) { #pragma omp atomic // omp45-error {{OpenMP constructs may not be nested inside a simd region}} ++a; @@ -10469,7 +10867,7 @@ } #pragma omp for for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{region cannot be closely nested inside 'for' region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} +#pragma omp scan // omp45-error {{region cannot be closely nested inside 'for' region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} omp51-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} bar(); } #pragma omp for @@ -10714,7 +11112,7 @@ } #pragma omp for simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} omp51-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} bar(); } #pragma omp for simd @@ -12388,7 +12786,7 @@ } #pragma omp parallel for for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{region cannot be closely nested inside 'parallel for' region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} +#pragma omp scan // omp45-error {{region cannot be closely nested inside 'parallel for' region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} omp51-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} bar(); } #pragma omp parallel for @@ -12663,7 +13061,7 @@ } #pragma omp parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} omp51-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} bar(); } #pragma omp parallel for simd @@ -15687,7 +16085,7 @@ #pragma omp teams #pragma omp distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } #pragma omp target @@ -16006,7 +16404,7 @@ #pragma omp teams #pragma omp distribute simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } #pragma omp target @@ -16287,7 +16685,7 @@ } #pragma omp target simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'target simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'target simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'target simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } #pragma omp target simd @@ -16837,7 +17235,7 @@ #pragma omp target #pragma omp teams distribute simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'teams distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'teams distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'teams distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } #pragma omp target @@ -17126,7 +17524,7 @@ #pragma omp target #pragma omp teams distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'teams distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'teams distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'teams distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } #pragma omp target @@ -18254,112 +18652,360 @@ for (int i = 0; i < 10; ++i) ++a; } -#pragma omp target teams distribute parallel for +#pragma omp target teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams // expected-error {{region cannot be nested inside 'target teams distribute parallel for' region}} + ++a; + } +#pragma omp target teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target teams distribute parallel for' region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute parallel for // expected-error {{region cannot be nested inside 'target teams distribute parallel for' region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute parallel for simd // expected-error {{region cannot be nested inside 'target teams distribute parallel for' region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute parallel for + for (int i = 0; i < 10; ++i) { +#pragma omp target teams distribute simd // expected-error {{region cannot be nested inside 'target teams distribute parallel for' region}} + for (int i = 0; i < 10; ++i) + ++a; + } + +// TARGET TEAMS DISTRIBUTE PARALLEL FOR SIMD DIRECTIVE +#pragma omp target teams distribute parallel for simd // OK + for (int i = 0; i < 10; ++i) + ; +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp distribute parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp simd // omp45warn-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { +#pragma omp single + { + bar(); + } + } + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} + { + bar(); + } + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'target teams distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'target teams distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} + bar(); + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp atomic // omp45-error {{OpenMP constructs may not be nested inside a simd region}} + ++a; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}} + ++a; + } +#pragma omp target teams distribute 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 target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute 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; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target exit data map(from: a) // expected-error {{OpenMP constructs may not be nested inside a simd region}} + ++a; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} + ++a; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target update to(a) // expected-error {{OpenMP constructs may not be nested inside a simd region}} + ++a; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp distribute simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp target simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp target teams distribute parallel for simd + for (int i = 0; i < 10; ++i) { +#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp target teams distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp target teams // expected-error {{region cannot be nested inside 'target teams distribute parallel for' region}} - ++a; +#pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} + a++; } -#pragma omp target teams distribute parallel for +#pragma omp target teams distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp target teams distribute // expected-error {{region cannot be nested inside 'target teams distribute parallel for' region}} +#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) - ++a; + ; } -#pragma omp target teams distribute parallel for +#pragma omp target teams distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp target teams distribute parallel for // expected-error {{region cannot be nested inside 'target teams distribute parallel for' region}} +#pragma omp target teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) - ++a; + ; } -#pragma omp target teams distribute parallel for +#pragma omp target teams distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp target teams distribute parallel for simd // expected-error {{region cannot be nested inside 'target teams distribute parallel for' region}} +#pragma omp target teams distribute parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) - ++a; + ; } -#pragma omp target teams distribute parallel for +#pragma omp target teams distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp target teams distribute simd // expected-error {{region cannot be nested inside 'target teams distribute parallel for' region}} +#pragma omp target teams distribute simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) - ++a; + ; } -// TARGET TEAMS DISTRIBUTE PARALLEL FOR SIMD DIRECTIVE -#pragma omp target teams distribute parallel for simd // OK +// TARGET TEAMS DISTRIBUTE SIMD DIRECTIVE +#pragma omp target teams distribute simd // OK for (int i = 0; i < 10; ++i) ; -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp distribute parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp simd // omp45warn-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} { bar(); } } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} { bar(); } } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} { bar(); } } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} { bar(); } } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} { bar(); } } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} { @@ -18369,415 +19015,564 @@ } } } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} { bar(); } } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} { bar(); } } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} bar(); } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} bar(); } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'target teams distribute parallel for simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} +#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'target teams distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} omp51-error {{region cannot be closely nested inside 'target teams distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} bar(); } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} bar(); } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} bar(); } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} bar(); } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp atomic // omp45-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp target parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp target parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp target enter data map(to: a) // expected-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp target exit data map(from: a) // expected-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp target update to(a) // expected-error {{OpenMP constructs may not be nested inside a simd region}} ++a; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp distribute simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ++a; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp target simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ++a; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ++a; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp teams distribute simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ++a; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp teams distribute parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ++a; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} a++; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp target teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp target teams distribute parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute parallel for simd +#pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { #pragma omp target teams distribute simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} for (int i = 0; i < 10; ++i) ; } -// TARGET TEAMS DISTRIBUTE SIMD DIRECTIVE -#pragma omp target teams distribute simd // OK + // SCOPE DIRECTIVE +#pragma omp scope +#pragma omp parallel // OK + bar(); +#pragma omp scope +#pragma omp parallel for // OK + for(int i = 0; i < 10; i++) + ; +#pragma omp scope +#pragma omp parallel for simd // OK + for(int i = 0; i < 10; i++) + ; +#pragma omp scope +#pragma omp for for (int i = 0; i < 10; ++i) ; -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp distribute parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; +#pragma omp scope +#pragma omp simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp scope +#pragma omp for simd + for (int i = 0; i < 10; ++i) + ; +#pragma omp scope +#pragma omp sections + { + bar(); } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; +#pragma omp scope +#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a scope region}} + { + bar(); } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} +#pragma omp scope +#pragma omp single + bar(); + +#pragma omp scope +#pragma omp master + { + bar(); + } +#pragma omp scope +#pragma omp critical + { + bar(); + } +#pragma omp scope +#pragma omp parallel sections + { + bar(); + } +#pragma omp scope +#pragma omp parallel master + { + bar(); + } +#pragma omp scope +#pragma omp parallel masked + { + bar(); + } +#pragma omp scope +#pragma omp task + { + bar(); + } +#pragma omp scope + { +#pragma omp taskyield + bar(); + } +#pragma omp scope + { +#pragma omp barrier + bar(); + } +#pragma omp scope + { +#pragma omp scan // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} + bar(); + } +#pragma omp scope + { +#pragma omp taskwait + bar(); + } +#pragma omp scope + { +#pragma omp flush + bar(); + } +#pragma omp scope + { +#pragma omp ordered // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} + bar(); + } +#pragma omp scope + { +#pragma omp atomic + ++a; + } +#pragma omp scope + { +#pragma omp target parallel + ++a; + } +#pragma omp scope + { +#pragma omp target parallel for + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp scope + { +#pragma omp target enter data map(to: a) + ++a; + } +#pragma omp scope + { +#pragma omp target exit data map(from: a) + ++a; + } +#pragma omp scope + { +#pragma omp taskloop + for (int i = 0; i < 10; ++i) + ++a; + } +#pragma omp scope + { +#pragma omp target // OK + a++; + } +#pragma omp scope + { +#pragma omp teams // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} + a++; + } +#pragma omp scope + { +#pragma omp target teams // OK + a++; + } +#pragma omp scope + { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp simd // omp45warn-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}} + #pragma omp scope + { + #pragma omp distribute parallel for simd // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp distribute parallel for simd' directive into a teams region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp scope + { +#pragma omp distribute simd // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp distribute simd' directive into a teams region?}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} +#pragma omp scope + { +#pragma omp target simd // OK for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} +#pragma omp scope + { + #pragma omp teams distribute // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp teams distribute' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; + } +#pragma omp scope + { +#pragma omp teams distribute simd // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp teams distribute simd' directive into a target region?}} for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} - { - bar(); - } - } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} - { - bar(); - } +#pragma omp scope + { +#pragma omp teams distribute parallel for simd // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp teams distribute parallel for simd' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} - { - bar(); - } +#pragma omp scope + { +#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'scope' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}} + for (int i = 0; i < 10; ++i) + ; } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} - { - bar(); - } +#pragma omp scope + { +#pragma omp target teams // OK + ++a; } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} - { - bar(); - } +#pragma omp scope + { +#pragma omp target teams distribute // OK + for (int i = 0; i < 10; ++i) + ; } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} - { -#pragma omp single - { - bar(); - } - } +#pragma omp scope + { +#pragma omp target teams distribute parallel for // OK + for (int i = 0; i < 10; ++i) + ; } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} +#pragma omp scope + { +#pragma omp target teams distribute parallel for simd // OK for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} +#pragma omp scope + { +#pragma omp target teams distribute simd // OK for (int i = 0; i < 10; ++i) ; } -#pragma omp target teams distribute simd +#pragma omp for for (int i = 0; i < 10; ++i) { -#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} - { - bar(); - } +#pragma omp scope // expected-error {{region cannot be closely nested inside 'for' region}} + bar(); } -#pragma omp target teams distribute simd + +#pragma omp for simd for (int i = 0; i < 10; ++i) { -#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); + } + +#pragma omp sections + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'sections' region}} + bar(); + } + +#pragma omp sections + { +#pragma omp section { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'section' region}} bar(); } } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} + +#pragma omp single + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'single' region}} bar(); } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} + +#pragma omp master + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'master' region}} bar(); } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp scan // omp45-error {{OpenMP constructs may not be nested inside a simd region}} omp50-error {{region cannot be closely nested inside 'target teams distribute simd' region; perhaps you forget to enclose 'omp scan' directive into a for, simd, for simd, parallel for, or parallel for simd region?}} + +#pragma omp critical + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'critical' region}} bar(); } -#pragma omp target teams distribute simd + +#pragma omp parallel for for (int i = 0; i < 10; ++i) { -#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} +#pragma omp scope // expected-error {{region cannot be closely nested inside 'parallel for' region}} bar(); } -#pragma omp target teams distribute simd + +#pragma omp parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} bar(); } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} + +#pragma omp parallel master + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'parallel master' region}} bar(); } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp atomic // omp45-error {{OpenMP constructs may not be nested inside a simd region}} - ++a; - } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}} - ++a; - } -#pragma omp target teams distribute 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 sections + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'parallel sections' region}} + bar(); } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp target parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; + +#pragma omp task + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'task' region}} + bar(); } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp target enter data map(to: a) // expected-error {{OpenMP constructs may not be nested inside a simd region}} - ++a; + +#pragma omp ordered + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'ordered' region}} + bar(); } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp target exit data map(from: a) // expected-error {{OpenMP constructs may not be nested inside a simd region}} - ++a; + +#pragma omp 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 lvalue expression with scalar type}} + // expected-note@+1 {{expected an expression statement}} + { +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside an atomic region}} + bar(); } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} - ++a; + +#pragma omp target +#pragma omp teams + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp scope' directive into a parallel region?}} + bar(); } -#pragma omp target teams distribute simd + +#pragma omp taskloop for (int i = 0; i < 10; ++i) { -#pragma omp target update to(a) // expected-error {{OpenMP constructs may not be nested inside a simd region}} - ++a; +#pragma omp scope // expected-error {{region cannot be closely nested inside 'taskloop' region}} + bar(); } -#pragma omp target teams distribute simd + +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for for (int i = 0; i < 10; ++i) { -#pragma omp distribute simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ++a; +#pragma omp scope // expected-error {{region cannot be closely nested inside 'distribute parallel for' region}} + bar(); } -#pragma omp target teams distribute simd + +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp target simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ++a; +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); } -#pragma omp target teams distribute simd + +#pragma omp target simd for (int i = 0; i < 10; ++i) { -#pragma omp teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ++a; +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); } -#pragma omp target teams distribute simd + +#pragma omp target +#pragma omp teams distribute simd for (int i = 0; i < 10; ++i) { -#pragma omp teams distribute simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ++a; +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); } -#pragma omp target teams distribute simd + +#pragma omp target +#pragma omp teams distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp teams distribute parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ++a; +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); } -#pragma omp target teams distribute simd + +#pragma omp target +#pragma omp teams distribute parallel for for (int i = 0; i < 10; ++i) { -#pragma omp teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; +#pragma omp scope // expected-error {{region cannot be closely nested inside 'teams distribute parallel for' region}} + bar(); } -#pragma omp target teams distribute simd - for (int i = 0; i < 10; ++i) { -#pragma omp target teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} - a++; + +#pragma omp target teams + { +#pragma omp scope // expected-error {{region cannot be closely nested inside 'target teams' region; perhaps you forget to enclose 'omp scope' directive into a parallel region?}} + bar(); } -#pragma omp target teams distribute simd + +#pragma omp target teams distribute parallel for for (int i = 0; i < 10; ++i) { -#pragma omp target teams distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; +#pragma omp scope // expected-error {{region cannot be closely nested inside 'target teams distribute parallel for' region}} + bar(); } -#pragma omp target teams distribute simd + +#pragma omp target teams distribute parallel for simd for (int i = 0; i < 10; ++i) { -#pragma omp target teams distribute parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); } + #pragma omp target teams distribute simd for (int i = 0; i < 10; ++i) { -#pragma omp target teams distribute parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); } -#pragma omp target teams distribute simd + +#pragma omp simd for (int i = 0; i < 10; ++i) { -#pragma omp target teams distribute simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} - for (int i = 0; i < 10; ++i) - ; +#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}} + bar(); } return foo(); Index: clang/test/OpenMP/scope_ast_print.cpp =================================================================== --- /dev/null +++ clang/test/OpenMP/scope_ast_print.cpp @@ -0,0 +1,88 @@ +//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu\ +//RUN: -fopenmp -fopenmp-version=51 \ +//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \ +//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \ +//RUN: -ast-print %s | FileCheck %s --check-prefix=PRINT + +//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu\ +//RUN: -fopenmp -fopenmp-version=51 \ +//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \ +//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \ +//RUN: -ast-dump %s | FileCheck %s --check-prefix=DUMP + +//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu\ +//RUN: -fopenmp -fopenmp-version=51 \ +//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \ +//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \ +//RUN: -emit-pch -o %t %s + +//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu\ +//RUN: -fopenmp -fopenmp-version=51 \ +//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \ +//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \ +//RUN: -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT + +//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu\ +//RUN: -fopenmp -fopenmp-version=51 \ +//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \ +//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \ +//RUN: -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP + +#ifndef HEADER +#define HEADER +int foo1() { + int a; + int i = 1; + #pragma omp scope private(a) reduction(+:i) nowait + { + a = 123; + ++i; + } + return i; +} + +//DUMP: FunctionDecl {{.*}}foo1 'int ()' +//DUMP: OMPScopeDirective +//DUMP: OMPPrivateClause +//DUMP: DeclRefExpr {{.*}}'int' lvalue Var{{.*}}'a' 'int' +//DUMP: OMPReductionClause +//DUMP: DeclRefExpr {{.*}}'int' lvalue Var{{.*}}'i' 'int' +//DUMP: OMPNowaitClause +//PRINT: #pragma omp scope private(a) reduction(+: i) nowait + +template +T run() { + T a; + T b; + + #pragma omp scope private(a) reduction(*:b) + { + b *= a; + } + return b; +} + +int template_test() { + double d; + d = run(); + return 0; +} + +//DUMP: FunctionTemplateDecl {{.*}}run +//DUMP: TemplateTypeParmDecl {{.*}}referenced typename depth 0 index 0 T +//DUMP: FunctionDecl {{.*}}run 'T ()' +//DUMP: OMPScopeDirective +//DUMP: OMPPrivateClause +//DUMP: DeclRefExpr {{.*}}'T' lvalue Var {{.*}} 'a' 'T' +//DUMP: OMPReductionClause +//DUMP: DeclRefExpr {{.*}}'T' lvalue Var {{.*}} 'b' 'T' +//DUMP: FunctionDecl {{.*}}used run 'double ()' +//DUMP: TemplateArgument type 'double' +//DUMP: BuiltinType {{.*}}'double' +//DUMP: OMPScopeDirective +//DUMP: OMPPrivateClause +//DUMP: DeclRefExpr {{.*}}'double':'double' lvalue Var {{.*}} 'a' 'double':'double' +//DUMP: OMPReductionClause +//DUMP: DeclRefExpr {{.*}}'double':'double' lvalue Var {{.*}} 'b' 'double':'double' +//PRINT: #pragma omp scope private(a) reduction(*: b) +#endif // HEADER Index: clang/test/OpenMP/scope_messages.cpp =================================================================== --- /dev/null +++ clang/test/OpenMP/scope_messages.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 %s -verify=expected,omp51 +// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 %s -verify=expected,omp51 + +void test1() +{ + int var1; + int var2; + int var3 = 1; + + // expected-error@+1 {{directive '#pragma omp scope' cannot contain more than one 'nowait' clause}} //omp51-error@+1{{unexpected OpenMP clause 'firstprivate' in directive '#pragma omp scope'}} + #pragma omp scope private(var1) firstprivate(var3) nowait nowait + { var1 = 123; ++var2; var3 = 2;} +} Index: clang/tools/libclang/CIndex.cpp =================================================================== --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -5889,6 +5889,8 @@ return cxstring::createRef("OMPSectionsDirective"); case CXCursor_OMPSectionDirective: return cxstring::createRef("OMPSectionDirective"); + case CXCursor_OMPScopeDirective: + return cxstring::createRef("OMPScopeDirective"); case CXCursor_OMPSingleDirective: return cxstring::createRef("OMPSingleDirective"); case CXCursor_OMPMasterDirective: Index: clang/tools/libclang/CXCursor.cpp =================================================================== --- clang/tools/libclang/CXCursor.cpp +++ clang/tools/libclang/CXCursor.cpp @@ -680,6 +680,9 @@ case Stmt::OMPSectionDirectiveClass: K = CXCursor_OMPSectionDirective; break; + case Stmt::OMPScopeDirectiveClass: + K = CXCursor_OMPScopeDirective; + break; case Stmt::OMPSingleDirectiveClass: K = CXCursor_OMPSingleDirective; break; Index: llvm/include/llvm/Frontend/OpenMP/OMP.td =================================================================== --- llvm/include/llvm/Frontend/OpenMP/OMP.td +++ llvm/include/llvm/Frontend/OpenMP/OMP.td @@ -1979,6 +1979,15 @@ def OMP_EndAssumes : Directive<"end assumes"> {} def OMP_BeginDeclareVariant : Directive<"begin declare variant"> {} def OMP_EndDeclareVariant : Directive<"end declare variant"> {} +def OMP_scope : Directive<"scope"> { + let allowedClauses = [ + VersionedClause, + VersionedClause, + ]; + let allowedOnceClauses = [ + VersionedClause + ]; +} def OMP_ParallelWorkshare : Directive<"parallel workshare"> { let allowedClauses = [ VersionedClause,