summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-07-23 07:46:59 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-07-23 07:46:59 +0000
commit298a81897bd3806ddead5c79bc6a0aaf8cb9d13e (patch)
treeea3b91fe7961335ef5abd4627b91416c208945df /lib/Sema/SemaOpenMP.cpp
parent2203f2c236decff724df42ceff926ef1effd6ca8 (diff)
[OPENMP] Initial parsing an sema analysis for 'write' clause of 'atomic' directive.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213728 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOpenMP.cpp')
-rw-r--r--lib/Sema/SemaOpenMP.cpp65
1 files changed, 39 insertions, 26 deletions
diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp
index 7ec0d2b944..318b00c5aa 100644
--- a/lib/Sema/SemaOpenMP.cpp
+++ b/lib/Sema/SemaOpenMP.cpp
@@ -92,16 +92,15 @@ private:
Scope *CurScope;
SourceLocation ConstructLoc;
bool OrderedRegion;
- SourceLocation AtomicClauseLoc;
SharingMapTy(OpenMPDirectiveKind DKind, DeclarationNameInfo Name,
Scope *CurScope, SourceLocation Loc)
: SharingMap(), AlignedMap(), DefaultAttr(DSA_unspecified),
Directive(DKind), DirectiveName(std::move(Name)), CurScope(CurScope),
- ConstructLoc(Loc), OrderedRegion(false), AtomicClauseLoc() {}
+ ConstructLoc(Loc), OrderedRegion(false) {}
SharingMapTy()
: SharingMap(), AlignedMap(), DefaultAttr(DSA_unspecified),
Directive(OMPD_unknown), DirectiveName(), CurScope(nullptr),
- ConstructLoc(), OrderedRegion(false), AtomicClauseLoc() {}
+ ConstructLoc(), OrderedRegion(false) {}
};
typedef SmallVector<SharingMapTy, 64> StackTy;
@@ -208,22 +207,6 @@ public:
return false;
}
- /// \brief Checks if the 'atomic' construct has explicitly specified 'read',
- /// 'update', 'write' or 'capture' clause.
- bool hasAtomicClause() const {
- return Stack.back().AtomicClauseLoc.isValid();
- }
- /// \brief Gets location of explicitly specified clause for 'atomic'
- /// construct.
- SourceLocation getAtomicClauseLoc() const {
- return Stack.back().AtomicClauseLoc;
- }
- /// \brief Sets location of explicitly specified clause for 'atomic'
- /// directive.
- void setAtomicClauseLoc(SourceLocation Loc) {
- Stack.back().AtomicClauseLoc = Loc;
- }
-
Scope *getCurScope() const { return Stack.back().CurScope; }
Scope *getCurScope() { return Stack.back().CurScope; }
SourceLocation getConstructLoc() { return Stack.back().ConstructLoc; }
@@ -2403,15 +2386,34 @@ StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
// The point of exit cannot be a branch out of the structured block.
// longjmp() and throw() must not violate the entry/exit criteria.
// TODO further analysis of associated statements and clauses.
+ OpenMPClauseKind AtomicKind = OMPC_unknown;
+ SourceLocation AtomicKindLoc;
for (auto *C : Clauses) {
- if (C->getClauseKind() == OMPC_read) {
- if (!isa<Expr>(CS->getCapturedStmt())) {
- Diag(CS->getCapturedStmt()->getLocStart(),
- diag::err_omp_atomic_read_not_expression_statement);
- return StmtError();
+ if (C->getClauseKind() == OMPC_read || C->getClauseKind() == OMPC_write) {
+ if (AtomicKind != OMPC_unknown) {
+ Diag(C->getLocStart(), diag::err_omp_atomic_several_clauses)
+ << SourceRange(C->getLocStart(), C->getLocEnd());
+ Diag(AtomicKindLoc, diag::note_omp_atomic_previous_clause)
+ << getOpenMPClauseName(AtomicKind);
+ } else {
+ AtomicKind = C->getClauseKind();
+ AtomicKindLoc = C->getLocStart();
}
}
}
+ if (AtomicKind == OMPC_read) {
+ if (!isa<Expr>(CS->getCapturedStmt())) {
+ Diag(CS->getCapturedStmt()->getLocStart(),
+ diag::err_omp_atomic_read_not_expression_statement);
+ return StmtError();
+ }
+ } else if (AtomicKind == OMPC_write) {
+ if (!isa<Expr>(CS->getCapturedStmt())) {
+ Diag(CS->getCapturedStmt()->getLocStart(),
+ diag::err_omp_atomic_write_not_expression_statement);
+ return StmtError();
+ }
+ }
getCurFunction()->setHasBranchProtectedScope();
@@ -2458,6 +2460,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
case OMPC_threadprivate:
case OMPC_flush:
case OMPC_read:
+ case OMPC_write:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -2500,7 +2503,6 @@ OMPClause *Sema::ActOnOpenMPFinalClause(Expr *Condition,
return new (Context) OMPFinalClause(ValExpr, StartLoc, LParenLoc, EndLoc);
}
-
ExprResult Sema::PerformOpenMPImplicitIntegerConversion(SourceLocation Loc,
Expr *Op) {
if (!Op)
@@ -2662,6 +2664,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
case OMPC_threadprivate:
case OMPC_flush:
case OMPC_read:
+ case OMPC_write:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -2778,6 +2781,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause(
case OMPC_threadprivate:
case OMPC_flush:
case OMPC_read:
+ case OMPC_write:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -2860,6 +2864,9 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
case OMPC_read:
Res = ActOnOpenMPReadClause(StartLoc, EndLoc);
break;
+ case OMPC_write:
+ Res = ActOnOpenMPWriteClause(StartLoc, EndLoc);
+ break;
case OMPC_if:
case OMPC_final:
case OMPC_num_threads:
@@ -2908,10 +2915,14 @@ OMPClause *Sema::ActOnOpenMPMergeableClause(SourceLocation StartLoc,
OMPClause *Sema::ActOnOpenMPReadClause(SourceLocation StartLoc,
SourceLocation EndLoc) {
- DSAStack->setAtomicClauseLoc(StartLoc);
return new (Context) OMPReadClause(StartLoc, EndLoc);
}
+OMPClause *Sema::ActOnOpenMPWriteClause(SourceLocation StartLoc,
+ SourceLocation EndLoc) {
+ return new (Context) OMPWriteClause(StartLoc, EndLoc);
+}
+
OMPClause *Sema::ActOnOpenMPVarListClause(
OpenMPClauseKind Kind, ArrayRef<Expr *> VarList, Expr *TailExpr,
SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc,
@@ -2966,6 +2977,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause(
case OMPC_mergeable:
case OMPC_threadprivate:
case OMPC_read:
+ case OMPC_write:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -4266,3 +4278,4 @@ OMPClause *Sema::ActOnOpenMPFlushClause(ArrayRef<Expr *> VarList,
return OMPFlushClause::Create(Context, StartLoc, LParenLoc, EndLoc, VarList);
}
+