[flang] [llvm] [Flang] [OpenMP] Add semantic checks for detach clause in task (PR #119172)

Thirumalai Shaktivel via llvm-commits llvm-commits at lists.llvm.org
Wed May 7 03:06:13 PDT 2025


================
@@ -4137,6 +4195,33 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Linear &x) {
   }
 }
 
+void OmpStructureChecker::Enter(const parser::OmpClause::Detach &x) {
+  unsigned version{context_.langOptions().OpenMPVersion};
+  if (version >= 52) {
+    SetContextClauseInfo(llvm::omp::Clause::OMPC_detach);
+  } else {
+    // OpenMP 5.0: 2.10.1 Task construct restrictions
+    CheckAllowedClause(llvm::omp::Clause::OMPC_detach);
+  }
----------------
Thirumalai-Shaktivel wrote:

> nit: won't CheckAllowedClause understand that this is allowed in newer standard versions?

Nope, are you suggesting to handle this in CheckAllowedClause itself?

```
At most one detach clause can appear on the directive.
```
The above restriction is available only for OpenMP 50 & 51.

I wanted this check not to be applied to versions equal to or above 52. But `CheckAllowedClause` will throw an error for all versions. I tried some methods in OMP.td, but it didn't help much. So, I took this route.

https://github.com/llvm/llvm-project/pull/119172


More information about the llvm-commits mailing list