diff options
author | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-22 23:04:24 +0000 |
---|---|---|
committer | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-22 23:04:24 +0000 |
commit | 64214dabd303be6b1134238ee99d05be78e83ff8 (patch) | |
tree | 72ccc17238a98a5218797e0019368cff25e58e57 /gcc/c-lex.c | |
parent | f2c255d4fa65514614d673a9e440dbe2b92b60b7 (diff) | |
download | gcc-64214dabd303be6b1134238ee99d05be78e83ff8.tar.gz |
2007-03-22 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR other/23572
* c-lex.c (interpret_float): On overflow, emit pedantic warning if
infinities not supported, otherwise emit warning if -Woverflow. On
underflow, emit warning if -Woverflow.
* real.c (real_from_string): Return -1 if underflow, +1 if overflow
and 0 otherwise.
* real.h (real_from_string): Update declaration
testsuite/
* gcc.dg/float-range-4.c: New.
* gcc.dg/float-range-1.c: Update. Test for a warning.
* gcc.dg/float-range-3.c: New.
* gcc.dg/float-range-5.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123137 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r-- | gcc/c-lex.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 108bc5cff17..a89643c6046 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -681,11 +681,23 @@ interpret_float (const cpp_token *token, unsigned int flags) /* Both C and C++ require a diagnostic for a floating constant outside the range of representable values of its type. Since we - have __builtin_inf* to produce an infinity, it might now be - appropriate for this to be a mandatory pedwarn rather than - conditioned on -pedantic. */ - if (REAL_VALUE_ISINF (real) && pedantic) - pedwarn ("floating constant exceeds range of %qT", type); + have __builtin_inf* to produce an infinity, this is now a + mandatory pedwarn if the target does not support infinities. */ + if (REAL_VALUE_ISINF (real)) + { + if (!MODE_HAS_INFINITIES (TYPE_MODE (type))) + pedwarn ("floating constant exceeds range of %qT", type); + else + warning (OPT_Woverflow, "floating constant exceeds range of %qT", type); + } + /* We also give a warning if the value underflows. */ + else if (REAL_VALUES_EQUAL (real, dconst0)) + { + REAL_VALUE_TYPE realvoidmode; + int overflow = real_from_string (&realvoidmode, copy); + if (overflow < 0 || !REAL_VALUES_EQUAL (realvoidmode, dconst0)) + warning (OPT_Woverflow, "floating constant truncated to zero"); + } /* Create a node with determined type and value. */ value = build_real (type, real); |