]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix bogus fix-it for FLT_MAX (PR c/89122)
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 31 Jan 2019 18:09:29 +0000 (18:09 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 31 Jan 2019 18:09:29 +0000 (18:09 +0000)
commitd6bfe4508ad877880021d7add95257dd2d65727f
tree353a626c0687248a7da4d78198b3f10714c0283a
parent8c28f0efefea6a4c18c659816b064c9aa93660b1
Fix bogus fix-it for FLT_MAX (PR c/89122)

PR c/89122 reports that we emit a bogus fix-it hint for the case where
the code uses FLT_MAX, but has included <limits.h> rather than <float.h>:

x.c:3:11: error: 'FLT_MAX' undeclared here (not in a function); did you
  mean 'INT_MAX'?
    3 | float f = FLT_MAX;
      |           ^~~~~~~
      |           INT_MAX

This patch adds some knowledge of <float.h> (and <cfloat>) to
known-headers.cc, fixing the issue:

x.c:3:11: error: 'FLT_MAX' undeclared here (not in a function)
    3 | float f = FLT_MAX;
      |           ^~~~~~~
x.c:2:1: note: 'FLT_MAX' is defined in header '<float.h>'; did you forget
  to '#include <float.h>'?
    1 | #include <limits.h>
  +++ |+#include <float.h>
    2 |

gcc/c-family/ChangeLog:
PR c/89122
* known-headers.cc (get_stdlib_header_for_name): Add
{FLT|DBL|LDBL}_{MAX|MIN} to "hints" array.

gcc/testsuite/ChangeLog:
PR c/89122
* g++.dg/spellcheck-stdlib.C (test_FLT_MAX): New test.
* gcc.dg/spellcheck-stdlib.c (test_FLT_MAX): New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268426 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/c-family/ChangeLog
gcc/c-family/known-headers.cc
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/spellcheck-stdlib.C
gcc/testsuite/gcc.dg/spellcheck-stdlib.c