Skip to content

Commit 218841a

Browse files
[Flang][OpenMP] Add Todo for doconcurrent with worksharing loop
This is a valid usage. We do not handle it as of now. Gfortran/Ifx produces an error, possibly because `do concurrent` was not allowed in previous versions of the OpenMP standard. Fixes #62649 Reviewed By: Leporacanthicus Differential Revision: https://reviews.llvm.org/D150869
1 parent ffd9d6e commit 218841a

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

flang/lib/Lower/OpenMP.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,11 @@ static void genOMP(Fortran::lower::AbstractConverter &converter,
15381538

15391539
// Collect the loops to collapse.
15401540
auto *doConstructEval = &eval.getFirstNestedEvaluation();
1541+
if (doConstructEval->getIf<Fortran::parser::DoConstruct>()
1542+
->IsDoConcurrent()) {
1543+
TODO(converter.getCurrentLocation(),
1544+
"Do Concurrent in Worksharing loop construct");
1545+
}
15411546

15421547
std::int64_t collapseValue =
15431548
Fortran::lower::getCollapseValue(loopOpClauseList);

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,11 @@ const parser::Name *DirectiveAttributeVisitor<T>::GetLoopIndex(
597597
const parser::DoConstruct &x) {
598598
using Bounds = parser::LoopControl::Bounds;
599599
if (x.GetLoopControl()) {
600-
return &std::get<Bounds>(x.GetLoopControl()->u).name.thing;
600+
if (const Bounds * b{std::get_if<Bounds>(&x.GetLoopControl()->u)}) {
601+
return &b->name.thing;
602+
} else {
603+
return nullptr;
604+
}
601605
} else {
602606
context_
603607
.Say(std::get<parser::Statement<parser::NonLabelDoStmt>>(x.t).source,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
2+
! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
3+
4+
! CHECK: not yet implemented: Do Concurrent in Worksharing loop construct
5+
subroutine sb()
6+
!$omp do
7+
do concurrent(i=1:10)
8+
print *, i
9+
end do
10+
end subroutine

0 commit comments

Comments
 (0)