trans-io.c (transfer_expr): Handle pointters.
authorPaul Brook <paul@codesourcery.com>
Tue, 10 Aug 2004 00:57:22 +0000 (00:57 +0000)
committerPaul Brook <pbrook@gcc.gnu.org>
Tue, 10 Aug 2004 00:57:22 +0000 (00:57 +0000)
* trans-io.c (transfer_expr): Handle pointters.
testsuite/
* gfortran.dg/der_io_1.f90: New test.

From-SVN: r85738

gcc/fortran/ChangeLog
gcc/fortran/trans-io.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/der_io_1.f90 [new file with mode: 0644]

index 12aca9d2e227741fabefd2345caa57ad7c09090f..1dd0bc32d026d630747bd99d2aebdc1a800a7e4c 100644 (file)
@@ -1,3 +1,7 @@
+2004-08-10  Paul Brook  <paul@codesourcery.com>
+
+       * trans-io.c (transfer_expr): Handle pointters.
+
 2004-08-10  Paul Brook  <paul@codesourcery.com>
 
        PR fortran/16919
index 9c4acc5e035dcb58dbc2cbe53b540f41fd3f8f34..b01b8f61e80ea9efc0bdb52ffc352ae9a1f516e7 100644 (file)
@@ -1138,7 +1138,11 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr)
              se->string_length =
                TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (tmp)));
            }
-         transfer_expr (se, &c->ts, gfc_build_addr_expr (NULL, tmp));
+         if (c->dimension)
+           gfc_todo_error ("IO of arrays in derived types");
+         if (!c->pointer)
+           tmp = gfc_build_addr_expr (NULL, tmp);
+         transfer_expr (se, &c->ts, tmp);
        }
       return;
 
index c42f6dd1454cbea334dc48cc1d2da60e0aa6d827..7011c1262b966cf35f4f22ae929c09dae4cc20ad 100644 (file)
@@ -1,3 +1,7 @@
+2004-08-10  Paul Brook  <paul@codesourcery.com>
+
+       * gfortran.dg/der_io_1.f90: New test.
+
 2004-08-10  Paul Brook  <paul@codesourcery.com>
 
        PR fortran/16919
diff --git a/gcc/testsuite/gfortran.dg/der_io_1.f90 b/gcc/testsuite/gfortran.dg/der_io_1.f90
new file mode 100644 (file)
index 0000000..32155aa
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do run }
+! IO of derived types containing pointers
+program der_io_1
+  type t
+    integer, pointer :: p
+  end type
+  integer, target :: i
+  type (t) v
+  character(4) :: s
+
+  v%p => i
+  i = 42
+  write (unit=s, fmt='(I2)'), v
+  if (s .ne. '42') call abort ()
+end program
+