[flang-commits] [flang] [llvm] [Flang] [OpenMP] Add semantic checks for detach clause in task (PR #119172)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Tue Dec 10 06:19:24 PST 2024
================
@@ -2739,6 +2739,59 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) {
llvm::omp::Clause::OMPC_copyprivate, {llvm::omp::Clause::OMPC_nowait});
}
+ if (GetContext().directive == llvm::omp::Directive::OMPD_task) {
+ if (auto *d_clause{FindClause(llvm::omp::Clause::OMPC_detach)}) {
+ // OpenMP 5.0: Task construct restrictions
+ CheckNotAllowedIfClause(
+ llvm::omp::Clause::OMPC_detach, {llvm::omp::Clause::OMPC_mergeable});
+
+ // OpenMP 5.2: Task 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 &detachClause{
+ std::get<parser::OmpClause::Detach>(d_clause->u)};
+ if (const auto *name{parser::Unwrap<parser::Name>(detachClause.v.v)}) {
+ if (name->symbol) {
+ std::string eventHandleSymName{name->ToString()};
+ auto checkVarAppearsInDataEnvClause = [&](const parser::OmpObjectList
+ &objs,
+ std::string clause) {
+ for (const auto &obj : objs.v) {
+ if (const parser::Name *objName{
+ parser::Unwrap<parser::Name>(obj)}) {
+ if (objName->ToString() == eventHandleSymName) {
+ context_.Say(GetContext().clauseSource,
+ "A variable: `%s` that appears in a DETACH clause cannot appear on %s clause on the same construct"_err_en_US,
+ eventHandleSymName, clause);
+ }
+ }
+ }
+ };
----------------
kparzysz wrote:
Please compare symbols, not names. You can compare the results of `&symbol->GetUltimate()` to be accurate.
https://github.com/llvm/llvm-project/pull/119172
More information about the flang-commits
mailing list