From: Richard Sandiford Date: Thu, 24 Jun 2004 15:30:07 +0000 (+0000) Subject: calls.c (shift_returned_value): Fix handling of non-integer TYPE_MODEs. X-Git-Tag: releases/gcc-4.0.0~7399 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a1f395394d8ac58ed5ade2185f3267b16493791;p=thirdparty%2Fgcc.git calls.c (shift_returned_value): Fix handling of non-integer TYPE_MODEs. * calls.c (shift_returned_value): Fix handling of non-integer TYPE_MODEs. From-SVN: r83595 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e8b77275bbd0..d50d7f061b5d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-06-24 Richard Sandiford + + * calls.c (shift_returned_value): Fix handling of non-integer + TYPE_MODEs. + 2004-06-24 Ulrich Weigand * c-decl.c (finish_function): Do not check for DEFAULT_MAIN_RETURN. diff --git a/gcc/calls.c b/gcc/calls.c index 80931003f921..ccefb54992c2 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1920,9 +1920,17 @@ shift_returned_value (tree type, rtx *value) - BITS_PER_UNIT * int_size_in_bytes (type)); if (shift > 0) { + /* Shift the value into the low part of the register. */ *value = expand_binop (GET_MODE (*value), lshr_optab, *value, GEN_INT (shift), 0, 1, OPTAB_WIDEN); - *value = convert_to_mode (TYPE_MODE (type), *value, 0); + + /* Truncate it to the type's mode, or its integer equivalent. + This is subject to TRULY_NOOP_TRUNCATION. */ + *value = convert_to_mode (int_mode_for_mode (TYPE_MODE (type)), + *value, 0); + + /* Now convert it to the final form. */ + *value = gen_lowpart (TYPE_MODE (type), *value); return true; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 539cd97951d8..07f99b51338b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-06-24 Richard Sandiford + + * gcc.c-torture/compile/20040624-1.c: New test. + 2004-06-24 Giovanni Bajo * g++.dg/tree-ssa/tree-ssa.exp: Remove. dg.exp already handles diff --git a/gcc/testsuite/gcc.c-torture/compile/20040624-1.c b/gcc/testsuite/gcc.c-torture/compile/20040624-1.c new file mode 100644 index 000000000000..8eb92a4a7aa9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20040624-1.c @@ -0,0 +1,3 @@ +struct s { float f[1]; }; +struct s foo(); +float bar() { return foo().f[0]; }