diagnostics: fix excessive range-printing involving macros [PR97932]
PR c/97932 describes a bug in which diagnostic_show_locus prints most
of a source file.
The issue is that it prints a range in which the start and end locations
are part of the same macro map, but the start location is for a token in
the definition of the macro, whereas the end location is for a token in
an argument of the macro.
This patch extends compatible_locations_p to require that range-printing
of macro maps requires the location to either be both for the definition
of the macro, or both for the arguments of the macro (not one of each),
fixing the issue.
gcc/ChangeLog:
PR c/97932
* diagnostic-show-locus.c (compatible_locations_p): Require
locations in the same macro map to be either both from the
macro definition, or both from the macro arguments.
gcc/testsuite/ChangeLog:
PR c/97932
* gcc.dg/pr97932.c: New test.