public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-7834] Fortran: Supply a missing dereference [PR92586]
@ 2023-09-24 14:35 Paul Thomas
0 siblings, 0 replies; only message in thread
From: Paul Thomas @ 2023-09-24 14:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9eb2f102d38697011d3069fac759b7c6e149bed4
commit r13-7834-g9eb2f102d38697011d3069fac759b7c6e149bed4
Author: Paul Thomas <pault@gcc.gnu.org>
Date: Sun Sep 24 15:34:57 2023 +0100
Fortran: Supply a missing dereference [PR92586]
2023-09-24 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/92586
* trans-expr.cc (gfc_trans_arrayfunc_assign): Supply a missing
dereference for the call to gfc_deallocate_alloc_comp_no_caf.
gcc/testsuite/
PR fortran/92586
* gfortran.dg/pr92586.f90 : New test
Diff:
---
gcc/fortran/trans-expr.cc | 3 +-
gcc/testsuite/gfortran.dg/pr92586.f90 | 61 +++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index c6f066e807f..65b4a62ff5c 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -10968,7 +10968,8 @@ gfc_trans_arrayfunc_assign (gfc_expr * expr1, gfc_expr * expr2)
if (expr1->ts.type == BT_DERIVED
&& expr1->ts.u.derived->attr.alloc_comp)
{
- tmp = gfc_deallocate_alloc_comp_no_caf (expr1->ts.u.derived, se.expr,
+ tmp = build_fold_indirect_ref_loc (input_location, se.expr);
+ tmp = gfc_deallocate_alloc_comp_no_caf (expr1->ts.u.derived, tmp,
expr1->rank);
gfc_add_expr_to_block (&se.pre, tmp);
}
diff --git a/gcc/testsuite/gfortran.dg/pr92586.f90 b/gcc/testsuite/gfortran.dg/pr92586.f90
new file mode 100644
index 00000000000..40ad50cb777
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr92586.f90
@@ -0,0 +1,61 @@
+! { dg-do compile }
+!
+! Contributed by Emanuele Pagone <epagone@email.it>
+!
+module foo_m
+ implicit none
+
+ type :: string
+ character(len=:), allocatable :: s
+ end type string
+
+ type :: foo_t
+ type(string), allocatable :: foo_s(:)
+ contains
+ procedure, public :: get_s
+ end type foo_t
+
+ type :: data_t
+ integer :: n_foo_s
+ type(foo_t), allocatable :: foo(:)
+ contains
+ procedure, public :: data_get_foo_s
+ end type data_t
+
+contains
+
+ function get_s(self)
+ class(foo_t), intent(in) :: self
+ type(string) :: get_s( size(self%foo_s) )
+ get_s = self%foo_s
+ end function get_s
+
+ function data_get_foo_s(self, ith)
+ class(data_t), intent(in) :: self
+ integer, intent(in) :: ith
+ type(string) :: data_get_foo_s(self%n_foo_s)
+
+ data_get_foo_s = self%foo(ith)%get_s() ! The lhs was not dereferenced in a byref call.
+
+ end function data_get_foo_s
+
+end module foo_m
+
+
+program bug_stringifor
+ use foo_m
+ implicit none
+
+ type(data_t) :: data
+ type(string), allocatable :: bar(:)
+
+ allocate( data%foo(1) )
+ data%foo(1)%foo_s = [string("alpha"), string("bravo"), string("charlie"), &
+ string("delta"), string("foxtrot")]
+ data%n_foo_s = 5
+
+ bar = data%data_get_foo_s(1)
+
+ print *, "bar = ", bar(1)%s
+
+end program bug_stringifor
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-24 14:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-24 14:35 [gcc r13-7834] Fortran: Supply a missing dereference [PR92586] Paul Thomas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).