diff options
author | Andre Vehreschild <vehre@gcc.gnu.org> | 2024-09-19 15:09:52 +0200 |
---|---|---|
committer | Andre Vehreschild <vehre@gcc.gnu.org> | 2024-09-24 13:15:37 +0200 |
commit | f5035d7d015ebd4a7f5df5831cfc1269f9567e06 (patch) | |
tree | 5eb7f5d1241a9e18d971de5d55da4b7eaa2f07e6 | |
parent | 9a795b3a5b6a0d8b4b4f38a66ab9782aabead92e (diff) | |
download | gcc-f5035d7d015ebd4a7f5df5831cfc1269f9567e06.zip gcc-f5035d7d015ebd4a7f5df5831cfc1269f9567e06.tar.gz gcc-f5035d7d015ebd4a7f5df5831cfc1269f9567e06.tar.bz2 |
Fortran: Assign allocated caf-memory to scalar members [PR84870]
Allocating a coarray required an array-descriptor. For scalars a
temporary descriptor was created. Assigning the allocated memory from
the temporary descriptor back to the scalar is now added.
gcc/fortran/ChangeLog:
PR fortran/84870
* trans-array.cc (duplicate_allocatable_coarray): For scalar
allocatable components the memory allocated is now assigned to
the component's pointer.
gcc/testsuite/ChangeLog:
* gfortran.dg/coarray/alloc_comp_10.f90: New test.
-rw-r--r-- | gcc/fortran/trans-array.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/coarray/alloc_comp_10.f90 | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 7d8274a..0b8ef0b 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -9505,6 +9505,7 @@ duplicate_allocatable_coarray (tree dest, tree dest_tok, tree src, tree type, gfc_build_addr_expr (NULL_TREE, dest_tok), NULL_TREE, NULL_TREE, NULL_TREE, GFC_CAF_COARRAY_ALLOC_REGISTER_ONLY); + gfc_add_modify (&block, dest, gfc_conv_descriptor_data_get (dummy_desc)); null_data = gfc_finish_block (&block); gfc_init_block (&block); @@ -9514,6 +9515,7 @@ duplicate_allocatable_coarray (tree dest, tree dest_tok, tree src, tree type, gfc_build_addr_expr (NULL_TREE, dest_tok), NULL_TREE, NULL_TREE, NULL_TREE, GFC_CAF_COARRAY_ALLOC); + gfc_add_modify (&block, dest, gfc_conv_descriptor_data_get (dummy_desc)); tmp = builtin_decl_explicit (BUILT_IN_MEMCPY); tmp = build_call_expr_loc (input_location, tmp, 3, dest, src, diff --git a/gcc/testsuite/gfortran.dg/coarray/alloc_comp_10.f90 b/gcc/testsuite/gfortran.dg/coarray/alloc_comp_10.f90 new file mode 100644 index 0000000..a31d005 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray/alloc_comp_10.f90 @@ -0,0 +1,24 @@ +!{ dg-do run } + +! Check that copying of memory for allocated scalar is assigned +! to coarray object. + +! Contributed by G. Steinmetz <gscfq@t-online.de> + +program p + type t + integer, allocatable :: a + end type + type t2 + type(t), allocatable :: b + end type + type(t2) :: x, y[*] + + x%b = t(1) + y = x + y%b%a = 2 + + if (x%b%a /= 1) stop 1 + if (y%b%a /= 2) stop 2 +end + |