[flang-commits] [flang] [flang][OpenMP] Improve clause checks on FLUSH construct (PR #226467)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Fri Sep 25 10:52:13 PDT 2026
================
@@ -3446,15 +3455,48 @@ void OmpStructureChecker::Leave(const parser::OpenMPFlushConstruct &x) {
}
}
- if (FindClause(llvm::omp::Clause::OMPC_acquire) ||
- FindClause(llvm::omp::Clause::OMPC_release) ||
- FindClause(llvm::omp::Clause::OMPC_acq_rel)) {
- context_.Say(flushList->source,
- "If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive"_err_en_US);
+ for (const parser::OmpClause &clause : x.v.Clauses().v) {
+ if (memOrder.test(clause.Id())) {
+ context_.Say(flushList->source,
+ "If a 'memory-order' clause is specified, list items must not be specified on the FLUSH directive"_err_en_US);
+ break;
+ }
+ }
+ }
+
+ for (const parser::OmpClause &clause : x.v.Clauses().v) {
+ llvm::omp::Clause clauseId{clause.Id()};
+ if (!memOrder.test(clauseId)) {
+ continue;
+ }
+ if (version == 50) {
+ // In 5.0 only ACQ_REL, ACQUIRE or RELEASE are allowed.
+ switch (clauseId) {
+ case llvm::omp::Clause::OMPC_acq_rel:
+ case llvm::omp::Clause::OMPC_acquire:
+ case llvm::omp::Clause::OMPC_release:
+ continue;
+ default:
+ context_.Say(clause.source,
+ "Only ACQ_REL, ACQUIRE or RELEASE memory-order clauses are allowed"_err_en_US);
+ break;
+ }
+ } else if (version >= 51) {
+ // In 5.1+ only ACQ_REL, ACQUIRE, RELEASE or SEQ_CST are allowed.
+ switch (clauseId) {
+ case llvm::omp::Clause::OMPC_acq_rel:
+ case llvm::omp::Clause::OMPC_acquire:
+ case llvm::omp::Clause::OMPC_release:
+ case llvm::omp::Clause::OMPC_seq_cst:
+ continue;
+ default:
+ context_.Say(clause.source,
+ "Only ACQ_REL, ACQUIRE, RELEASE or SEQ_CST memory-order clauses are allowed"_err_en_US);
+ break;
+ }
----------------
kparzysz wrote:
Makes sense. I will improve it then.
https://github.com/llvm/llvm-project/pull/226467
More information about the flang-commits
mailing list