[Bug c++/62314] Fix-it Hints
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62314 David Malcolm changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #9 from David Malcolm --- (In reply to David Malcolm from comment #4) > Keeping this bug open, since it has lots of examples of fix-it hints that we > could provide. Closing this one out; other ideas for fix-it hints should be tracked individually as separate bugs.
[Bug c++/62314] Fix-it Hints
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62314 --- Comment #8 from David Malcolm --- Author: dmalcolm Date: Tue Jul 5 15:50:54 2016 New Revision: 238008 URL: https://gcc.gnu.org/viewcvs?rev=238008&root=gcc&view=rev Log: PR c++/62314: add fixit hint for "expected ';' after class definition" gcc/cp/ChangeLog: PR c++/62314 * parser.c (cp_parser_class_specifier_1): When reporting missing semicolons, use a fixit-hint to suggest insertion of a semicolon immediately after the closing brace, offsetting the reported column accordingly. gcc/testsuite/ChangeLog: PR c++/62314 * gcc/testsuite/g++.dg/parse/error5.C: Update column number of missing semicolon error. * g++.dg/pr62314-2.C: New test case. Added: trunk/gcc/testsuite/g++.dg/pr62314-2.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/parser.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/parse/error5.C
[Bug c++/62314] Fix-it Hints
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62314 --- Comment #7 from David Malcolm --- Author: dmalcolm Date: Mon May 2 19:09:30 2016 New Revision: 235785 URL: https://gcc.gnu.org/viewcvs?rev=235785&root=gcc&view=rev Log: PR c++/62314: C++: add fixit hint to misspelled member names When we emit a hint about a misspelled member name, it will slightly aid readability if we use a fixit-hint to show the proposed name in context within the source code (and in the future this might support some kind of auto-apply in an IDE). This patch adds such a hint to the C++ frontend, taking us from: test.cc:10:15: error: 'struct foo' has no member named 'colour'; did you mean 'color'? return ptr->colour; ^~ to: test.cc:10:15: error: 'struct foo' has no member named 'colour'; did you mean 'color'? return ptr->colour; ^~ color gcc/cp/ChangeLog: PR c++/62314 * typeck.c (finish_class_member_access_expr): When giving a hint about a possibly-misspelled member name, add a fix-it replacement hint. gcc/testsuite/ChangeLog: PR c++/62314 * g++.dg/spellcheck-fields-2.C: New test case. Added: trunk/gcc/testsuite/g++.dg/spellcheck-fields-2.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog
[Bug c++/62314] Fix-it Hints
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62314 --- Comment #6 from David Malcolm --- Author: dmalcolm Date: Mon May 2 18:36:40 2016 New Revision: 235777 URL: https://gcc.gnu.org/viewcvs?rev=235777&root=gcc&view=rev Log: PR c++/62314: add fixit hint for missing "template <> " in explicit specialization gcc/cp/ChangeLog: PR c++/62314 * parser.c (cp_parser_class_head): Capture the start location; use it to emit a fix-it insertion hint when complaining about missing "template <> " in explicit specializations. gcc/testsuite/ChangeLog: PR c++/62314 * g++.dg/pr62314.C: New test case. Added: trunk/gcc/testsuite/g++.dg/pr62314.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/parser.c trunk/gcc/testsuite/ChangeLog
[Bug c++/62314] Fix-it Hints
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62314 David Malcolm changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2016-04-28 Assignee|unassigned at gcc dot gnu.org |dmalcolm at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #5 from David Malcolm --- Updated patch kit posted as: https://gcc.gnu.org/ml/gcc-patches/2016-04/msg01835.html
[Bug c++/62314] Fix-it Hints
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62314 --- Comment #4 from David Malcolm --- I've committed support for fix-it hints within diagnostics to trunk (for gcc 6) as r230674 (along with one trivial example of a fix-it hint in the C frontend). Keeping this bug open, since it has lots of examples of fix-it hints that we could provide.
[Bug c++/62314] Fix-it Hints
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62314 --- Comment #3 from David Malcolm --- Author: dmalcolm Date: Fri Nov 20 20:08:47 2015 New Revision: 230674 URL: https://gcc.gnu.org/viewcvs?rev=230674&root=gcc&view=rev Log: PR 62314: add ability to add fixit-hints to a diagnostic This is the combination of two patches: [PATCH 01/02] PR/62314: add ability to add fixit-hints [PATCH 02/02] C FE: add fix-it hint for . vs -> gcc/ChangeLog: PR 62314 * diagnostic-show-locus.c (colorizer::set_fixit_hint): New. (class layout): Update comment (layout::print_any_fixits): New method. (layout::move_to_column): New method. (diagnostic_show_locus): Add call to layout.print_any_fixits. gcc/c/ChangeLog: PR 62314 * c-typeck.c (should_suggest_deref_p): New function. (build_component_ref): Special-case POINTER_TYPE when generating a "not a structure of union" error message, and suggest a "->" rather than a ".", providing a fix-it hint. gcc/testsuite/ChangeLog: PR 62314 * gcc.dg/fixits.c: New file. * gcc.dg/plugin/diagnostic-test-show-locus-ascii-bw.c (test_fixit_insert): New. (test_fixit_remove): New. (test_fixit_replace): New. * gcc.dg/plugin/diagnostic-test-show-locus-ascii-color.c (test_fixit_insert): New. (test_fixit_remove): New. (test_fixit_replace): New. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (test_show_locus): Add tests of rendering fixit hints. libcpp/ChangeLog: PR 62314 * include/line-map.h (source_range::intersects_line_p): New method. (rich_location::~rich_location): New. (rich_location::add_fixit_insert): New method. (rich_location::add_fixit_remove): New method. (rich_location::add_fixit_replace): New method. (rich_location::get_num_fixit_hints): New accessor. (rich_location::get_fixit_hint): New accessor. (rich_location::MAX_FIXIT_HINTS): New constant. (rich_location::m_num_fixit_hints): New field. (rich_location::m_fixit_hints): New field. (class fixit_hint): New class. (class fixit_insert): New class. (class fixit_remove): New class. (class fixit_replace): New class. * line-map.c (source_range::intersects_line_p): New method. (rich_location::rich_location): Add initialization of m_num_fixit_hints to both ctors. (rich_location::~rich_location): New. (rich_location::add_fixit_insert): New method. (rich_location::add_fixit_remove): New method. (rich_location::add_fixit_replace): New method. (fixit_insert::fixit_insert): New. (fixit_insert::~fixit_insert): New. (fixit_insert::affects_line_p): New. (fixit_remove::fixit_remove): New. (fixit_remove::affects_line_p): New. (fixit_replace::fixit_replace): New. (fixit_replace::~fixit_replace): New. (fixit_replace::affects_line_p): New. Added: trunk/gcc/testsuite/gcc.dg/fixits.c Modified: trunk/gcc/ChangeLog trunk/gcc/c/ChangeLog trunk/gcc/c/c-typeck.c trunk/gcc/diagnostic-show-locus.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-bw.c trunk/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-color.c trunk/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c trunk/libcpp/ChangeLog trunk/libcpp/include/line-map.h trunk/libcpp/line-map.c
[Bug c++/62314] Fix-it Hints
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62314 David Malcolm changed: What|Removed |Added CC||dmalcolm at gcc dot gnu.org --- Comment #2 from David Malcolm --- I had a go at implementing fixit-hints here: https://gcc.gnu.org/ml/gcc-patches/2015-09/msg00732.html and: https://gcc.gnu.org/ml/gcc-patches/2015-09/msg00747.html
[Bug c++/62314] Fix-it Hints
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62314 --- Comment #1 from Manuel López-Ibáñez --- There are other examples here: http://clang.llvm.org/docs/InternalsManual.html#fix-it-hints