+2007-11-13 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/34080
+ * iresolve.c (gfc_resolve_transfer): Do not try to convert
+ to a constant MOLD expression, if it is an assumed size
+ dummy.
+
2007-11-10 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* trans-common.c: Remove prototype for gfc_get_common.
/* TODO: Make this do something meaningful. */
static char transfer0[] = "__transfer0", transfer1[] = "__transfer1";
- if (mold->ts.type == BT_CHARACTER && !mold->ts.cl->length)
+ if (mold->ts.type == BT_CHARACTER && !mold->ts.cl->length
+ && !(mold->expr_type == EXPR_VARIABLE && mold->symtree->n.sym->attr.dummy))
mold->ts.cl->length = gfc_int_expr (mold->value.character.length);
f->ts = mold->ts;
--- /dev/null
+! { dg-do run }
+! Tests the fix for the regression PR34080, in which the character
+! length of the assumed length arguments to TRANSFER were getting
+! lost.
+!
+! Drew McCormack <drewmccormack@mac.com>
+!
+module TransferBug
+ type ByteType
+ private
+ character(len=1) :: singleByte
+ end type
+
+ type (ByteType), save :: BytesPrototype(1)
+
+contains
+
+ function StringToBytes(v) result (bytes)
+ character(len=*), intent(in) :: v
+ type (ByteType) :: bytes(size(transfer(v, BytesPrototype)))
+ bytes = transfer(v, BytesPrototype)
+ end function
+
+ subroutine BytesToString(bytes, string)
+ type (ByteType), intent(in) :: bytes(:)
+ character(len=*), intent(out) :: string
+ character(len=1) :: singleChar(1)
+ integer :: numChars
+ numChars = size(transfer(bytes,singleChar))
+ string = ''
+ string = transfer(bytes, string)
+ string(numChars+1:) = ''
+ end subroutine
+
+end module
+
+
+program main
+ use TransferBug
+ character(len=100) :: str
+ call BytesToString( StringToBytes('Hi'), str )
+ if (trim(str) .ne. "Hi") call abort ()
+end program
+! { dg-final { cleanup-modules "TransferBug" } }
+