This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [PATCH] Re: Some type mismatches
On Thu, 31 May 2007, FX Coudert wrote:
> OK provided it bootstraps.
>
> FX
This is what I will commit shortly. Bootstrapped and tested on
x86_64-unknown-linux-gnu.
Richard.
2007-05-31 Richard Guenther <rguenther@suse.de>
* trans-expr.c (gfc_conv_expr_op): Use zero constant
that matches the lse type.
(gfc_trans_string_copy): Use sizetype zero constant.
* intrinsic.c (add_functions): The sizeof intrinsic has
index type result.
* trans-types.c (gfc_get_dtype): Convert size to index
type before shifting.
* trans-array.c (gfc_trans_array_constructor_value): Use
index type for offset computation.
* trans-intrinsic.c (gfc_conv_associated): Use correct type
for zero constant.
Index: trans-expr.c
===================================================================
*** trans-expr.c (revision 125217)
--- trans-expr.c (working copy)
*************** gfc_conv_expr_op (gfc_se * se, gfc_expr
*** 1149,1155 ****
lse.expr = gfc_build_compare_string (lse.string_length, lse.expr,
rse.string_length, rse.expr);
! rse.expr = integer_zero_node;
gfc_add_block_to_block (&lse.post, &rse.post);
}
--- 1149,1155 ----
lse.expr = gfc_build_compare_string (lse.string_length, lse.expr,
rse.string_length, rse.expr);
! rse.expr = build_int_cst (TREE_TYPE (lse.expr), 0);
gfc_add_block_to_block (&lse.post, &rse.post);
}
*************** gfc_trans_string_copy (stmtblock_t * blo
*** 2537,2543 ****
/* Do nothing if the destination length is zero. */
cond = fold_build2 (GT_EXPR, boolean_type_node, dlen,
! build_int_cst (gfc_charlen_type_node, 0));
/* The following code was previously in _gfortran_copy_string:
--- 2537,2543 ----
/* Do nothing if the destination length is zero. */
cond = fold_build2 (GT_EXPR, boolean_type_node, dlen,
! build_int_cst (size_type_node, 0));
/* The following code was previously in _gfortran_copy_string:
Index: trans-array.c
===================================================================
*** trans-array.c (revision 125217)
--- trans-array.c (working copy)
*************** gfc_trans_array_constructor_value (stmtb
*** 1196,1202 ****
gfc_add_expr_to_block (&body, tmp);
*poffset = fold_build2 (PLUS_EXPR, gfc_array_index_type,
! *poffset, build_int_cst (NULL_TREE, n));
}
if (!INTEGER_CST_P (*poffset))
{
--- 1196,1203 ----
gfc_add_expr_to_block (&body, tmp);
*poffset = fold_build2 (PLUS_EXPR, gfc_array_index_type,
! *poffset,
! build_int_cst (gfc_array_index_type, n));
}
if (!INTEGER_CST_P (*poffset))
{
Index: trans-types.c
===================================================================
*** trans-types.c (revision 125217)
--- trans-types.c (working copy)
*************** gfc_get_dtype (tree type)
*** 993,999 ****
if (size && !INTEGER_CST_P (size))
{
tmp = build_int_cst (gfc_array_index_type, GFC_DTYPE_SIZE_SHIFT);
! tmp = fold_build2 (LSHIFT_EXPR, gfc_array_index_type, size, tmp);
dtype = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp, dtype);
}
/* If we don't know the size we leave it as zero. This should never happen
--- 993,1000 ----
if (size && !INTEGER_CST_P (size))
{
tmp = build_int_cst (gfc_array_index_type, GFC_DTYPE_SIZE_SHIFT);
! tmp = fold_build2 (LSHIFT_EXPR, gfc_array_index_type,
! fold_convert (gfc_array_index_type, size), tmp);
dtype = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp, dtype);
}
/* If we don't know the size we leave it as zero. This should never happen
Index: trans-intrinsic.c
===================================================================
*** trans-intrinsic.c (revision 125217)
--- trans-intrinsic.c (working copy)
*************** gfc_conv_associated (gfc_se *se, gfc_exp
*** 3271,3277 ****
tmp = gfc_conv_descriptor_stride (arg1se.expr,
gfc_rank_cst[arg1->expr->rank - 1]);
nonzero_arraylen = build2 (NE_EXPR, boolean_type_node,
! tmp, integer_zero_node);
/* A pointer to an array, call library function _gfor_associated. */
gcc_assert (ss2 != gfc_ss_terminator);
--- 3271,3277 ----
tmp = gfc_conv_descriptor_stride (arg1se.expr,
gfc_rank_cst[arg1->expr->rank - 1]);
nonzero_arraylen = build2 (NE_EXPR, boolean_type_node,
! tmp, build_int_cst (TREE_TYPE (tmp), 0));
/* A pointer to an array, call library function _gfor_associated. */
gcc_assert (ss2 != gfc_ss_terminator);
Index: intrinsic.c
===================================================================
*** intrinsic.c (revision 125217)
--- intrinsic.c (working copy)
*************** add_functions (void)
*** 2143,2151 ****
make_generic ("size", GFC_ISYM_SIZE, GFC_STD_F95);
! add_sym_1 ("sizeof", GFC_ISYM_SIZEOF, NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, di,
GFC_STD_GNU, gfc_check_sizeof, NULL, NULL,
! i, BT_INTEGER, di, REQUIRED);
make_generic ("sizeof", GFC_ISYM_SIZEOF, GFC_STD_GNU);
--- 2143,2151 ----
make_generic ("size", GFC_ISYM_SIZE, GFC_STD_F95);
! add_sym_1 ("sizeof", GFC_ISYM_SIZEOF, NOT_ELEMENTAL, ACTUAL_NO, BT_INTEGER, ii,
GFC_STD_GNU, gfc_check_sizeof, NULL, NULL,
! i, BT_UNKNOWN, 0, REQUIRED);
make_generic ("sizeof", GFC_ISYM_SIZEOF, GFC_STD_GNU);