Skip to content

Commit 3649ab1

Browse files
committed
[flang][OpenMP] Don't allow DO CONCURRENT inside of a loop nest
I don't think DO CONCURRENT fits the definition of a Canonical Loop Nest (OpenMP 6.0 section 6.4.1). Fixes #144178
1 parent aa01e8e commit 3649ab1

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,12 @@ void OmpAttributeVisitor::PrivatizeAssociatedLoopIndexAndCheckLoopLevel(
19521952
const auto &outer{std::get<std::optional<parser::DoConstruct>>(x.t)};
19531953
if (outer.has_value()) {
19541954
for (const parser::DoConstruct *loop{&*outer}; loop && level > 0; --level) {
1955+
if (loop->IsDoConcurrent()) {
1956+
auto &stmt =
1957+
std::get<parser::Statement<parser::NonLabelDoStmt>>(loop->t);
1958+
context_.Say(stmt.source,
1959+
"DO CONCURRENT loops cannot form part of a loop nest."_err_en_US);
1960+
}
19551961
// go through all the nested do-loops and resolve index variables
19561962
const parser::Name *iv{GetLoopIndex(*loop)};
19571963
if (iv) {

flang/test/Lower/OpenMP/Todo/omp-doconcurrent.f90

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
!RUN: %python %S/../test_errors.py %s %flang -fopenmp
2+
3+
integer :: i, j
4+
!$omp parallel do collapse(2)
5+
do i = 1, 1
6+
! ERROR: DO CONCURRENT loops cannot form part of a loop nest.
7+
do concurrent (j = 1:2)
8+
print *, j
9+
end do
10+
end do
11+
12+
!$omp parallel do
13+
do i = 1, 1
14+
! This should not lead to an error because it is not part of a loop nest:
15+
do concurrent (j = 1:2)
16+
print *, j
17+
end do
18+
end do
19+
end

0 commit comments

Comments
 (0)