aboutsummaryrefslogtreecommitdiff
path: root/libcpp/include/cpplib.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-08-18 18:52:43 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-08-18 18:52:43 +0000
commitcb18fd07f2962779c2651adc970541210d4ad98f (patch)
treeb325fd07e1c9c2f08551326602a989303e28ddfd /libcpp/include/cpplib.h
parenta76989dc7c9236214856db196da88a739f0e7baa (diff)
downloadgcc-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 'libcpp/include/cpplib.h')
-rw-r--r--libcpp/include/cpplib.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 659686b..a497811 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -597,6 +597,9 @@ struct cpp_callbacks
/* Callback to parse SOURCE_DATE_EPOCH from environment. */
time_t (*get_source_date_epoch) (cpp_reader *);
+
+ /* Callback for providing suggestions for misspelled directives. */
+ const char *(*get_suggestion) (cpp_reader *, const char *, const char *const *);
};
#ifdef VMS
@@ -1066,6 +1069,11 @@ extern bool cpp_error_at (cpp_reader * pfile, int level,
source_location src_loc, const char *msgid, ...)
ATTRIBUTE_PRINTF_4;
+extern bool cpp_error_at_richloc (cpp_reader * pfile, int level,
+ rich_location *richloc, const char *msgid,
+ ...)
+ ATTRIBUTE_PRINTF_4;
+
/* In lex.c */
extern int cpp_ideq (const cpp_token *, const char *);
extern void cpp_output_line (cpp_reader *, FILE *);