[flang-commits] [flang] [llvm] [flang][OpenMP]Add support for fail clause (PR #118683)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Sat Dec 7 14:04:58 PST 2024
================
@@ -114,6 +114,11 @@ class SemanticsVisitor : public virtual BaseChecker, public virtual C... {
context_.set_location(std::nullopt);
}
+ // This is necessary to avoid "walking" into the Fail clause,
+ // which confuses the CheckAllowed into thinking there's another
+ // memoryorder, when it's actually the argument to the fail clause.
+ bool Pre(const parser::OmpFailClause &) { return false; }
----------------
kiranchandramohan wrote:
I was asking whether this solution will prevent the ability to perform the following semantic check from the OpenMP 5.2 standard.
-> `acq_rel` and `release` cannot be specified as arguments to the `fail` clause.
If you do not want to change the parse-tree representation, an alternative solution could be to remember whether we are visiting the FailClause and only call `CheckAllowedClause` for the MemoryOrder clauses if we are not inside the FailClause. Something like the following (only done for Release MemoryOrder clause).
```
+void OmpStructureChecker::Enter(const parser::OmpFailClause &) {
+ CheckAllowedClause(llvm::omp::Clause::OMPC_fail);
+ isFailClause = true;
+}
+
+void OmpStructureChecker::Leave(const parser::OmpFailClause &) {
+ isFailClause = false;
+}
+
+void OmpStructureChecker::Enter(const parser::OmpClause::Release &) {
+ if(!isFailClause) {
+ CheckAllowedClause(llvm::omp::Clause::OMPC_release);
+ }
+}
```
Note: The above code will also involve removing the CHECK_SIMPLE_CLAUSE entries for the Release MemoryOrder clause, adding isFailClause as a member of OmpStructureChecker, and adding the Enter and Leave signatures in OmpStructureChecker for the OmpFailClause.
https://github.com/llvm/llvm-project/pull/118683
More information about the flang-commits
mailing list