Skip to content

Commit 3ae8746

Browse files
[Flang][OpenMP] Avoid default none errors for seq loop indices in par… (#76258)
…allel
1 parent 2eb71e8 commit 3ae8746

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,11 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
19461946
if (Symbol * found{currScope().FindSymbol(name.source)}) {
19471947
if (symbol != found) {
19481948
name.symbol = found; // adjust the symbol within region
1949-
} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone) {
1949+
} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
1950+
// Exclude indices of sequential loops that are privatised in
1951+
// the scope of the parallel region, and not in this scope.
1952+
// TODO: check whether this should be caught in IsObjectWithDSA
1953+
!symbol->test(Symbol::Flag::OmpPrivate)) {
19501954
context_.Say(name.source,
19511955
"The DEFAULT(NONE) clause requires that '%s' must be listed in "
19521956
"a data-sharing attribute clause"_err_en_US,

flang/test/Semantics/OpenMP/resolve05.f90

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,20 @@ subroutine default_none()
1717
!$omp end parallel
1818
end subroutine default_none
1919

20+
! Test that indices of sequential loops are privatised and hence do not error
21+
! for DEFAULT(NONE)
22+
subroutine default_none_seq_loop
23+
integer :: i
24+
25+
!$omp parallel do default(none)
26+
do i = 1, 10
27+
do j = 1, 20
28+
enddo
29+
enddo
30+
end subroutine
31+
2032
program mm
2133
call default_none()
34+
call default_none_seq_loop()
2235
!TODO: private, firstprivate, shared
2336
end

0 commit comments

Comments
 (0)