From 298a81897bd3806ddead5c79bc6a0aaf8cb9d13e Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Wed, 23 Jul 2014 07:46:59 +0000 Subject: [PATCH] [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 --- include/clang/AST/DataRecursiveASTVisitor.h | 5 ++ include/clang/AST/OpenMPClause.h | 29 +++++++++ include/clang/AST/RecursiveASTVisitor.h | 5 ++ include/clang/Basic/DiagnosticSemaKinds.td | 7 +++ include/clang/Basic/OpenMPKinds.def | 2 + include/clang/Sema/Sema.h | 3 + lib/AST/StmtPrinter.cpp | 2 + lib/AST/StmtProfile.cpp | 2 + lib/Basic/OpenMPKinds.cpp | 2 + lib/Parse/ParseOpenMP.cpp | 7 ++- lib/Sema/SemaOpenMP.cpp | 65 ++++++++++++--------- lib/Sema/TreeTransform.h | 6 ++ lib/Serialization/ASTReaderStmt.cpp | 5 ++ lib/Serialization/ASTWriterStmt.cpp | 2 + test/OpenMP/atomic_ast_print.cpp | 28 ++++++--- test/OpenMP/atomic_messages.cpp | 56 ++++++++++++++++++ tools/libclang/CIndex.cpp | 2 + 17 files changed, 192 insertions(+), 36 deletions(-) diff --git a/include/clang/AST/DataRecursiveASTVisitor.h b/include/clang/AST/DataRecursiveASTVisitor.h index 579d24cfa9..3e4c3c9e14 100644 --- a/include/clang/AST/DataRecursiveASTVisitor.h +++ b/include/clang/AST/DataRecursiveASTVisitor.h @@ -2425,6 +2425,11 @@ bool RecursiveASTVisitor::VisitOMPReadClause(OMPReadClause *) { return true; } +template +bool RecursiveASTVisitor::VisitOMPWriteClause(OMPWriteClause *) { + return true; +} + template template bool RecursiveASTVisitor::VisitOMPClauseList(T *Node) { diff --git a/include/clang/AST/OpenMPClause.h b/include/clang/AST/OpenMPClause.h index 08b1379187..b213ddd8d6 100644 --- a/include/clang/AST/OpenMPClause.h +++ b/include/clang/AST/OpenMPClause.h @@ -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 diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index cef019b76e..727c8a5248 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -2447,6 +2447,11 @@ bool RecursiveASTVisitor::VisitOMPReadClause(OMPReadClause *) { return true; } +template +bool RecursiveASTVisitor::VisitOMPWriteClause(OMPWriteClause *) { + return true; +} + template template bool RecursiveASTVisitor::VisitOMPClauseList(T *Node) { diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index f0975bdc51..28590cf64f 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -7151,6 +7151,13 @@ def err_omp_parallel_reduction_in_task_firstprivate : Error< 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 { diff --git a/include/clang/Basic/OpenMPKinds.def b/include/clang/Basic/OpenMPKinds.def index 9fe3fe938e..ac87a2a07d 100644 --- a/include/clang/Basic/OpenMPKinds.def +++ b/include/clang/Basic/OpenMPKinds.def @@ -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 diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index b08c27882d..4b59583a29 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -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 Vars, diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 2a704c3a84..bf90a5e232 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -667,6 +667,8 @@ void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) { void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) { OS << "read"; } +void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) { OS << "write"; } + template void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { for (typename T::varlist_iterator I = Node->varlist_begin(), diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp index 4cf7077ee8..b65d07036b 100644 --- a/lib/AST/StmtProfile.cpp +++ b/lib/AST/StmtProfile.cpp @@ -312,6 +312,8 @@ void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {} void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {} +void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {} + template void OMPClauseProfiler::VisitOMPClauseList(T *Node) { for (auto *I : Node->varlists()) diff --git a/lib/Basic/OpenMPKinds.cpp b/lib/Basic/OpenMPKinds.cpp index 78cfa18d8f..db86cc713c 100644 --- a/lib/Basic/OpenMPKinds.cpp +++ b/lib/Basic/OpenMPKinds.cpp @@ -109,6 +109,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, 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::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, case OMPC_mergeable: case OMPC_flush: case OMPC_read: + case OMPC_write: break; } llvm_unreachable("Invalid OpenMP simple clause kind"); diff --git a/lib/Parse/ParseOpenMP.cpp b/lib/Parse/ParseOpenMP.cpp index 9ba18b4e98..a5bc4a4494 100644 --- a/lib/Parse/ParseOpenMP.cpp +++ b/lib/Parse/ParseOpenMP.cpp @@ -342,7 +342,7 @@ bool Parser::ParseOpenMPSimpleVarList(OpenMPDirectiveKind Kind, /// | 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(OpenMPDirectiveKind DKind, 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(OpenMPDirectiveKind DKind, 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(OpenMPDirectiveKind DKind, 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(OpenMPDirectiveKind DKind, 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(OpenMPDirectiveKind DKind, if (!FirstClause) { Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind) << getOpenMPClauseName(CKind); + ErrorFound = true; } Clause = ParseOpenMPClause(CKind); 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 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 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(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(CS->getCapturedStmt())) { + Diag(CS->getCapturedStmt()->getLocStart(), + diag::err_omp_atomic_read_not_expression_statement); + return StmtError(); + } + } else if (AtomicKind == OMPC_write) { + if (!isa(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 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 VarList, return OMPFlushClause::Create(Context, StartLoc, LParenLoc, EndLoc, VarList); } + diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index fff0e57ee7..66da412b2c 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -6767,6 +6767,12 @@ OMPClause *TreeTransform::TransformOMPReadClause(OMPReadClause *C) { return C; } +template +OMPClause *TreeTransform::TransformOMPWriteClause(OMPWriteClause *C) { + // No need to rebuild this clause, no template-dependent parameters. + return C; +} + template OMPClause * TreeTransform::TransformOMPPrivateClause(OMPPrivateClause *C) { diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index ae870176d3..7cefa80e23 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -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::VisitOMPMergeableClause(OMPMergeableClause *) {} void OMPClauseReader::VisitOMPReadClause(OMPReadClause *) {} +void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {} + void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) { C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); unsigned NumVars = C->varlist_size(); diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp index d42f9d6513..5048594bc6 100644 --- a/lib/Serialization/ASTWriterStmt.cpp +++ b/lib/Serialization/ASTWriterStmt.cpp @@ -1737,6 +1737,8 @@ void OMPClauseWriter::VisitOMPMergeableClause(OMPMergeableClause *) {} 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); diff --git a/test/OpenMP/atomic_ast_print.cpp b/test/OpenMP/atomic_ast_print.cpp index 957d4ae771..a24e34fd52 100644 --- a/test/OpenMP/atomic_ast_print.cpp +++ b/test/OpenMP/atomic_ast_print.cpp @@ -7,37 +7,47 @@ #define HEADER template -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); } diff --git a/test/OpenMP/atomic_messages.cpp b/test/OpenMP/atomic_messages.cpp index 7b35e42dc7..4bc7686c11 100644 --- a/test/OpenMP/atomic_messages.cpp +++ b/test/OpenMP/atomic_messages.cpp @@ -45,3 +45,59 @@ int read() { return read(); } + +template +T write() { + T a, b = 0; +// Test for atomic write +#pragma omp atomic write +// expected-error@+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@+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@+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@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}} +#pragma omp atomic write write + a = b; + + return write(); +} + +template +T mixed() { + T a, b = T(); +// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} +// expected-note@+1 2 {{'read' clause used here}} +#pragma omp atomic read write + a = b; +// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} +// expected-note@+1 2 {{'write' clause used here}} +#pragma omp atomic write read + a = b; + return T(); +} + +int mixed() { + int a, b = 0; +// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} +// expected-note@+1 {{'read' clause used here}} +#pragma omp atomic read write + a = b; +// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} +// expected-note@+1 {{'write' clause used here}} +#pragma omp atomic write read + a = b; +// expected-note@+1 {{in instantiation of function template specialization 'mixed' requested here}} + return mixed(); +} + diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 099302fe2c..e989566a45 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -1983,6 +1983,8 @@ void OMPClauseEnqueue::VisitOMPMergeableClause(const OMPMergeableClause *) {} void OMPClauseEnqueue::VisitOMPReadClause(const OMPReadClause *) {} +void OMPClauseEnqueue::VisitOMPWriteClause(const OMPWriteClause *) {} + template void OMPClauseEnqueue::VisitOMPClauseList(T *Node) { for (const auto *I : Node->varlists()) -- 2.40.0