r213728 - [OPENMP] Initial parsing an sema analysis for 'write' clause of 'atomic' directive.
Alexey Bataev
a.bataev at hotmail.com
Wed Jul 23 00:46:59 PDT 2014
Author: abataev
Date: Wed Jul 23 02:46:59 2014
New Revision: 213728
URL: http://llvm.org/viewvc/llvm-project?rev=213728&view=rev
Log:
[OPENMP] Initial parsing an sema analysis for 'write' clause of 'atomic' directive.
Modified:
cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/atomic_ast_print.cpp
cfe/trunk/test/OpenMP/atomic_messages.cpp
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Wed Jul 23 02:46:59 2014
@@ -2426,6 +2426,11 @@ bool RecursiveASTVisitor<Derived>::Visit
}
template <typename Derived>
+bool RecursiveASTVisitor<Derived>::VisitOMPWriteClause(OMPWriteClause *) {
+ return true;
+}
+
+template <typename Derived>
template <typename T>
bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
for (auto *E : Node->varlists()) {
Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Wed Jul 23 02:46:59 2014
@@ -798,6 +798,35 @@ public:
StmtRange children() { return StmtRange(); }
};
+/// \brief This represents 'write' clause in the '#pragma omp atomic' directive.
+///
+/// \code
+/// #pragma omp atomic write
+/// \endcode
+/// In this example directive '#pragma omp atomic' has 'write' clause.
+///
+class OMPWriteClause : public OMPClause {
+public:
+ /// \brief Build 'write' clause.
+ ///
+ /// \param StartLoc Starting location of the clause.
+ /// \param EndLoc Ending location of the clause.
+ ///
+ OMPWriteClause(SourceLocation StartLoc, SourceLocation EndLoc)
+ : OMPClause(OMPC_write, StartLoc, EndLoc) {}
+
+ /// \brief Build an empty clause.
+ ///
+ OMPWriteClause()
+ : OMPClause(OMPC_write, SourceLocation(), SourceLocation()) {}
+
+ static bool classof(const OMPClause *T) {
+ return T->getClauseKind() == OMPC_write;
+ }
+
+ StmtRange children() { return StmtRange(); }
+};
+
/// \brief This represents clause 'private' in the '#pragma omp ...' directives.
///
/// \code
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Jul 23 02:46:59 2014
@@ -2448,6 +2448,11 @@ bool RecursiveASTVisitor<Derived>::Visit
}
template <typename Derived>
+bool RecursiveASTVisitor<Derived>::VisitOMPWriteClause(OMPWriteClause *) {
+ return true;
+}
+
+template <typename Derived>
template <typename T>
bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
for (auto *E : Node->varlists()) {
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul 23 02:46:59 2014
@@ -7151,6 +7151,13 @@ def err_omp_parallel_reduction_in_task_f
def err_omp_atomic_read_not_expression_statement : Error<
"the statement for 'atomic read' must be an expression statement of form 'v = x;',"
" where v and x are both l-value expressions with scalar type">;
+def err_omp_atomic_write_not_expression_statement : Error<
+ "the statement for 'atomic write' must be an expression statement of form 'x = expr;',"
+ " where x is an l-value expression with scalar type">;
+def err_omp_atomic_several_clauses : Error<
+ "directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause">;
+def note_omp_atomic_previous_clause : Note<
+ "'%0' clause used here">;
} // end of OpenMP category
let CategoryName = "Related Result Type Issue" in {
Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Wed Jul 23 02:46:59 2014
@@ -102,6 +102,7 @@ OPENMP_CLAUSE(untied, OMPUntiedClause)
OPENMP_CLAUSE(mergeable, OMPMergeableClause)
OPENMP_CLAUSE(flush, OMPFlushClause)
OPENMP_CLAUSE(read, OMPReadClause)
+OPENMP_CLAUSE(write, OMPWriteClause)
// Clauses allowed for OpenMP directive 'parallel'.
OPENMP_PARALLEL_CLAUSE(if)
@@ -201,6 +202,7 @@ OPENMP_TASK_CLAUSE(mergeable)
// TODO More clauses allowed for OpenMP directive 'atomic'.
OPENMP_ATOMIC_CLAUSE(read)
+OPENMP_ATOMIC_CLAUSE(write)
#undef OPENMP_SCHEDULE_KIND
#undef OPENMP_PROC_BIND_KIND
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jul 23 02:46:59 2014
@@ -7485,6 +7485,9 @@ public:
/// \brief Called on well-formed 'read' clause.
OMPClause *ActOnOpenMPReadClause(SourceLocation StartLoc,
SourceLocation EndLoc);
+ /// \brief Called on well-formed 'write' clause.
+ OMPClause *ActOnOpenMPWriteClause(SourceLocation StartLoc,
+ SourceLocation EndLoc);
OMPClause *
ActOnOpenMPVarListClause(OpenMPClauseKind Kind, ArrayRef<Expr *> Vars,
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Wed Jul 23 02:46:59 2014
@@ -667,6 +667,8 @@ void OMPClausePrinter::VisitOMPMergeable
void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) { OS << "read"; }
+void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) { OS << "write"; }
+
template<typename T>
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
for (typename T::varlist_iterator I = Node->varlist_begin(),
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Wed Jul 23 02:46:59 2014
@@ -312,6 +312,8 @@ void OMPClauseProfiler::VisitOMPMergeabl
void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
+void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
+
template<typename T>
void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
for (auto *I : Node->varlists())
Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Wed Jul 23 02:46:59 2014
@@ -109,6 +109,7 @@ unsigned clang::getOpenMPSimpleClauseTyp
case OMPC_mergeable:
case OMPC_flush:
case OMPC_read:
+ case OMPC_write:
break;
}
llvm_unreachable("Invalid OpenMP simple clause kind");
@@ -169,6 +170,7 @@ const char *clang::getOpenMPSimpleClause
case OMPC_mergeable:
case OMPC_flush:
case OMPC_read:
+ case OMPC_write:
break;
}
llvm_unreachable("Invalid OpenMP simple clause kind");
Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Wed Jul 23 02:46:59 2014
@@ -342,7 +342,7 @@ bool Parser::ParseOpenMPSimpleVarList(Op
/// | linear-clause | aligned-clause | collapse-clause |
/// lastprivate-clause | reduction-clause | proc_bind-clause |
/// schedule-clause | copyin-clause | copyprivate-clause | untied-clause |
-/// mergeable-clause | flush-clause | read-clause
+/// mergeable-clause | flush-clause | read-clause | write-clause
///
OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
OpenMPClauseKind CKind, bool FirstClause) {
@@ -373,6 +373,7 @@ OMPClause *Parser::ParseOpenMPClause(Ope
if (!FirstClause) {
Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind)
<< getOpenMPClauseName(CKind);
+ ErrorFound = true;
}
Clause = ParseOpenMPSingleExprClause(CKind);
@@ -387,6 +388,7 @@ OMPClause *Parser::ParseOpenMPClause(Ope
if (!FirstClause) {
Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind)
<< getOpenMPClauseName(CKind);
+ ErrorFound = true;
}
Clause = ParseOpenMPSimpleClause(CKind);
@@ -397,6 +399,7 @@ OMPClause *Parser::ParseOpenMPClause(Ope
if (!FirstClause) {
Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind)
<< getOpenMPClauseName(CKind);
+ ErrorFound = true;
}
Clause = ParseOpenMPSingleExprWithArgClause(CKind);
@@ -406,6 +409,7 @@ OMPClause *Parser::ParseOpenMPClause(Ope
case OMPC_untied:
case OMPC_mergeable:
case OMPC_read:
+ case OMPC_write:
// OpenMP [2.7.1, Restrictions, p. 9]
// Only one ordered clause can appear on a loop directive.
// OpenMP [2.7.1, Restrictions, C/C++, p. 4]
@@ -413,6 +417,7 @@ OMPClause *Parser::ParseOpenMPClause(Ope
if (!FirstClause) {
Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind)
<< getOpenMPClauseName(CKind);
+ ErrorFound = true;
}
Clause = ParseOpenMPClause(CKind);
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Jul 23 02:46:59 2014
@@ -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::ActOnOpenMPAtomicDirect
// 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::ActOnOpenMPSingleExprCl
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(
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::ActOnOpenMPSingleExprWi
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(OpenM
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::ActOnOpenMPMergeableCla
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::ActOnOpenMPVarListClaus
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(
return OMPFlushClause::Create(Context, StartLoc, LParenLoc, EndLoc, VarList);
}
+
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed Jul 23 02:46:59 2014
@@ -6768,6 +6768,12 @@ OMPClause *TreeTransform<Derived>::Trans
}
template <typename Derived>
+OMPClause *TreeTransform<Derived>::TransformOMPWriteClause(OMPWriteClause *C) {
+ // No need to rebuild this clause, no template-dependent parameters.
+ return C;
+}
+
+template <typename Derived>
OMPClause *
TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) {
llvm::SmallVector<Expr *, 16> Vars;
Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Wed Jul 23 02:46:59 2014
@@ -1718,6 +1718,9 @@ OMPClause *OMPClauseReader::readClause()
case OMPC_read:
C = new (Context) OMPReadClause();
break;
+ case OMPC_write:
+ C = new (Context) OMPWriteClause();
+ break;
case OMPC_private:
C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]);
break;
@@ -1814,6 +1817,8 @@ void OMPClauseReader::VisitOMPMergeableC
void OMPClauseReader::VisitOMPReadClause(OMPReadClause *) {}
+void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {}
+
void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
unsigned NumVars = C->varlist_size();
Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Wed Jul 23 02:46:59 2014
@@ -1737,6 +1737,8 @@ void OMPClauseWriter::VisitOMPMergeableC
void OMPClauseWriter::VisitOMPReadClause(OMPReadClause *) {}
+void OMPClauseWriter::VisitOMPWriteClause(OMPWriteClause *) {}
+
void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) {
Record.push_back(C->varlist_size());
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
Modified: cfe/trunk/test/OpenMP/atomic_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_ast_print.cpp?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/atomic_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/atomic_ast_print.cpp Wed Jul 23 02:46:59 2014
@@ -7,37 +7,47 @@
#define HEADER
template <class T>
-T foo(T arg) {
- T a;
+T foo(T argc) {
+ T a = T();
#pragma omp atomic
a++;
#pragma omp atomic read
- a = arg;
+ a = argc;
+#pragma omp atomic write
+ a = argc + argc;
return T();
}
-// CHECK: int a;
+// CHECK: int a = int();
// CHECK-NEXT: #pragma omp atomic
// CHECK-NEXT: a++;
// CHECK-NEXT: #pragma omp atomic read
-// CHECK-NEXT: a = arg;
-// CHECK: T a;
+// CHECK-NEXT: a = argc;
+// CHECK-NEXT: #pragma omp atomic write
+// CHECK-NEXT: a = argc + argc;
+// CHECK: T a = T();
// CHECK-NEXT: #pragma omp atomic
// CHECK-NEXT: a++;
// CHECK-NEXT: #pragma omp atomic read
-// CHECK-NEXT: a = arg;
+// CHECK-NEXT: a = argc;
+// CHECK-NEXT: #pragma omp atomic write
+// CHECK-NEXT: a = argc + argc;
int main(int argc, char **argv) {
- int a;
-// CHECK: int a;
+ int a = 0;
+// CHECK: int a = 0;
#pragma omp atomic
a++;
#pragma omp atomic read
a = argc;
+#pragma omp atomic write
+ a = argc + argc;
// CHECK-NEXT: #pragma omp atomic
// CHECK-NEXT: a++;
// CHECK-NEXT: #pragma omp atomic read
// CHECK-NEXT: a = argc;
+ // CHECK-NEXT: #pragma omp atomic write
+ // CHECK-NEXT: a = argc + argc;
return foo(a);
}
Modified: cfe/trunk/test/OpenMP/atomic_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_messages.cpp?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/atomic_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/atomic_messages.cpp Wed Jul 23 02:46:59 2014
@@ -45,3 +45,59 @@ int read() {
return read<int>();
}
+
+template <class T>
+T write() {
+ T a, b = 0;
+// Test for atomic write
+#pragma omp atomic write
+// expected-error at +1 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is an l-value expression with scalar type}}
+ ;
+// expected-error at +1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}}
+#pragma omp atomic write write
+ a = b;
+
+ return T();
+}
+
+int write() {
+ int a, b = 0;
+// Test for atomic write
+#pragma omp atomic write
+// expected-error at +1 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is an l-value expression with scalar type}}
+ ;
+// expected-error at +1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}}
+#pragma omp atomic write write
+ a = b;
+
+ return write<int>();
+}
+
+template <class T>
+T mixed() {
+ T a, b = T();
+// expected-error at +2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note at +1 2 {{'read' clause used here}}
+#pragma omp atomic read write
+ a = b;
+// expected-error at +2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note at +1 2 {{'write' clause used here}}
+#pragma omp atomic write read
+ a = b;
+ return T();
+}
+
+int mixed() {
+ int a, b = 0;
+// expected-error at +2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note at +1 {{'read' clause used here}}
+#pragma omp atomic read write
+ a = b;
+// expected-error at +2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note at +1 {{'write' clause used here}}
+#pragma omp atomic write read
+ a = b;
+// expected-note at +1 {{in instantiation of function template specialization 'mixed<int>' requested here}}
+ return mixed<int>();
+}
+
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=213728&r1=213727&r2=213728&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Jul 23 02:46:59 2014
@@ -1983,6 +1983,8 @@ void OMPClauseEnqueue::VisitOMPMergeable
void OMPClauseEnqueue::VisitOMPReadClause(const OMPReadClause *) {}
+void OMPClauseEnqueue::VisitOMPWriteClause(const OMPWriteClause *) {}
+
template<typename T>
void OMPClauseEnqueue::VisitOMPClauseList(T *Node) {
for (const auto *I : Node->varlists())
More information about the cfe-commits
mailing list