Skip to content

Commit 4e291f6

Browse files
committed
[flang][OpenMP] Don't try to privatize FORALL indices
FORALL indices have predetermined private DSA (OpenMP 5.2 5.1.1). As lowering already makes them private, don't modify FORALL index symbols. Fixes #120023
1 parent 8a229f5 commit 4e291f6

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,7 @@ static bool IsPrivatizable(const Symbol *sym) {
21192119
*sym) && /* OpenMP 5.2, 5.1.1: Assumed-size arrays are shared*/
21202120
!sym->owner().IsDerivedType() &&
21212121
sym->owner().kind() != Scope::Kind::ImpliedDos &&
2122+
sym->owner().kind() != Scope::Kind::Forall &&
21222123
!sym->detailsIf<semantics::AssocEntityDetails>() &&
21232124
!sym->detailsIf<semantics::NamelistDetails>() &&
21242125
(!misc ||
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
! RUN: %python %S/../test_symbols.py %s %flang_fc1 -fopenmp
2+
3+
! OpenMP 5.2 5.1.1 Variables Referenced in a Construct
4+
! FORALL indices have predetermined private DSA.
5+
! As lowering already makes them private, check that their symbols are not
6+
! modified.
7+
8+
!DEF: /MainProgram1/a ObjectEntity INTEGER(4)
9+
!DEF: /MainProgram1/b ObjectEntity INTEGER(4)
10+
integer a(5), b(5)
11+
12+
!REF: /MainProgram1/a
13+
a = 0
14+
!REF: /MainProgram1/b
15+
b = 0
16+
17+
!$omp parallel
18+
!DEF: /MainProgram1/OtherConstruct1/Forall1/i (Implicit) ObjectEntity INTEGER(4)
19+
!DEF: /MainProgram1/OtherConstruct1/a HostAssoc INTEGER(4)
20+
!DEF: /MainProgram1/OtherConstruct1/b HostAssoc INTEGER(4)
21+
forall(i = 1:5) a(i) = b(i) * 2
22+
!$omp end parallel
23+
24+
!$omp parallel default(private)
25+
!DEF: /MainProgram1/OtherConstruct2/Forall1/i (Implicit) ObjectEntity INTEGER(4)
26+
!DEF: /MainProgram1/OtherConstruct2/a (OmpPrivate) HostAssoc INTEGER(4)
27+
!DEF: /MainProgram1/OtherConstruct2/b (OmpPrivate) HostAssoc INTEGER(4)
28+
forall(i = 1:5) a(i) = b(i) * 2
29+
!$omp end parallel
30+
end program

0 commit comments

Comments
 (0)