diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-07-20 14:03:03 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-07-20 14:03:03 +0000 |
commit | 7c8f7eaa75d53ca642203178fb2c6bbe800bc2ea (patch) | |
tree | 4295610e81aed46c2605b630ee7f4d3963766ac1 /gcc/diagnostic-show-locus.c | |
parent | 7419f4417a33ff9143317794aa985f7681d1e2a0 (diff) | |
download | gcc-7c8f7eaa75d53ca642203178fb2c6bbe800bc2ea.tar.gz |
Enabling work for C++ handling of misspelled identifiers and typenames
gcc/c/ChangeLog:
* c-decl.c (struct edit_distance_traits<cpp_hashnode *>): Move to
spellcheck-tree.h
(best_macro_match): Likewise, converting from a typedef to a
subclass.
(find_closest_macro_cpp_cb): Move to spellcheck-tree.c.
(lookup_name_fuzzy): Update for change of best_macro_match to a
subclass with a ctor that calls cpp_forall_identifiers.
gcc/ChangeLog:
* diagnostic-show-locus.c (diagnostic_show_locus): If this is the
same location as last time, don't skip if we have fix-it hints.
Clarify the skipping logic by converting it from one "if" clause
to repeated "if" clauses.
* spellcheck-tree.c: Include "cpplib.h".
(find_closest_macro_cpp_cb): Move here from c/c-decl.c.
(best_macro_match::best_macro_match): New constructor.
* spellcheck-tree.h (struct edit_distance_traits<cpp_hashnode *>):
Move here from c/c-decl.c.
(class best_macro_match): Move here from c/c-decl.c, converting
from a typedef to a subclass, gaining a ctor.
From-SVN: r238522
Diffstat (limited to 'gcc/diagnostic-show-locus.c')
-rw-r--r-- | gcc/diagnostic-show-locus.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c index 7aab658b697..49f7f119782 100644 --- a/gcc/diagnostic-show-locus.c +++ b/gcc/diagnostic-show-locus.c @@ -1280,9 +1280,18 @@ diagnostic_show_locus (diagnostic_context * context, { pp_newline (context->printer); - if (!context->show_caret - || diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION - || diagnostic_location (diagnostic, 0) == context->last_location) + /* Do nothing if source-printing has been disabled. */ + if (!context->show_caret) + return; + + /* Don't attempt to print source for UNKNOWN_LOCATION and for builtins. */ + if (diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION) + return; + + /* Don't print the same source location twice in a row, unless we have + fix-it hints. */ + if (diagnostic_location (diagnostic, 0) == context->last_location + && diagnostic->richloc->get_num_fixit_hints () == 0) return; context->last_location = diagnostic_location (diagnostic, 0); |