From cf73cdac51a20dacfc1b569b0bd6fcef1d71f852 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20Schl=C3=BCter?= Date: Tue, 31 Aug 2004 18:52:41 +0200 Subject: [PATCH] re PR fortran/17244 (gfortran fatal error: gfc_todo: Not Implemented: Returning derived types) fortran/ PR fortran/17244 * trans-types.c (gfc_return_by_reference): Remove TODO error, add comment pointing out possible issue WRT compatibility with g77. testsuite/ PR fortran/17244 * gfortran.dg/func_derived_1.f90: New test. From-SVN: r86832 --- gcc/fortran/ChangeLog | 6 ++++ gcc/fortran/trans-types.c | 4 +-- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gfortran.dg/func_derived_1.f90 | 38 ++++++++++++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/func_derived_1.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 74ada4c8a35..a4f76e37b54 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2004-08-31 Tobias Schlueter + + PR fortran/17244 + * trans-types.c (gfc_return_by_reference): Remove TODO error, + add comment pointing out possible issue WRT compatibility with g77. + 2004-08-31 Tobias Schlueter * trans-decl.c, trans-expr.c, trans-io.c, trans-types.c: Replace diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index f65a9d71c21..26866b4c016 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -1451,9 +1451,7 @@ gfc_return_by_reference (gfc_symbol * sym) if (sym->ts.type == BT_CHARACTER) return 1; - if (sym->ts.type == BT_DERIVED) - gfc_todo_error ("Returning derived types"); - /* Possibly return derived types by reference. */ + /* Possibly return complex numbers by reference for g77 compatibility. */ return 0; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index df86733ee71..86a392c8f20 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-08-31 Tobias Schlueter + + PR fortran/17244 + * gfortran.dg/func_derived_1.f90: New test. + 2004-08-31 Paul Brook * gfortran.dg/eof_1.f90: New test. diff --git a/gcc/testsuite/gfortran.dg/func_derived_1.f90 b/gcc/testsuite/gfortran.dg/func_derived_1.f90 new file mode 100644 index 00000000000..5160e5ae7f2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/func_derived_1.f90 @@ -0,0 +1,38 @@ +! { dg-do run } +! PR 17244 +! verifies that functions returning derived type work +module m + type t + integer i + real x + character*5 c + integer arr(5,5) + end type t +end module m + +use m +type(t) :: r +integer arr(5,5), vect(25), vect2(25) +do i=1,25 + vect = 0 + vect(i) = i + arr = reshape (vect, shape(arr)) + r = f(i,real(i),"HALLO",arr) + + if (r%i .ne. i) call abort() + if (r%x .ne. real(i)) call abort() + if (r%c .ne. "HALLO") call abort() + vect2 = reshape (r%arr, shape(vect2)) + if (any(vect2.ne.vect)) call abort() +end do +contains + +function f(i,x,c,arr) + type(t) :: f + character*5 c + integer arr(5,5) + + f = t(i,x,c,arr) +end function f + +end -- 2.30.2