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/fortran/trans-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/fortran/trans-const.c')
-rw-r--r-- | gcc/fortran/trans-const.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/fortran/trans-const.c b/gcc/fortran/trans-const.c index fd3d58f..4db3512 100644 --- a/gcc/fortran/trans-const.c +++ b/gcc/fortran/trans-const.c @@ -281,13 +281,19 @@ gfc_conv_constant_to_tree (gfc_expr * expr) case BT_LOGICAL: if (expr->representation.string) - return fold_build1 (VIEW_CONVERT_EXPR, - gfc_get_logical_type (expr->ts.kind), - gfc_build_string_const (expr->representation.length, - expr->representation.string)); + { + tree tmp = fold_build1 (VIEW_CONVERT_EXPR, + gfc_get_int_type (expr->ts.kind), + gfc_build_string_const (expr->representation.length, + expr->representation.string)); + if (!integer_zerop (tmp) && !integer_onep (tmp)) + gfc_warning ("Assigning value other than 0 or 1 to LOGICAL" + " has undefined result at %L", &expr->where); + return fold_convert (gfc_get_logical_type (expr->ts.kind), tmp); + } else return build_int_cst (gfc_get_logical_type (expr->ts.kind), - expr->value.logical); + expr->value.logical); case BT_COMPLEX: if (expr->representation.string) |