diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-03-29 20:43:48 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-03-29 20:43:48 +0000 |
commit | 62e98ef1a23b06c939d5fde19ac65d77a5922ccd (patch) | |
tree | 9d01cf6e271276c71032bebae47e9ab8a33c3548 /gcc/c-family/known-headers.cc | |
parent | 1e2b90c4ac0b08279fdfe65c6fab3c49573f236c (diff) | |
download | gcc-62e98ef1a23b06c939d5fde19ac65d77a5922ccd.zip gcc-62e98ef1a23b06c939d5fde19ac65d77a5922ccd.tar.gz gcc-62e98ef1a23b06c939d5fde19ac65d77a5922ccd.tar.bz2 |
More #include suggestions (PR c++/84269)
PR c++/84269 reports a number of names in the C and C++ standard
libraries for which we don't yet offer #include fix-it hints.
This patch adds them (up to comment #9).
gcc/c-family/ChangeLog:
PR c++/84269
* known-headers.cc (get_stdlib_header_for_name): Add various names
from <assert.h>, <string.h>, and <memory.h>; add more names from
<stdio.h>.
gcc/cp/ChangeLog:
PR c++/84269
* name-lookup.c (get_std_name_hint): Add names from <memory>,
<tuple>, and <utility>.
gcc/testsuite/ChangeLog:
PR c++/84269
* g++.dg/lookup/missing-std-include-6.C: New test.
* g++.dg/lookup/missing-std-include.C: Add std::pair and
std::tuple tests.
* g++.dg/spellcheck-reswords.C: Expect a hint about <cstring>.
* g++.dg/spellcheck-stdlib.C: Add tests for names in <cstdio>,
<cstring>, <cassert>, and <cstdlib>.
From-SVN: r258966
Diffstat (limited to 'gcc/c-family/known-headers.cc')
-rw-r--r-- | gcc/c-family/known-headers.cc | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/gcc/c-family/known-headers.cc b/gcc/c-family/known-headers.cc index ef23cbe..5524d21 100644 --- a/gcc/c-family/known-headers.cc +++ b/gcc/c-family/known-headers.cc @@ -57,6 +57,9 @@ get_stdlib_header_for_name (const char *name, enum stdlib lib) gcc_assert (lib < NUM_STDLIBS); static const stdlib_hint hints[] = { + /* <assert.h> and <cassert>. */ + {"assert", {"<assert.h>", "<cassert>"} }, + /* <errno.h> and <cerrno>. */ {"errno", {"<errno.h>", "<cerrno>"} }, @@ -92,16 +95,44 @@ get_stdlib_header_for_name (const char *name, enum stdlib lib) {"size_t", {"<stddef.h>", "<cstddef>"} }, {"wchar_t", {"<stddef.h>", NULL /* a keyword in C++ */} }, - /* <stdio.h>. */ + /* <stdio.h> and <cstdio>. */ {"BUFSIZ", {"<stdio.h>", "<cstdio>"} }, {"EOF", {"<stdio.h>", "<cstdio>"} }, {"FILE", {"<stdio.h>", "<cstdio>"} }, {"FILENAME_MAX", {"<stdio.h>", "<cstdio>"} }, + {"fopen", {"<stdio.h>", "<cstdio>"} }, {"fpos_t", {"<stdio.h>", "<cstdio>"} }, + {"getchar", {"<stdio.h>", "<cstdio>"} }, + {"printf", {"<stdio.h>", "<cstdio>"} }, + {"snprintf", {"<stdio.h>", "<cstdio>"} }, + {"sprintf", {"<stdio.h>", "<cstdio>"} }, {"stderr", {"<stdio.h>", "<cstdio>"} }, {"stdin", {"<stdio.h>", "<cstdio>"} }, {"stdout", {"<stdio.h>", "<cstdio>"} }, + /* <stdlib.h> and <cstdlib>. */ + {"free", {"<stdlib.h>", "<cstdlib>"} }, + {"malloc", {"<stdlib.h>", "<cstdlib>"} }, + {"realloc", {"<stdlib.h>", "<cstdlib>"} }, + + /* <string.h> and <cstring>. */ + {"memchr", {"<string.h>", "<cstring>"} }, + {"memcmp", {"<string.h>", "<cstring>"} }, + {"memcpy", {"<string.h>", "<cstring>"} }, + {"memmove", {"<string.h>", "<cstring>"} }, + {"memset", {"<string.h>", "<cstring>"} }, + {"strcat", {"<string.h>", "<cstring>"} }, + {"strchr", {"<string.h>", "<cstring>"} }, + {"strcmp", {"<string.h>", "<cstring>"} }, + {"strcpy", {"<string.h>", "<cstring>"} }, + {"strlen", {"<string.h>", "<cstring>"} }, + {"strncat", {"<string.h>", "<cstring>"} }, + {"strncmp", {"<string.h>", "<cstring>"} }, + {"strncpy", {"<string.h>", "<cstring>"} }, + {"strrchr", {"<string.h>", "<cstring>"} }, + {"strspn", {"<string.h>", "<cstring>"} }, + {"strstr", {"<string.h>", "<cstring>"} }, + /* <stdint.h>. */ {"PTRDIFF_MAX", {"<stdint.h>", "<cstdint>"} }, {"PTRDIFF_MIN", {"<stdint.h>", "<cstdint>"} }, |