[flang][semantics][OpenMP] store DSA using ultimate sym (#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 #78235
This commit is contained in:
Tom Eccles
2024-09-03 10:19:22 +01:00
committed by GitHub
parent 851bacb7ce
commit 4befe65cf0
2 changed files with 21 additions and 2 deletions

View File

@@ -2514,14 +2514,14 @@ void OmpAttributeVisitor::CheckMultipleAppearances(
target = &details->symbol();
}
}
if (HasDataSharingAttributeObject(*target) &&
if (HasDataSharingAttributeObject(target->GetUltimate()) &&
!WithMultipleAppearancesOmpException(symbol, ompFlag)) {
context_.Say(name.source,
"'%s' appears in more than one data-sharing clause "
"on the same OpenMP directive"_err_en_US,
name.ToString());
} else {
AddDataSharingAttributeObject(*target);
AddDataSharingAttributeObject(target->GetUltimate());
if (privateDataSharingAttributeFlags.test(ompFlag)) {
AddPrivateDataSharingAttributeObjects(*target);
}

View File

@@ -0,0 +1,19 @@
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
! Ensure that checks on more than one data-sharing clause do not depend upon
! the clause order
PROGRAM main
INTEGER:: I, N1, N2
!ERROR: 'n1' appears in more than one data-sharing clause on the same OpenMP directive
!$OMP PARALLEL DO PRIVATE(N1) SHARED(N1)
DO I=1, 4
ENDDO
!$OMP END PARALLEL DO
!ERROR: 'n2' appears in more than one data-sharing clause on the same OpenMP directive
!$OMP PARALLEL DO SHARED(N2) PRIVATE(N2)
DO I=1, 4
ENDDO
!$OMP END PARALLEL DO
END PROGRAM