diff options
author | Simon Martin <simon@nasilyan.com> | 2025-05-05 10:12:08 +0200 |
---|---|---|
committer | Simon Martin <simon@nasilyan.com> | 2025-05-05 10:26:13 +0200 |
commit | 0f1d55a75b09c13e3db09654c2b5aaad5741262f (patch) | |
tree | b7bcf96734f3458a562ae74685c7ca9cc5543a0b /libstdc++-v3/include/std/numeric | |
parent | 7eeb28717b27d5e3786387b35859bbc5d78ed6b6 (diff) | |
download | gcc-0f1d55a75b09c13e3db09654c2b5aaad5741262f.zip gcc-0f1d55a75b09c13e3db09654c2b5aaad5741262f.tar.gz gcc-0f1d55a75b09c13e3db09654c2b5aaad5741262f.tar.bz2 |
c++: Inhibit subsequent warnings/notes in diagnostic_groups with an inhibited warning [PR118163,PR118392]
Those 2 PRs show that even when using a *single* diagnostic_group, it's
possible to end up with a warning being inhibited and its associated
note still emitted, which leads to puzzling user experience. Example
from PR118392:
===
$ gcc/cc1plus inhibit-warn-3.C -w
inhibit-warn-3.C:10:17: note: only here as a ‘friend’
10 | friend void bar();
| ^~~
===
Following a suggestion from ppalka@, this patch keeps track of the
"diagnostic depth" at which a warning in inhibited, and makes sure that
all subsequent notes at that depth or deeper are inhibited as well,
until a subsequent warning or error is accepted at that depth, or the
diagnostic_group or nesting level is popped.
PR c++/118163
PR c++/118392
gcc/ChangeLog:
* diagnostic.cc (diagnostic_context::initialize): Initialize
m_diagnostic_groups.m_inhibiting_notes_from.
(diagnostic_context::inhibit_notes_in_group): New.
(diagnostic_context::notes_inhibited_in_group): New
(diagnostic_context::report_diagnostic): Call
inhibit_notes_in_group and notes_inhibited_in_group.
(diagnostic_context::end_group): Call inhibit_notes_in_group.
(diagnostic_context::pop_nesting_level): Ditto.
* diagnostic.h (diagnostic_context::m_diagnostic_groups): Add
member to track the depth at which a warning has been inhibited.
(diagnostic_context::notes_inhibited_in_group): Declare.
(diagnostic_context::inhibit_notes_in_group): Declare.
* doc/ux.texi: Document diagnostic_group behavior with regards
to inhibited warnings.
gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/incomplete-type-2.C: New test.
* g++.dg/diagnostic/incomplete-type-2a.C: New test.
* g++.dg/diagnostic/inhibit-warn-3.C: New test.
Diffstat (limited to 'libstdc++-v3/include/std/numeric')
0 files changed, 0 insertions, 0 deletions