[flang-commits] [flang] Assumed-size arrays are shared and cannot be privatized (PR #112963)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Fri Oct 18 12:46:15 PDT 2024


https://github.com/kiranchandramohan created https://github.com/llvm/llvm-project/pull/112963

Do not error out if default(none) is specified and the region has an assumed-size array.

Fixes #110442

>From 308241df397d75ae20648813dfaa8aa1b9ef85af Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Fri, 18 Oct 2024 15:59:25 +0000
Subject: [PATCH] Assumed-size arrays are shared and cannot be privatized

Do not error out if default(none) is specified and the
region has an assumed-size array.

Fixes #110442
---
 flang/lib/Semantics/resolve-directives.cpp   |  1 +
 flang/test/Semantics/OpenMP/default-none.f90 | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 186b58bcc52c35..81997c4df68b0c 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2047,6 +2047,7 @@ void OmpAttributeVisitor::Post(const parser::OpenMPAllocatorsConstruct &x) {
 static bool IsPrivatizable(const Symbol *sym) {
   auto *misc{sym->detailsIf<MiscDetails>()};
   return !IsProcedure(*sym) && !IsNamedConstant(*sym) &&
+      !semantics::IsAssumedSizeArray(*sym) && /*Assumed-size arrays are shared*/
       !sym->owner().IsDerivedType() &&
       sym->owner().kind() != Scope::Kind::ImpliedDos &&
       !sym->detailsIf<semantics::AssocEntityDetails>() &&
diff --git a/flang/test/Semantics/OpenMP/default-none.f90 b/flang/test/Semantics/OpenMP/default-none.f90
index 11ba878ea77940..761c2385466a08 100644
--- a/flang/test/Semantics/OpenMP/default-none.f90
+++ b/flang/test/Semantics/OpenMP/default-none.f90
@@ -47,3 +47,14 @@ subroutine sb4
     end do loop
   !$omp end parallel
 end subroutine
+
+! Test that default(none) does not error for assumed-size array
+subroutine sub( aaa)
+  real,dimension(*),intent(in)::aaa
+  integer::ip
+  real::ccc
+!$omp parallel do private(ip,ccc) default(none)
+  do ip = 1, 10
+     ccc= aaa(ip)
+  end do
+end subroutine sub



More information about the flang-commits mailing list