[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
Tue Dec 10 20:19:19 PST 2024


================
@@ -3711,6 +3768,30 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Linear &x) {
       x.v.u);
 }
 
+void OmpStructureChecker::Enter(const parser::OmpClause::Detach &x) {
+  // OpenMP 5.0: Task construct restrictions
+  CheckAllowedClause(llvm::omp::Clause::OMPC_detach);
+
+  // OpenMP 5.2: Detach clause restrictions
+  CheckIsVarPartOfAnotherVar(GetContext().clauseSource, x.v.v, "DETACH");
+  if (const auto *name{parser::Unwrap<parser::Name>(x.v.v)}) {
+    if (name->symbol) {
+      if (IsPointer(*name->symbol)) {
+        context_.Say(GetContext().clauseSource,
+            "The event-handle: `%s` must not have the POINTER attribute"_err_en_US,
+            name->ToString());
+      }
+    }
+    auto type{name->symbol->GetType()};
+    if (!name->symbol->GetType()->IsNumeric(TypeCategory::Integer) ||
+        evaluate::ToInt64(type->numericTypeSpec().kind()) != 8) {
----------------
Thirumalai-Shaktivel wrote:

Yes, I felt the same. But, the only info I had was the `kind` => `8` to throw an error for the following:
```fortran
    !ERROR: The event-handle: `e` must be of type integer(kind=omp_event_handle_kind)
    !$omp task detach(e)
        x = x + 1
    !$omp end task
```

Do you know any other way to add a check for this?

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


More information about the llvm-commits mailing list