From: Eric Botcazou Date: Fri, 23 Apr 2010 16:16:50 +0000 (+0000) Subject: expr.c (expand_expr_real_1): Only use conversion between modes if both types are... X-Git-Tag: upstream/12.2.0~93550 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=915f592197faeac0125688de07a5a8862c7e8995;p=platform%2Fupstream%2Fgcc.git expr.c (expand_expr_real_1): Only use conversion between modes if both types are integral. * expr.c (expand_expr_real_1) : Only use conversion between modes if both types are integral. From-SVN: r158675 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c7eecfb..6b5feae 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2010-04-23 Eric Botcazou + + * expr.c (expand_expr_real_1) : Only use conversion + between modes if both types are integral. + 2010-04-23 Richard Guenther PR tree-optimization/43572 diff --git a/gcc/expr.c b/gcc/expr.c index e9e5326..e61ad1e 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -9323,9 +9323,8 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, op0 = force_reg (GET_MODE (op0), op0); op0 = gen_lowpart (mode, op0); } - /* If both modes are integral, then we can convert from one to the - other. */ - else if (SCALAR_INT_MODE_P (GET_MODE (op0)) && SCALAR_INT_MODE_P (mode)) + /* If both types are integral, convert from one mode to the other. */ + else if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (treeop0))) op0 = convert_modes (mode, GET_MODE (op0), op0, TYPE_UNSIGNED (TREE_TYPE (treeop0))); /* As a last resort, spill op0 to memory, and reload it in a diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dacc10e..fc5f35f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-04-23 Eric Botcazou + + * gnat.dg/unchecked_convert5.adb: New test. + 2010-04-23 Richard Guenther PR lto/41734 diff --git a/gcc/testsuite/gnat.dg/unchecked_convert5.adb b/gcc/testsuite/gnat.dg/unchecked_convert5.adb new file mode 100644 index 0000000..e3e4312 --- /dev/null +++ b/gcc/testsuite/gnat.dg/unchecked_convert5.adb @@ -0,0 +1,22 @@ +-- { dg-do run { target hppa*-*-* sparc*-*-* powerpc*-*-* } } + +with Unchecked_Conversion; + +procedure Unchecked_Convert5 is + + subtype c_1 is string(1..1); + + function int2c1 is -- { dg-warning "different sizes" } + new unchecked_conversion (source => integer, target => c_1); + + c1 : c_1; + +begin + + c1 := int2c1(16#12#); + + if c1 (1) /= ASCII.Nul then + raise Program_Error; + end if; + +end;