]> git.ipfire.org Git - thirdparty/gcc.git/commit - libcpp/ChangeLog
Spelling suggestions for misspelled preprocessor directives
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 18 Aug 2016 18:52:43 +0000 (18:52 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Thu, 18 Aug 2016 18:52:43 +0000 (18:52 +0000)
commitcb18fd07f2962779c2651adc970541210d4ad98f
treeb325fd07e1c9c2f08551326602a989303e28ddfd
parenta76989dc7c9236214856db196da88a739f0e7baa
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
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c-family/c-lex.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/misspelled-directive-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/misspelled-directive-2.c [new file with mode: 0644]
libcpp/ChangeLog
libcpp/directives.c
libcpp/errors.c
libcpp/include/cpplib.h