[flang-commits] [flang] [llvm] [Flang] [OpenMP] Add semantic checks for detach clause in task (PR #119172)
Thirumalai Shaktivel via flang-commits
flang-commits at lists.llvm.org
Fri May 2 05:05:56 PDT 2025
================
@@ -2961,6 +2961,63 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) {
// clause
CheckMultListItems();
+ if (GetContext().directive == llvm::omp::Directive::OMPD_task) {
+ if (auto *detachClause{FindClause(llvm::omp::Clause::OMPC_detach)}) {
+ unsigned version{context_.langOptions().OpenMPVersion};
+ if (version == 50 || version == 51) {
+ // OpenMP 5.0: 2.10.1 Task construct restrictions
+ CheckNotAllowedIfClause(llvm::omp::Clause::OMPC_detach,
+ {llvm::omp::Clause::OMPC_mergeable});
+ } else if (version >= 52) {
+ // OpenMP 5.2: 12.5.2 Detach construct restrictions
+ if (FindClause(llvm::omp::Clause::OMPC_final)) {
+ context_.Say(GetContext().clauseSource,
+ "If a DETACH clause appears on a directive, then the encountering task must not be a FINAL task"_err_en_US);
+ }
+
+ const auto &detach{
+ std::get<parser::OmpClause::Detach>(detachClause->u)};
+ if (const auto *name{parser::Unwrap<parser::Name>(detach.v.v)}) {
+ if (name->symbol) {
----------------
Thirumalai-Shaktivel wrote:
Done
https://github.com/llvm/llvm-project/pull/119172
More information about the flang-commits
mailing list