diagnostic_show_locus can sometimes do the wrong thing when handling expressions built up from macros. PR c++/70105 (currently marked as a P3 regression) has an example of a diagnostic where over 500 lines of irrelevant source are printed, and underlined, giving >1000 lines of useless spew to stderr. This patch adds extra sanitization to diagnostic-show-locus.c, so that we only attempt to print underlines and secondary locations if such locations are "sufficiently sane" relative to the primary location of a diagnostic. This "sufficiently sane" condition is implemented by a new helper function compatible_locations_p, which requires such locations to have the same macro expansion hierarchy as the primary location, using linemap_macro_map_loc_unwind_toward_spelling, effectively mimicing the expansion performed by LRK_SPELLING_LOCATION. This may be too strong a condition, but it effectively fixes PR c++/70105, without removing any underlines in my testing. Successfully bootstrapped®rtested in combination with the previous patch on x86_64-pc-linux-gnu; adds 15 new PASS results to g++.sum and 4 new PASS results to gcc.sum. gcc/ChangeLog: PR c/68473 PR c++/70105 * diagnostic-show-locus.c (compatible_locations_p): New function. (layout::layout): Sanitize ranges using compatible_locations_p. gcc/testsuite/ChangeLog: PR c/68473 PR c++/70105 * g++.dg/diagnostic/pr70105.C: New test. * gcc.dg/plugin/diagnostic-test-expressions-1.c (foo): New decl. (test_multiple_ordinary_maps): New test function. libcpp/ChangeLog: PR c/68473 PR c++/70105 * line-map.c (linemap_macro_map_loc_unwind_toward_spelling): Move decl... * include/line-map.h (linemap_macro_map_loc_unwind_toward_spelling): ...here, converting from static to extern. From-SVN: r234088
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
diagnostic-test-expressions-1.c | Loading commit data... | |
diagnostic-test-show-locus-bw.c | Loading commit data... | |
diagnostic-test-show-locus-color.c | Loading commit data... | |
diagnostic-test-show-trees-1.c | Loading commit data... | |
diagnostic_plugin_show_trees.c | Loading commit data... | |
diagnostic_plugin_test_show_locus.c | Loading commit data... | |
diagnostic_plugin_test_tree_expression_range.c | Loading commit data... | |
finish_unit-test-1.c | Loading commit data... | |
finish_unit_plugin.c | Loading commit data... | |
ggcplug-test-1.c | Loading commit data... | |
ggcplug.c | Loading commit data... | |
levenshtein-test-1.c | Loading commit data... | |
levenshtein_plugin.c | Loading commit data... | |
location-overflow-test-1.c | Loading commit data... | |
location-overflow-test-2.c | Loading commit data... | |
location_overflow_plugin.c | Loading commit data... | |
one_time-test-1.c | Loading commit data... | |
one_time_plugin.c | Loading commit data... | |
plugin.exp | Loading commit data... | |
plugindir1.c | Loading commit data... | |
plugindir2.c | Loading commit data... | |
plugindir3.c | Loading commit data... | |
plugindir4.c | Loading commit data... | |
self-assign-test-1.c | Loading commit data... | |
self-assign-test-2.c | Loading commit data... | |
selfassign.c | Loading commit data... | |
sreal-test-1.c | Loading commit data... | |
sreal_plugin.c | Loading commit data... | |
start_unit-test-1.c | Loading commit data... | |
start_unit_plugin.c | Loading commit data... | |
wide-int-test-1.c | Loading commit data... | |
wide-int_plugin.c | Loading commit data... |