Suggest including <stdbool.h> for bool, true and false
authorMark Wielaard <mark@klomp.org>
Tue, 19 May 2020 21:18:09 +0000 (23:18 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 22 May 2020 21:21:56 +0000 (23:21 +0200)
commit45c50b6a63a120d3eb6957883c4c7b968c84d010
tree1448d767725d0846fda35da6d62253fbde7d31e4
parent72af65b91cc2a2eb726afe56af6b44d6c57bb10f
Suggest including <stdbool.h> for bool, true and false

Currently gcc suggests to use _Bool instead of bool and doesn't give
any suggestions when true or false are used, but undefined. This patch
makes it so that (for C99 or higher) a fixit hint is emitted to include
<stdbool.h>.

gcc/c-family/ChangeLog:

* known-headers.cc (get_stdlib_header_for_name): Return
"<stdbool.h>" for "bool", "true" or "false" when STDLIB_C and
flag_isoc99.

gcc/testsuite/ChangeLog:

* gcc.dg/spellcheck-stdbool.c: New test.
gcc/c-family/ChangeLog
gcc/c-family/known-headers.cc
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/spellcheck-stdbool.c [new file with mode: 0644]