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

via flang-commits flang-commits at lists.llvm.org
Sun Oct 27 11:58:50 PDT 2024


Author: Kiran Chandramohan
Date: 2024-10-27T18:58:47Z
New Revision: eef3766ae5a39fea6f7f81ac444f878969743d85

URL: https://github.com/llvm/llvm-project/commit/eef3766ae5a39fea6f7f81ac444f878969743d85
DIFF: https://github.com/llvm/llvm-project/commit/eef3766ae5a39fea6f7f81ac444f878969743d85.diff

LOG: Assumed-size arrays are shared and cannot be privatized (#112963)

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

Fixes #110442

Added: 
    

Modified: 
    flang/lib/Semantics/resolve-directives.cpp
    flang/test/Semantics/OpenMP/default-none.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 513e42bee976a9..979570a7d4103a 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2052,6 +2052,8 @@ 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) && /* OpenMP 5.2, 5.1.1: 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