[OPENMP] Parsing and sema analysis for 'omp parallel sections' directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212516 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexey Bataev 2014-07-08 08:12:03 +00:00
parent 9eb8a68c1b
commit 61d27f11f3
38 changed files with 2576 additions and 8 deletions

View File

@ -2159,9 +2159,13 @@ enum CXCursorKind {
*/
CXCursor_OMPParallelForDirective = 238,
/** \brief OpenMP parallel sections directive.
*/
CXCursor_OMPParallelSectionsDirective = 239,
/** \brief Windows Structured Exception Handling's leave statement.
*/
CXCursor_SEHLeaveStmt = 239,
CXCursor_SEHLeaveStmt = 240,
CXCursor_LastStmt = CXCursor_SEHLeaveStmt,

View File

@ -2316,6 +2316,11 @@ DEF_TRAVERSE_STMT(OMPParallelForDirective, {
return false;
})
DEF_TRAVERSE_STMT(OMPParallelSectionsDirective, {
if (!TraverseOMPExecutableDirective(S))
return false;
})
// OpenMP clauses.
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {

View File

@ -2338,6 +2338,11 @@ DEF_TRAVERSE_STMT(OMPParallelForDirective, {
return false;
})
DEF_TRAVERSE_STMT(OMPParallelSectionsDirective, {
if (!TraverseOMPExecutableDirective(S))
return false;
})
// OpenMP clauses.
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {

View File

@ -599,6 +599,65 @@ public:
}
};
/// \brief This represents '#pragma omp parallel sections' directive.
///
/// \code
/// #pragma omp parallel sections private(a,b) reduction(+:c,d)
/// \endcode
/// In this example directive '#pragma omp parallel sections' has clauses
/// 'private' with the variables 'a' and 'b' and 'reduction' with operator '+'
/// and variables 'c' and 'd'.
///
class OMPParallelSectionsDirective : 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.
///
OMPParallelSectionsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
unsigned NumClauses)
: OMPExecutableDirective(this, OMPParallelSectionsDirectiveClass,
OMPD_parallel_sections, StartLoc, EndLoc,
NumClauses, 1) {}
/// \brief Build an empty directive.
///
/// \param NumClauses Number of clauses.
///
explicit OMPParallelSectionsDirective(unsigned NumClauses)
: OMPExecutableDirective(this, OMPParallelSectionsDirectiveClass,
OMPD_parallel_sections, 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 OMPParallelSectionsDirective *
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 OMPParallelSectionsDirective *
CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
static bool classof(const Stmt *T) {
return T->getStmtClass() == OMPParallelSectionsDirectiveClass;
}
};
} // end namespace clang
#endif

View File

@ -7124,11 +7124,15 @@ def err_omp_prohibited_region_simd : Error<
"OpenMP constructs may not be nested inside a simd region">;
def err_omp_sections_not_compound_stmt : Error<
"the statement for '#pragma omp sections' must be a compound statement">;
def err_omp_parallel_sections_not_compound_stmt : Error<
"the statement for '#pragma omp parallel sections' must be a compound statement">;
def err_omp_orphaned_section_directive : Error<
"%select{orphaned 'omp section' directives are prohibited, it|'omp section' directive}0"
" must be closely nested to a sections region%select{|, not a %1 region}0">;
def err_omp_sections_substmt_not_section : Error<
"statement in 'omp sections' directive must be enclosed into a section region">;
def err_omp_parallel_sections_substmt_not_section : Error<
"statement in 'omp parallel sections' directive must be enclosed into a section region">;
} // end of OpenMP category
let CategoryName = "Related Result Type Issue" in {

View File

@ -39,6 +39,9 @@
#ifndef OPENMP_PARALLEL_FOR_CLAUSE
# define OPENMP_PARALLEL_FOR_CLAUSE(Name)
#endif
#ifndef OPENMP_PARALLEL_SECTIONS_CLAUSE
# define OPENMP_PARALLEL_SECTIONS_CLAUSE(Name)
#endif
#ifndef OPENMP_DEFAULT_KIND
# define OPENMP_DEFAULT_KIND(Name)
#endif
@ -59,6 +62,7 @@ OPENMP_DIRECTIVE(sections)
OPENMP_DIRECTIVE(section)
OPENMP_DIRECTIVE(single)
OPENMP_DIRECTIVE_EXT(parallel_for, "parallel for")
OPENMP_DIRECTIVE_EXT(parallel_sections, "parallel sections")
// OpenMP clauses.
OPENMP_CLAUSE(if, OMPIfClause)
@ -153,6 +157,18 @@ OPENMP_PARALLEL_FOR_CLAUSE(collapse)
OPENMP_PARALLEL_FOR_CLAUSE(schedule)
OPENMP_PARALLEL_FOR_CLAUSE(ordered)
// Clauses allowed for OpenMP directive 'parallel sections'.
OPENMP_PARALLEL_SECTIONS_CLAUSE(if)
OPENMP_PARALLEL_SECTIONS_CLAUSE(num_threads)
OPENMP_PARALLEL_SECTIONS_CLAUSE(default)
OPENMP_PARALLEL_SECTIONS_CLAUSE(proc_bind)
OPENMP_PARALLEL_SECTIONS_CLAUSE(private)
OPENMP_PARALLEL_SECTIONS_CLAUSE(firstprivate)
OPENMP_PARALLEL_SECTIONS_CLAUSE(shared)
OPENMP_PARALLEL_SECTIONS_CLAUSE(reduction)
OPENMP_PARALLEL_SECTIONS_CLAUSE(copyin)
OPENMP_PARALLEL_SECTIONS_CLAUSE(lastprivate)
#undef OPENMP_SCHEDULE_KIND
#undef OPENMP_PROC_BIND_KIND
#undef OPENMP_DEFAULT_KIND
@ -163,6 +179,7 @@ OPENMP_PARALLEL_FOR_CLAUSE(ordered)
#undef OPENMP_SECTIONS_CLAUSE
#undef OPENMP_PARALLEL_CLAUSE
#undef OPENMP_PARALLEL_FOR_CLAUSE
#undef OPENMP_PARALLEL_SECTIONS_CLAUSE
#undef OPENMP_SIMD_CLAUSE
#undef OPENMP_FOR_CLAUSE

View File

@ -185,3 +185,4 @@ def OMPSectionsDirective : DStmt<OMPExecutableDirective>;
def OMPSectionDirective : DStmt<OMPExecutableDirective>;
def OMPSingleDirective : DStmt<OMPExecutableDirective>;
def OMPParallelForDirective : DStmt<OMPExecutableDirective>;
def OMPParallelSectionsDirective : DStmt<OMPExecutableDirective>;

View File

@ -7342,6 +7342,12 @@ public:
ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
SourceLocation EndLoc,
llvm::DenseMap<VarDecl *, Expr *> &VarsWithImplicitDSA);
/// \brief Called on well-formed '\#pragma omp parallel sections' after
/// parsing of the associated statement.
StmtResult ActOnOpenMPParallelSectionsDirective(ArrayRef<OMPClause *> Clauses,
Stmt *AStmt,
SourceLocation StartLoc,
SourceLocation EndLoc);
OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
Expr *Expr,

View File

@ -1347,6 +1347,7 @@ namespace clang {
STMT_OMP_SECTION_DIRECTIVE,
STMT_OMP_SINGLE_DIRECTIVE,
STMT_OMP_PARALLEL_FOR_DIRECTIVE,
STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE,
// ARC
EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr

View File

@ -1504,3 +1504,27 @@ OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
return new (Mem) OMPParallelForDirective(CollapsedNum, NumClauses);
}
OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create(
const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelSectionsDirective),
llvm::alignOf<OMPClause *>());
void *Mem =
C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
OMPParallelSectionsDirective *Dir =
new (Mem) OMPParallelSectionsDirective(StartLoc, EndLoc, Clauses.size());
Dir->setClauses(Clauses);
Dir->setAssociatedStmt(AssociatedStmt);
return Dir;
}
OMPParallelSectionsDirective *
OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C,
unsigned NumClauses, EmptyShell) {
unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelSectionsDirective),
llvm::alignOf<OMPClause *>());
void *Mem =
C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
return new (Mem) OMPParallelSectionsDirective(NumClauses);
}

View File

@ -820,6 +820,12 @@ void StmtPrinter::VisitOMPParallelForDirective(OMPParallelForDirective *Node) {
PrintOMPExecutableDirective(Node);
}
void StmtPrinter::VisitOMPParallelSectionsDirective(
OMPParallelSectionsDirective *Node) {
Indent() << "#pragma omp parallel sections ";
PrintOMPExecutableDirective(Node);
}
//===----------------------------------------------------------------------===//
// Expr printing methods.
//===----------------------------------------------------------------------===//

View File

@ -385,6 +385,11 @@ StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
VisitOMPExecutableDirective(S);
}
void StmtProfiler::VisitOMPParallelSectionsDirective(
const OMPParallelSectionsDirective *S) {
VisitOMPExecutableDirective(S);
}
void StmtProfiler::VisitExpr(const Expr *S) {
VisitStmt(S);
}

View File

@ -222,6 +222,16 @@ bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
#define OPENMP_PARALLEL_FOR_CLAUSE(Name) \
case OMPC_##Name: \
return true;
#include "clang/Basic/OpenMPKinds.def"
default:
break;
}
break;
case OMPD_parallel_sections:
switch (CKind) {
#define OPENMP_PARALLEL_SECTIONS_CLAUSE(Name) \
case OMPC_##Name: \
return true;
#include "clang/Basic/OpenMPKinds.def"
default:
break;
@ -243,13 +253,13 @@ bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
return DKind == OMPD_for || DKind == OMPD_sections || DKind == OMPD_section ||
DKind == OMPD_single ||
DKind == OMPD_parallel_for; // TODO add next directives.
DKind == OMPD_single || DKind == OMPD_parallel_for ||
DKind == OMPD_parallel_sections; // TODO add next directives.
}
bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
return DKind == OMPD_parallel ||
DKind == OMPD_parallel_for; // TODO add next directives.
return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
DKind == OMPD_parallel_sections; // TODO add next directives.
}
bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {

View File

@ -197,6 +197,9 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
case Stmt::OMPParallelForDirectiveClass:
EmitOMPParallelForDirective(cast<OMPParallelForDirective>(*S));
break;
case Stmt::OMPParallelSectionsDirectiveClass:
EmitOMPParallelSectionsDirective(cast<OMPParallelSectionsDirective>(*S));
break;
}
}

View File

@ -95,3 +95,8 @@ CodeGenFunction::EmitOMPParallelForDirective(const OMPParallelForDirective &) {
llvm_unreachable("CodeGen for 'omp parallel for' is not supported yet.");
}
void CodeGenFunction::EmitOMPParallelSectionsDirective(
const OMPParallelSectionsDirective &) {
llvm_unreachable("CodeGen for 'omp parallel sections' is not supported yet.");
}

View File

@ -1904,6 +1904,7 @@ public:
void EmitOMPSectionDirective(const OMPSectionDirective &S);
void EmitOMPSingleDirective(const OMPSingleDirective &S);
void EmitOMPParallelForDirective(const OMPParallelForDirective &S);
void EmitOMPParallelSectionsDirective(const OMPParallelSectionsDirective &S);
//===--------------------------------------------------------------------===//
// LValue Expression Emission

View File

@ -40,6 +40,9 @@ static OpenMPDirectiveKind ParseOpenMPDirectiveKind(Parser &P) {
if (SDKind == OMPD_for) {
P.ConsumeToken();
DKind = OMPD_parallel_for;
} else if (SDKind == OMPD_sections) {
P.ConsumeToken();
DKind = OMPD_parallel_sections;
}
}
return DKind;
@ -85,6 +88,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() {
case OMPD_section:
case OMPD_single:
case OMPD_parallel_for:
case OMPD_parallel_sections:
Diag(Tok, diag::err_omp_unexpected_directive)
<< getOpenMPDirectiveName(DKind);
break;
@ -101,7 +105,8 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() {
///
/// executable-directive:
/// annot_pragma_openmp 'parallel' | 'simd' | 'for' | 'sections' |
/// 'section' | 'single' | 'parallel for' {clause} annot_pragma_openmp_end
/// 'section' | 'single' | 'parallel for' | 'parallel sections' {clause}
/// annot_pragma_openmp_end
///
StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective() {
assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");
@ -141,7 +146,8 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective() {
case OMPD_sections:
case OMPD_single:
case OMPD_section:
case OMPD_parallel_for: {
case OMPD_parallel_for:
case OMPD_parallel_sections: {
ConsumeToken();
if (isOpenMPLoopDirective(DKind))

View File

@ -976,6 +976,14 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) {
Params);
break;
}
case OMPD_parallel_sections: {
Sema::CapturedParamNameType Params[] = {
std::make_pair(StringRef(), QualType()) // __context with shared vars
};
ActOnCapturedRegionStart(DSAStack->getConstructLoc(), CurScope, CR_OpenMP,
Params);
break;
}
case OMPD_threadprivate:
case OMPD_task:
llvm_unreachable("OpenMP Directive is not allowed");
@ -998,6 +1006,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | parallel | section | + |
// | parallel | single | * |
// | parallel | parallel for | * |
// | parallel |parallel sections| * |
// +------------------+-----------------+------------------------------------+
// | for | parallel | * |
// | for | for | + |
@ -1006,6 +1015,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | for | section | + |
// | for | single | + |
// | for | parallel for | * |
// | for |parallel sections| * |
// +------------------+-----------------+------------------------------------+
// | simd | parallel | |
// | simd | for | |
@ -1014,6 +1024,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | simd | section | |
// | simd | single | |
// | simd | parallel for | |
// | simd |parallel sections| |
// +------------------+-----------------+------------------------------------+
// | sections | parallel | * |
// | sections | for | + |
@ -1022,6 +1033,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | sections | section | * |
// | sections | single | + |
// | sections | parallel for | * |
// | sections |parallel sections| * |
// +------------------+-----------------+------------------------------------+
// | section | parallel | * |
// | section | for | + |
@ -1030,6 +1042,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | section | section | + |
// | section | single | + |
// | section | parallel for | * |
// | section |parallel sections| * |
// +------------------+-----------------+------------------------------------+
// | single | parallel | * |
// | single | for | + |
@ -1038,6 +1051,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | single | section | + |
// | single | single | + |
// | single | parallel for | * |
// | single |parallel sections| * |
// +------------------+-----------------+------------------------------------+
// | parallel for | parallel | * |
// | parallel for | for | + |
@ -1046,6 +1060,16 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | parallel for | section | + |
// | parallel for | single | + |
// | parallel for | parallel for | * |
// | parallel for |parallel sections| * |
// +------------------+-----------------+------------------------------------+
// | parallel sections| parallel | * |
// | parallel sections| for | + |
// | parallel sections| simd | * |
// | parallel sections| sections | + |
// | parallel sections| section | * |
// | parallel sections| single | + |
// | parallel sections| parallel for | * |
// | parallel sections|parallel sections| * |
// +------------------+-----------------+------------------------------------+
if (Stack->getCurScope()) {
auto ParentRegion = Stack->getParentDirective();
@ -1063,7 +1087,8 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// Orphaned section directives are prohibited. That is, the section
// directives must appear within the sections construct and must not be
// encountered elsewhere in the sections region.
if (ParentRegion != OMPD_sections) {
if (ParentRegion != OMPD_sections &&
ParentRegion != OMPD_parallel_sections) {
SemaRef.Diag(StartLoc, diag::err_omp_orphaned_section_directive)
<< (ParentRegion != OMPD_unknown)
<< getOpenMPDirectiveName(ParentRegion);
@ -1155,6 +1180,10 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind,
Res = ActOnOpenMPParallelForDirective(ClausesWithImplicit, AStmt, StartLoc,
EndLoc, VarsWithInheritedDSA);
break;
case OMPD_parallel_sections:
Res = ActOnOpenMPParallelSectionsDirective(ClausesWithImplicit, AStmt,
StartLoc, EndLoc);
break;
case OMPD_threadprivate:
case OMPD_task:
llvm_unreachable("OpenMP Directive is not allowed");
@ -1834,6 +1863,41 @@ StmtResult Sema::ActOnOpenMPParallelForDirective(
NestedLoopCount, Clauses, AStmt);
}
StmtResult
Sema::ActOnOpenMPParallelSectionsDirective(ArrayRef<OMPClause *> Clauses,
Stmt *AStmt, SourceLocation StartLoc,
SourceLocation EndLoc) {
assert(AStmt && isa<CapturedStmt>(AStmt) && "Captured statement expected");
auto BaseStmt = AStmt;
while (CapturedStmt *CS = dyn_cast_or_null<CapturedStmt>(BaseStmt))
BaseStmt = CS->getCapturedStmt();
if (auto C = dyn_cast_or_null<CompoundStmt>(BaseStmt)) {
auto S = C->children();
if (!S)
return StmtError();
// All associated statements must be '#pragma omp section' except for
// the first one.
for (++S; S; ++S) {
auto SectionStmt = *S;
if (!SectionStmt || !isa<OMPSectionDirective>(SectionStmt)) {
if (SectionStmt)
Diag(SectionStmt->getLocStart(),
diag::err_omp_parallel_sections_substmt_not_section);
return StmtError();
}
}
} else {
Diag(AStmt->getLocStart(),
diag::err_omp_parallel_sections_not_compound_stmt);
return StmtError();
}
getCurFunction()->setHasBranchProtectedScope();
return OMPParallelSectionsDirective::Create(Context, StartLoc, EndLoc,
Clauses, AStmt);
}
OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
SourceLocation StartLoc,
SourceLocation LParenLoc,

View File

@ -6494,6 +6494,17 @@ StmtResult TreeTransform<Derived>::TransformOMPParallelForDirective(
return Res;
}
template <typename Derived>
StmtResult TreeTransform<Derived>::TransformOMPParallelSectionsDirective(
OMPParallelSectionsDirective *D) {
DeclarationNameInfo DirName;
getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_sections, DirName,
nullptr, D->getLocStart());
StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
getDerived().getSema().EndOpenMPDSABlock(Res.get());
return Res;
}
//===----------------------------------------------------------------------===//
// OpenMP clause transformation
//===----------------------------------------------------------------------===//

View File

@ -1950,6 +1950,14 @@ void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPParallelSectionsDirective(
OMPParallelSectionsDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
++Idx;
VisitOMPExecutableDirective(D);
}
//===----------------------------------------------------------------------===//
// ASTReader Implementation
//===----------------------------------------------------------------------===//
@ -2470,6 +2478,11 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
break;
}
case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
S = OMPParallelSectionsDirective::CreateEmpty(
Context, Record[ASTStmtReader::NumStmtFields], Empty);
break;
case EXPR_CXX_OPERATOR_CALL:
S = new (Context) CXXOperatorCallExpr(Context, Empty);
break;

View File

@ -1859,6 +1859,14 @@ void ASTStmtWriter::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Code = serialization::STMT_OMP_PARALLEL_FOR_DIRECTIVE;
}
void ASTStmtWriter::VisitOMPParallelSectionsDirective(
OMPParallelSectionsDirective *D) {
VisitStmt(D);
Record.push_back(D->getNumClauses());
VisitOMPExecutableDirective(D);
Code = serialization::STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE;
}
//===----------------------------------------------------------------------===//
// ASTWriter Implementation
//===----------------------------------------------------------------------===//

View File

@ -738,6 +738,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::OMPSectionDirectiveClass:
case Stmt::OMPSingleDirectiveClass:
case Stmt::OMPParallelForDirectiveClass:
case Stmt::OMPParallelSectionsDirectiveClass:
llvm_unreachable("Stmt should not be in analyzer evaluation loop");
case Stmt::ObjCSubscriptRefExprClass:

View File

@ -30,6 +30,11 @@ void foo() {
#pragma omp parallel for
for (int i = 0; i < 10; ++i)
;
#pragma omp parallel
#pragma omp parallel sections
{
bar();
}
// SIMD DIRECTIVE
#pragma omp simd
@ -77,6 +82,13 @@ void foo() {
for (int i = 0; i < 10; ++i)
;
}
#pragma omp simd
for (int i = 0; i < 10; ++i) {
#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
{
bar();
}
}
// FOR DIRECTIVE
#pragma omp for
@ -141,6 +153,13 @@ void foo() {
for (int i = 0; i < 10; ++i)
;
}
#pragma omp for
for (int i = 0; i < 10; ++i) {
#pragma omp parallel sections
{
bar();
}
}
// SECTIONS DIRECTIVE
#pragma omp sections
@ -206,6 +225,13 @@ void foo() {
for (int i = 0; i < 10; ++i)
;
}
#pragma omp sections
{
#pragma omp parallel sections
{
bar();
}
}
// SECTION DIRECTIVE
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
@ -269,6 +295,13 @@ void foo() {
for (int i = 0; i < 10; ++i)
;
}
#pragma omp single
{
#pragma omp parallel sections
{
bar();
}
}
// PARALLEL FOR DIRECTIVE
#pragma omp parallel for
@ -333,6 +366,85 @@ void foo() {
for (int i = 0; i < 10; ++i)
;
}
#pragma omp parallel for
for (int i = 0; i < 10; ++i) {
#pragma omp parallel sections
{
bar();
}
}
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
{
#pragma omp for // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
for (int i = 0; i < 10; ++i)
;
}
#pragma omp parallel sections
{
#pragma omp simd
for (int i = 0; i < 10; ++i)
;
}
#pragma omp parallel sections
{
#pragma omp parallel
for (int i = 0; i < 10; ++i)
;
}
#pragma omp parallel sections
{
#pragma omp sections // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
{
bar();
}
}
#pragma omp parallel sections
{
#pragma omp section
{
bar();
}
}
#pragma omp parallel 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 parallel sections
{
#pragma omp parallel
{
#pragma omp single // OK
{
bar();
}
#pragma omp for // OK
for (int i = 0; i < 10; ++i)
;
#pragma omp sections // OK
{
bar();
}
}
}
#pragma omp parallel sections
{
#pragma omp parallel for
for (int i = 0; i < 10; ++i)
;
}
#pragma omp parallel sections
{
#pragma omp parallel sections
{
bar();
}
}
}
void foo() {
@ -367,6 +479,11 @@ void foo() {
#pragma omp parallel for
for (int i = 0; i < 10; ++i)
;
#pragma omp parallel
#pragma omp parallel sections
{
bar();
}
// SIMD DIRECTIVE
#pragma omp simd
@ -412,6 +529,13 @@ void foo() {
for (int i = 0; i < 10; ++i)
;
}
#pragma omp simd
for (int i = 0; i < 10; ++i) {
#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
{
bar();
}
}
// FOR DIRECTIVE
#pragma omp for
@ -474,6 +598,13 @@ void foo() {
for (int i = 0; i < 10; ++i)
;
}
#pragma omp for
for (int i = 0; i < 10; ++i) {
#pragma omp parallel sections
{
bar();
}
}
// SECTIONS DIRECTIVE
#pragma omp sections
@ -536,6 +667,13 @@ void foo() {
for (int i = 0; i < 10; ++i)
;
}
#pragma omp sections
{
#pragma omp parallel sections
{
bar();
}
}
// SECTION DIRECTIVE
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
@ -599,6 +737,13 @@ void foo() {
for (int i = 0; i < 10; ++i)
;
}
#pragma omp single
{
#pragma omp parallel sections
{
bar();
}
}
// PARALLEL FOR DIRECTIVE
#pragma omp parallel for
@ -663,6 +808,85 @@ void foo() {
for (int i = 0; i < 10; ++i)
;
}
#pragma omp parallel for
for (int i = 0; i < 10; ++i) {
#pragma omp parallel sections
{
bar();
}
}
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
{
#pragma omp for // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
for (int i = 0; i < 10; ++i)
;
}
#pragma omp parallel sections
{
#pragma omp simd
for (int i = 0; i < 10; ++i)
;
}
#pragma omp parallel sections
{
#pragma omp parallel
for (int i = 0; i < 10; ++i)
;
}
#pragma omp parallel sections
{
#pragma omp sections // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
{
bar();
}
}
#pragma omp parallel sections
{
#pragma omp section
{
bar();
}
}
#pragma omp parallel 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 parallel sections
{
#pragma omp parallel
{
#pragma omp single // OK
{
bar();
}
#pragma omp for // OK
for (int i = 0; i < 10; ++i)
;
#pragma omp sections // OK
{
bar();
}
}
}
#pragma omp parallel sections
{
#pragma omp parallel for
for (int i = 0; i < 10; ++i)
;
}
#pragma omp parallel sections
{
#pragma omp parallel sections
{
bar();
}
}
return foo<int>();
}

View File

@ -0,0 +1,144 @@
// 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 parallel sections
{
a = 2;
}
#pragma omp parallel sections default(none), private(argc, b) firstprivate(argv) shared(d) if (argc > 0) num_threads(C) copyin(S < T > ::TS) proc_bind(master) reduction(+ : c) reduction(max : e)
{
foo();
}
#pragma omp parallel sections if (C) num_threads(s) proc_bind(close) reduction(^ : e, f) reduction(&& : g) lastprivate(b, c)
{
foo();
#pragma omp section
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 parallel sections
// CHECK-NEXT: {
// CHECK-NEXT: a = 2;
// CHECK-NEXT: }
// CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) num_threads(5) copyin(S<int>::TS) proc_bind(master) reduction(+: c) reduction(max: e)
// CHECK-NEXT: {
// CHECK-NEXT: foo();
// CHECK-NEXT: }
// CHECK-NEXT: #pragma omp parallel sections if(5) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c)
// CHECK-NEXT: {
// CHECK-NEXT: foo();
// CHECK-NEXT: #pragma omp section
// CHECK-NEXT: foo();
// CHECK-NEXT: }
// 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 parallel sections
// CHECK-NEXT: {
// CHECK-NEXT: a = 2;
// CHECK-NEXT: }
// CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) num_threads(1) copyin(S<long>::TS) proc_bind(master) reduction(+: c) reduction(max: e)
// CHECK-NEXT: {
// CHECK-NEXT: foo();
// CHECK-NEXT: }
// CHECK-NEXT: #pragma omp parallel sections if(1) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c)
// CHECK-NEXT: {
// CHECK-NEXT: foo();
// CHECK-NEXT: #pragma omp section
// CHECK-NEXT: foo();
// CHECK-NEXT: }
// 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 parallel sections
// CHECK-NEXT: {
// CHECK-NEXT: a = 2;
// CHECK-NEXT: }
// CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) num_threads(C) copyin(S<T>::TS) proc_bind(master) reduction(+: c) reduction(max: e)
// CHECK-NEXT: {
// CHECK-NEXT: foo();
// CHECK-NEXT: }
// CHECK-NEXT: #pragma omp parallel sections if(C) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c)
// CHECK-NEXT: {
// CHECK-NEXT: foo();
// CHECK-NEXT: #pragma omp section
// CHECK-NEXT: foo();
// CHECK-NEXT: }
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 parallel sections
// CHECK-NEXT: #pragma omp parallel sections
{
a = 2;
}
// CHECK-NEXT: {
// CHECK-NEXT: a = 2;
// CHECK-NEXT: }
#pragma omp parallel sections default(none), private(argc, b) firstprivate(argv) if (argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(| : c, d) reduction(* : e) lastprivate(argv)
// CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) if(argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(|: c,d) reduction(*: e) lastprivate(argv)
{
foo();
#pragma omp section
foo();
#pragma omp section
foo();
}
// CHECK-NEXT: {
// CHECK-NEXT: foo();
// CHECK-NEXT: #pragma omp section
// CHECK-NEXT: foo();
// CHECK-NEXT: #pragma omp section
// CHECK-NEXT: foo();
// CHECK-NEXT: }
return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);
}
#endif

View File

@ -0,0 +1,105 @@
// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -o - %s
void foo() {
}
bool foobool(int argc) {
return argc;
}
struct S1; // expected-note {{declared here}}
class S2 {
mutable int a;
public:
S2() : a(0) {}
S2 &operator=(S2 &s2) { return *this; }
};
class S3 {
int a;
public:
S3() : a(0) {}
S3 &operator=(S3 &s3) { return *this; }
};
class S4 { // expected-note {{'S4' declared here}}
int a;
S4();
S4 &operator=(const S4 &s4);
public:
S4(int v) : a(v) {}
};
class S5 { // expected-note {{'S5' declared here}}
int a;
S5() : a(0) {}
S5 &operator=(const S5 &s5) { return *this; }
public:
S5(int v) : a(v) {}
};
template <class T>
class ST {
public:
static T s;
};
S2 k;
S3 h;
S4 l(3); // expected-note {{'l' defined here}}
S5 m(4); // expected-note {{'m' defined here}}
#pragma omp threadprivate(h, k, l, m)
int main(int argc, char **argv) {
int i;
#pragma omp parallel sections copyin // expected-error {{expected '(' after 'copyin'}}
{
foo();
}
#pragma omp parallel sections copyin( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections copyin() // expected-error {{expected expression}}
{
foo();
}
#pragma omp parallel sections copyin(k // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections copyin(h, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections copyin(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections copyin(l) // expected-error {{copyin variable must have an accessible, unambiguous copy assignment operator}}
{
foo();
}
#pragma omp parallel sections copyin(S1) // expected-error {{'S1' does not refer to a value}}
{
foo();
}
#pragma omp parallel sections copyin(argv[1]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections copyin(i) // expected-error {{copyin variable must be threadprivate}}
{
foo();
}
#pragma omp parallel sections copyin(m) // expected-error {{copyin variable must have an accessible, unambiguous copy assignment operator}}
{
foo();
}
#pragma omp parallel sections copyin(ST < int > ::s) // expected-error {{copyin variable must be threadprivate}}
{
foo();
}
return 0;
}

View File

@ -0,0 +1,39 @@
// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -o - %s
void foo();
int main(int argc, char **argv) {
#pragma omp parallel sections default // expected-error {{expected '(' after 'default'}}
{
#pragma omp parallel sections default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
#pragma omp parallel sections default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
{
#pragma omp parallel sections default(none // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
#pragma omp parallel sections default(shared), default(shared) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'default' clause}}
{
#pragma omp parallel sections default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
{
foo();
}
}
}
}
}
}
#pragma omp parallel sections default(none)
{
++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
}
#pragma omp parallel sections default(none)
{
#pragma omp parallel sections default(shared)
{
++argc;
}
}
return 0;
}

View File

@ -0,0 +1,295 @@
// 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 sections firstprivate // expected-error {{expected '(' after 'firstprivate'}}
{
foo();
}
#pragma omp parallel sections firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections firstprivate() // expected-error {{expected expression}}
{
foo();
}
#pragma omp parallel sections firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections firstprivate(argc)
{
foo();
}
#pragma omp parallel sections firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
{
foo();
}
#pragma omp parallel sections firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
{
foo();
}
#pragma omp parallel sections firstprivate(argv[1]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
{
foo();
}
#pragma omp parallel sections firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
{
foo();
}
#pragma omp parallel sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel sections'}}
{
foo();
}
#pragma omp parallel
{
int v = 0;
int i;
#pragma omp parallel sections firstprivate(i)
{
foo();
}
v += i;
}
#pragma omp parallel shared(i)
#pragma omp parallel private(i)
#pragma omp parallel sections firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
{
foo();
}
#pragma omp parallel sections firstprivate(i)
{
foo();
}
#pragma omp parallel sections lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
{
foo();
}
#pragma omp parallel private(i)
#pragma omp parallel sections firstprivate(i)
{
foo();
}
#pragma omp parallel reduction(+ : i)
#pragma omp parallel sections firstprivate(i)
{
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 sections firstprivate // expected-error {{expected '(' after 'firstprivate'}}
{
foo();
}
#pragma omp parallel sections firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections firstprivate() // expected-error {{expected expression}}
{
foo();
}
#pragma omp parallel sections firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections firstprivate(argc)
{
foo();
}
#pragma omp parallel sections firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
{
foo();
}
#pragma omp parallel sections firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
{
foo();
}
#pragma omp parallel sections firstprivate(argv[1]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections firstprivate(2 * 2) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections firstprivate(ba) // OK
{
foo();
}
#pragma omp parallel sections firstprivate(ca) // OK
{
foo();
}
#pragma omp parallel sections firstprivate(da) // OK
{
foo();
}
int xa;
#pragma omp parallel sections firstprivate(xa) // OK
{
foo();
}
#pragma omp parallel sections firstprivate(S2::S2s) // OK
{
foo();
}
#pragma omp parallel sections firstprivate(S2::S2sc) // OK
{
foo();
}
#pragma omp parallel sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel sections'}}
{
foo();
}
#pragma omp parallel sections firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
{
foo();
}
#pragma omp parallel sections firstprivate(m) // OK
{
foo();
}
#pragma omp parallel sections firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
{
foo();
}
#pragma omp parallel sections private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
{
foo();
}
#pragma omp parallel shared(xa)
#pragma omp parallel sections firstprivate(xa) // OK: may be firstprivate
{
foo();
}
#pragma omp parallel sections firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
{
foo();
}
#pragma omp parallel sections lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
{
foo();
}
#pragma omp parallel sections lastprivate(n) firstprivate(n) // OK
{
foo();
}
#pragma omp parallel
{
int v = 0;
int i;
#pragma omp parallel sections firstprivate(i)
{
foo();
}
v += i;
}
#pragma omp parallel private(i)
#pragma omp parallel sections firstprivate(i)
{
foo();
}
#pragma omp parallel reduction(+ : i)
#pragma omp parallel sections firstprivate(i)
{
foo();
}
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
}

View File

@ -0,0 +1,113 @@
// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
void foo() {
}
bool foobool(int argc) {
return argc;
}
struct S1; // expected-note {{declared here}}
template <class T, class S> // expected-note {{declared here}}
int tmain(T argc, S **argv) {
#pragma omp parallel sections if // expected-error {{expected '(' after 'if'}}
{
foo();
}
#pragma omp parallel sections if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections if () // expected-error {{expected expression}}
{
foo();
}
#pragma omp parallel sections if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
{
foo();
}
#pragma omp parallel sections if (argc > 0 ? argv[1] : argv[2])
{
foo();
}
#pragma omp parallel sections if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'if' clause}}
{
foo();
}
#pragma omp parallel sections if (S) // expected-error {{'S' does not refer to a value}}
{
foo();
}
#pragma omp parallel sections if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections if(argc)
{
foo();
}
return 0;
}
int main(int argc, char **argv) {
#pragma omp parallel sections if // expected-error {{expected '(' after 'if'}}
{
foo();
}
#pragma omp parallel sections if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections if () // expected-error {{expected expression}}
{
foo();
}
#pragma omp parallel sections if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
{
foo();
}
#pragma omp parallel sections if (argc > 0 ? argv[1] : argv[2])
{
foo();
}
#pragma omp parallel sections if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'if' clause}}
{
foo();
}
#pragma omp parallel sections if (S1) // expected-error {{'S1' does not refer to a value}}
{
foo();
}
#pragma omp parallel sections if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
return tmain(argc, argv);
}

View File

@ -0,0 +1,269 @@
// 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; // expected-note {{static data member is predetermined as shared}}
static const float S2sc;
};
const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}}
const S2 b;
const S2 ba[5];
class S3 { // expected-note 2 {{'S3' declared here}}
int a;
S3 &operator=(const S3 &s3);
public:
S3() : a(0) {}
S3(S3 &s3) : a(s3.a) {}
};
const S3 c; // expected-note {{global variable is predetermined as shared}}
const S3 ca[5]; // expected-note {{global variable is predetermined as shared}}
extern const int f; // expected-note {{global variable is predetermined as shared}}
class S4 { // expected-note 3 {{'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) {}
public:
S5(const S5 &s5) : a(s5.a) {}
S5(int v) : a(v) {}
};
class S6 {
int a;
S6() : a(0) {}
public:
S6(const S6 &s6) : a(s6.a) {}
S6(int v) : a(v) {}
};
S3 h;
#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
template <class I, class C>
int foomain(int argc, char **argv) {
I e(4); // expected-note {{'e' defined here}}
I g(5); // expected-note {{'g' defined here}}
int i;
int &j = i; // expected-note {{'j' defined here}}
#pragma omp parallel sections lastprivate // expected-error {{expected '(' after 'lastprivate'}}
{
foo();
}
#pragma omp parallel sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections lastprivate() // expected-error {{expected expression}}
{
foo();
}
#pragma omp parallel sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections lastprivate(argc)
{
foo();
}
#pragma omp parallel sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
{
foo();
}
#pragma omp parallel sections lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
{
foo();
}
#pragma omp parallel sections lastprivate(argv[1]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}}
{
foo();
}
#pragma omp parallel sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
{
foo();
}
#pragma omp parallel sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel sections'}}
{
foo();
}
#pragma omp parallel
{
int v = 0;
int i;
#pragma omp parallel sections lastprivate(i)
{
foo();
}
v += i;
}
#pragma omp parallel shared(i)
#pragma omp parallel private(i)
#pragma omp parallel sections lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
{
foo();
}
#pragma omp parallel sections lastprivate(i)
{
foo();
}
return 0;
}
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}}
S3 m; // expected-note 2 {{'m' defined here}}
S6 n(2);
int i;
int &j = i; // expected-note {{'j' defined here}}
#pragma omp parallel sections lastprivate // expected-error {{expected '(' after 'lastprivate'}}
{
foo();
}
#pragma omp parallel sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections lastprivate() // expected-error {{expected expression}}
{
foo();
}
#pragma omp parallel sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections lastprivate(argc)
{
foo();
}
#pragma omp parallel sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
{
foo();
}
#pragma omp parallel sections lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}}
{
foo();
}
#pragma omp parallel sections lastprivate(argv[1]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections lastprivate(2 * 2) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections lastprivate(ba)
{
foo();
}
#pragma omp parallel sections lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
{
foo();
}
#pragma omp parallel sections lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
{
foo();
}
int xa;
#pragma omp parallel sections lastprivate(xa) // OK
{
foo();
}
#pragma omp parallel sections lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
{
foo();
}
#pragma omp parallel sections lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
{
foo();
}
#pragma omp parallel sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel sections'}}
{
foo();
}
#pragma omp parallel sections lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}}
{
foo();
}
#pragma omp parallel sections lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}}
{
foo();
}
#pragma omp parallel sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
{
foo();
}
#pragma omp parallel sections private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
{
foo();
}
#pragma omp parallel sections lastprivate(i)
{
foo();
}
#pragma omp parallel private(xa)
#pragma omp parallel sections lastprivate(xa)
{
foo();
}
#pragma omp parallel reduction(+ : xa)
#pragma omp parallel sections lastprivate(xa)
{
foo();
}
#pragma omp parallel sections lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
{
foo();
}
#pragma omp parallel sections firstprivate(m) lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}}
{
foo();
}
#pragma omp parallel sections lastprivate(n) firstprivate(n) // OK
{
foo();
}
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
}

View File

@ -0,0 +1,86 @@
// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -std=c++11 -o - %s
void foo() {
}
#pragma omp parallel sections // expected-error {{unexpected OpenMP directive '#pragma omp parallel sections'}}
int main(int argc, char **argv) {
#pragma omp parallel sections {// expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
{
foo();
}
#pragma omp parallel sections( // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
{
foo();
}
#pragma omp parallel sections[ // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
{
foo();
}
#pragma omp parallel sections] // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
{
foo();
}
#pragma omp parallel sections) // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
{
foo();
}
#pragma omp parallel sections } // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
{
foo();
}
// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
#pragma omp parallel sections unknown()
{
foo();
#pragma omp section
L1:
foo();
}
#pragma omp parallel sections
{
;
}
#pragma omp parallel sections
{
goto L1; // expected-error {{use of undeclared label 'L1'}}
}
for (int i = 0; i < 10; ++i) {
switch (argc) {
case (0):
#pragma omp parallel sections
{
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 parallel sections 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 parallel sections
{
L2:
foo();
}
#pragma omp parallel sections
{
return 1; // expected-error {{cannot return from OpenMP region}}
}
[[]] // expected-error {{an attribute list cannot appear here}}
#pragma omp parallel sections
{
}
return 0;
}

View File

@ -0,0 +1,260 @@
// RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -verify %s
void foo();
// expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel sections'}}
#pragma omp parallel sections
// expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel sections'}}
#pragma omp parallel sections foo
void test_no_clause() {
int i;
#pragma omp parallel sections
{
foo();
}
// expected-error@+2 {{the statement for '#pragma omp parallel sections' must be a compound statement}}
#pragma omp parallel sections
++i;
#pragma omp parallel sections
{
foo();
foo(); // expected-error {{statement in 'omp parallel sections' directive must be enclosed into a section region}}
}
}
void test_branch_protected_scope() {
int i = 0;
L1:
++i;
int x[24];
#pragma omp parallel sections
{
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]++;
}
#pragma omp section
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 L3;
else if (i == 8) {
L3:
x[i]++;
}
}
if (x[0] == 0)
goto L2; // expected-error {{use of undeclared label 'L2'}}
else if (x[1] == 1)
goto L1;
goto L3; // expected-error {{use of undeclared label 'L3'}}
}
void test_invalid_clause() {
int i;
// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
#pragma omp parallel sections foo bar
{
foo();
// expected-error@+1 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp section'}}
#pragma omp section nowait
;
}
}
void test_non_identifiers() {
int i, x;
// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
#pragma omp parallel sections;
{
foo();
}
// expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel sections'}}
// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
#pragma omp parallel sections linear(x);
{
foo();
}
// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
#pragma omp parallel sections private(x);
{
foo();
}
// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
#pragma omp parallel sections, private(x);
{
foo();
}
}
void test_private() {
int i;
// expected-error@+2 {{expected expression}}
// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp parallel sections private(
{
foo();
}
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 2 {{expected expression}}
#pragma omp parallel sections private(,
{
foo();
}
// expected-error@+1 2 {{expected expression}}
#pragma omp parallel sections private(, )
{
foo();
}
// expected-error@+1 {{expected expression}}
#pragma omp parallel sections private()
{
foo();
}
// expected-error@+1 {{expected expression}}
#pragma omp parallel sections private(int)
{
foo();
}
// expected-error@+1 {{expected variable name}}
#pragma omp parallel sections private(0)
{
foo();
}
int x, y, z;
#pragma omp parallel sections private(x)
{
foo();
}
#pragma omp parallel sections private(x, y)
{
foo();
}
#pragma omp parallel sections private(x, y, z)
{
foo();
}
}
void test_lastprivate() {
int i;
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 {{expected expression}}
#pragma omp parallel sections lastprivate(
{
foo();
}
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 2 {{expected expression}}
#pragma omp parallel sections lastprivate(,
{
foo();
}
// expected-error@+1 2 {{expected expression}}
#pragma omp parallel sections lastprivate(, )
{
foo();
}
// expected-error@+1 {{expected expression}}
#pragma omp parallel sections lastprivate()
{
foo();
}
// expected-error@+1 {{expected expression}}
#pragma omp parallel sections lastprivate(int)
{
foo();
}
// expected-error@+1 {{expected variable name}}
#pragma omp parallel sections lastprivate(0)
{
foo();
}
int x, y, z;
#pragma omp parallel sections lastprivate(x)
{
foo();
}
#pragma omp parallel sections lastprivate(x, y)
{
foo();
}
#pragma omp parallel sections lastprivate(x, y, z)
{
foo();
}
}
void test_firstprivate() {
int i;
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 {{expected expression}}
#pragma omp parallel sections firstprivate(
{
foo();
}
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 2 {{expected expression}}
#pragma omp parallel sections firstprivate(,
{
foo();
}
// expected-error@+1 2 {{expected expression}}
#pragma omp parallel sections firstprivate(, )
{
foo();
}
// expected-error@+1 {{expected expression}}
#pragma omp parallel sections firstprivate()
{
foo();
}
// expected-error@+1 {{expected expression}}
#pragma omp parallel sections firstprivate(int)
{
foo();
}
// expected-error@+1 {{expected variable name}}
#pragma omp parallel sections firstprivate(0)
{
foo();
}
int x, y, z;
#pragma omp parallel sections lastprivate(x) firstprivate(x)
{
foo();
}
#pragma omp parallel sections lastprivate(x, y) firstprivate(x, y)
{
foo();
}
#pragma omp parallel sections lastprivate(x, y, z) firstprivate(x, y, z)
{
foo();
}
}

View File

@ -0,0 +1,63 @@
// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
void foo() {
}
bool foobool(int argc) {
return argc;
}
struct S1; // expected-note {{declared here}}
template <class T, typename S, int N> // expected-note {{declared here}}
T tmain(T argc, S **argv) {
#pragma omp parallel sections num_threads // expected-error {{expected '(' after 'num_threads'}}
{foo();}
#pragma omp parallel sections num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{foo();}
#pragma omp parallel sections num_threads () // expected-error {{expected expression}}
{foo();}
#pragma omp parallel sections num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
{foo();}
#pragma omp parallel sections num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
{foo();}
#pragma omp parallel sections num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
{foo();}
#pragma omp parallel sections num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp parallel sections' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a positive integer value}}
{foo();}
#pragma omp parallel sections num_threads (S) // expected-error {{'S' does not refer to a value}}
{foo();}
#pragma omp parallel sections num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
{foo();}
#pragma omp parallel sections num_threads (argc)
{foo();}
#pragma omp parallel sections num_threads (N) // expected-error {{argument to 'num_threads' clause must be a positive integer value}}
{foo();}
return argc;
}
int main(int argc, char **argv) {
#pragma omp parallel sections num_threads // expected-error {{expected '(' after 'num_threads'}}
{foo();}
#pragma omp parallel sections num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{foo();}
#pragma omp parallel sections num_threads () // expected-error {{expected expression}}
{foo();}
#pragma omp parallel sections num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
{foo();}
#pragma omp parallel sections num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
{foo();}
#pragma omp parallel sections num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }}
{foo();}
#pragma omp parallel sections num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp parallel sections' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a positive integer value}}
{foo();}
#pragma omp parallel sections num_threads (S1) // expected-error {{'S1' does not refer to a value}}
{foo();}
#pragma omp parallel sections num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}}
{foo();}
#pragma omp parallel sections num_threads (num_threads(tmain<int, char, -1>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} expected-note {{in instantiation of function template specialization 'tmain<int, char, -1>' requested here}}
{foo();}
return tmain<int, char, 3>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 3>' requested here}}
}

View File

@ -0,0 +1,204 @@
// 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 parallel sections private // expected-error {{expected '(' after 'private'}}
{
foo();
}
#pragma omp parallel sections private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections private() // expected-error {{expected expression}}
{
foo();
}
#pragma omp parallel sections private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections private(argc)
{
foo();
}
#pragma omp parallel sections private(S1) // expected-error {{'S1' does not refer to a value}}
{
foo();
}
#pragma omp parallel sections private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
{
foo();
}
#pragma omp parallel sections private(argv[1]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections private(e, g)
{
foo();
}
#pragma omp parallel sections private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
{
foo();
}
#pragma omp parallel sections copyprivate(i) // expected-error {{unexpected OpenMP clause 'copyprivate' in directive '#pragma omp parallel sections'}}
{
foo();
}
#pragma omp parallel
{
int v = 0;
int i;
#pragma omp parallel sections private(i)
{
foo();
}
v += i;
}
#pragma omp parallel shared(i)
#pragma omp parallel private(i)
#pragma omp parallel sections private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
{
foo();
}
#pragma omp parallel sections 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 parallel sections private // expected-error {{expected '(' after 'private'}}
{
foo();
}
#pragma omp parallel sections private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections private() // expected-error {{expected expression}}
{
foo();
}
#pragma omp parallel sections private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections private(argc)
{
foo();
}
#pragma omp parallel sections private(S1) // expected-error {{'S1' does not refer to a value}}
{
foo();
}
#pragma omp parallel sections private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
{
foo();
}
#pragma omp parallel sections private(argv[1]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}}
{
foo();
}
#pragma omp parallel sections private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
{
foo();
}
#pragma omp parallel sections copyprivate(i) // expected-error {{unexpected OpenMP clause 'copyprivate' in directive '#pragma omp parallel sections'}}
{
foo();
}
#pragma omp parallel
{
int i;
#pragma omp parallel sections private(i)
{
foo();
}
}
#pragma omp parallel shared(i)
#pragma omp parallel private(i)
#pragma omp parallel sections private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
{
foo();
}
#pragma omp parallel sections private(i)
{
foo();
}
return 0;
}

View File

@ -0,0 +1,28 @@
// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -o - %s
void foo();
int main(int argc, char **argv) {
#pragma omp parallel sections proc_bind // expected-error {{expected '(' after 'proc_bind'}}
{ foo(); }
#pragma omp parallel sections proc_bind( // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{ foo(); }
#pragma omp parallel sections proc_bind() // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}}
{ foo(); }
#pragma omp parallel sections proc_bind(master // expected-error {{expected ')'}} expected-note {{to match this '('}}
{ foo(); }
#pragma omp parallel sections proc_bind(close), proc_bind(spread) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'proc_bind' clause}}
{ foo(); }
#pragma omp parallel sections proc_bind(x) // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}}
{ foo(); }
#pragma omp parallel sections proc_bind(master)
{ ++argc; }
#pragma omp parallel sections proc_bind(close)
{
#pragma omp parallel sections proc_bind(spread)
{ ++argc; }
}
return 0;
}

View File

@ -0,0 +1,358 @@
// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -o - %s
void foo() {
}
bool foobool(int argc) {
return argc;
}
struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
extern S1 a;
class S2 {
mutable int a;
S2 &operator+=(const S2 &arg) { return (*this); }
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 parallel sections reduction // expected-error {{expected '(' after 'reduction'}}
{
foo();
}
#pragma omp parallel sections reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
{
foo();
}
#pragma omp parallel sections reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
{
foo();
}
#pragma omp parallel sections reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
{
foo();
}
#pragma omp parallel sections reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
{
foo();
}
#pragma omp parallel sections 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 parallel sections 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 parallel sections reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name}}
{
foo();
}
#pragma omp parallel sections reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
{
foo();
}
#pragma omp parallel sections reduction(&& : argc)
{
foo();
}
#pragma omp parallel sections reduction(^ : T) // expected-error {{'T' does not refer to a value}}
{
foo();
}
#pragma omp parallel sections 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 parallel sections 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 parallel sections reduction(max : qa[1]) // expected-error 2 {{expected variable name}}
{
foo();
}
#pragma omp parallel sections reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}}
{
foo();
}
#pragma omp parallel sections reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}}
{
foo();
}
#pragma omp parallel sections 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 parallel sections reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}}
{
foo();
}
#pragma omp parallel sections reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
{
foo();
}
#pragma omp parallel sections reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
{
foo();
}
#pragma omp parallel sections reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
{
foo();
}
#pragma omp parallel sections reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}}
{
foo();
}
#pragma omp parallel sections 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 parallel sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
{
foo();
}
#pragma omp parallel sections 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 parallel sections 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 parallel sections reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
{
foo();
}
#pragma omp parallel private(fl)
#pragma omp parallel sections reduction(+ : fl)
{
foo();
}
#pragma omp parallel reduction(* : fl)
#pragma omp parallel sections 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 parallel sections reduction // expected-error {{expected '(' after 'reduction'}}
{
foo();
}
#pragma omp parallel sections reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
{
foo();
}
#pragma omp parallel sections reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
{
foo();
}
#pragma omp parallel sections reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
{
foo();
}
#pragma omp parallel sections reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
{
foo();
}
#pragma omp parallel sections 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 parallel sections reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
foo();
}
#pragma omp parallel sections reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections reduction(~ : argc) // expected-error {{expected unqualified-id}}
{
foo();
}
#pragma omp parallel sections reduction(&& : argc)
{
foo();
}
#pragma omp parallel sections reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
{
foo();
}
#pragma omp parallel sections 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 parallel sections 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 parallel sections reduction(max : argv[1]) // expected-error {{expected variable name}}
{
foo();
}
#pragma omp parallel sections reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}}
{
foo();
}
#pragma omp parallel sections reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}}
{
foo();
}
#pragma omp parallel sections reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}}
{
foo();
}
#pragma omp parallel sections reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}}
{
foo();
}
#pragma omp parallel sections reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
{
foo();
}
#pragma omp parallel sections reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
{
foo();
}
#pragma omp parallel sections 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 parallel sections reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
{
foo();
}
#pragma omp parallel sections reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}}
{
foo();
}
#pragma omp parallel sections 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 parallel sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
{
foo();
}
#pragma omp parallel sections reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
{
foo();
}
#pragma omp parallel sections reduction(+ : r) // expected-error {{const-qualified variable cannot be reduction}}
{
foo();
}
#pragma omp parallel shared(i)
#pragma omp parallel reduction(min : i)
#pragma omp parallel sections reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
{
foo();
}
#pragma omp parallel private(fl)
#pragma omp parallel sections reduction(+ : fl)
{
foo();
}
#pragma omp parallel reduction(* : fl)
#pragma omp parallel sections 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}}
}

View File

@ -0,0 +1,110 @@
// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
void foo() {
}
bool foobool(int argc) {
return argc;
}
struct S1; // expected-note {{declared here}}
extern S1 a;
class S2 {
mutable int a;
public:
S2() : a(0) {}
S2(S2 &s2) : a(s2.a) {}
};
const S2 b;
const S2 ba[5];
class S3 {
int a;
public:
S3() : a(0) {}
S3(S3 &s3) : a(s3.a) {}
};
const S3 c;
const S3 ca[5];
extern const int f;
class S4 {
int a;
S4();
S4(const S4 &s4);
public:
S4(int v) : a(v) {}
};
class S5 {
int a;
S5() : a(0) {}
S5(const S5 &s5) : a(s5.a) {}
public:
S5(int v) : a(v) {}
};
S3 h;
#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
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 parallel sections shared // expected-error {{expected '(' after 'shared'}}
{ foo(); }
#pragma omp parallel sections shared( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{ foo(); }
#pragma omp parallel sections shared() // expected-error {{expected expression}}
{ foo(); }
#pragma omp parallel sections shared(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
{ foo(); }
#pragma omp parallel sections shared(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{ foo(); }
#pragma omp parallel sections shared(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
{ foo(); }
#pragma omp parallel sections shared(argc)
{ foo(); }
#pragma omp parallel sections shared(S1) // expected-error {{'S1' does not refer to a value}}
{ foo(); }
#pragma omp parallel sections shared(a, b, c, d, f)
{ foo(); }
#pragma omp parallel sections shared(argv[1]) // expected-error {{expected variable name}}
{ foo(); }
#pragma omp parallel sections shared(ba)
{ foo(); }
#pragma omp parallel sections shared(ca)
{ foo(); }
#pragma omp parallel sections shared(da)
{ foo(); }
#pragma omp parallel sections shared(e, g)
{ foo(); }
#pragma omp parallel sections shared(h) // expected-error {{threadprivate or thread local variable cannot be shared}}
{ foo(); }
#pragma omp parallel sections private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
{ foo(); }
#pragma omp parallel sections firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
{ foo(); }
#pragma omp parallel sections private(i)
{
#pragma omp parallel sections shared(i)
{
#pragma omp parallel sections shared(j)
{ foo(); }
}
}
#pragma omp parallel sections firstprivate(i)
{
#pragma omp parallel sections shared(i)
{
#pragma omp parallel sections shared(j)
{ foo(); }
}
}
return 0;
}

View File

@ -1861,6 +1861,7 @@ public:
void VisitOMPSectionDirective(const OMPSectionDirective *D);
void VisitOMPSingleDirective(const OMPSingleDirective *D);
void VisitOMPParallelForDirective(const OMPParallelForDirective *D);
void VisitOMPParallelSectionsDirective(const OMPParallelSectionsDirective *D);
private:
void AddDeclarationNameInfo(const Stmt *S);
@ -2317,6 +2318,11 @@ EnqueueVisitor::VisitOMPParallelForDirective(const OMPParallelForDirective *D) {
VisitOMPExecutableDirective(D);
}
void EnqueueVisitor::VisitOMPParallelSectionsDirective(
const OMPParallelSectionsDirective *D) {
VisitOMPExecutableDirective(D);
}
void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, const Stmt *S) {
EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S);
}
@ -4003,6 +4009,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
return cxstring::createRef("OMPSingleDirective");
case CXCursor_OMPParallelForDirective:
return cxstring::createRef("OMPParallelForDirective");
case CXCursor_OMPParallelSectionsDirective:
return cxstring::createRef("OMPParallelSectionsDirective");
}
llvm_unreachable("Unhandled CXCursorKind");

View File

@ -538,6 +538,9 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
case Stmt::OMPParallelForDirectiveClass:
K = CXCursor_OMPParallelForDirective;
break;
case Stmt::OMPParallelSectionsDirectiveClass:
K = CXCursor_OMPParallelSectionsDirective;
break;
}
CXCursor C = { K, 0, { Parent, S, TU } };