[flang-commits] [flang] b6521e8 - [flang][OpenMP] Show error for task depend with no valid modifiers (#142595)
via flang-commits
flang-commits at lists.llvm.org
Thu Jun 5 04:00:34 PDT 2025
Author: Kajetan Puchalski
Date: 2025-06-05T12:00:29+01:00
New Revision: b6521e8bb9cb1d1edb43d983e81513fb32a3b382
URL: https://github.com/llvm/llvm-project/commit/b6521e8bb9cb1d1edb43d983e81513fb32a3b382
DIFF: https://github.com/llvm/llvm-project/commit/b6521e8bb9cb1d1edb43d983e81513fb32a3b382.diff
LOG: [flang][OpenMP] Show error for task depend with no valid modifiers (#142595)
If a "TASK DEPEND" clause is not given a valid task dependece type
modifier, the semantic checks for the clause will result in an ICE
because they assume that such modifiers will be present. Check whether
the modifiers are present and show an appropriate error instead of
crashing the compiler if they are not.
Fixes llvm#133678.
Signed-off-by: Kajetan Puchalski <kajetan.puchalski at arm.com>
Added:
flang/test/Semantics/OpenMP/task-depend.f90
Modified:
flang/lib/Semantics/check-omp-structure.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 76dfd40c6a62c..f9d645dc2e78a 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -4420,6 +4420,13 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Depend &x) {
CheckDoacross(*doaDep);
CheckDependenceType(doaDep->GetDepType());
} else {
+ using Modifier = parser::OmpDependClause::TaskDep::Modifier;
+ auto &modifiers{std::get<std::optional<std::list<Modifier>>>(taskDep->t)};
+ if (!modifiers) {
+ context_.Say(GetContext().clauseSource,
+ "A DEPEND clause on a TASK construct must have a valid task dependence type"_err_en_US);
+ return;
+ }
CheckTaskDependenceType(taskDep->GetTaskDepType());
}
diff --git a/flang/test/Semantics/OpenMP/task-depend.f90 b/flang/test/Semantics/OpenMP/task-depend.f90
new file mode 100644
index 0000000000000..69a37e014bde3
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/task-depend.f90
@@ -0,0 +1,8 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+
+program test
+! ERROR: A DEPEND clause on a TASK construct must have a valid task dependence type
+!$omp task depend(ii)
+!$omp end task
+end
+
More information about the flang-commits
mailing list