diff options
author | David Malcolm <dmalcolm@redhat.com> | 2017-11-21 00:46:24 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2017-11-21 00:46:24 +0000 |
commit | b1212255558f0a4a398c7314f92effe4dbdcfec2 (patch) | |
tree | 21b4a30929c43eb96e39856f306ac8ee9bdbcf69 /gcc/c/ChangeLog | |
parent | 01ada12136c64ad9ff305f456637d43b9f6d4356 (diff) | |
download | gcc-b1212255558f0a4a398c7314f92effe4dbdcfec2.zip gcc-b1212255558f0a4a398c7314f92effe4dbdcfec2.tar.gz gcc-b1212255558f0a4a398c7314f92effe4dbdcfec2.tar.bz2 |
C: hints for missing stdlib includes for macros and types
The C frontend already "knows" about many common functions in
the C standard library:
test.c: In function 'test':
test.c:3:3: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
printf ("hello world\n");
^~~~~~
test.c:3:3: warning: incompatible implicit declaration of built-in function 'printf'
test.c:3:3: note: include '<stdio.h>' or provide a declaration of 'printf'
and which header file they are in.
However it doesn't know about various types and macros:
test.c:1:13: error: 'NULL' undeclared here (not in a function)
void *ptr = NULL;
^~~~
This patch uses the name_hint/deferred_diagnostic machinery to
add hints for missing C standard library headers for some of the
most common type and macro names.
For example, the above becomes:
test.c:1:13: error: 'NULL' undeclared here (not in a function)
void *ptr = NULL;
^~~~
test.c:1:13: note: 'NULL' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
gcc/c/ChangeLog:
* c-decl.c (get_c_name_hint): New function.
(class suggest_missing_header): New class.
(lookup_name_fuzzy): Call get_c_name_hint and use it to
suggest missing headers to the user.
gcc/testsuite/ChangeLog:
* gcc.dg/spellcheck-stdlib.c: New test case.
From-SVN: r254979
Diffstat (limited to 'gcc/c/ChangeLog')
-rw-r--r-- | gcc/c/ChangeLog | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 6e19393..b60a8e7 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,5 +1,12 @@ 2017-11-20 David Malcolm <dmalcolm@redhat.com> + * c-decl.c (get_c_name_hint): New function. + (class suggest_missing_header): New class. + (lookup_name_fuzzy): Call get_c_name_hint and use it to + suggest missing headers to the user. + +2017-11-20 David Malcolm <dmalcolm@redhat.com> + * c-decl.c: Define INCLUDE_UNIQUE_PTR before including system.h. Include "c-family/name-hint.h" (implicit_decl_warning): Convert "hint" from |