re PR fortran/17244 (gfortran fatal error: gfc_todo: Not Implemented: Returning deriv...
authorTobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
Tue, 31 Aug 2004 16:52:41 +0000 (18:52 +0200)
committerTobias Schlüter <tobi@gcc.gnu.org>
Tue, 31 Aug 2004 16:52:41 +0000 (18:52 +0200)
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
gcc/fortran/trans-types.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/func_derived_1.f90 [new file with mode: 0644]

index 74ada4c8a35d2e06a9c90d6e071a51f6115eb6fa..a4f76e37b54cd99288f1745c2b2a8e761e9489a1 100644 (file)
@@ -1,3 +1,9 @@
+2004-08-31  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       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  <tobias.schlueter@physik.uni-muenchen.de>
 
        * trans-decl.c, trans-expr.c, trans-io.c, trans-types.c: Replace
index f65a9d71c218c4d361cbb14a58db78e358504cc7..26866b4c016e298fe0a07a6ef4533aad7c0407c0 100644 (file)
@@ -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;
 }
 \f
index df86733ee71bf6587e93566147891ff86417d3a7..86a392c8f20dc1b54300a73540d00d1f6c02dbd6 100644 (file)
@@ -1,3 +1,8 @@
+2004-08-31  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       PR fortran/17244
+       * gfortran.dg/func_derived_1.f90: New test.
+
 2004-08-31  Paul Brook  <paul@codesourcery.com>
 
        * 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 (file)
index 0000000..5160e5a
--- /dev/null
@@ -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