diff options
author | Jakub Jelinek <jakub@redhat.com> | 2008-11-12 18:01:51 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2008-11-12 18:01:51 +0100 |
commit | 27a4e07281d191dff6b8c109b51a62d8b0731210 (patch) | |
tree | 90513cc0221974d0adbd9f6b5ecaf6cfe813b33b /gcc/fold-const.c | |
parent | d2cf2f07a9eabdc50dd002970d3c6bf634ed1292 (diff) | |
download | gcc-27a4e07281d191dff6b8c109b51a62d8b0731210.zip gcc-27a4e07281d191dff6b8c109b51a62d8b0731210.tar.gz gcc-27a4e07281d191dff6b8c109b51a62d8b0731210.tar.bz2 |
re PR target/35366 (gfortran.dg/equiv_7.f90 fails with -m64 -Os on powerpc-apple-darwin9)
PR target/35366
PR fortran/33759
* fold-const.c (native_encode_string): New function.
(native_encode_expr): Use it for STRING_CST.
* trans-const.c (gfc_conv_constant_to_tree): Warn when
converting an integer outside of LOGICAL's range to
LOGICAL.
* trans-intrinsic.c (gfc_conv_intrinsic_function,
gfc_conv_intrinsic_array_transfer, gfc_conv_intrinsic_transfer):
Use INTEGER_TYPE instead of BOOLEAN_TYPE for TRANSFER as
argument of another TRANSFER.
* gfortran.dg/hollerith.f90: Don't assume a 32-bit value
stored into logical variable will be preserved.
* gfortran.dg/transfer_simplify_4.f90: Remove undefined
cases. Run at all optimization levels. Add a couple of
new tests.
* gfortran.dg/hollerith5.f90: New test.
* gfortran.dg/hollerith_legacy.f90: Add dg-warning.
From-SVN: r141790
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 1a96c3f..8dddca1 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7315,6 +7315,37 @@ native_encode_vector (const_tree expr, unsigned char *ptr, int len) } +/* Subroutine of native_encode_expr. Encode the STRING_CST + specified by EXPR into the buffer PTR of length LEN bytes. + Return the number of bytes placed in the buffer, or zero + upon failure. */ + +static int +native_encode_string (const_tree expr, unsigned char *ptr, int len) +{ + tree type = TREE_TYPE (expr); + HOST_WIDE_INT total_bytes; + + if (TREE_CODE (type) != ARRAY_TYPE + || TREE_CODE (TREE_TYPE (type)) != INTEGER_TYPE + || GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (type))) != BITS_PER_UNIT + || !host_integerp (TYPE_SIZE_UNIT (type), 0)) + return 0; + total_bytes = tree_low_cst (TYPE_SIZE_UNIT (type), 0); + if (total_bytes > len) + return 0; + if (TREE_STRING_LENGTH (expr) < total_bytes) + { + memcpy (ptr, TREE_STRING_POINTER (expr), TREE_STRING_LENGTH (expr)); + memset (ptr + TREE_STRING_LENGTH (expr), 0, + total_bytes - TREE_STRING_LENGTH (expr)); + } + else + memcpy (ptr, TREE_STRING_POINTER (expr), total_bytes); + return total_bytes; +} + + /* Subroutine of fold_view_convert_expr. Encode the INTEGER_CST, REAL_CST, COMPLEX_CST or VECTOR_CST specified by EXPR into the buffer PTR of length LEN bytes. Return the number of bytes @@ -7337,6 +7368,9 @@ native_encode_expr (const_tree expr, unsigned char *ptr, int len) case VECTOR_CST: return native_encode_vector (expr, ptr, len); + case STRING_CST: + return native_encode_string (expr, ptr, len); + default: return 0; } |