[Bug c++/118392] "-w" fails to fully inhibit "'void a::b()' has not been declared within a" warning

2025-05-05 Thread simartin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118392

Simon Martin  changed:

   What|Removed |Added

  Known to work||16.0
   Target Milestone|--- |16.0
 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #7 from Simon Martin  ---
Fixed in GCC 16; won't backport.

[Bug c++/118392] "-w" fails to fully inhibit "'void a::b()' has not been declared within a" warning

2025-05-05 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118392

--- Comment #6 from GCC Commits  ---
The master branch has been updated by Simon Martin :

https://gcc.gnu.org/g:0f1d55a75b09c13e3db09654c2b5aaad5741262f

commit r16-383-g0f1d55a75b09c13e3db09654c2b5aaad5741262f
Author: Simon Martin 
Date:   Mon May 5 10:12:08 2025 +0200

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.

[Bug c++/118392] "-w" fails to fully inhibit "'void a::b()' has not been declared within a" warning

2025-01-12 Thread simartin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118392

--- Comment #5 from Simon Martin  ---
Patch submitted in
https://gcc.gnu.org/pipermail/gcc-patches/2025-January/673394.html

[Bug c++/118392] "-w" fails to fully inhibit "'void a::b()' has not been declared within a" warning

2025-01-09 Thread simartin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118392

Simon Martin  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |simartin at gcc dot 
gnu.org

--- Comment #4 from Simon Martin  ---
Working on it through bug #118163

[Bug c++/118392] "-w" fails to fully inhibit "'void a::b()' has not been declared within a" warning

2025-01-09 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118392

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2025-01-10
 Ever confirmed|0   |1

--- Comment #3 from Andrew Pinski  ---
Confirmed.

[Bug c++/118392] "-w" fails to fully inhibit "'void a::b()' has not been declared within a" warning

2025-01-09 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118392

--- Comment #2 from Andrew Pinski  ---
Created attachment 60087
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60087&action=edit
testcase

Next time please attach or paste inline the testcase.

Note attaching has a way to paste into a field instead of needing to attach via
a file.

[Bug c++/118392] "-w" fails to fully inhibit "'void a::b()' has not been declared within a" warning

2025-01-09 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118392

--- Comment #1 from Andrew Pinski  ---
There is auto_diagnostic_group but it looks like it is not working. 


  if (hidden_p)
{
  auto_diagnostic_group d;
  pedwarn (DECL_SOURCE_LOCATION (decl), 0,
   "%qD has not been declared within %qD", decl, scope);
  inform (DECL_SOURCE_LOCATION (found),
  "only here as a %");
}