diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-08-18 18:52:43 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-08-18 18:52:43 +0000 |
commit | cb18fd07f2962779c2651adc970541210d4ad98f (patch) | |
tree | b325fd07e1c9c2f08551326602a989303e28ddfd /gcc/c-family/c-common.h | |
parent | a76989dc7c9236214856db196da88a739f0e7baa (diff) | |
download | gcc-cb18fd07f2962779c2651adc970541210d4ad98f.zip gcc-cb18fd07f2962779c2651adc970541210d4ad98f.tar.gz gcc-cb18fd07f2962779c2651adc970541210d4ad98f.tar.bz2 |
Spelling suggestions for misspelled preprocessor directives
This patch allows the preprocessor to offer suggestions for misspelled
directives, taking us from e.g.:
test.c:5:2: error: invalid preprocessing directive #endfi
#endfi
^~~~~
to:
test.c:5:2: error: invalid preprocessing directive #endfi; did you mean #endif?
#endfi
^~~~~
endif
gcc/c-family/ChangeLog:
* c-common.c: Include "spellcheck.h".
(cb_get_suggestion): New function.
* c-common.h (cb_get_suggestion): New decl.
* c-lex.c (init_c_lex): Initialize cb->get_suggestion to
cb_get_suggestion.
gcc/testsuite/ChangeLog:
* gcc.dg/cpp/misspelled-directive-1.c: New testcase.
* gcc.dg/cpp/misspelled-directive-2.c: New testcase.
libcpp/ChangeLog:
* directives.c (directive_names): New array.
(_cpp_handle_directive): Offer spelling suggestions for misspelled
directives.
* errors.c (cpp_diagnostic_at_richloc): New function.
(cpp_error_at_richloc): New function.
* include/cpplib.h (struct cpp_callbacks): Add field
"get_suggestion".
(cpp_error_at_richloc): New decl.
From-SVN: r239585
Diffstat (limited to 'gcc/c-family/c-common.h')
-rw-r--r-- | gcc/c-family/c-common.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 4673123..31320bf 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1110,6 +1110,11 @@ extern time_t cb_get_source_date_epoch (cpp_reader *pfile); __TIME__ can store. */ #define MAX_SOURCE_DATE_EPOCH HOST_WIDE_INT_C (253402300799) +/* Callback for libcpp for offering spelling suggestions for misspelled + directives. */ +extern const char *cb_get_suggestion (cpp_reader *, const char *, + const char *const *); + extern GTY(()) string_concat_db *g_string_concat_db; /* libcpp can calculate location information about a range of characters |