diff options
author | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-02-19 21:12:09 +0000 |
---|---|---|
committer | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-02-19 21:12:09 +0000 |
commit | 4c2cfa8125c9a53b563d4d50c7fe83c2167e73fa (patch) | |
tree | a8b8399751e464e4ec4287a9c9a0996327cc76f4 /gcc/c-common.c | |
parent | 83a23b050c3e304cdbfe91ddcad06d3a20aff63f (diff) | |
download | gcc-4c2cfa8125c9a53b563d4d50c7fe83c2167e73fa.tar.gz |
2010-02-19 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR 41779
* c-common.c (conversion_warning): Remove widening conversions
before checking the conversion of integers to reals.
testsuite/
* c-c++-common/pr41779.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156911 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index f9bdf38f2d2..1039e24e0d4 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2192,12 +2192,17 @@ conversion_warning (tree type, tree expr) else if (TREE_CODE (expr_type) == INTEGER_TYPE && TREE_CODE (type) == REAL_TYPE) { - tree type_low_bound = TYPE_MIN_VALUE (expr_type); - tree type_high_bound = TYPE_MAX_VALUE (expr_type); - REAL_VALUE_TYPE real_low_bound - = real_value_from_int_cst (0, type_low_bound); - REAL_VALUE_TYPE real_high_bound - = real_value_from_int_cst (0, type_high_bound); + tree type_low_bound, type_high_bound; + REAL_VALUE_TYPE real_low_bound, real_high_bound; + + /* Don't warn about char y = 0xff; float x = (int) y; */ + expr = get_unwidened (expr, 0); + expr_type = TREE_TYPE (expr); + + type_low_bound = TYPE_MIN_VALUE (expr_type); + type_high_bound = TYPE_MAX_VALUE (expr_type); + real_low_bound = real_value_from_int_cst (0, type_low_bound); + real_high_bound = real_value_from_int_cst (0, type_high_bound); if (!exact_real_truncate (TYPE_MODE (type), &real_low_bound) || !exact_real_truncate (TYPE_MODE (type), &real_high_bound)) |