+2020-05-22 Mark Wielaard <mark@klomp.org>
+
+ * known-headers.cc (get_stdlib_header_for_name): Return
+ "<stdbool.h>" for "bool", "true" or "false" when STDLIB_C and
+ flag_isoc99.
+
2020-05-20 Nathan Sidwell <nathan@acm.org>
* c-common.c (try_to_locate_new_include_insertion_point): Revert change.
for (size_t i = 0; i < num_hints; i++)
if (strcmp (name, hints[i].name) == 0)
return hints[i].header[lib];
+
+ /* Only for C99 and higher. */
+ if (lib == STDLIB_C && flag_isoc99)
+ if (strcmp (name, "bool") == 0
+ || strcmp (name, "true") == 0
+ || strcmp (name, "false") == 0)
+ return "<stdbool.h>";
+
return NULL;
}
+2020-05-22 Mark Wielaard <mark@klomp.org>
+
+ * gcc.dg/spellcheck-stdbool.c: New test.
+
2020-05-22 Mark Wielaard <mark@klomp.org>
* gcc.dg/analyzer/signal-exit.c: New testcase.
--- /dev/null
+/* { dg-options "-std=c99" } */
+/* Missing <stdbool.h>. */
+
+bool b; /* { dg-error "unknown type name 'bool'" } */
+/* { dg-message "'bool' is defined in header '<stdbool.h>'; did you forget to '#include <stdbool.h>'?" "" { target *-*-* } .-1 } */
+
+int test_true (void)
+{
+ return true; /* { dg-error "'true' undeclared" } */
+ /* { dg-message "'true' is defined in header '<stdbool.h>'; did you forget to '#include <stdbool.h>'?" "" { target *-*-* } .-1 } */
+}
+
+int test_false (void)
+{
+ return false; /* { dg-error "'false' undeclared" } */
+ /* { dg-message "'false' is defined in header '<stdbool.h>'; did you forget to '#include <stdbool.h>'?" "" { target *-*-* } .-1 } */
+}