[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-fortran
Subject: Some type mismatches
From: Richard Guenther <rguenther () suse ! de>
Date: 2007-05-31 13:29:18
Message-ID: Pine.LNX.4.64.0705311524471.27490 () zhemvz ! fhfr ! qr
[Download RAW message or body]
For the sizeof intrinsic we currently have
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);
but use gfc_array_index_type in gfc_conv_intrinsic_sizeof, so we create
a mismatch between 4 byte and 8 byte integers on 64bit. One fix is for
example to do
Index: intrinsic.c
===================================================================
--- intrinsic.c (revision 125217)
+++ intrinsic.c (working copy)
@@ -2143,9 +2143,9 @@ add_functions (void)
make_generic ("size", GFC_ISYM_SIZE, GFC_STD_F95);
- add_sym_1 ("sizeof", GFC_ISYM_SIZEOF, NOT_ELEMENTAL, ACTUAL_NO,
BT_INTEGER, di,
+ add_sym_1 ("sizeof", GFC_ISYM_SIZEOF, NOT_ELEMENTAL, ACTUAL_NO,
BT_INTEGER, ii,
GFC_STD_GNU, gfc_check_sizeof, NULL, NULL,
- i, BT_INTEGER, di, REQUIRED);
+ i, BT_INTEGER, ii, REQUIRED);
make_generic ("sizeof", GFC_ISYM_SIZEOF, GFC_STD_GNU);
In type computations we have similar mismatches for shifts which is
cured by
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
And in string operations we compare different size integers which is
cured by
Index: trans-expr.c
===================================================================
--- trans-expr.c (revision 125217)
+++ trans-expr.c (working copy)
@@ -1149,7 +1149,7 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr
lse.expr = gfc_build_compare_string (lse.string_length, lse.expr,
rse.string_length, rse.expr);
- rse.expr = integer_zero_node;
+ rse.expr = build_int_cst (TREE_TYPE (lse.expr), 0);
gfc_add_block_to_block (&lse.post, &rse.post);
}
@@ -2537,7 +2537,7 @@ gfc_trans_string_copy (stmtblock_t * blo
/* 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));
+ build_int_cst (size_type_node, 0));
/* The following code was previously in _gfortran_copy_string:
I didn't yet bootstrap or regtest any of the above, but will shortly
do so. Ok if that passes? I'm especially curious about the sizeof case.
Richard.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic