Skip to content

Commit b0db164

Browse files
committed
Check for VOLATILE and ASYNCHRONOUS.
1 parent c0b2a94 commit b0db164

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

flang/lib/Lower/ConvertVariable.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,10 @@ static void deallocateIntentOut(Fortran::lower::AbstractConverter &converter,
10161016
}
10171017
}
10181018

1019+
/// Return true iff the given symbol represents a dummy array
1020+
/// that needs to be repacked when -frepack-arrays is set.
1021+
/// In general, the repacking is done for assumed-shape
1022+
/// dummy arguments, but there are limitations.
10191023
static bool needsRepack(Fortran::lower::AbstractConverter &converter,
10201024
const Fortran::semantics::Symbol &sym) {
10211025
const auto &attrs = sym.attrs();
@@ -1027,7 +1031,10 @@ static bool needsRepack(Fortran::lower::AbstractConverter &converter,
10271031
// TARGET dummy may be accessed indirectly, so it is unsafe
10281032
// to repack it. Some compilers provide options to override
10291033
// this.
1030-
attrs.test(Fortran::semantics::Attr::TARGET))
1034+
// Repacking of VOLATILE and ASYNCHRONOUS is also unsafe.
1035+
attrs.HasAny({Fortran::semantics::Attr::ASYNCHRONOUS,
1036+
Fortran::semantics::Attr::TARGET,
1037+
Fortran::semantics::Attr::VOLATILE}))
10311038
return false;
10321039

10331040
return true;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
! RUN: bbc -emit-hlfir -frepack-arrays %s -o - | FileCheck --check-prefixes=CHECK %s
2+
3+
! Check that there is no repacking for ASYNCHRONOUS dummy argument.
4+
5+
! CHECK-LABEL: func.func @_QPtest(
6+
! CHECK-NOT: fir.pack_array
7+
! CHECK-NOT: fir.unpack_array
8+
subroutine test(x)
9+
integer, asynchronous :: x(:)
10+
end subroutine test

flang/test/Lower/repack-arrays-target.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
! RUN: bbc -emit-hlfir -frepack-arrays %s -o - -I nowhere | FileCheck --check-prefixes=CHECK %s
1+
! RUN: bbc -emit-hlfir -frepack-arrays %s -o - | FileCheck --check-prefixes=CHECK %s
22

33
! Check that there is no repacking for TARGET dummy argument.
44

0 commit comments

Comments
 (0)