Skip to content

Commit 4befe65

Browse files
authored
[flang][semantics][OpenMP] store DSA using ultimate sym (llvm#107002)
Previously we tracked data sharing attributes by the symbol itself not by the ultimate symbol. When the private clause came first, subsequent uses of the symbol found a host-associated version instead of the ultimate symbol and so the check didn't consider them to be the same symbol. Always adding and checking for the ultimate symbol ensures that we have the same behaviour no matter the order of clauses. The modified list is only used for this multiple clause check. Closes llvm#78235
1 parent 851bacb commit 4befe65

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

flang/lib/Semantics/resolve-directives.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2514,14 +2514,14 @@ void OmpAttributeVisitor::CheckMultipleAppearances(
25142514
target = &details->symbol();
25152515
}
25162516
}
2517-
if (HasDataSharingAttributeObject(*target) &&
2517+
if (HasDataSharingAttributeObject(target->GetUltimate()) &&
25182518
!WithMultipleAppearancesOmpException(symbol, ompFlag)) {
25192519
context_.Say(name.source,
25202520
"'%s' appears in more than one data-sharing clause "
25212521
"on the same OpenMP directive"_err_en_US,
25222522
name.ToString());
25232523
} else {
2524-
AddDataSharingAttributeObject(*target);
2524+
AddDataSharingAttributeObject(target->GetUltimate());
25252525
if (privateDataSharingAttributeFlags.test(ompFlag)) {
25262526
AddPrivateDataSharingAttributeObjects(*target);
25272527
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
2+
! Ensure that checks on more than one data-sharing clause do not depend upon
3+
! the clause order
4+
5+
PROGRAM main
6+
INTEGER:: I, N1, N2
7+
8+
!ERROR: 'n1' appears in more than one data-sharing clause on the same OpenMP directive
9+
!$OMP PARALLEL DO PRIVATE(N1) SHARED(N1)
10+
DO I=1, 4
11+
ENDDO
12+
!$OMP END PARALLEL DO
13+
14+
!ERROR: 'n2' appears in more than one data-sharing clause on the same OpenMP directive
15+
!$OMP PARALLEL DO SHARED(N2) PRIVATE(N2)
16+
DO I=1, 4
17+
ENDDO
18+
!$OMP END PARALLEL DO
19+
END PROGRAM

0 commit comments

Comments
 (0)