*/
CXCursor_OMPTargetDirective = 252,
- /** \brief OpenMP teams directive.
- */
- CXCursor_OMPTeamsDirective = 253,
-
- CXCursor_LastStmt = CXCursor_OMPTeamsDirective,
+ CXCursor_LastStmt = CXCursor_OMPTargetDirective,
/**
* \brief Cursor that represents the translation unit itself.
DEF_TRAVERSE_STMT(OMPTargetDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
-DEF_TRAVERSE_STMT(OMPTeamsDirective,
- { TRY_TO(TraverseOMPExecutableDirective(S)); })
-
// OpenMP clauses.
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
DEF_TRAVERSE_STMT(OMPTargetDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
-DEF_TRAVERSE_STMT(OMPTeamsDirective,
- { TRY_TO(TraverseOMPExecutableDirective(S)); })
-
// OpenMP clauses.
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
}
};
-/// \brief This represents '#pragma omp teams' directive.
-///
-/// \code
-/// #pragma omp teams if(a)
-/// \endcode
-/// In this example directive '#pragma omp teams' has clause 'if' with
-/// condition 'a'.
-///
-class OMPTeamsDirective : public OMPExecutableDirective {
- friend class ASTStmtReader;
- /// \brief Build directive with the given start and end location.
- ///
- /// \param StartLoc Starting location of the directive kind.
- /// \param EndLoc Ending location of the directive.
- /// \param NumClauses Number of clauses.
- ///
- OMPTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
- unsigned NumClauses)
- : OMPExecutableDirective(this, OMPTeamsDirectiveClass, OMPD_teams,
- StartLoc, EndLoc, NumClauses, 1) {}
-
- /// \brief Build an empty directive.
- ///
- /// \param NumClauses Number of clauses.
- ///
- explicit OMPTeamsDirective(unsigned NumClauses)
- : OMPExecutableDirective(this, OMPTeamsDirectiveClass, OMPD_teams,
- SourceLocation(), SourceLocation(), NumClauses,
- 1) {}
-
-public:
- /// \brief Creates directive with a list of \a Clauses.
- ///
- /// \param C AST context.
- /// \param StartLoc Starting location of the directive kind.
- /// \param EndLoc Ending Location of the directive.
- /// \param Clauses List of clauses.
- /// \param AssociatedStmt Statement, associated with the directive.
- ///
- static OMPTeamsDirective *Create(const ASTContext &C, SourceLocation StartLoc,
- SourceLocation EndLoc,
- ArrayRef<OMPClause *> Clauses,
- Stmt *AssociatedStmt);
-
- /// \brief Creates an empty directive with the place for \a NumClauses
- /// clauses.
- ///
- /// \param C AST context.
- /// \param NumClauses Number of clauses.
- ///
- static OMPTeamsDirective *CreateEmpty(const ASTContext &C,
- unsigned NumClauses, EmptyShell);
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == OMPTeamsDirectiveClass;
- }
-};
-
} // end namespace clang
#endif
def err_omp_prohibited_region : Error<
"region cannot be%select{| closely}0 nested inside '%1' region"
"%select{|; perhaps you forget to enclose 'omp %3' directive into a parallel region?|"
- "; perhaps you forget to enclose 'omp %3' directive into a for or a parallel for region with 'ordered' clause?|"
- "; perhaps you forget to enclose 'omp %3' directive into a target region?}2">;
+ "; perhaps you forget to enclose 'omp %3' directive into a for or a parallel for region with 'ordered' clause?}2">;
def err_omp_prohibited_region_simd : Error<
"OpenMP constructs may not be nested inside a simd region">;
def err_omp_prohibited_region_atomic : Error<
"directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause">;
def note_omp_atomic_previous_clause : Note<
"'%0' clause used here">;
-def err_omp_target_contains_not_only_teams : Error<
- "target construct with nested teams region contains statements outside of the teams construct">;
-def note_omp_nested_teams_construct_here : Note<
- "nested teams construct here">;
-def note_omp_nested_statement_here : Note<
- "%select{statement|directive}0 outside teams construct here">;
} // end of OpenMP category
let CategoryName = "Related Result Type Issue" in {
#ifndef OPENMP_TARGET_CLAUSE
# define OPENMP_TARGET_CLAUSE(Name)
#endif
-#ifndef OPENMP_TEAMS_CLAUSE
-# define OPENMP_TEAMS_CLAUSE(Name)
-#endif
#ifndef OPENMP_DEFAULT_KIND
# define OPENMP_DEFAULT_KIND(Name)
#endif
OPENMP_DIRECTIVE(ordered)
OPENMP_DIRECTIVE(atomic)
OPENMP_DIRECTIVE(target)
-OPENMP_DIRECTIVE(teams)
OPENMP_DIRECTIVE_EXT(parallel_for, "parallel for")
OPENMP_DIRECTIVE_EXT(parallel_for_simd, "parallel for simd")
OPENMP_DIRECTIVE_EXT(parallel_sections, "parallel sections")
// TODO More clauses for 'target' directive.
OPENMP_TARGET_CLAUSE(if)
-// Clauses allowed for OpenMP directive 'teams'.
-// TODO More clauses for 'teams' directive.
-OPENMP_TEAMS_CLAUSE(default)
-OPENMP_TEAMS_CLAUSE(private)
-OPENMP_TEAMS_CLAUSE(firstprivate)
-OPENMP_TEAMS_CLAUSE(shared)
-OPENMP_TEAMS_CLAUSE(reduction)
-
#undef OPENMP_SCHEDULE_KIND
#undef OPENMP_PROC_BIND_KIND
#undef OPENMP_DEFAULT_KIND
#undef OPENMP_TASK_CLAUSE
#undef OPENMP_ATOMIC_CLAUSE
#undef OPENMP_TARGET_CLAUSE
-#undef OPENMP_TEAMS_CLAUSE
#undef OPENMP_SIMD_CLAUSE
#undef OPENMP_FOR_CLAUSE
#undef OPENMP_FOR_SIMD_CLAUSE
/// parallel', otherwise - false.
bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind);
-/// \brief Checks if the specified directive is a teams-kind directive.
-/// \param DKind Specified directive.
-/// \return true - the directive is a teams-like directive like 'omp teams',
-/// otherwise - false.
-bool isOpenMPTeamsDirective(OpenMPDirectiveKind DKind);
-
/// \brief Checks if the specified directive is a simd directive.
/// \param DKind Specified directive.
/// \return true - the directive is a simd directive like 'omp simd',
def OMPOrderedDirective : DStmt<OMPExecutableDirective>;
def OMPAtomicDirective : DStmt<OMPExecutableDirective>;
def OMPTargetDirective : DStmt<OMPExecutableDirective>;
-def OMPTeamsDirective : DStmt<OMPExecutableDirective>;
StmtResult ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
Stmt *AStmt, SourceLocation StartLoc,
SourceLocation EndLoc);
+
/// \brief Called on well-formed '\#pragma omp target' after parsing of the
/// associated statement.
StmtResult ActOnOpenMPTargetDirective(ArrayRef<OMPClause *> Clauses,
Stmt *AStmt, SourceLocation StartLoc,
SourceLocation EndLoc);
- /// \brief Called on well-formed '\#pragma omp teams' after parsing of the
- /// associated statement.
- StmtResult ActOnOpenMPTeamsDirective(ArrayRef<OMPClause *> Clauses,
- Stmt *AStmt, SourceLocation StartLoc,
- SourceLocation EndLoc);
OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
Expr *Expr,
STMT_OMP_ORDERED_DIRECTIVE,
STMT_OMP_ATOMIC_DIRECTIVE,
STMT_OMP_TARGET_DIRECTIVE,
- STMT_OMP_TEAMS_DIRECTIVE,
// ARC
EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr
return new (Mem) OMPTargetDirective(NumClauses);
}
-OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,
- SourceLocation StartLoc,
- SourceLocation EndLoc,
- ArrayRef<OMPClause *> Clauses,
- Stmt *AssociatedStmt) {
- unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTeamsDirective),
- llvm::alignOf<OMPClause *>());
- void *Mem =
- C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
- OMPTeamsDirective *Dir =
- new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size());
- Dir->setClauses(Clauses);
- Dir->setAssociatedStmt(AssociatedStmt);
- return Dir;
-}
-
-OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,
- unsigned NumClauses,
- EmptyShell) {
- unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTeamsDirective),
- llvm::alignOf<OMPClause *>());
- void *Mem =
- C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
- return new (Mem) OMPTeamsDirective(NumClauses);
-}
-
PrintOMPExecutableDirective(Node);
}
-void StmtPrinter::VisitOMPTeamsDirective(OMPTeamsDirective *Node) {
- Indent() << "#pragma omp teams ";
- PrintOMPExecutableDirective(Node);
-}
-
//===----------------------------------------------------------------------===//
// Expr printing methods.
//===----------------------------------------------------------------------===//
VisitOMPExecutableDirective(S);
}
-void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
- VisitOMPExecutableDirective(S);
-}
-
void StmtProfiler::VisitExpr(const Expr *S) {
VisitStmt(S);
}
#define OPENMP_TARGET_CLAUSE(Name) \
case OMPC_##Name: \
return true;
-#include "clang/Basic/OpenMPKinds.def"
- default:
- break;
- }
- break;
- case OMPD_teams:
- switch (CKind) {
-#define OPENMP_TEAMS_CLAUSE(Name) \
- case OMPC_##Name: \
- return true;
#include "clang/Basic/OpenMPKinds.def"
default:
break;
DKind == OMPD_parallel_sections; // TODO add next directives.
}
-bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {
- return DKind == OMPD_teams; // TODO add next directives.
-}
-
bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {
return DKind == OMPD_simd || DKind == OMPD_for_simd ||
DKind == OMPD_parallel_for_simd; // TODO add next directives.
case Stmt::OMPTargetDirectiveClass:
EmitOMPTargetDirective(cast<OMPTargetDirective>(*S));
break;
- case Stmt::OMPTeamsDirectiveClass:
- EmitOMPTeamsDirective(cast<OMPTeamsDirective>(*S));
- break;
}
}
llvm_unreachable("CodeGen for 'omp target' is not supported yet.");
}
-void CodeGenFunction::EmitOMPTeamsDirective(const OMPTeamsDirective &) {
- llvm_unreachable("CodeGen for 'omp teams' is not supported yet.");
-}
-
void EmitOMPOrderedDirective(const OMPOrderedDirective &S);
void EmitOMPAtomicDirective(const OMPAtomicDirective &S);
void EmitOMPTargetDirective(const OMPTargetDirective &S);
- void EmitOMPTeamsDirective(const OMPTeamsDirective &S);
/// Helpers for 'omp simd' directive.
void EmitOMPLoopBody(const OMPLoopDirective &Directive,
case OMPD_parallel_sections:
case OMPD_atomic:
case OMPD_target:
- case OMPD_teams:
Diag(Tok, diag::err_omp_unexpected_directive)
<< getOpenMPDirectiveName(DKind);
break;
/// 'section' | 'single' | 'master' | 'critical' [ '(' <name> ')' ] |
/// 'parallel for' | 'parallel sections' | 'task' | 'taskyield' |
/// 'barrier' | 'taskwait' | 'flush' | 'ordered' | 'atomic' |
-/// 'for simd' | 'parallel for simd' | 'target' | 'teams' {clause}
+/// 'for simd' | 'parallel for simd' | 'target' {clause}
/// annot_pragma_openmp_end
///
StmtResult
case OMPD_task:
case OMPD_ordered:
case OMPD_atomic:
- case OMPD_target:
- case OMPD_teams: {
+ case OMPD_target: {
ConsumeToken();
// Parse directive name of the 'critical' directive if any.
if (DKind == OMPD_critical) {
Scope *CurScope;
SourceLocation ConstructLoc;
bool OrderedRegion;
- SourceLocation InnerTeamsRegionLoc;
SharingMapTy(OpenMPDirectiveKind DKind, DeclarationNameInfo Name,
Scope *CurScope, SourceLocation Loc)
: SharingMap(), AlignedMap(), DefaultAttr(DSA_unspecified),
Directive(DKind), DirectiveName(std::move(Name)), CurScope(CurScope),
- ConstructLoc(Loc), OrderedRegion(false), InnerTeamsRegionLoc() {}
+ ConstructLoc(Loc), OrderedRegion(false) {}
SharingMapTy()
: SharingMap(), AlignedMap(), DefaultAttr(DSA_unspecified),
Directive(OMPD_unknown), DirectiveName(), CurScope(nullptr),
- ConstructLoc(), OrderedRegion(false), InnerTeamsRegionLoc() {}
+ ConstructLoc(), OrderedRegion(false) {}
};
typedef SmallVector<SharingMapTy, 64> StackTy;
return false;
}
- /// \brief Marks current target region as one with closely nested teams
- /// region.
- void setParentTeamsRegionLoc(SourceLocation TeamsRegionLoc) {
- if (Stack.size() > 2)
- Stack[Stack.size() - 2].InnerTeamsRegionLoc = TeamsRegionLoc;
- }
- /// \brief Returns true, if current region has closely nested teams region.
- bool hasInnerTeamsRegion() const {
- return getInnerTeamsRegionLoc().isValid();
- }
- /// \brief Returns location of the nested teams region (if any).
- SourceLocation getInnerTeamsRegionLoc() const {
- if (Stack.size() > 1)
- return Stack.back().InnerTeamsRegionLoc;
- return SourceLocation();
- }
-
Scope *getCurScope() const { return Stack.back().CurScope; }
Scope *getCurScope() { return Stack.back().CurScope; }
SourceLocation getConstructLoc() { return Stack.back().ConstructLoc; }
};
bool isParallelOrTaskRegion(OpenMPDirectiveKind DKind) {
return isOpenMPParallelDirective(DKind) || DKind == OMPD_task ||
- isOpenMPTeamsDirective(DKind) || DKind == OMPD_unknown;
+ DKind == OMPD_unknown;
}
} // namespace
// In a parallel construct, if no default clause is present, these
// variables are shared.
DVar.ImplicitDSALoc = Iter->DefaultAttrLoc;
- if (isOpenMPParallelDirective(DVar.DKind) ||
- isOpenMPTeamsDirective(DVar.DKind)) {
+ if (isOpenMPParallelDirective(DVar.DKind)) {
DVar.CKind = OMPC_shared;
return DVar;
}
DVar = Stack->hasInnermostDSA(VD, MatchesAnyClause(OMPC_reduction),
[](OpenMPDirectiveKind K) -> bool {
return isOpenMPParallelDirective(K) ||
- isOpenMPWorksharingDirective(K) ||
- isOpenMPTeamsDirective(K);
+ isOpenMPWorksharingDirective(K);
},
false);
if (DKind == OMPD_task && DVar.CKind == OMPC_reduction) {
Params);
break;
}
- case OMPD_teams: {
- QualType KmpInt32Ty = Context.getIntTypeForBitwidth(32, 1);
- QualType KmpInt32PtrTy = Context.getPointerType(KmpInt32Ty);
- Sema::CapturedParamNameType Params[] = {
- std::make_pair(".global_tid.", KmpInt32PtrTy),
- std::make_pair(".bound_tid.", KmpInt32PtrTy),
- std::make_pair(StringRef(), QualType()) // __context with shared vars
- };
- ActOnCapturedRegionStart(DSAStack->getConstructLoc(), CurScope, CR_OpenMP,
- Params);
- break;
- }
case OMPD_threadprivate:
llvm_unreachable("OpenMP Directive is not allowed");
case OMPD_unknown:
// | parallel | ordered | + |
// | parallel | atomic | * |
// | parallel | target | * |
- // | parallel | teams | + |
// +------------------+-----------------+------------------------------------+
// | for | parallel | * |
// | for | for | + |
// | for | ordered | * (if construct is ordered) |
// | for | atomic | * |
// | for | target | * |
- // | for | teams | + |
// +------------------+-----------------+------------------------------------+
// | master | parallel | * |
// | master | for | + |
// | master | ordered | + |
// | master | atomic | * |
// | master | target | * |
- // | master | teams | + |
// +------------------+-----------------+------------------------------------+
// | critical | parallel | * |
// | critical | for | + |
// | critical | ordered | + |
// | critical | atomic | * |
// | critical | target | * |
- // | critical | teams | + |
// +------------------+-----------------+------------------------------------+
// | simd | parallel | |
// | simd | for | |
// | simd | ordered | |
// | simd | atomic | |
// | simd | target | |
- // | simd | teams | |
// +------------------+-----------------+------------------------------------+
// | for simd | parallel | |
// | for simd | for | |
// | for simd | ordered | |
// | for simd | atomic | |
// | for simd | target | |
- // | for simd | teams | |
// +------------------+-----------------+------------------------------------+
// | parallel for simd| parallel | |
// | parallel for simd| for | |
// | parallel for simd| ordered | |
// | parallel for simd| atomic | |
// | parallel for simd| target | |
- // | parallel for simd| teams | |
// +------------------+-----------------+------------------------------------+
// | sections | parallel | * |
// | sections | for | + |
// | sections | ordered | + |
// | sections | atomic | * |
// | sections | target | * |
- // | sections | teams | + |
// +------------------+-----------------+------------------------------------+
// | section | parallel | * |
// | section | for | + |
// | section | ordered | + |
// | section | atomic | * |
// | section | target | * |
- // | section | teams | + |
// +------------------+-----------------+------------------------------------+
// | single | parallel | * |
// | single | for | + |
// | single | ordered | + |
// | single | atomic | * |
// | single | target | * |
- // | single | teams | + |
// +------------------+-----------------+------------------------------------+
// | parallel for | parallel | * |
// | parallel for | for | + |
// | parallel for | ordered | * (if construct is ordered) |
// | parallel for | atomic | * |
// | parallel for | target | * |
- // | parallel for | teams | + |
// +------------------+-----------------+------------------------------------+
// | parallel sections| parallel | * |
// | parallel sections| for | + |
// | parallel sections| ordered | + |
// | parallel sections| atomic | * |
// | parallel sections| target | * |
- // | parallel sections| teams | + |
// +------------------+-----------------+------------------------------------+
// | task | parallel | * |
// | task | for | + |
// | task | ordered | + |
// | task | atomic | * |
// | task | target | * |
- // | task | teams | + |
// +------------------+-----------------+------------------------------------+
// | ordered | parallel | * |
// | ordered | for | + |
// | ordered | ordered | + |
// | ordered | atomic | * |
// | ordered | target | * |
- // | ordered | teams | + |
// +------------------+-----------------+------------------------------------+
// | atomic | parallel | |
// | atomic | for | |
// | atomic | ordered | |
// | atomic | atomic | |
// | atomic | target | |
- // | atomic | teams | |
// +------------------+-----------------+------------------------------------+
// | target | parallel | * |
// | target | for | * |
// | target | ordered | * |
// | target | atomic | * |
// | target | target | * |
- // | target | teams | * |
- // +------------------+-----------------+------------------------------------+
- // | teams | parallel | * |
- // | teams | for | + |
- // | teams | for simd | + |
- // | teams | master | + |
- // | teams | critical | + |
- // | teams | simd | + |
- // | teams | sections | + |
- // | teams | section | + |
- // | teams | single | + |
- // | teams | parallel for | * |
- // | teams |parallel for simd| * |
- // | teams |parallel sections| * |
- // | teams | task | + |
- // | teams | taskyield | + |
- // | teams | barrier | + |
- // | teams | taskwait | + |
- // | teams | flush | + |
- // | teams | ordered | + |
- // | teams | atomic | + |
- // | teams | target | + |
- // | teams | teams | + |
// +------------------+-----------------+------------------------------------+
if (Stack->getCurScope()) {
auto ParentRegion = Stack->getParentDirective();
enum {
NoRecommend,
ShouldBeInParallelRegion,
- ShouldBeInOrderedRegion,
- ShouldBeInTargetRegion
+ ShouldBeInOrderedRegion
} Recommend = NoRecommend;
if (isOpenMPSimdDirective(ParentRegion)) {
// OpenMP [2.16, Nesting of Regions]
ParentRegion == OMPD_task ||
!Stack->isParentOrderedRegion();
Recommend = ShouldBeInOrderedRegion;
- } else if (isOpenMPTeamsDirective(CurrentRegion)) {
- // OpenMP [2.16, Nesting of Regions]
- // If specified, a teams construct must be contained within a target
- // construct.
- NestingProhibited = ParentRegion != OMPD_target;
- Recommend = ShouldBeInTargetRegion;
- Stack->setParentTeamsRegionLoc(Stack->getConstructLoc());
- }
- if (!NestingProhibited && isOpenMPTeamsDirective(ParentRegion)) {
- // OpenMP [2.16, Nesting of Regions]
- // distribute, parallel, parallel sections, parallel workshare, and the
- // parallel loop and parallel loop SIMD constructs are the only OpenMP
- // constructs that can be closely nested in the teams region.
- // TODO: add distribute directive.
- NestingProhibited = !isOpenMPParallelDirective(CurrentRegion);
- Recommend = ShouldBeInParallelRegion;
}
if (NestingProhibited) {
SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
Res = ActOnOpenMPAtomicDirective(ClausesWithImplicit, AStmt, StartLoc,
EndLoc);
break;
- case OMPD_teams:
- Res =
- ActOnOpenMPTeamsDirective(ClausesWithImplicit, AStmt, StartLoc, EndLoc);
- break;
case OMPD_target:
Res = ActOnOpenMPTargetDirective(ClausesWithImplicit, AStmt, StartLoc,
EndLoc);
SourceLocation EndLoc) {
assert(AStmt && isa<CapturedStmt>(AStmt) && "Captured statement expected");
- // OpenMP [2.16, Nesting of Regions]
- // If specified, a teams construct must be contained within a target
- // construct. That target construct must contain no statements or directives
- // outside of the teams construct.
- if (DSAStack->hasInnerTeamsRegion()) {
- auto S = AStmt->IgnoreContainers(/*IgnoreCaptured*/ true);
- bool OMPTeamsFound = true;
- if (auto *CS = dyn_cast<CompoundStmt>(S)) {
- auto I = CS->body_begin();
- while (I != CS->body_end()) {
- auto OED = dyn_cast<OMPExecutableDirective>(*I);
- if (!OED || !isOpenMPTeamsDirective(OED->getDirectiveKind())) {
- OMPTeamsFound = false;
- break;
- }
- ++I;
- }
- assert(I != CS->body_end() && "Not found statement");
- S = *I;
- }
- if (!OMPTeamsFound) {
- Diag(StartLoc, diag::err_omp_target_contains_not_only_teams);
- Diag(DSAStack->getInnerTeamsRegionLoc(),
- diag::note_omp_nested_teams_construct_here);
- Diag(S->getLocStart(), diag::note_omp_nested_statement_here)
- << isa<OMPExecutableDirective>(S);
- return StmtError();
- }
- }
-
getCurFunction()->setHasBranchProtectedScope();
return OMPTargetDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt);
}
-StmtResult Sema::ActOnOpenMPTeamsDirective(ArrayRef<OMPClause *> Clauses,
- Stmt *AStmt, SourceLocation StartLoc,
- SourceLocation EndLoc) {
- assert(AStmt && isa<CapturedStmt>(AStmt) && "Captured statement expected");
- CapturedStmt *CS = cast<CapturedStmt>(AStmt);
- // 1.2.2 OpenMP Language Terminology
- // Structured block - An executable statement with a single entry at the
- // top and a single exit at the bottom.
- // The point of exit cannot be a branch out of the structured block.
- // longjmp() and throw() must not violate the entry/exit criteria.
- CS->getCapturedDecl()->setNothrow();
-
- getCurFunction()->setHasBranchProtectedScope();
-
- return OMPTeamsDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt);
-}
-
OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
SourceLocation StartLoc,
SourceLocation LParenLoc,
return Res;
}
-template <typename Derived>
-StmtResult
-TreeTransform<Derived>::TransformOMPTeamsDirective(OMPTeamsDirective *D) {
- DeclarationNameInfo DirName;
- getDerived().getSema().StartOpenMPDSABlock(OMPD_teams, DirName, nullptr,
- D->getLocStart());
- StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
- getDerived().getSema().EndOpenMPDSABlock(Res.get());
- return Res;
-}
-
//===----------------------------------------------------------------------===//
// OpenMP clause transformation
//===----------------------------------------------------------------------===//
VisitOMPExecutableDirective(D);
}
-void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
- VisitStmt(D);
- // The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
- VisitOMPExecutableDirective(D);
-}
-
//===----------------------------------------------------------------------===//
// ASTReader Implementation
//===----------------------------------------------------------------------===//
Context, Record[ASTStmtReader::NumStmtFields], Empty);
break;
- case STMT_OMP_TEAMS_DIRECTIVE:
- S = OMPTeamsDirective::CreateEmpty(
- Context, Record[ASTStmtReader::NumStmtFields], Empty);
- break;
-
case EXPR_CXX_OPERATOR_CALL:
S = new (Context) CXXOperatorCallExpr(Context, Empty);
break;
Code = serialization::STMT_OMP_ORDERED_DIRECTIVE;
}
-void ASTStmtWriter::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
- VisitStmt(D);
- Record.push_back(D->getNumClauses());
- VisitOMPExecutableDirective(D);
- Code = serialization::STMT_OMP_TEAMS_DIRECTIVE;
-}
-
//===----------------------------------------------------------------------===//
// ASTWriter Implementation
//===----------------------------------------------------------------------===//
case Stmt::OMPOrderedDirectiveClass:
case Stmt::OMPAtomicDirectiveClass:
case Stmt::OMPTargetDirectiveClass:
- case Stmt::OMPTeamsDirectiveClass:
llvm_unreachable("Stmt should not be in analyzer evaluation loop");
case Stmt::ObjCSubscriptRefExprClass:
#pragma omp target
++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;
- }
// SIMD DIRECTIVE
#pragma omp simd
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
-#pragma omp simd
- for (int i = 0; i < 10; ++i) {
-#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
- ++a;
- }
// FOR DIRECTIVE
#pragma omp for
#pragma omp target
++a;
}
-#pragma omp for
- for (int i = 0; i < 10; ++i) {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// FOR SIMD DIRECTIVE
#pragma omp for simd
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
-#pragma omp for simd
- for (int i = 0; i < 10; ++i) {
-#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
- ++a;
- }
// SECTIONS DIRECTIVE
#pragma omp sections
#pragma omp target
++a;
}
-#pragma omp sections
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// SECTION DIRECTIVE
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
#pragma omp target
++a;
}
-#pragma omp sections
- {
-#pragma omp section
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// SINGLE DIRECTIVE
#pragma omp single
#pragma omp target
++a;
}
-#pragma omp single
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// MASTER DIRECTIVE
#pragma omp master
#pragma omp target
++a;
}
-#pragma omp master
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// CRITICAL DIRECTIVE
#pragma omp critical
#pragma omp target
++a;
}
-#pragma omp critical
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// PARALLEL FOR DIRECTIVE
#pragma omp parallel for
#pragma omp target
++a;
}
-#pragma omp parallel for
- for (int i = 0; i < 10; ++i) {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// PARALLEL FOR SIMD DIRECTIVE
#pragma omp parallel for simd
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
-#pragma omp parallel for simd
- for (int i = 0; i < 10; ++i) {
-#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
- ++a;
- }
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
#pragma omp target
++a;
}
-#pragma omp parallel sections
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// TASK DIRECTIVE
#pragma omp task
#pragma omp target
++a;
}
-#pragma omp task
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// ORDERED DIRECTIVE
#pragma omp ordered
#pragma omp target
++a;
}
-#pragma omp ordered
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// ATOMIC DIRECTIVE
#pragma omp atomic
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
++a;
}
-#pragma omp atomic
- // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
- {
-#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
- ++a;
- }
// TARGET DIRECTIVE
#pragma omp target
#pragma omp target
++a;
}
-#pragma omp target
- {
-#pragma omp teams
- ++a;
- }
-#pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}}
- {
- ++a; // expected-note {{statement outside teams construct here}}
-#pragma omp teams // expected-note {{nested teams construct here}}
- ++a;
- }
-
-// TEAMS DIRECTIVE
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel
- bar();
-#pragma omp target
-#pragma omp teams
-#pragma omp for // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
- for (int i = 0; i < 10; ++i)
- ;
-#pragma omp target
-#pragma omp teams
-#pragma omp simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp simd' directive into a parallel region?}}
- for (int i = 0; i < 10; ++i)
- ;
-#pragma omp target
-#pragma omp teams
-#pragma omp for simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
- for (int i = 0; i < 10; ++i)
- ;
-#pragma omp target
-#pragma omp teams
-#pragma omp sections // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
- {
- bar();
- }
-#pragma omp target
-#pragma omp teams
-#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a teams region}}
- {
- bar();
- }
-#pragma omp target
-#pragma omp teams
-#pragma omp single // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
- bar();
-
-#pragma omp target
-#pragma omp teams
-#pragma omp master // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp master' directive into a parallel region?}}
- {
- bar();
- }
-#pragma omp target
-#pragma omp teams
-#pragma omp critical // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp critical' directive into a parallel region?}}
- {
- bar();
- }
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel for
- for (int i = 0; i < 10; ++i)
- ;
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel for simd
- for (int i = 0; i < 10; ++i)
- ;
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel sections
- {
- bar();
- }
-#pragma omp target
-#pragma omp teams
-#pragma omp task // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp task' directive into a parallel region?}}
- {
- bar();
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp taskyield // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskyield' directive into a parallel region?}}
- bar();
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp barrier // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp barrier' directive into a parallel region?}}
- bar();
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp taskwait // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskwait' directive into a parallel region?}}
- bar();
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp flush // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp flush' directive into a parallel region?}}
- bar();
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp ordered // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
- bar();
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp atomic // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp atomic' directive into a parallel region?}}
- ++a;
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp target // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp target' directive into a parallel region?}}
- ++a;
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
}
void foo() {
#pragma omp target
++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;
- }
// SIMD DIRECTIVE
#pragma omp simd
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
-#pragma omp simd
- for (int i = 0; i < 10; ++i) {
-#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
- ++a;
- }
// FOR DIRECTIVE
#pragma omp for
#pragma omp target
++a;
}
-#pragma omp for
- for (int i = 0; i < 10; ++i) {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// FOR SIMD DIRECTIVE
#pragma omp for simd
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
-#pragma omp for simd
- for (int i = 0; i < 10; ++i) {
-#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
- ++a;
- }
// SECTIONS DIRECTIVE
#pragma omp sections
#pragma omp target
++a;
}
-#pragma omp sections
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// SECTION DIRECTIVE
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
++a;
}
}
-#pragma omp sections
- {
-#pragma omp section
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
- }
// SINGLE DIRECTIVE
#pragma omp single
#pragma omp target
++a;
}
-#pragma omp single
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// MASTER DIRECTIVE
#pragma omp master
#pragma omp target
++a;
}
-#pragma omp master
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// CRITICAL DIRECTIVE
#pragma omp critical
#pragma omp target
++a;
}
-#pragma omp critical
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// PARALLEL FOR DIRECTIVE
#pragma omp parallel for
#pragma omp target
++a;
}
-#pragma omp parallel for
- for (int i = 0; i < 10; ++i) {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// PARALLEL FOR SIMD DIRECTIVE
#pragma omp parallel for simd
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
-#pragma omp parallel for simd
- for (int i = 0; i < 10; ++i) {
-#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
- ++a;
- }
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
#pragma omp target
++a;
}
-#pragma omp parallel sections
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// TASK DIRECTIVE
#pragma omp task
#pragma omp target
++a;
}
-#pragma omp task
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
// ATOMIC DIRECTIVE
#pragma omp atomic
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
++a;
}
-#pragma omp atomic
- // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
- {
-#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
- ++a;
- }
// TARGET DIRECTIVE
#pragma omp target
#pragma omp target
++a;
}
-#pragma omp target
- {
-#pragma omp teams
- ++a;
- }
-#pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}}
- {
- ++a; // expected-note {{statement outside teams construct here}}
-#pragma omp teams // expected-note {{nested teams construct here}}
- ++a;
- }
-
-// TEAMS DIRECTIVE
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel
- bar();
-#pragma omp target
-#pragma omp teams
-#pragma omp for // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
- for (int i = 0; i < 10; ++i)
- ;
-#pragma omp target
-#pragma omp teams
-#pragma omp simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp simd' directive into a parallel region?}}
- for (int i = 0; i < 10; ++i)
- ;
-#pragma omp target
-#pragma omp teams
-#pragma omp for simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
- for (int i = 0; i < 10; ++i)
- ;
-#pragma omp target
-#pragma omp teams
-#pragma omp sections // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
- {
- bar();
- }
-#pragma omp target
-#pragma omp teams
-#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a teams region}}
- {
- bar();
- }
-#pragma omp target
-#pragma omp teams
-#pragma omp single // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
- bar();
-
-#pragma omp target
-#pragma omp teams
-#pragma omp master // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp master' directive into a parallel region?}}
- {
- bar();
- }
-#pragma omp target
-#pragma omp teams
-#pragma omp critical // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp critical' directive into a parallel region?}}
- {
- bar();
- }
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel for
- for (int i = 0; i < 10; ++i)
- ;
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel for simd
- for (int i = 0; i < 10; ++i)
- ;
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel sections
- {
- bar();
- }
-#pragma omp target
-#pragma omp teams
-#pragma omp task // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp task' directive into a parallel region?}}
- {
- bar();
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp taskyield // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskyield' directive into a parallel region?}}
- bar();
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp barrier // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp barrier' directive into a parallel region?}}
- bar();
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp taskwait // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskwait' directive into a parallel region?}}
- bar();
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp flush // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp flush' directive into a parallel region?}}
- bar();
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp ordered // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
- bar();
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp atomic // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp atomic' directive into a parallel region?}}
- ++a;
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp target // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp target' directive into a parallel region?}}
- ++a;
- }
-#pragma omp target
-#pragma omp teams
- {
-#pragma omp teams // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
- ++a;
- }
return foo<int>();
}
+++ /dev/null
-// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
-// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
-// expected-no-diagnostics
-
-#ifndef HEADER
-#define HEADER
-
-void foo() {}
-
-template <class T>
-struct S {
- operator T() {return T();}
- static T TS;
- #pragma omp threadprivate(TS)
-};
-
-// CHECK: template <class T = int> struct S {
-// CHECK: static int TS;
-// CHECK-NEXT: #pragma omp threadprivate(S<int>::TS)
-// CHECK-NEXT: }
-// CHECK: template <class T = long> struct S {
-// CHECK: static long TS;
-// CHECK-NEXT: #pragma omp threadprivate(S<long>::TS)
-// CHECK-NEXT: }
-// CHECK: template <class T> struct S {
-// CHECK: static T TS;
-// CHECK-NEXT: #pragma omp threadprivate(S::TS)
-// CHECK: };
-
-template <typename T, int C>
-T tmain(T argc, T *argv) {
- T b = argc, c, d, e, f, g;
- static T a;
- S<T> s;
-#pragma omp target
-#pragma omp teams
- a=2;
-#pragma omp target
-#pragma omp teams default(none), private(argc,b) firstprivate(argv) shared (d) reduction(+:c) reduction(max:e)
- foo();
-#pragma omp target
-#pragma omp teams reduction(^:e, f) reduction(&& : g)
- foo();
- return 0;
-}
-
-// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) {
-// CHECK-NEXT: int b = argc, c, d, e, f, g;
-// CHECK-NEXT: static int a;
-// CHECK-NEXT: S<int> s;
-// CHECK-NEXT: #pragma omp target
-// CHECK-NEXT: #pragma omp teams
-// CHECK-NEXT: a = 2;
-// CHECK-NEXT: #pragma omp target
-// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e)
-// CHECK-NEXT: foo()
-// CHECK-NEXT: #pragma omp target
-// CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g)
-// CHECK-NEXT: foo()
-// CHECK: template <typename T = long, int C = 1> long tmain(long argc, long *argv) {
-// CHECK-NEXT: long b = argc, c, d, e, f, g;
-// CHECK-NEXT: static long a;
-// CHECK-NEXT: S<long> s;
-// CHECK-NEXT: #pragma omp target
-// CHECK-NEXT: #pragma omp teams
-// CHECK-NEXT: a = 2;
-// CHECK-NEXT: #pragma omp target
-// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e)
-// CHECK-NEXT: foo()
-// CHECK-NEXT: #pragma omp target
-// CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g)
-// CHECK-NEXT: foo()
-// CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
-// CHECK-NEXT: T b = argc, c, d, e, f, g;
-// CHECK-NEXT: static T a;
-// CHECK-NEXT: S<T> s;
-// CHECK-NEXT: #pragma omp target
-// CHECK-NEXT: #pragma omp teams
-// CHECK-NEXT: a = 2;
-// CHECK-NEXT: #pragma omp target
-// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e)
-// CHECK-NEXT: foo()
-// CHECK-NEXT: #pragma omp target
-// CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g)
-// CHECK-NEXT: foo()
-
-enum Enum { };
-
-int main (int argc, char **argv) {
- long x;
- int b = argc, c, d, e, f, g;
- static int a;
- #pragma omp threadprivate(a)
- Enum ee;
-// CHECK: Enum ee;
-#pragma omp target
-#pragma omp teams
-// CHECK-NEXT: #pragma omp target
-// CHECK-NEXT: #pragma omp teams
- a=2;
-// CHECK-NEXT: a = 2;
-#pragma omp target
-#pragma omp teams default(none), private(argc,b) firstprivate(argv) reduction(| : c, d) reduction(* : e)
-// CHECK-NEXT: #pragma omp target
-// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) reduction(|: c,d) reduction(*: e)
- foo();
-// CHECK-NEXT: foo();
- return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);
-}
-
-#endif
+++ /dev/null
-// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -o - %s
-
-void foo();
-
-int main(int argc, char **argv) {
- #pragma omp target
- #pragma omp teams default // expected-error {{expected '(' after 'default'}}
- foo();
- #pragma omp target
- #pragma omp teams default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
- #pragma omp target
- #pragma omp teams default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
- foo();
- #pragma omp target
- #pragma omp teams default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
- #pragma omp target
- #pragma omp teams default (shared), default(shared) // expected-error {{directive '#pragma omp teams' cannot contain more than one 'default' clause}}
- foo();
- #pragma omp target
- #pragma omp teams default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
- foo();
-
- #pragma omp target
- #pragma omp teams default(none)
- ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
-
- #pragma omp target
- #pragma omp teams default(none)
- #pragma omp parallel default(shared)
- ++argc;
- return 0;
-}
+++ /dev/null
-// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
-
-void foo() {
-}
-
-bool foobool(int argc) {
- return argc;
-}
-
-struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
-extern S1 a;
-class S2 {
- mutable int a;
-public:
- S2():a(0) { }
- S2(S2 &s2):a(s2.a) { }
- static float S2s;
- static const float S2sc;
-};
-const float S2::S2sc = 0;
-const S2 b;
-const S2 ba[5];
-class S3 {
- int a;
-public:
- S3():a(0) { }
- S3(S3 &s3):a(s3.a) { }
-};
-const S3 c;
-const S3 ca[5];
-extern const int f;
-class S4 { // expected-note {{'S4' declared here}}
- int a;
- S4();
- S4(const S4 &s4);
-public:
- S4(int v):a(v) { }
-};
-class S5 { // expected-note {{'S5' declared here}}
- int a;
- S5():a(0) {}
- S5(const S5 &s5):a(s5.a) { }
-public:
- S5(int v):a(v) { }
-};
-
-S3 h;
-#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
-
-int main(int argc, char **argv) {
- const int d = 5;
- const int da[5] = { 0 };
- S4 e(4); // expected-note {{'e' defined here}}
- S5 g(5); // expected-note {{'g' defined here}}
- int i;
- int &j = i; // expected-note {{'j' defined here}}
- #pragma omp target
- #pragma omp teams firstprivate // expected-error {{expected '(' after 'firstprivate'}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate () // expected-error {{expected expression}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate (argc)
- foo();
- #pragma omp target
- #pragma omp teams firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate (argv[1]) // expected-error {{expected variable name}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(ba)
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(ca)
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(da)
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(S2::S2s)
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(S2::S2sc)
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
- foo();
- #pragma omp target
- #pragma omp teams private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
- foo();
- #pragma omp target
- #pragma omp teams shared(i)
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(i)
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
- foo();
-
- return 0;
-}
+++ /dev/null
-// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -std=c++11 -o - %s
-
-void foo() {
-}
-
-#pragma omp teams // expected-error {{unexpected OpenMP directive '#pragma omp teams'}}
-
-int main(int argc, char **argv) {
- #pragma omp target
- #pragma omp teams { // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
- foo();
- #pragma omp target
- #pragma omp teams ( // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
- foo();
- #pragma omp target
- #pragma omp teams [ // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
- foo();
- #pragma omp target
- #pragma omp teams ] // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
- foo();
- #pragma omp target
- #pragma omp teams ) // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
- foo();
- #pragma omp target
- #pragma omp teams } // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
- foo();
- #pragma omp target
- #pragma omp teams
- foo();
- // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams' are ignored}}
- #pragma omp target
- #pragma omp teams unknown()
- foo();
- L1:
- foo();
- #pragma omp target
- #pragma omp teams
- ;
- #pragma omp target
- #pragma omp teams
- {
- goto L1; // expected-error {{use of undeclared label 'L1'}}
- argc++;
- }
-
- for (int i = 0; i < 10; ++i) {
- switch(argc) {
- case (0):
- #pragma omp target
- #pragma omp teams
- {
- foo();
- break; // expected-error {{'break' statement not in loop or switch statement}}
- continue; // expected-error {{'continue' statement not in loop statement}}
- }
- default:
- break;
- }
- }
- #pragma omp target
- #pragma omp teams default(none)
- ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
-
- goto L2; // expected-error {{use of undeclared label 'L2'}}
- #pragma omp target
- #pragma omp teams
- L2:
- foo();
- #pragma omp target
- #pragma omp teams
- {
- return 1; // expected-error {{cannot return from OpenMP region}}
- }
-
- [[]] // expected-error {{an attribute list cannot appear here}}
- #pragma omp target
- #pragma omp teams
- for (int n = 0; n < 100; ++n) {}
-
- return 0;
-}
-
+++ /dev/null
-// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
-
-void foo() {
-}
-
-bool foobool(int argc) {
- return argc;
-}
-
-struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
-extern S1 a;
-class S2 {
- mutable int a;
-public:
- S2():a(0) { }
- static float S2s; // expected-note {{static data member is predetermined as shared}}
-};
-const S2 b;
-const S2 ba[5];
-class S3 {
- int a;
-public:
- S3():a(0) { }
-};
-const S3 c; // expected-note {{global variable is predetermined as shared}}
-const S3 ca[5]; // expected-note {{global variable is predetermined as shared}}
-extern const int f; // expected-note {{global variable is predetermined as shared}}
-class S4 { // expected-note {{'S4' declared here}}
- int a;
- S4();
-public:
- S4(int v):a(v) { }
-};
-class S5 { // expected-note {{'S5' declared here}}
- int a;
- S5():a(0) {}
-public:
- S5(int v):a(v) { }
-};
-
-int threadvar;
-#pragma omp threadprivate(threadvar) // expected-note {{defined as threadprivate or thread local}}
-
-int main(int argc, char **argv) {
- const int d = 5; // expected-note {{constant variable is predetermined as shared}}
- const int da[5] = { 0 }; // expected-note {{constant variable is predetermined as shared}}
- S4 e(4); // expected-note {{'e' defined here}}
- S5 g(5); // expected-note {{'g' defined here}}
- int i;
- int &j = i; // expected-note {{'j' defined here}}
- #pragma omp target
- #pragma omp teams private // expected-error {{expected '(' after 'private'}}
- foo();
- #pragma omp target
- #pragma omp teams private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
- #pragma omp target
- #pragma omp teams private () // expected-error {{expected expression}}
- foo();
- #pragma omp target
- #pragma omp teams private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
- #pragma omp target
- #pragma omp teams private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
- #pragma omp target
- #pragma omp teams private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
- foo();
- #pragma omp target
- #pragma omp teams private (argc argv) // expected-error {{expected ',' or ')' in 'private' clause}}
- foo();
- #pragma omp target
- #pragma omp teams private (S1) // expected-error {{'S1' does not refer to a value}}
- foo();
- #pragma omp target
- #pragma omp teams private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}}
- foo();
- #pragma omp target
- #pragma omp teams private (argv[1]) // expected-error {{expected variable name}}
- foo();
- #pragma omp target
- #pragma omp teams private(ba)
- foo();
- #pragma omp target
- #pragma omp teams private(ca) // expected-error {{shared variable cannot be private}}
- foo();
- #pragma omp target
- #pragma omp teams private(da) // expected-error {{shared variable cannot be private}}
- foo();
- #pragma omp target
- #pragma omp teams private(S2::S2s) // expected-error {{shared variable cannot be private}}
- foo();
- #pragma omp target
- #pragma omp teams private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}}
- foo();
- #pragma omp target
- #pragma omp teams private(threadvar) // expected-error {{threadprivate or thread local variable cannot be private}}
- foo();
- #pragma omp target
- #pragma omp teams shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}}
- foo();
- #pragma omp target
- #pragma omp teams private(i)
- foo();
- #pragma omp target
- #pragma omp teams private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type 'int &'}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(i)
- for (int k = 0; k < 10; ++k) {
- #pragma omp parallel private(i)
- foo();
- }
-
- return 0;
-}
+++ /dev/null
-// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -o - %s
-
-void foo() {
-}
-
-bool foobool(int argc) {
- return argc;
-}
-
-struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
-extern S1 a;
-class S2 {
- mutable int a;
- S2 &operator+=(const S2 &arg) { return (*this); }
-
-public:
- S2() : a(0) {}
- S2(S2 &s2) : a(s2.a) {}
- static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
- static const float S2sc;
-};
-const float S2::S2sc = 0; // expected-note 2 {{'S2sc' defined here}}
-S2 b; // expected-note 2 {{'b' defined here}}
-const S2 ba[5]; // expected-note 2 {{'ba' defined here}}
-class S3 {
- int a;
-
-public:
- S3() : a(0) {}
- S3(const S3 &s3) : a(s3.a) {}
- S3 operator+=(const S3 &arg1) { return arg1; }
-};
-int operator+=(const S3 &arg1, const S3 &arg2) { return 5; }
-S3 c; // expected-note 2 {{'c' defined here}}
-const S3 ca[5]; // expected-note 2 {{'ca' defined here}}
-extern const int f; // expected-note 4 {{'f' declared here}}
-class S4 { // expected-note {{'S4' declared here}}
- int a;
- S4();
- S4(const S4 &s4);
- S4 &operator+=(const S4 &arg) { return (*this); }
-
-public:
- S4(int v) : a(v) {}
-};
-S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
-class S5 {
- int a;
- S5() : a(0) {}
- S5(const S5 &s5) : a(s5.a) {}
- S5 &operator+=(const S5 &arg);
-
-public:
- S5(int v) : a(v) {}
-};
-class S6 {
- int a;
-
-public:
- S6() : a(6) {}
- operator int() { return 6; }
-} o; // expected-note 2 {{'o' defined here}}
-
-S3 h, k;
-#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
-
-template <class T> // expected-note {{declared here}}
-T tmain(T argc) { // expected-note 2 {{'argc' defined here}}
- const T d = T(); // expected-note 4 {{'d' defined here}}
- const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
- T qa[5] = {T()};
- T i;
- T &j = i; // expected-note 4 {{'j' defined here}}
- S3 &p = k; // expected-note 2 {{'p' defined here}}
- const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}}
- T &q = qa[(int)i]; // expected-note 2 {{'q' defined here}}
- T fl; // expected-note {{'fl' defined here}}
-#pragma omp target
-#pragma omp teams reduction // expected-error {{expected '(' after 'reduction'}}
- foo();
-#pragma omp target
-#pragma omp teams reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
- foo();
-#pragma omp target
-#pragma omp teams reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
-#pragma omp target
-#pragma omp teams reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{variable of type 'float' is not valid for specified reduction operation}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{variable of type 'float' is not valid for specified reduction operation}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(&& : argc)
- foo();
-#pragma omp target
-#pragma omp teams reduction(^ : T) // expected-error {{'T' does not refer to a value}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(+ : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 3 {{const-qualified variable cannot be reduction}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(min : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified variable cannot be reduction}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(max : qa[1]) // expected-error 2 {{expected variable name}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}} expected-error {{a reduction variable with array type 'const float [5]'}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}}
- foo();
-#pragma omp target
-#pragma omp teams private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
- foo();
-#pragma omp parallel private(k)
-#pragma omp target
-#pragma omp teams reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(+ : p), reduction(+ : p) // expected-error 3 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 3 {{previously referenced here}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(+ : r) // expected-error 2 {{const-qualified variable cannot be reduction}}
- foo();
-#pragma omp parallel shared(i)
-#pragma omp parallel reduction(min : i)
-#pragma omp target
-#pragma omp teams reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
- foo();
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel for private(fl)
- for (int i = 0; i < 10; ++i)
-#pragma omp target
-#pragma omp teams reduction(+ : fl)
- foo();
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel for reduction(- : fl)
- for (int i = 0; i < 10; ++i)
-#pragma omp target
-#pragma omp teams reduction(+ : fl)
- foo();
-
- return T();
-}
-
-int main(int argc, char **argv) {
- const int d = 5; // expected-note 2 {{'d' defined here}}
- const int da[5] = {0}; // expected-note {{'da' defined here}}
- int qa[5] = {0};
- S4 e(4); // expected-note {{'e' defined here}}
- S5 g(5); // expected-note {{'g' defined here}}
- int i;
- int &j = i; // expected-note 2 {{'j' defined here}}
- S3 &p = k; // expected-note 2 {{'p' defined here}}
- const int &r = da[i]; // expected-note {{'r' defined here}}
- int &q = qa[i]; // expected-note {{'q' defined here}}
- float fl; // expected-note {{'fl' defined here}}
-#pragma omp target
-#pragma omp teams reduction // expected-error {{expected '(' after 'reduction'}}
- foo();
-#pragma omp target
-#pragma omp teams reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
- foo();
-#pragma omp target
-#pragma omp teams reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
-#pragma omp target
-#pragma omp teams reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(~ : argc) // expected-error {{expected unqualified-id}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(&& : argc)
- foo();
-#pragma omp target
-#pragma omp teams reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(+ : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{const-qualified variable cannot be reduction}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(min : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified variable cannot be reduction}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(max : argv[1]) // expected-error {{expected variable name}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(& : e, g) // expected-error {{reduction variable must have an accessible, unambiguous default constructor}} expected-error {{variable of type 'S5' is not valid for specified reduction operation}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}}
- foo();
-#pragma omp target
-#pragma omp teams private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
- foo();
-#pragma omp parallel private(k)
-#pragma omp target
-#pragma omp teams reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
- foo();
-#pragma omp target
-#pragma omp teams reduction(+ : r) // expected-error {{const-qualified variable cannot be reduction}}
- foo();
-#pragma omp parallel shared(i)
-#pragma omp parallel reduction(min : i)
-#pragma omp target
-#pragma omp teams reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
- foo();
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel for private(fl)
- for (int i = 0; i < 10; ++i)
-#pragma omp target
-#pragma omp teams reduction(+ : fl)
- foo();
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel for reduction(- : fl)
- for (int i = 0; i < 10; ++i)
-#pragma omp target
-#pragma omp teams reduction(+ : fl)
- foo();
-
- return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<float>' requested here}}
-}
+++ /dev/null
-// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
-
-void foo() {
-}
-
-bool foobool(int argc) {
- return argc;
-}
-
-struct S1; // expected-note {{declared here}}
-extern S1 a;
-class S2 {
- mutable int a;
-public:
- S2():a(0) { }
- S2(S2 &s2):a(s2.a) { }
-};
-const S2 b;
-const S2 ba[5];
-class S3 {
- int a;
-public:
- S3():a(0) { }
- S3(S3 &s3):a(s3.a) { }
-};
-const S3 c;
-const S3 ca[5];
-extern const int f;
-class S4 {
- int a;
- S4();
- S4(const S4 &s4);
-public:
- S4(int v):a(v) { }
-};
-class S5 {
- int a;
- S5():a(0) {}
- S5(const S5 &s5):a(s5.a) { }
-public:
- S5(int v):a(v) { }
-};
-
-S3 h;
-#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
-
-int main(int argc, char **argv) {
- const int d = 5;
- const int da[5] = { 0 };
- S4 e(4);
- S5 g(5);
- int i;
- int &j = i;
- #pragma omp target
- #pragma omp teams shared // expected-error {{expected '(' after 'shared'}}
- foo();
- #pragma omp target
- #pragma omp teams shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
- #pragma omp target
- #pragma omp teams shared () // expected-error {{expected expression}}
- foo();
- #pragma omp target
- #pragma omp teams shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
- #pragma omp target
- #pragma omp teams shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- foo();
- #pragma omp target
- #pragma omp teams shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
- foo();
- #pragma omp target
- #pragma omp teams shared (argc)
- foo();
- #pragma omp target
- #pragma omp teams shared (S1) // expected-error {{'S1' does not refer to a value}}
- foo();
- #pragma omp target
- #pragma omp teams shared (a, b, c, d, f)
- foo();
- #pragma omp target
- #pragma omp teams shared (argv[1]) // expected-error {{expected variable name}}
- foo();
- #pragma omp target
- #pragma omp teams shared(ba)
- foo();
- #pragma omp target
- #pragma omp teams shared(ca)
- foo();
- #pragma omp target
- #pragma omp teams shared(da)
- foo();
- #pragma omp target
- #pragma omp teams shared(e, g)
- foo();
- #pragma omp target
- #pragma omp teams shared(h) // expected-error {{threadprivate or thread local variable cannot be shared}}
- foo();
- #pragma omp target
- #pragma omp teams private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
- foo();
- #pragma omp target
- #pragma omp teams private(i)
- foo();
- #pragma omp target
- #pragma omp teams shared(i)
- foo();
- #pragma omp target
- #pragma omp teams shared(j)
- foo();
- #pragma omp target
- #pragma omp teams firstprivate(i)
- foo();
- #pragma omp target
- #pragma omp teams shared(i)
- foo();
- #pragma omp target
- #pragma omp teams shared(j)
- foo();
-
- return 0;
-}
void VisitOMPOrderedDirective(const OMPOrderedDirective *D);
void VisitOMPAtomicDirective(const OMPAtomicDirective *D);
void VisitOMPTargetDirective(const OMPTargetDirective *D);
- void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
private:
void AddDeclarationNameInfo(const Stmt *S);
VisitOMPExecutableDirective(D);
}
-void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
- VisitOMPExecutableDirective(D);
-}
-
void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, const Stmt *S) {
EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S);
}
return cxstring::createRef("OMPAtomicDirective");
case CXCursor_OMPTargetDirective:
return cxstring::createRef("OMPTargetDirective");
- case CXCursor_OMPTeamsDirective:
- return cxstring::createRef("OMPTeamsDirective");
}
llvm_unreachable("Unhandled CXCursorKind");
case Stmt::OMPTargetDirectiveClass:
K = CXCursor_OMPTargetDirective;
break;
- case Stmt::OMPTeamsDirectiveClass:
- K = CXCursor_OMPTeamsDirective;
- break;
}
CXCursor C = { K, 0, { Parent, S, TU } };