re PR fortran/29951 (incorrect conversion from string to integer by TRANSFER())
2006-11-25 Andrew Pinski <pinskia@gmail.com> PR fortran/29951 * trans-intrinsic.c (gfc_conv_intrinsic_transfer): Change to call memcpy instead of creating a VIEW_CONVERT_EXRP. 2006-11-25 Andrew Pinski <pinskia@gmail.com> PR fortran/29951 * gfortran.fortran-torture/execute/transfer2.f90: New test From-SVN: r119211
This commit is contained in:
parent
56d8eb6260
commit
85d6cbd388
|
@ -1,3 +1,9 @@
|
|||
2006-11-25 Andrew Pinski <pinskia@gmail.com>
|
||||
|
||||
PR fortran/29951
|
||||
* trans-intrinsic.c (gfc_conv_intrinsic_transfer): Change to
|
||||
call memcpy instead of creating a VIEW_CONVERT_EXRP.
|
||||
|
||||
2006-11-25 Francois-Xavier Coudert <coudert@clipper.ens.fr>
|
||||
|
||||
PR fortran/29711
|
||||
|
|
|
@ -2989,7 +2989,7 @@ gfc_conv_intrinsic_array_transfer (gfc_se * se, gfc_expr * expr)
|
|||
|
||||
|
||||
/* Scalar transfer statement.
|
||||
TRANSFER (source, mold) = VIEW_CONVERT_EXPR<typeof<mold> >source. */
|
||||
TRANSFER (source, mold) = memcpy(&tmpdecl, &source, size), tmpdecl. */
|
||||
|
||||
static void
|
||||
gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr)
|
||||
|
@ -2999,6 +2999,7 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr)
|
|||
tree type;
|
||||
tree ptr;
|
||||
gfc_ss *ss;
|
||||
tree tmpdecl, tmp, args;
|
||||
|
||||
/* Get a pointer to the source. */
|
||||
arg = expr->value.function.actual;
|
||||
|
@ -3014,6 +3015,7 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr)
|
|||
|
||||
arg = arg->next;
|
||||
type = gfc_typenode_for_spec (&expr->ts);
|
||||
|
||||
if (expr->ts.type == BT_CHARACTER)
|
||||
{
|
||||
ptr = convert (build_pointer_type (type), ptr);
|
||||
|
@ -3026,8 +3028,22 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr)
|
|||
}
|
||||
else
|
||||
{
|
||||
tree tmp = build_fold_indirect_ref (ptr);
|
||||
se->expr = fold_build1 (VIEW_CONVERT_EXPR, type, tmp);
|
||||
tree moldsize;
|
||||
tmpdecl = gfc_create_var (type, "transfer");
|
||||
moldsize = size_in_bytes (type);
|
||||
|
||||
/* Use memcpy to do the transfer. */
|
||||
tmp = build1 (ADDR_EXPR, build_pointer_type (type), tmpdecl);
|
||||
tmp = fold_convert (pvoid_type_node, tmp);
|
||||
args = gfc_chainon_list (NULL_TREE, tmp);
|
||||
tmp = fold_convert (pvoid_type_node, ptr);
|
||||
args = gfc_chainon_list (args, tmp);
|
||||
args = gfc_chainon_list (args, moldsize);
|
||||
tmp = built_in_decls[BUILT_IN_MEMCPY];
|
||||
tmp = build_function_call_expr (tmp, args);
|
||||
gfc_add_expr_to_block (&se->pre, tmp);
|
||||
|
||||
se->expr = tmpdecl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2006-11-25 Andrew Pinski <pinskia@gmail.com>
|
||||
|
||||
PR fortran/29951
|
||||
* gfortran.fortran-torture/execute/transfer2.f90: New test.
|
||||
|
||||
2006-11-25 Francois-Xavier Coudert <coudert@clipper.ens.fr>
|
||||
|
||||
* gfortran.fortran-torture/execute/specifics.f90: Remove test
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
program test_convert
|
||||
|
||||
implicit none
|
||||
character(len=4) :: byte_string
|
||||
character(len=1),dimension(4) :: byte_array
|
||||
integer*4 :: value,value1,n,i
|
||||
|
||||
byte_string(1:1) = char(157)
|
||||
byte_string(2:2) = char(127)
|
||||
byte_string(3:3) = char(100)
|
||||
byte_string(4:4) = char(0)
|
||||
|
||||
byte_array(1:4) = (/char(157),char(127),char(100),char(0)/)
|
||||
|
||||
value = transfer(byte_string(1:4),value)
|
||||
value1 = transfer(byte_array(1:4),value1)
|
||||
|
||||
if (value .ne. value1) call abort()
|
||||
end program test_convert
|
Loading…
Reference in New Issue