diagnostics: Fix macro tracking for ad-hoc locations
authorLewis Hyatt <lhyatt@gmail.com>
Tue, 1 Nov 2022 21:50:27 +0000 (17:50 -0400)
committerLewis Hyatt <lhyatt@gmail.com>
Tue, 15 Nov 2022 15:50:23 +0000 (10:50 -0500)
commit6238cc20f0e588f272569230b33458fedf755ab2
tree300f206677cf5b7b0739d258452779dd8c188f1c
parent3037f11fb86eda234a27ab26748958f71a805005
diagnostics: Fix macro tracking for ad-hoc locations

The result of linemap_resolve_location() can be an ad-hoc location, if that is
what was stored in a relevant macro map.  maybe_unwind_expanded_macro_loc()
did not previously handle this case, causing it to print the wrong tracking
information for an example such as the new testcase macro-trace-1.c.  Fix that
by checking for ad-hoc locations where needed.

gcc/ChangeLog:

* tree-diagnostic.cc (maybe_unwind_expanded_macro_loc): Handle ad-hoc
location in return value of linemap_resolve_location().

gcc/testsuite/ChangeLog:

* c-c++-common/cpp/macro-trace-1.c: New test.
gcc/testsuite/c-c++-common/cpp/macro-trace-1.c [new file with mode: 0644]
gcc/tree-diagnostic.cc