summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-06-25 11:44:49 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-06-25 11:44:49 +0000
commit71f61a886646fca18a9dbed747ff34b0faa0dc98 (patch)
tree9cf6bd28790e4ce856530984d227bf1f316c5e71 /lib/Sema/SemaOpenMP.cpp
parentab6dc444704d6f49ebc9ed60cc9fec0ec034b384 (diff)
downloadclang-71f61a886646fca18a9dbed747ff34b0faa0dc98.tar.gz
clang-71f61a886646fca18a9dbed747ff34b0faa0dc98.tar.bz2
clang-71f61a886646fca18a9dbed747ff34b0faa0dc98.tar.xz
[OPENMP] Initial support for 'sections' directive.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211685 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOpenMP.cpp')
-rw-r--r--lib/Sema/SemaOpenMP.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp
index aef7ae5a59..db471b88ad 100644
--- a/lib/Sema/SemaOpenMP.cpp
+++ b/lib/Sema/SemaOpenMP.cpp
@@ -910,6 +910,13 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, SourceLocation Loc,
ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP, Params);
break;
}
+ case OMPD_sections: {
+ 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");
@@ -997,6 +1004,10 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind,
case OMPD_for:
Res = ActOnOpenMPForDirective(ClausesWithImplicit, AStmt, StartLoc, EndLoc);
break;
+ case OMPD_sections:
+ Res = ActOnOpenMPSectionsDirective(ClausesWithImplicit, AStmt, StartLoc,
+ EndLoc);
+ break;
case OMPD_threadprivate:
case OMPD_task:
llvm_unreachable("OpenMP Directive is not allowed");
@@ -1567,6 +1578,32 @@ StmtResult Sema::ActOnOpenMPForDirective(ArrayRef<OMPClause *> Clauses,
Clauses, AStmt);
}
+StmtResult Sema::ActOnOpenMPSectionsDirective(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.
+ // TODO
+ } else {
+ Diag(AStmt->getLocStart(), diag::err_omp_sections_not_compound_stmt);
+ return StmtError();
+ }
+
+ getCurFunction()->setHasBranchProtectedScope();
+
+ return OMPSectionsDirective::Create(Context, StartLoc, EndLoc, Clauses,
+ AStmt);
+}
+
OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
SourceLocation StartLoc,
SourceLocation LParenLoc,