diff options
author | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-11-23 18:49:22 +0000 |
---|---|---|
committer | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-11-23 18:49:22 +0000 |
commit | 0570334c0707d5ac88a64e10c65f1c1beac3d38f (patch) | |
tree | df3f642a41dbe83c7c2667bea513265952d3112a | |
parent | 583272a21e6049df9034256ab8aefd809663002e (diff) | |
download | gcc-0570334c0707d5ac88a64e10c65f1c1beac3d38f.tar.gz |
2006-11-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
* real.h (real_isinteger): Declare.
* real.c (real_isinteger): Define.
* builtins.c (integer_valued_real_p): Use it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119130 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/builtins.c | 10 | ||||
-rw-r--r-- | gcc/real.c | 11 | ||||
-rw-r--r-- | gcc/real.h | 3 |
4 files changed, 21 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f649c7b7749..0244e455aa3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2006-11-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org> + * real.h (real_isinteger): Declare. + * real.c (real_isinteger): Define. + * builtins.c (integer_valued_real_p): Use it. + +2006-11-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org> + PR c/9072 * c.opt (Wtraditional-conversion): New. (Wconversion): Update description. diff --git a/gcc/builtins.c b/gcc/builtins.c index 4e4ea969cd7..75b47fb2391 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -6677,15 +6677,7 @@ integer_valued_real_p (tree t) && integer_valued_real_p (TREE_OPERAND (t, 2)); case REAL_CST: - if (! TREE_CONSTANT_OVERFLOW (t)) - { - REAL_VALUE_TYPE c, cint; - - c = TREE_REAL_CST (t); - real_trunc (&cint, TYPE_MODE (TREE_TYPE (t)), &c); - return real_identical (&c, &cint); - } - break; + return real_isinteger (TREE_REAL_CST_PTR (t), TYPE_MODE (TREE_TYPE (t))); case NOP_EXPR: { diff --git a/gcc/real.c b/gcc/real.c index bfb8462baea..0d239b3379d 100644 --- a/gcc/real.c +++ b/gcc/real.c @@ -4968,3 +4968,14 @@ real_from_mpfr (REAL_VALUE_TYPE *r, mpfr_srcptr m) real_from_string (r, buf); } + +/* Check whether the real constant value given is an integer. */ + +bool +real_isinteger (const REAL_VALUE_TYPE *c, enum machine_mode mode) +{ + REAL_VALUE_TYPE cint; + + real_trunc (&cint, mode, c); + return real_identical (c, &cint); +} diff --git a/gcc/real.h b/gcc/real.h index 5a45892d301..4198b02aee6 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -433,4 +433,7 @@ extern void real_copysign (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *); extern void real_from_mpfr (REAL_VALUE_TYPE *, mpfr_srcptr); extern void mpfr_from_real (mpfr_ptr, const REAL_VALUE_TYPE *); +/* Check whether the real constant value given is an integer. */ +extern bool real_isinteger (const REAL_VALUE_TYPE *c, enum machine_mode mode); + #endif /* ! GCC_REAL_H */ |