diff options
author | Sandra Loosemore <sandra@codesourcery.com> | 2009-05-15 13:28:47 -0400 |
---|---|---|
committer | Sandra Loosemore <sandra@gcc.gnu.org> | 2009-05-15 13:28:47 -0400 |
commit | d33e4b70f65df2876f67172944512b9d3356169f (patch) | |
tree | dc6d7cf139391ffd759113efa90ed726e869d03c /gcc | |
parent | a02ab464e35947a129a601352467f1f2961612c8 (diff) | |
download | gcc-d33e4b70f65df2876f67172944512b9d3356169f.zip gcc-d33e4b70f65df2876f67172944512b9d3356169f.tar.gz gcc-d33e4b70f65df2876f67172944512b9d3356169f.tar.bz2 |
fold-const.c (fold_convert_const_real_from_real): Check for overflow.
2009-05-15 Sandra Loosemore <sandra@codesourcery.com>
gcc/
* fold-const.c (fold_convert_const_real_from_real): Check for
overflow.
From-SVN: r147589
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const.c | 19 |
2 files changed, 23 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2cd3e25..b347aff 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2009-05-15 Sandra Loosemore <sandra@codesourcery.com> + + * fold-const.c (fold_convert_const_real_from_real): Check for + overflow. + 2009-05-15 H.J. Lu <hongjiu.lu@intel.com> * config/i386/i386.c (ix86_reorg): Call optimize_function_for_speed_p diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 32de681..1a1a80f 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2327,7 +2327,24 @@ fold_convert_const_real_from_real (tree type, const_tree arg1) real_convert (&value, TYPE_MODE (type), &TREE_REAL_CST (arg1)); t = build_real (type, value); - TREE_OVERFLOW (t) = TREE_OVERFLOW (arg1); + /* If converting an infinity or NAN to a representation that doesn't + have one, set the overflow bit so that we can produce some kind of + error message at the appropriate point if necessary. It's not the + most user-friendly message, but it's better than nothing. */ + if (REAL_VALUE_ISINF (TREE_REAL_CST (arg1)) + && !MODE_HAS_INFINITIES (TYPE_MODE (type))) + TREE_OVERFLOW (t) = 1; + else if (REAL_VALUE_ISNAN (TREE_REAL_CST (arg1)) + && !MODE_HAS_NANS (TYPE_MODE (type))) + TREE_OVERFLOW (t) = 1; + /* Regular overflow, conversion produced an infinity in a mode that + can't represent them. */ + else if (!MODE_HAS_INFINITIES (TYPE_MODE (type)) + && REAL_VALUE_ISINF (value) + && !REAL_VALUE_ISINF (TREE_REAL_CST (arg1))) + TREE_OVERFLOW (t) = 1; + else + TREE_OVERFLOW (t) = TREE_OVERFLOW (arg1); return t; } |