Add support for mutually-incompatible fix-it hints

Programming / Compilers / GCC - dmalcolm [138bc75d-0d04-0410-961f-82ee72b054a4] - 9 June 2017 16:57 EDT

This patch adds a method: rich_location::fixits_cannot_be_auto_applied for ensuring that mutually-incompatible fix-its hints don't lead to insane output from -fdiagnostics-generate-patch.

Fix-it hints within such rich_location instances are printed as normal by diagnostic_show_locus, but don't affect the output of -fdiagnostics-generate-patch.

gcc/ChangeLog:
- diagnostic.c (diagnostic_report_diagnostic): Only add fixits to the edit_context if they can be auto-applied.

gcc/testsuite/ChangeLog:
- gcc.dg/plugin/diagnostic-test-show-locus-bw.c (test_mutually_exclusive_suggestions): New test function.
- gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c (test_mutually_exclusive_suggestions): New test function.
- gcc.dg/plugin/diagnostic-test-show-locus-parseable-fixits.c (test_mutually_exclusive_suggestions): New test function.
- gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (test_show_locus): Add special-case for "test_mutually_exclusive_suggestions".

libcpp/ChangeLog:
- include/line-map.h (rich_location::fixits_cannot_be_auto_applied): New method. (rich_location::fixits_can_be_auto_applied_p): New accessor. (rich_location::m_fixits_cannot_be_auto_applied): New field.
- line-map.c (rich_location::rich_location): Initialize new field.

112ca2a Add support for mutually-incompatible fix-it hints
gcc/ChangeLog | 5 +++++
gcc/diagnostic.c | 3 ++-
gcc/testsuite/ChangeLog | 12 +++++++++++
.../gcc.dg/plugin/diagnostic-test-show-locus-bw.c | 20 ++++++++++++++++++
.../diagnostic-test-show-locus-generate-patch.c | 13 ++++++++++++
.../diagnostic-test-show-locus-parseable-fixits.c | 14 +++++++++++++
.../plugin/diagnostic_plugin_test_show_locus.c | 24 ++++++++++++++++++++++
libcpp/ChangeLog | 8 ++++++++
libcpp/include/line-map.h | 22 ++++++++++++++++++++
libcpp/line-map.c | 3 ++-
10 files changed, 122 insertions(+), 2 deletions(-)

Upstream: gcc.gnu.org


  • Share