forked from OSchip/llvm-project
[OPENMP] Initial parsing and sema analysis for 'single' directive.
llvm-svn: 211774
This commit is contained in:
parent
aee4541828
commit
d1e40fbfe1
|
@ -2151,7 +2151,11 @@ enum CXCursorKind {
|
|||
*/
|
||||
CXCursor_OMPSectionDirective = 236,
|
||||
|
||||
CXCursor_LastStmt = CXCursor_OMPSectionDirective,
|
||||
/** \brief OpenMP single directive.
|
||||
*/
|
||||
CXCursor_OMPSingleDirective = 237,
|
||||
|
||||
CXCursor_LastStmt = CXCursor_OMPSingleDirective,
|
||||
|
||||
/**
|
||||
* \brief Cursor that represents the translation unit itself.
|
||||
|
|
|
@ -2305,6 +2305,11 @@ DEF_TRAVERSE_STMT(OMPSectionDirective, {
|
|||
return false;
|
||||
})
|
||||
|
||||
DEF_TRAVERSE_STMT(OMPSingleDirective, {
|
||||
if (!TraverseOMPExecutableDirective(S))
|
||||
return false;
|
||||
})
|
||||
|
||||
// OpenMP clauses.
|
||||
template <typename Derived>
|
||||
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
|
||||
|
|
|
@ -2327,6 +2327,11 @@ DEF_TRAVERSE_STMT(OMPSectionDirective, {
|
|||
return false;
|
||||
})
|
||||
|
||||
DEF_TRAVERSE_STMT(OMPSingleDirective, {
|
||||
if (!TraverseOMPExecutableDirective(S))
|
||||
return false;
|
||||
})
|
||||
|
||||
// OpenMP clauses.
|
||||
template <typename Derived>
|
||||
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
|
||||
|
|
|
@ -470,6 +470,63 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/// \brief This represents '#pragma omp single' directive.
|
||||
///
|
||||
/// \code
|
||||
/// #pragma omp single private(a,b) copyprivate(c,d)
|
||||
/// \endcode
|
||||
/// In this example directive '#pragma omp single' has clauses 'private' with
|
||||
/// the variables 'a' and 'b' and 'copyprivate' with variables 'c' and 'd'.
|
||||
///
|
||||
class OMPSingleDirective : 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.
|
||||
///
|
||||
OMPSingleDirective(SourceLocation StartLoc, SourceLocation EndLoc,
|
||||
unsigned NumClauses)
|
||||
: OMPExecutableDirective(this, OMPSingleDirectiveClass, OMPD_single,
|
||||
StartLoc, EndLoc, NumClauses, 1) {}
|
||||
|
||||
/// \brief Build an empty directive.
|
||||
///
|
||||
/// \param NumClauses Number of clauses.
|
||||
///
|
||||
explicit OMPSingleDirective(unsigned NumClauses)
|
||||
: OMPExecutableDirective(this, OMPSingleDirectiveClass, OMPD_single,
|
||||
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 OMPSingleDirective *
|
||||
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 OMPSingleDirective *CreateEmpty(const ASTContext &C,
|
||||
unsigned NumClauses, EmptyShell);
|
||||
|
||||
static bool classof(const Stmt *T) {
|
||||
return T->getStmtClass() == OMPSingleDirectiveClass;
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace clang
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
#ifndef OPENMP_SECTIONS_CLAUSE
|
||||
# define OPENMP_SECTIONS_CLAUSE(Name)
|
||||
#endif
|
||||
#ifndef OPENMP_SINGLE_CLAUSE
|
||||
# define OPENMP_SINGLE_CLAUSE(Name)
|
||||
#endif
|
||||
#ifndef OPENMP_DEFAULT_KIND
|
||||
# define OPENMP_DEFAULT_KIND(Name)
|
||||
#endif
|
||||
|
@ -48,6 +51,7 @@ OPENMP_DIRECTIVE(simd)
|
|||
OPENMP_DIRECTIVE(for)
|
||||
OPENMP_DIRECTIVE(sections)
|
||||
OPENMP_DIRECTIVE(section)
|
||||
OPENMP_DIRECTIVE(single)
|
||||
|
||||
// OpenMP clauses.
|
||||
OPENMP_CLAUSE(if, OMPIfClause)
|
||||
|
@ -104,6 +108,11 @@ OPENMP_SECTIONS_CLAUSE(firstprivate)
|
|||
OPENMP_SECTIONS_CLAUSE(reduction)
|
||||
OPENMP_SECTIONS_CLAUSE(nowait)
|
||||
|
||||
// TODO more clauses allowed for directive 'omp single'.
|
||||
OPENMP_SINGLE_CLAUSE(private)
|
||||
OPENMP_SINGLE_CLAUSE(firstprivate)
|
||||
OPENMP_SINGLE_CLAUSE(nowait)
|
||||
|
||||
// Static attributes for 'default' clause.
|
||||
OPENMP_DEFAULT_KIND(none)
|
||||
OPENMP_DEFAULT_KIND(shared)
|
||||
|
@ -125,6 +134,7 @@ OPENMP_SCHEDULE_KIND(runtime)
|
|||
#undef OPENMP_DEFAULT_KIND
|
||||
#undef OPENMP_DIRECTIVE
|
||||
#undef OPENMP_CLAUSE
|
||||
#undef OPENMP_SINGLE_CLAUSE
|
||||
#undef OPENMP_SECTIONS_CLAUSE
|
||||
#undef OPENMP_PARALLEL_CLAUSE
|
||||
#undef OPENMP_SIMD_CLAUSE
|
||||
|
|
|
@ -182,3 +182,4 @@ def OMPSimdDirective : DStmt<OMPExecutableDirective>;
|
|||
def OMPForDirective : DStmt<OMPExecutableDirective>;
|
||||
def OMPSectionsDirective : DStmt<OMPExecutableDirective>;
|
||||
def OMPSectionDirective : DStmt<OMPExecutableDirective>;
|
||||
def OMPSingleDirective : DStmt<OMPExecutableDirective>;
|
||||
|
|
|
@ -7331,6 +7331,11 @@ public:
|
|||
/// associated statement.
|
||||
StmtResult ActOnOpenMPSectionDirective(Stmt *AStmt, SourceLocation StartLoc,
|
||||
SourceLocation EndLoc);
|
||||
/// \brief Called on well-formed '\#pragma omp single' after parsing of the
|
||||
/// associated statement.
|
||||
StmtResult ActOnOpenMPSingleDirective(ArrayRef<OMPClause *> Clauses,
|
||||
Stmt *AStmt, SourceLocation StartLoc,
|
||||
SourceLocation EndLoc);
|
||||
|
||||
OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
|
||||
Expr *Expr,
|
||||
|
|
|
@ -1344,6 +1344,7 @@ namespace clang {
|
|||
STMT_OMP_FOR_DIRECTIVE,
|
||||
STMT_OMP_SECTIONS_DIRECTIVE,
|
||||
STMT_OMP_SECTION_DIRECTIVE,
|
||||
STMT_OMP_SINGLE_DIRECTIVE,
|
||||
|
||||
// ARC
|
||||
EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr
|
||||
|
|
|
@ -1430,3 +1430,29 @@ OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C,
|
|||
return new (Mem) OMPSectionDirective();
|
||||
}
|
||||
|
||||
OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C,
|
||||
SourceLocation StartLoc,
|
||||
SourceLocation EndLoc,
|
||||
ArrayRef<OMPClause *> Clauses,
|
||||
Stmt *AssociatedStmt) {
|
||||
unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSingleDirective),
|
||||
llvm::alignOf<OMPClause *>());
|
||||
void *Mem =
|
||||
C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
|
||||
OMPSingleDirective *Dir =
|
||||
new (Mem) OMPSingleDirective(StartLoc, EndLoc, Clauses.size());
|
||||
Dir->setClauses(Clauses);
|
||||
Dir->setAssociatedStmt(AssociatedStmt);
|
||||
return Dir;
|
||||
}
|
||||
|
||||
OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C,
|
||||
unsigned NumClauses,
|
||||
EmptyShell) {
|
||||
unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSingleDirective),
|
||||
llvm::alignOf<OMPClause *>());
|
||||
void *Mem =
|
||||
C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
|
||||
return new (Mem) OMPSingleDirective(NumClauses);
|
||||
}
|
||||
|
||||
|
|
|
@ -797,6 +797,11 @@ void StmtPrinter::VisitOMPSectionDirective(OMPSectionDirective *Node) {
|
|||
PrintOMPExecutableDirective(Node);
|
||||
}
|
||||
|
||||
void StmtPrinter::VisitOMPSingleDirective(OMPSingleDirective *Node) {
|
||||
Indent() << "#pragma omp single ";
|
||||
PrintOMPExecutableDirective(Node);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Expr printing methods.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -368,6 +368,10 @@ void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
|
|||
VisitOMPExecutableDirective(S);
|
||||
}
|
||||
|
||||
void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
|
||||
VisitOMPExecutableDirective(S);
|
||||
}
|
||||
|
||||
void StmtProfiler::VisitExpr(const Expr *S) {
|
||||
VisitStmt(S);
|
||||
}
|
||||
|
|
|
@ -196,6 +196,16 @@ bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
|
|||
#define OPENMP_SECTIONS_CLAUSE(Name) \
|
||||
case OMPC_##Name: \
|
||||
return true;
|
||||
#include "clang/Basic/OpenMPKinds.def"
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OMPD_single:
|
||||
switch (CKind) {
|
||||
#define OPENMP_SINGLE_CLAUSE(Name) \
|
||||
case OMPC_##Name: \
|
||||
return true;
|
||||
#include "clang/Basic/OpenMPKinds.def"
|
||||
default:
|
||||
break;
|
||||
|
@ -215,8 +225,8 @@ bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
|
|||
}
|
||||
|
||||
bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
|
||||
return DKind == OMPD_for || DKind == OMPD_sections ||
|
||||
DKind == OMPD_section; // TODO add next directives.
|
||||
return DKind == OMPD_for || DKind == OMPD_sections || DKind == OMPD_section ||
|
||||
DKind == OMPD_single; // TODO add next directives.
|
||||
}
|
||||
|
||||
bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
|
||||
|
|
|
@ -188,6 +188,9 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
|
|||
case Stmt::OMPSectionDirectiveClass:
|
||||
EmitOMPSectionDirective(cast<OMPSectionDirective>(*S));
|
||||
break;
|
||||
case Stmt::OMPSingleDirectiveClass:
|
||||
EmitOMPSingleDirective(cast<OMPSingleDirective>(*S));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,3 +87,7 @@ void CodeGenFunction::EmitOMPSectionDirective(const OMPSectionDirective &) {
|
|||
llvm_unreachable("CodeGen for 'omp section' is not supported yet.");
|
||||
}
|
||||
|
||||
void CodeGenFunction::EmitOMPSingleDirective(const OMPSingleDirective &) {
|
||||
llvm_unreachable("CodeGen for 'omp single' is not supported yet.");
|
||||
}
|
||||
|
||||
|
|
|
@ -1905,6 +1905,7 @@ public:
|
|||
void EmitOMPForDirective(const OMPForDirective &S);
|
||||
void EmitOMPSectionsDirective(const OMPSectionsDirective &S);
|
||||
void EmitOMPSectionDirective(const OMPSectionDirective &S);
|
||||
void EmitOMPSingleDirective(const OMPSingleDirective &S);
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// LValue Expression Emission
|
||||
|
|
|
@ -65,6 +65,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() {
|
|||
case OMPD_for:
|
||||
case OMPD_sections:
|
||||
case OMPD_section:
|
||||
case OMPD_single:
|
||||
Diag(Tok, diag::err_omp_unexpected_directive)
|
||||
<< getOpenMPDirectiveName(DKind);
|
||||
break;
|
||||
|
@ -80,8 +81,8 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() {
|
|||
/// annot_pragma_openmp_end
|
||||
///
|
||||
/// executable-directive:
|
||||
/// annot_pragma_openmp 'parallel'|'simd'|'for'|'sections'|'section'
|
||||
/// {clause} annot_pragma_openmp_end
|
||||
/// annot_pragma_openmp 'parallel' | 'simd' | 'for' | 'sections' |
|
||||
/// 'section' | 'single' {clause} annot_pragma_openmp_end
|
||||
///
|
||||
StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective() {
|
||||
assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");
|
||||
|
@ -121,6 +122,7 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective() {
|
|||
case OMPD_simd:
|
||||
case OMPD_for:
|
||||
case OMPD_sections:
|
||||
case OMPD_single:
|
||||
case OMPD_section: {
|
||||
ConsumeToken();
|
||||
|
||||
|
|
|
@ -924,6 +924,13 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, SourceLocation Loc,
|
|||
ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP, Params);
|
||||
break;
|
||||
}
|
||||
case OMPD_single: {
|
||||
Sema::CapturedParamNameType Params[] = {
|
||||
std::make_pair(StringRef(), QualType()) // __context with shared vars
|
||||
};
|
||||
ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP, Params);
|
||||
break;
|
||||
}
|
||||
case OMPD_threadprivate:
|
||||
case OMPD_task:
|
||||
llvm_unreachable("OpenMP Directive is not allowed");
|
||||
|
@ -1033,6 +1040,10 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind,
|
|||
"No clauses is allowed for 'omp section' directive");
|
||||
Res = ActOnOpenMPSectionDirective(AStmt, StartLoc, EndLoc);
|
||||
break;
|
||||
case OMPD_single:
|
||||
Res = ActOnOpenMPSingleDirective(ClausesWithImplicit, AStmt, StartLoc,
|
||||
EndLoc);
|
||||
break;
|
||||
case OMPD_threadprivate:
|
||||
case OMPD_task:
|
||||
llvm_unreachable("OpenMP Directive is not allowed");
|
||||
|
@ -1647,6 +1658,14 @@ StmtResult Sema::ActOnOpenMPSectionDirective(Stmt *AStmt,
|
|||
return OMPSectionDirective::Create(Context, StartLoc, EndLoc, AStmt);
|
||||
}
|
||||
|
||||
StmtResult Sema::ActOnOpenMPSingleDirective(ArrayRef<OMPClause *> Clauses,
|
||||
Stmt *AStmt,
|
||||
SourceLocation StartLoc,
|
||||
SourceLocation EndLoc) {
|
||||
getCurFunction()->setHasBranchProtectedScope();
|
||||
return OMPSingleDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt);
|
||||
}
|
||||
|
||||
OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
|
||||
SourceLocation StartLoc,
|
||||
SourceLocation LParenLoc,
|
||||
|
|
|
@ -6449,6 +6449,16 @@ TreeTransform<Derived>::TransformOMPSectionDirective(OMPSectionDirective *D) {
|
|||
return Res;
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
StmtResult
|
||||
TreeTransform<Derived>::TransformOMPSingleDirective(OMPSingleDirective *D) {
|
||||
DeclarationNameInfo DirName;
|
||||
getDerived().getSema().StartOpenMPDSABlock(OMPD_single, DirName, nullptr);
|
||||
StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
|
||||
getDerived().getSema().EndOpenMPDSABlock(Res.get());
|
||||
return Res;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// OpenMP clause transformation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -1918,6 +1918,13 @@ void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
|
|||
VisitOMPExecutableDirective(D);
|
||||
}
|
||||
|
||||
void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
|
||||
VisitStmt(D);
|
||||
// The NumClauses field was read in ReadStmtFromStream.
|
||||
++Idx;
|
||||
VisitOMPExecutableDirective(D);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ASTReader Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -2422,6 +2429,11 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
|
|||
S = OMPSectionDirective::CreateEmpty(Context, Empty);
|
||||
break;
|
||||
|
||||
case STMT_OMP_SINGLE_DIRECTIVE:
|
||||
S = OMPSingleDirective::CreateEmpty(
|
||||
Context, Record[ASTStmtReader::NumStmtFields], Empty);
|
||||
break;
|
||||
|
||||
case EXPR_CXX_OPERATOR_CALL:
|
||||
S = new (Context) CXXOperatorCallExpr(Context, Empty);
|
||||
break;
|
||||
|
|
|
@ -1831,6 +1831,13 @@ void ASTStmtWriter::VisitOMPSectionDirective(OMPSectionDirective *D) {
|
|||
Code = serialization::STMT_OMP_SECTION_DIRECTIVE;
|
||||
}
|
||||
|
||||
void ASTStmtWriter::VisitOMPSingleDirective(OMPSingleDirective *D) {
|
||||
VisitStmt(D);
|
||||
Record.push_back(D->getNumClauses());
|
||||
VisitOMPExecutableDirective(D);
|
||||
Code = serialization::STMT_OMP_SINGLE_DIRECTIVE;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ASTWriter Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -735,6 +735,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
|
|||
case Stmt::OMPForDirectiveClass:
|
||||
case Stmt::OMPSectionsDirectiveClass:
|
||||
case Stmt::OMPSectionDirectiveClass:
|
||||
case Stmt::OMPSingleDirectiveClass:
|
||||
llvm_unreachable("Stmt should not be in analyzer evaluation loop");
|
||||
|
||||
case Stmt::ObjCSubscriptRefExprClass:
|
||||
|
|
|
@ -22,6 +22,9 @@ void foo() {
|
|||
{
|
||||
bar();
|
||||
}
|
||||
#pragma omp parallel
|
||||
#pragma omp single
|
||||
bar();
|
||||
#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}}
|
||||
|
@ -54,6 +57,13 @@ void foo() {
|
|||
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 for
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
#pragma omp for // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
|
||||
|
@ -86,6 +96,13 @@ void foo() {
|
|||
bar();
|
||||
}
|
||||
}
|
||||
#pragma omp for
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
#pragma omp single // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
|
||||
{
|
||||
bar();
|
||||
}
|
||||
}
|
||||
#pragma omp sections
|
||||
{
|
||||
#pragma omp for // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
|
||||
|
@ -118,10 +135,50 @@ void foo() {
|
|||
bar();
|
||||
}
|
||||
}
|
||||
#pragma omp sections
|
||||
{
|
||||
#pragma omp section
|
||||
{
|
||||
#pragma omp single // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
|
||||
bar();
|
||||
}
|
||||
}
|
||||
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
|
||||
{
|
||||
bar();
|
||||
}
|
||||
#pragma omp single
|
||||
{
|
||||
#pragma omp for // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
;
|
||||
}
|
||||
#pragma omp single
|
||||
{
|
||||
#pragma omp simd
|
||||
for (int i = 0; i < 10; ++i)
|
||||
;
|
||||
}
|
||||
#pragma omp single
|
||||
{
|
||||
#pragma omp parallel
|
||||
for (int i = 0; i < 10; ++i)
|
||||
;
|
||||
}
|
||||
#pragma omp single
|
||||
{
|
||||
#pragma omp single // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
|
||||
{
|
||||
bar();
|
||||
}
|
||||
}
|
||||
#pragma omp single
|
||||
{
|
||||
#pragma omp sections // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
|
||||
{
|
||||
bar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
@ -143,6 +200,14 @@ void foo() {
|
|||
{
|
||||
bar();
|
||||
}
|
||||
#pragma omp parallel
|
||||
#pragma omp sections
|
||||
{
|
||||
bar();
|
||||
}
|
||||
#pragma omp parallel
|
||||
#pragma omp single
|
||||
bar();
|
||||
#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}}
|
||||
|
@ -175,6 +240,11 @@ void foo() {
|
|||
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 for
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
#pragma omp for // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
|
||||
|
@ -207,6 +277,11 @@ void foo() {
|
|||
bar();
|
||||
}
|
||||
}
|
||||
#pragma omp for
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
#pragma omp single // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
|
||||
bar();
|
||||
}
|
||||
#pragma omp sections
|
||||
{
|
||||
#pragma omp for // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
|
||||
|
@ -239,10 +314,47 @@ void foo() {
|
|||
bar();
|
||||
}
|
||||
}
|
||||
#pragma omp sections
|
||||
{
|
||||
#pragma omp single // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
|
||||
bar();
|
||||
}
|
||||
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
|
||||
{
|
||||
bar();
|
||||
}
|
||||
#pragma omp single
|
||||
{
|
||||
#pragma omp for // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
;
|
||||
}
|
||||
#pragma omp single
|
||||
{
|
||||
#pragma omp simd
|
||||
for (int i = 0; i < 10; ++i)
|
||||
;
|
||||
}
|
||||
#pragma omp single
|
||||
{
|
||||
#pragma omp parallel
|
||||
for (int i = 0; i < 10; ++i)
|
||||
;
|
||||
}
|
||||
#pragma omp single
|
||||
{
|
||||
#pragma omp single // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
|
||||
{
|
||||
bar();
|
||||
}
|
||||
}
|
||||
#pragma omp single
|
||||
{
|
||||
#pragma omp sections // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
|
||||
{
|
||||
bar();
|
||||
}
|
||||
}
|
||||
return foo<int>();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
// 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, int N>
|
||||
T tmain(T argc) {
|
||||
T b = argc, c, d, e, f, g;
|
||||
static T a;
|
||||
// CHECK: static T a;
|
||||
#pragma omp parallel
|
||||
#pragma omp single private(argc, b), firstprivate(c, d), nowait
|
||||
foo();
|
||||
// CHECK-NEXT: #pragma omp parallel
|
||||
// CHECK-NEXT: #pragma omp single private(argc,b) firstprivate(c,d) nowait
|
||||
// CHECK-NEXT: foo();
|
||||
return T();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int b = argc, c, d, e, f, g;
|
||||
static int a;
|
||||
// CHECK: static int a;
|
||||
#pragma omp parallel
|
||||
#pragma omp single private(argc, b), firstprivate(argv, c), nowait
|
||||
foo();
|
||||
// CHECK-NEXT: #pragma omp parallel
|
||||
// CHECK-NEXT: #pragma omp single private(argc,b) firstprivate(argv,c) nowait
|
||||
// CHECK-NEXT: foo();
|
||||
return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,239 @@
|
|||
// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
|
||||
|
||||
void foo() {
|
||||
}
|
||||
|
||||
bool foobool(int argc) {
|
||||
return argc;
|
||||
}
|
||||
|
||||
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
|
||||
extern S1 a;
|
||||
class S2 {
|
||||
mutable int a;
|
||||
|
||||
public:
|
||||
S2() : a(0) {}
|
||||
S2(S2 &s2) : a(s2.a) {}
|
||||
static float S2s;
|
||||
static const float S2sc;
|
||||
};
|
||||
const float S2::S2sc = 0;
|
||||
const S2 b;
|
||||
const S2 ba[5];
|
||||
class S3 {
|
||||
int a;
|
||||
S3 &operator=(const S3 &s3);
|
||||
|
||||
public:
|
||||
S3() : a(0) {}
|
||||
S3(S3 &s3) : a(s3.a) {}
|
||||
};
|
||||
const S3 c;
|
||||
const S3 ca[5];
|
||||
extern const int f;
|
||||
class S4 { // expected-note 2 {{'S4' declared here}}
|
||||
int a;
|
||||
S4();
|
||||
S4(const S4 &s4);
|
||||
|
||||
public:
|
||||
S4(int v) : a(v) {}
|
||||
};
|
||||
class S5 { // expected-note 4 {{'S5' declared here}}
|
||||
int a;
|
||||
S5(const S5 &s5) : a(s5.a) {}
|
||||
|
||||
public:
|
||||
S5() : a(0) {}
|
||||
S5(int v) : a(v) {}
|
||||
};
|
||||
class S6 {
|
||||
int a;
|
||||
S6() : a(0) {}
|
||||
|
||||
public:
|
||||
S6(const S6 &s6) : a(s6.a) {}
|
||||
S6(int v) : a(v) {}
|
||||
};
|
||||
|
||||
S3 h;
|
||||
#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
|
||||
|
||||
template <class I, class C>
|
||||
int foomain(int argc, char **argv) {
|
||||
I e(4); // expected-note {{'e' defined here}}
|
||||
C g(5); // expected-note 2 {{'g' defined here}}
|
||||
int i;
|
||||
int &j = i; // expected-note {{'j' defined here}}
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate // expected-error {{expected '(' after 'firstprivate'}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate() // expected-error {{expected expression}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(argc)
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(argv[1]) // expected-error {{expected variable name}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp single'}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
{
|
||||
int v = 0;
|
||||
int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp single' directive into a parallel or another task region?}}
|
||||
#pragma omp single firstprivate(i) // expected-error {{private variable cannot be firstprivate}}
|
||||
foo();
|
||||
v += i;
|
||||
}
|
||||
#pragma omp parallel shared(i)
|
||||
#pragma omp parallel private(i)
|
||||
#pragma omp single firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(i)
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
|
||||
foo();
|
||||
#pragma omp parallel private(i) // expected-note {{defined as private}}
|
||||
#pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
|
||||
foo();
|
||||
#pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
|
||||
#pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
|
||||
foo();
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 2 {{'g' defined here}}
|
||||
S3 m;
|
||||
S6 n(2);
|
||||
int i;
|
||||
int &j = i; // expected-note {{'j' defined here}}
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate // expected-error {{expected '(' after 'firstprivate'}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate() // expected-error {{expected expression}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(argc)
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(argv[1]) // expected-error {{expected variable name}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(2 * 2) // expected-error {{expected variable name}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(ba) // OK
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(ca) // OK
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(da) // OK
|
||||
foo();
|
||||
int xa;
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(xa) // OK
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(S2::S2s) // OK
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(S2::S2sc) // OK
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp single'}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(m) // OK
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
|
||||
foo();
|
||||
#pragma omp parallel shared(xa)
|
||||
#pragma omp single firstprivate(xa) // OK: may be firstprivate
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single firstprivate(n) // OK
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
{
|
||||
int v = 0;
|
||||
int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp single' directive into a parallel or another task region?}}
|
||||
#pragma omp single firstprivate(i) // expected-error {{private variable cannot be firstprivate}}
|
||||
foo();
|
||||
v += i;
|
||||
}
|
||||
#pragma omp parallel private(i) // expected-note {{defined as private}}
|
||||
#pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
|
||||
foo();
|
||||
#pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
|
||||
#pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
|
||||
foo();
|
||||
|
||||
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -verify %s
|
||||
|
||||
void foo();
|
||||
|
||||
// expected-error@+1 {{unexpected OpenMP directive '#pragma omp single'}}
|
||||
#pragma omp single
|
||||
|
||||
// expected-error@+1 {{unexpected OpenMP directive '#pragma omp single'}}
|
||||
#pragma omp single foo
|
||||
|
||||
void test_no_clause() {
|
||||
int i;
|
||||
#pragma omp single
|
||||
foo();
|
||||
|
||||
#pragma omp single
|
||||
++i;
|
||||
}
|
||||
|
||||
void test_branch_protected_scope() {
|
||||
int i = 0;
|
||||
L1:
|
||||
++i;
|
||||
|
||||
int x[24];
|
||||
|
||||
#pragma omp parallel
|
||||
#pragma omp single
|
||||
{
|
||||
if (i == 5)
|
||||
goto L1; // expected-error {{use of undeclared label 'L1'}}
|
||||
else if (i == 6)
|
||||
return; // expected-error {{cannot return from OpenMP region}}
|
||||
else if (i == 7)
|
||||
goto L2;
|
||||
else if (i == 8) {
|
||||
L2:
|
||||
x[i]++;
|
||||
}
|
||||
}
|
||||
|
||||
if (x[0] == 0)
|
||||
goto L2; // expected-error {{use of undeclared label 'L2'}}
|
||||
else if (x[1] == 1)
|
||||
goto L1;
|
||||
}
|
||||
|
||||
void test_invalid_clause() {
|
||||
int i;
|
||||
#pragma omp parallel
|
||||
// expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
|
||||
#pragma omp single foo bar
|
||||
foo();
|
||||
}
|
||||
|
||||
void test_non_identifiers() {
|
||||
int i, x;
|
||||
|
||||
#pragma omp parallel
|
||||
// expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
|
||||
#pragma omp single;
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
// expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp single'}}
|
||||
// expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
|
||||
#pragma omp single linear(x);
|
||||
foo();
|
||||
|
||||
#pragma omp parallel
|
||||
// expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
|
||||
#pragma omp single private(x);
|
||||
foo();
|
||||
|
||||
#pragma omp parallel
|
||||
// expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
|
||||
#pragma omp single, private(x);
|
||||
foo();
|
||||
}
|
||||
|
||||
void test_private() {
|
||||
int i;
|
||||
#pragma omp parallel
|
||||
// expected-error@+2 {{expected expression}}
|
||||
// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
|
||||
#pragma omp single private(
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
|
||||
// expected-error@+1 2 {{expected expression}}
|
||||
#pragma omp single private(,
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
// expected-error@+1 2 {{expected expression}}
|
||||
#pragma omp single private(, )
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
// expected-error@+1 {{expected expression}}
|
||||
#pragma omp single private()
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
// expected-error@+1 {{expected expression}}
|
||||
#pragma omp single private(int)
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
// expected-error@+1 {{expected variable name}}
|
||||
#pragma omp single private(0)
|
||||
foo();
|
||||
|
||||
int x, y, z;
|
||||
#pragma omp parallel
|
||||
#pragma omp single private(x)
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single private(x, y)
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
#pragma omp single private(x, y, z)
|
||||
foo();
|
||||
}
|
||||
|
||||
void test_firstprivate() {
|
||||
int i;
|
||||
#pragma omp parallel
|
||||
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
|
||||
// expected-error@+1 {{expected expression}}
|
||||
#pragma omp single firstprivate(
|
||||
foo();
|
||||
|
||||
#pragma omp parallel
|
||||
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
|
||||
// expected-error@+1 2 {{expected expression}}
|
||||
#pragma omp single firstprivate(,
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
// expected-error@+1 2 {{expected expression}}
|
||||
#pragma omp single firstprivate(, )
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
// expected-error@+1 {{expected expression}}
|
||||
#pragma omp single firstprivate()
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
// expected-error@+1 {{expected expression}}
|
||||
#pragma omp single firstprivate(int)
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
// expected-error@+1 {{expected variable name}}
|
||||
#pragma omp single firstprivate(0)
|
||||
foo();
|
||||
}
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
|
||||
|
||||
void foo() {
|
||||
}
|
||||
|
||||
bool foobool(int argc) {
|
||||
return argc;
|
||||
}
|
||||
|
||||
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
|
||||
extern S1 a;
|
||||
class S2 {
|
||||
mutable int a;
|
||||
|
||||
public:
|
||||
S2() : a(0) {}
|
||||
};
|
||||
const S2 b;
|
||||
const S2 ba[5];
|
||||
class S3 {
|
||||
int a;
|
||||
|
||||
public:
|
||||
S3() : a(0) {}
|
||||
};
|
||||
const S3 ca[5];
|
||||
class S4 { // 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) {}
|
||||
};
|
||||
|
||||
S3 h;
|
||||
#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
|
||||
|
||||
template <class I, class C>
|
||||
int foomain(I argc, C **argv) {
|
||||
I e(4);
|
||||
I g(5);
|
||||
int i;
|
||||
int &j = i; // expected-note {{'j' defined here}}
|
||||
#pragma omp single private // expected-error {{expected '(' after 'private'}}
|
||||
foo();
|
||||
#pragma omp single private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
foo();
|
||||
#pragma omp single private() // expected-error {{expected expression}}
|
||||
foo();
|
||||
#pragma omp single private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
foo();
|
||||
#pragma omp single private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
foo();
|
||||
#pragma omp single private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
|
||||
foo();
|
||||
#pragma omp single private(argc)
|
||||
foo();
|
||||
#pragma omp single private(S1) // expected-error {{'S1' does not refer to a value}}
|
||||
foo();
|
||||
#pragma omp single private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
|
||||
foo();
|
||||
#pragma omp single private(argv[1]) // expected-error {{expected variable name}}
|
||||
foo();
|
||||
#pragma omp single private(e, g)
|
||||
foo();
|
||||
#pragma omp single private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
|
||||
foo();
|
||||
#pragma omp single shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp single'}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
{
|
||||
int v = 0;
|
||||
int i;
|
||||
#pragma omp single private(i)
|
||||
foo();
|
||||
v += i;
|
||||
}
|
||||
#pragma omp parallel shared(i)
|
||||
#pragma omp parallel private(i)
|
||||
#pragma omp single private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
|
||||
foo();
|
||||
#pragma omp single private(i)
|
||||
foo();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
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 single private // expected-error {{expected '(' after 'private'}}
|
||||
foo();
|
||||
#pragma omp single private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
foo();
|
||||
#pragma omp single private() // expected-error {{expected expression}}
|
||||
foo();
|
||||
#pragma omp single private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
foo();
|
||||
#pragma omp single private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
foo();
|
||||
#pragma omp single private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
|
||||
foo();
|
||||
#pragma omp single private(argc)
|
||||
foo();
|
||||
#pragma omp single private(S1) // expected-error {{'S1' does not refer to a value}}
|
||||
foo();
|
||||
#pragma omp single private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
|
||||
foo();
|
||||
#pragma omp single private(argv[1]) // expected-error {{expected variable name}}
|
||||
foo();
|
||||
#pragma omp single private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}}
|
||||
foo();
|
||||
#pragma omp single private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
|
||||
foo();
|
||||
#pragma omp single shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp single'}}
|
||||
foo();
|
||||
#pragma omp parallel
|
||||
{
|
||||
int i;
|
||||
#pragma omp single private(i)
|
||||
foo();
|
||||
}
|
||||
#pragma omp parallel shared(i)
|
||||
#pragma omp parallel private(i)
|
||||
#pragma omp single private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
|
||||
foo();
|
||||
#pragma omp single private(i)
|
||||
foo();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1854,6 +1854,7 @@ public:
|
|||
void VisitOMPForDirective(const OMPForDirective *D);
|
||||
void VisitOMPSectionsDirective(const OMPSectionsDirective *D);
|
||||
void VisitOMPSectionDirective(const OMPSectionDirective *D);
|
||||
void VisitOMPSingleDirective(const OMPSingleDirective *D);
|
||||
|
||||
private:
|
||||
void AddDeclarationNameInfo(const Stmt *S);
|
||||
|
@ -2297,6 +2298,10 @@ void EnqueueVisitor::VisitOMPSectionDirective(const OMPSectionDirective *D) {
|
|||
VisitOMPExecutableDirective(D);
|
||||
}
|
||||
|
||||
void EnqueueVisitor::VisitOMPSingleDirective(const OMPSingleDirective *D) {
|
||||
VisitOMPExecutableDirective(D);
|
||||
}
|
||||
|
||||
void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, const Stmt *S) {
|
||||
EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S);
|
||||
}
|
||||
|
@ -3979,6 +3984,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
|
|||
return cxstring::createRef("OMPSectionsDirective");
|
||||
case CXCursor_OMPSectionDirective:
|
||||
return cxstring::createRef("OMPSectionDirective");
|
||||
case CXCursor_OMPSingleDirective:
|
||||
return cxstring::createRef("OMPSingleDirective");
|
||||
}
|
||||
|
||||
llvm_unreachable("Unhandled CXCursorKind");
|
||||
|
|
|
@ -528,6 +528,9 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
|
|||
case Stmt::OMPSectionDirectiveClass:
|
||||
K = CXCursor_OMPSectionDirective;
|
||||
break;
|
||||
case Stmt::OMPSingleDirectiveClass:
|
||||
K = CXCursor_OMPSingleDirective;
|
||||
break;
|
||||
}
|
||||
|
||||
CXCursor C = { K, 0, { Parent, S, TU } };
|
||||
|
|
Loading…
Reference in New Issue