Skip to content

Commit cfa79cf

Browse files
mrkajetanprorth
authored andcommitted
[flang][OpenMP] Show error for task depend with no valid modifiers (llvm#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@arm.com>
1 parent deccef3 commit cfa79cf

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4420,6 +4420,13 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Depend &x) {
44204420
CheckDoacross(*doaDep);
44214421
CheckDependenceType(doaDep->GetDepType());
44224422
} else {
4423+
using Modifier = parser::OmpDependClause::TaskDep::Modifier;
4424+
auto &modifiers{std::get<std::optional<std::list<Modifier>>>(taskDep->t)};
4425+
if (!modifiers) {
4426+
context_.Say(GetContext().clauseSource,
4427+
"A DEPEND clause on a TASK construct must have a valid task dependence type"_err_en_US);
4428+
return;
4429+
}
44234430
CheckTaskDependenceType(taskDep->GetTaskDepType());
44244431
}
44254432

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
2+
3+
program test
4+
! ERROR: A DEPEND clause on a TASK construct must have a valid task dependence type
5+
!$omp task depend(ii)
6+
!$omp end task
7+
end
8+

0 commit comments

Comments
 (0)