Skip to content

Commit c952f0e

Browse files
[Flang][OpenMP] Do not default privatize symbols that are not variables (#117886)
Fixes an issue where the compiler is trying to default privatize construct names. Fixes #112572
1 parent e4ee970 commit c952f0e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,7 @@ void OmpAttributeVisitor::Post(const parser::OpenMPAllocatorsConstruct &x) {
21192119

21202120
static bool IsPrivatizable(const Symbol *sym) {
21212121
auto *misc{sym->detailsIf<MiscDetails>()};
2122-
return !IsProcedure(*sym) && !IsNamedConstant(*sym) &&
2122+
return IsVariableName(*sym) && !IsProcedure(*sym) && !IsNamedConstant(*sym) &&
21232123
!semantics::IsAssumedSizeArray(
21242124
*sym) && /* OpenMP 5.2, 5.1.1: Assumed-size arrays are shared*/
21252125
!sym->owner().IsDerivedType() &&
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
! RUN: %flang_fc1 -fopenmp -fdebug-dump-symbols %s | FileCheck %s
2+
! Test that we do not make a private copy of the critical name
3+
4+
!CHECK: MainProgram scope: mn
5+
!CHECK-NEXT: j size=4 offset=0: ObjectEntity type: INTEGER(4)
6+
!CHECK-NEXT: OtherConstruct scope:
7+
!CHECK-NEXT: j (OmpPrivate): HostAssoc
8+
!CHECK-NEXT: k2 (OmpCriticalLock): Unknown
9+
program mn
10+
integer :: j
11+
j=2
12+
!$omp parallel default(private)
13+
!$omp critical(k2)
14+
j=200
15+
!$omp end critical(k2)
16+
!$omp end parallel
17+
end

0 commit comments

Comments
 (0)