diagnostic: avoid repeating include path
authorJason Merrill <jason@redhat.com>
Fri, 17 Dec 2021 10:45:02 +0000 (05:45 -0500)
committerJason Merrill <jason@redhat.com>
Mon, 17 Jan 2022 16:58:12 +0000 (11:58 -0500)
commitd3a57993359c9759990fe8f2aa4088684ed82190
tree82399b3aeabcffc665f0808ade49811306a04557
parent450c85b81f4dd67bf6211d307afdc0f3c07ef44f
diagnostic: avoid repeating include path

When a sequence of diagnostic messages bounces back and forth repeatedly
between two includes, as with

 #include <map>
 std::map<const char*, const char*> m ("123", "456");

The output is quite a bit longer than necessary because we dump the include
path each time it changes.  I'd think we could print the include path once
for each header file, and then expect that the user can look earlier in the
output if they're wondering.

gcc/ChangeLog:

* diagnostic.h (struct diagnostic_context): Add includes_seen.
* diagnostic.c (diagnostic_initialize): Initialize it.
(diagnostic_finish): Clean it up.
(includes_seen): New function.
(diagnostic_report_current_module): Use it.

gcc/testsuite/ChangeLog:

* c-c++-common/cpp/line-2.c: Only expect includes once.
* c-c++-common/cpp/line-3.c: Likewise.
gcc/diagnostic.c
gcc/diagnostic.h
gcc/testsuite/c-c++-common/cpp/line-2.c
gcc/testsuite/c-c++-common/cpp/line-3.c