[flang-commits] [compiler-rt] [libc] [clang] [flang] [lldb] [libcxx] [llvm] [mlir] [clang-tools-extra] [OpenMP] atomic compare weak : Parser & AST support (PR #79475)
via flang-commits
flang-commits at lists.llvm.org
Tue Jan 30 10:45:15 PST 2024
https://github.com/SunilKuravinakop updated https://github.com/llvm/llvm-project/pull/79475
>From 6614e517cf0888b4502efc0af974d1612fa7a822 Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop <kuravina at pe28vega.us.cray.com>
Date: Thu, 25 Jan 2024 10:37:20 -0600
Subject: [PATCH 1/3] Changes to Support Parsing & Sema of atomic compare weak.
Changes to be committed:
modified: clang/include/clang/AST/OpenMPClause.h
modified: clang/include/clang/AST/RecursiveASTVisitor.h
modified: clang/include/clang/Basic/DiagnosticSemaKinds.td
modified: clang/include/clang/Sema/Sema.h
modified: clang/lib/AST/OpenMPClause.cpp
modified: clang/lib/AST/StmtProfile.cpp
modified: clang/lib/CodeGen/CGStmtOpenMP.cpp
modified: clang/lib/Parse/ParseOpenMP.cpp
modified: clang/lib/Sema/SemaOpenMP.cpp
modified: clang/lib/Sema/TreeTransform.h
modified: clang/lib/Serialization/ASTReader.cpp
modified: clang/lib/Serialization/ASTWriter.cpp
modified: clang/test/OpenMP/atomic_ast_print.cpp
modified: clang/test/OpenMP/atomic_messages.cpp
modified: clang/tools/libclang/CIndex.cpp
modified: llvm/include/llvm/Frontend/OpenMP/OMP.td
---
clang/include/clang/AST/OpenMPClause.h | 40 +++++++++++++++++++
clang/include/clang/AST/RecursiveASTVisitor.h | 5 +++
.../clang/Basic/DiagnosticSemaKinds.td | 3 +-
clang/include/clang/Sema/Sema.h | 3 ++
clang/lib/AST/OpenMPClause.cpp | 2 +
clang/lib/AST/StmtProfile.cpp | 2 +
clang/lib/CodeGen/CGStmtOpenMP.cpp | 3 ++
clang/lib/Parse/ParseOpenMP.cpp | 1 +
clang/lib/Sema/SemaOpenMP.cpp | 35 +++++++++++++++-
clang/lib/Sema/TreeTransform.h | 6 +++
clang/lib/Serialization/ASTReader.cpp | 5 +++
clang/lib/Serialization/ASTWriter.cpp | 2 +
clang/test/OpenMP/atomic_ast_print.cpp | 8 ++++
clang/test/OpenMP/atomic_messages.cpp | 11 +++++
clang/tools/libclang/CIndex.cpp | 2 +
llvm/include/llvm/Frontend/OpenMP/OMP.td | 4 +-
16 files changed, 129 insertions(+), 3 deletions(-)
diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h
index 924ca189381ba..325a1baa44614 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -2513,6 +2513,46 @@ class OMPRelaxedClause final : public OMPClause {
}
};
+/// This represents 'weak' clause in the '#pragma omp atomic'
+/// directives.
+///
+/// \code
+/// #pragma omp atomic compare weak
+/// \endcode
+/// In this example directive '#pragma omp atomic' has 'weak' clause.
+class OMPWeakClause final : public OMPClause {
+public:
+ /// Build 'weak' clause.
+ ///
+ /// \param StartLoc Starting location of the clause.
+ /// \param EndLoc Ending location of the clause.
+ OMPWeakClause(SourceLocation StartLoc, SourceLocation EndLoc)
+ : OMPClause(llvm::omp::OMPC_weak, StartLoc, EndLoc) {}
+
+ /// Build an empty clause.
+ OMPWeakClause()
+ : OMPClause(llvm::omp::OMPC_weak, SourceLocation(), SourceLocation()) {}
+
+ child_range children() {
+ return child_range(child_iterator(), child_iterator());
+ }
+
+ const_child_range children() const {
+ return const_child_range(const_child_iterator(), const_child_iterator());
+ }
+
+ child_range used_children() {
+ return child_range(child_iterator(), child_iterator());
+ }
+ const_child_range used_children() const {
+ return const_child_range(const_child_iterator(), const_child_iterator());
+ }
+
+ static bool classof(const OMPClause *T) {
+ return T->getClauseKind() == llvm::omp::OMPC_weak;
+ }
+};
+
/// This represents 'fail' clause in the '#pragma omp atomic'
/// directive.
///
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
index 8f2714e142bbe..0fbf3e30e2d8d 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3423,6 +3423,11 @@ bool RecursiveASTVisitor<Derived>::VisitOMPRelaxedClause(OMPRelaxedClause *) {
return true;
}
+template <typename Derived>
+bool RecursiveASTVisitor<Derived>::VisitOMPWeakClause(OMPWeakClause *) {
+ return true;
+}
+
template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPThreadsClause(OMPThreadsClause *) {
return true;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a97182cad5d51..42fa19e0424fb 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10996,7 +10996,8 @@ def note_omp_atomic_compare: Note<
"expect lvalue for result value|expect scalar value|expect integer value|unexpected 'else' statement|expect '==' operator|expect an assignment statement 'v = x'|"
"expect a 'if' statement|expect no more than two statements|expect a compound statement|expect 'else' statement|expect a form 'r = x == e; if (r) ...'}0">;
def err_omp_atomic_fail_wrong_or_no_clauses : Error<"expected a memory order clause">;
-def err_omp_atomic_fail_no_compare : Error<"expected 'compare' clause with the 'fail' modifier">;
+def err_omp_atomic_no_compare : Error<"expected 'compare' clause with the '%0' modifier">;
+def err_omp_atomic_weak_no_equality : Error<"expected '==' operator for 'weak' clause">;
def err_omp_atomic_several_clauses : Error<
"directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause">;
def err_omp_several_mem_order_clauses : Error<
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 8f44adef38159..a46026cff6ade 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12243,6 +12243,9 @@ class Sema final {
/// Called on well-formed 'relaxed' clause.
OMPClause *ActOnOpenMPRelaxedClause(SourceLocation StartLoc,
SourceLocation EndLoc);
+ /// Called on well-formed 'weak' clause.
+ OMPClause *ActOnOpenMPWeakClause(SourceLocation StartLoc,
+ SourceLocation EndLoc);
/// Called on well-formed 'init' clause.
OMPClause *
diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index 04f680a8f5c92..042a5df5906ca 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -1957,6 +1957,8 @@ void OMPClausePrinter::VisitOMPRelaxedClause(OMPRelaxedClause *) {
OS << "relaxed";
}
+void OMPClausePrinter::VisitOMPWeakClause(OMPWeakClause *) { OS << "weak"; }
+
void OMPClausePrinter::VisitOMPThreadsClause(OMPThreadsClause *) {
OS << "threads";
}
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index d7b980a585702..0b933597f136b 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -594,6 +594,8 @@ void OMPClauseProfiler::VisitOMPReleaseClause(const OMPReleaseClause *) {}
void OMPClauseProfiler::VisitOMPRelaxedClause(const OMPRelaxedClause *) {}
+void OMPClauseProfiler::VisitOMPWeakClause(const OMPWeakClause *) {}
+
void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {}
void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {}
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index e362c9da51fe3..8fd74697de3c0 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6546,6 +6546,9 @@ void CodeGenFunction::EmitOMPAtomicDirective(const OMPAtomicDirective &S) {
// Find first clause (skip seq_cst|acq_rel|aqcuire|release|relaxed clause,
// if it is first).
OpenMPClauseKind K = C->getClauseKind();
+ // TBD
+ if (K == OMPC_weak)
+ return;
if (K == OMPC_seq_cst || K == OMPC_acq_rel || K == OMPC_acquire ||
K == OMPC_release || K == OMPC_relaxed || K == OMPC_hint)
continue;
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index da5f6605c6ffa..bfc31f2653c23 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -3314,6 +3314,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
case OMPC_acquire:
case OMPC_release:
case OMPC_relaxed:
+ case OMPC_weak:
case OMPC_threads:
case OMPC_simd:
case OMPC_nogroup:
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index f34d2959dc619..895a27f560dec 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -12682,9 +12682,11 @@ StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
}
break;
}
+ case OMPC_weak:
case OMPC_fail: {
if (!EncounteredAtomicKinds.contains(OMPC_compare)) {
- Diag(C->getBeginLoc(), diag::err_omp_atomic_fail_no_compare)
+ Diag(C->getBeginLoc(), diag::err_omp_atomic_no_compare)
+ << getOpenMPClauseName(C->getClauseKind())
<< SourceRange(C->getBeginLoc(), C->getEndLoc());
return StmtError();
}
@@ -13176,6 +13178,29 @@ StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
E = Checker.getE();
D = Checker.getD();
CE = Checker.getCond();
+ /* The weak clause may only appear if the resulting atomic operation is
+ * an atomic conditional update for which the comparison tests for
+ * equality.
+ * It was not possible to do this check in
+ * OpenMPAtomicCompareChecker::checkStmt() as the check for OMPC_weak
+ * could not be performed (Clauses are not available).
+ */
+ for (OMPClause *C : Clauses) {
+ if (C->getClauseKind() == llvm::omp::Clause::OMPC_weak) {
+ auto *Cond = dyn_cast<BinaryOperator>(CE);
+ if (Cond->getOpcode() != BO_EQ) {
+
+ ErrorInfo.Error = Checker.ErrorTy::NotAnAssignment;
+ ErrorInfo.ErrorLoc = Cond->getExprLoc();
+ ErrorInfo.NoteLoc = Cond->getOperatorLoc();
+ ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
+
+ Diag(ErrorInfo.ErrorLoc, diag::err_omp_atomic_weak_no_equality)
+ << ErrorInfo.ErrorRange;
+ return StmtError();
+ }
+ }
+ }
// We reuse IsXLHSInRHSPart to tell if it is in the form 'x ordop expr'.
IsXLHSInRHSPart = Checker.isXBinopExpr();
}
@@ -17567,6 +17592,9 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
case OMPC_relaxed:
Res = ActOnOpenMPRelaxedClause(StartLoc, EndLoc);
break;
+ case OMPC_weak:
+ Res = ActOnOpenMPWeakClause(StartLoc, EndLoc);
+ break;
case OMPC_threads:
Res = ActOnOpenMPThreadsClause(StartLoc, EndLoc);
break;
@@ -17755,6 +17783,11 @@ OMPClause *Sema::ActOnOpenMPRelaxedClause(SourceLocation StartLoc,
return new (Context) OMPRelaxedClause(StartLoc, EndLoc);
}
+OMPClause *Sema::ActOnOpenMPWeakClause(SourceLocation StartLoc,
+ SourceLocation EndLoc) {
+ return new (Context) OMPWeakClause(StartLoc, EndLoc);
+}
+
OMPClause *Sema::ActOnOpenMPThreadsClause(SourceLocation StartLoc,
SourceLocation EndLoc) {
return new (Context) OMPThreadsClause(StartLoc, EndLoc);
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index c8c5a51bf9f94..29f557dbaa862 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -9922,6 +9922,12 @@ TreeTransform<Derived>::TransformOMPRelaxedClause(OMPRelaxedClause *C) {
return C;
}
+template <typename Derived>
+OMPClause *TreeTransform<Derived>::TransformOMPWeakClause(OMPWeakClause *C) {
+ // No need to rebuild this clause, no template-dependent parameters.
+ return C;
+}
+
template <typename Derived>
OMPClause *
TreeTransform<Derived>::TransformOMPThreadsClause(OMPThreadsClause *C) {
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 9effd333daccd..ba2257f9529c3 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -10294,6 +10294,9 @@ OMPClause *OMPClauseReader::readClause() {
case llvm::omp::OMPC_relaxed:
C = new (Context) OMPRelaxedClause();
break;
+ case llvm::omp::OMPC_weak:
+ C = new (Context) OMPWeakClause();
+ break;
case llvm::omp::OMPC_threads:
C = new (Context) OMPThreadsClause();
break;
@@ -10692,6 +10695,8 @@ void OMPClauseReader::VisitOMPReleaseClause(OMPReleaseClause *) {}
void OMPClauseReader::VisitOMPRelaxedClause(OMPRelaxedClause *) {}
+void OMPClauseReader::VisitOMPWeakClause(OMPWeakClause *) {}
+
void OMPClauseReader::VisitOMPThreadsClause(OMPThreadsClause *) {}
void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {}
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 78939bfd533ff..2a3ebb2fbb1d7 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -6646,6 +6646,8 @@ void OMPClauseWriter::VisitOMPReleaseClause(OMPReleaseClause *) {}
void OMPClauseWriter::VisitOMPRelaxedClause(OMPRelaxedClause *) {}
+void OMPClauseWriter::VisitOMPWeakClause(OMPWeakClause *) {}
+
void OMPClauseWriter::VisitOMPThreadsClause(OMPThreadsClause *) {}
void OMPClauseWriter::VisitOMPSIMDClause(OMPSIMDClause *) {}
diff --git a/clang/test/OpenMP/atomic_ast_print.cpp b/clang/test/OpenMP/atomic_ast_print.cpp
index 6886ef29a6752..b16a5fcdbdd3e 100644
--- a/clang/test/OpenMP/atomic_ast_print.cpp
+++ b/clang/test/OpenMP/atomic_ast_print.cpp
@@ -232,6 +232,8 @@ T foo(T argc) {
{ if (a < c) { a = c; } }
#pragma omp atomic compare fail(seq_cst)
{ if (a < c) { a = c; } }
+#pragma omp atomic compare seq_cst weak
+ { if(a == b) { a = c; } }
#endif
return T();
}
@@ -1111,6 +1113,8 @@ int main(int argc, char **argv) {
if(a < b) { a = b; }
#pragma omp atomic compare fail(seq_cst)
if(a < b) { a = b; }
+#pragma omp atomic compare seq_cst weak
+ if(a == b) { a = c; }
#endif
// CHECK-NEXT: #pragma omp atomic
// CHECK-NEXT: a++;
@@ -1453,6 +1457,10 @@ int main(int argc, char **argv) {
// CHECK-51-NEXT: if (a < b) {
// CHECK-51-NEXT: a = b;
// CHECK-51-NEXT: }
+ // CHECK-51-NEXT: #pragma omp atomic compare seq_cst weak
+ // CHECK-51-NEXT: if (a == b) {
+ // CHECK-51-NEXT: a = c;
+ // CHECK-51-NEXT: }
// expect-note at +1 {{in instantiation of function template specialization 'foo<int>' requested here}}
return foo(a);
}
diff --git a/clang/test/OpenMP/atomic_messages.cpp b/clang/test/OpenMP/atomic_messages.cpp
index b09e3318cd9ac..d492f6ee1e896 100644
--- a/clang/test/OpenMP/atomic_messages.cpp
+++ b/clang/test/OpenMP/atomic_messages.cpp
@@ -974,6 +974,17 @@ int mixed() {
// expected-error at +1 {{directive '#pragma omp atomic' cannot contain more than one 'fail' clause}}
#pragma omp atomic compare fail(relaxed) fail(seq_cst)
if(v < a) { v = a; }
+#pragma omp atomic compare seq_cst weak
+ if(v == a) { v = a; }
+// expected-error at +1 {{expected 'compare' clause with the 'weak' modifier}}
+#pragma omp atomic weak
+ if(v < a) { v = a; }
+#pragma omp atomic compare release weak
+// expected-error at +1 {{expected '==' operator for 'weak' clause}}
+ if(v < a) { v = a; }
+// expected-error at +1 {{directive '#pragma omp atomic' cannot contain more than one 'weak' clause}}
+#pragma omp atomic compare release weak fail(seq_cst) weak
+ if(v == a) { v = a; }
#endif
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 841522a0f4788..15d3b00de0a53 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -2414,6 +2414,8 @@ void OMPClauseEnqueue::VisitOMPReleaseClause(const OMPReleaseClause *) {}
void OMPClauseEnqueue::VisitOMPRelaxedClause(const OMPRelaxedClause *) {}
+void OMPClauseEnqueue::VisitOMPWeakClause(const OMPWeakClause *) {}
+
void OMPClauseEnqueue::VisitOMPThreadsClause(const OMPThreadsClause *) {}
void OMPClauseEnqueue::VisitOMPSIMDClause(const OMPSIMDClause *) {}
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td
index 2388abac81ceb..1481328bf483b 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -215,6 +215,7 @@ def OMPC_AcqRel : Clause<"acq_rel"> { let clangClass = "OMPAcqRelClause"; }
def OMPC_Acquire : Clause<"acquire"> { let clangClass = "OMPAcquireClause"; }
def OMPC_Release : Clause<"release"> { let clangClass = "OMPReleaseClause"; }
def OMPC_Relaxed : Clause<"relaxed"> { let clangClass = "OMPRelaxedClause"; }
+def OMPC_Weak : Clause<"weak"> { let clangClass = "OMPWeakClause"; }
def OMPC_Depend : Clause<"depend"> {
let clangClass = "OMPDependClause";
let flangClass = "OmpDependClause";
@@ -642,7 +643,8 @@ def OMP_Atomic : Directive<"atomic"> {
VersionedClause<OMPC_Release, 50>,
VersionedClause<OMPC_Relaxed, 50>,
VersionedClause<OMPC_Hint, 50>,
- VersionedClause<OMPC_Fail, 51>
+ VersionedClause<OMPC_Fail, 51>,
+ VersionedClause<OMPC_Weak, 51>
];
}
def OMP_Target : Directive<"target"> {
>From d0ed3c729766baa0bea7cca1a82e6d03980be828 Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop <kuravina at pe28vega.us.cray.com>
Date: Sat, 27 Jan 2024 05:09:44 -0600
Subject: [PATCH 2/3] Changes done: 1) C++ style comments. 2) Code changed to
use find_if() algorithms of C++ Standard Library.
Changes to be committed:
modified: clang/lib/Sema/SemaOpenMP.cpp
---
clang/lib/Sema/SemaOpenMP.cpp | 40 +++++++++++++++++------------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index b632e4ef8a8c0..c4e6cafee47a1 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -13204,27 +13204,25 @@ StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
E = Checker.getE();
D = Checker.getD();
CE = Checker.getCond();
- /* The weak clause may only appear if the resulting atomic operation is
- * an atomic conditional update for which the comparison tests for
- * equality.
- * It was not possible to do this check in
- * OpenMPAtomicCompareChecker::checkStmt() as the check for OMPC_weak
- * could not be performed (Clauses are not available).
- */
- for (OMPClause *C : Clauses) {
- if (C->getClauseKind() == llvm::omp::Clause::OMPC_weak) {
- auto *Cond = dyn_cast<BinaryOperator>(CE);
- if (Cond->getOpcode() != BO_EQ) {
-
- ErrorInfo.Error = Checker.ErrorTy::NotAnAssignment;
- ErrorInfo.ErrorLoc = Cond->getExprLoc();
- ErrorInfo.NoteLoc = Cond->getOperatorLoc();
- ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
-
- Diag(ErrorInfo.ErrorLoc, diag::err_omp_atomic_weak_no_equality)
- << ErrorInfo.ErrorRange;
- return StmtError();
- }
+ // The weak clause may only appear if the resulting atomic operation is
+ // an atomic conditional update for which the comparison tests for
+ // equality. It was not possible to do this check in
+ // OpenMPAtomicCompareChecker::checkStmt() as the check for OMPC_weak
+ // could not be performed (Clauses are not available).
+ auto *It = find_if(Clauses, [](OMPClause *C) {
+ return C->getClauseKind() == llvm::omp::Clause::OMPC_weak;
+ });
+ if (It != Clauses.end()) {
+ auto *Cond = dyn_cast<BinaryOperator>(CE);
+ if (Cond->getOpcode() != BO_EQ) {
+ ErrorInfo.Error = Checker.ErrorTy::NotAnAssignment;
+ ErrorInfo.ErrorLoc = Cond->getExprLoc();
+ ErrorInfo.NoteLoc = Cond->getOperatorLoc();
+ ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
+
+ Diag(ErrorInfo.ErrorLoc, diag::err_omp_atomic_weak_no_equality)
+ << ErrorInfo.ErrorRange;
+ return StmtError();
}
}
// We reuse IsXLHSInRHSPart to tell if it is in the form 'x ordop expr'.
>From 8e42412f6223c876fa5dff58bd9289fbb586c0e1 Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop <kuravina at pe28vega.us.cray.com>
Date: Tue, 30 Jan 2024 09:56:56 -0600
Subject: [PATCH 3/3] Adding CHECK_SIMPLE_CLAUSE(Weak, OMPC_weak) to avoid
undefined symbol:
Fortran::semantics::OmpStructureChecker::Enter(Fortran::parser::OmpClause::Weak
const&)
Changes to be committed:
modified: flang/lib/Semantics/check-omp-structure.cpp
---
flang/lib/Semantics/check-omp-structure.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 22e9d5d4dd799..03423de0c6104 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -2264,6 +2264,7 @@ CHECK_SIMPLE_CLAUSE(OmpxAttribute, OMPC_ompx_attribute)
CHECK_SIMPLE_CLAUSE(OmpxBare, OMPC_ompx_bare)
CHECK_SIMPLE_CLAUSE(Enter, OMPC_enter)
CHECK_SIMPLE_CLAUSE(Fail, OMPC_fail)
+CHECK_SIMPLE_CLAUSE(Weak, OMPC_weak)
CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
More information about the flang-commits
mailing list