[Bug c++/96063] [10/11 Regression] mismatched-tags warnings in stdlib headers

2020-07-13 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063

--- Comment #18 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Martin Sebor
:

https://gcc.gnu.org/g:5e4c9ebbab7bec3b5994f85aebce13bf37cf46e9

commit r10-8471-g5e4c9ebbab7bec3b5994f85aebce13bf37cf46e9
Author: Martin Sebor 
Date:   Mon Jul 13 09:32:40 2020 -0600

Avoid printing informational notes when -Wmismatched-tags is suppressed in
system headers (PR c++/96063)

Related:
PR c++/96063 - mismatched-tags warnings in stdlib headers

gcc/cp/ChangeLog:

PR c++/96063
* parser.c (class_decl_loc_t::diag_mismatched_tags): Print notes
only
if warning_at returns nonzero.

gcc/testsuite/ChangeLog:

PR c++/96063
* g++.dg/warn/Wmismatched-tags-7.C: New test.
* g++.dg/warn/Wmismatched-tags-8.C: New test.

[Bug c++/96063] [10/11 Regression] mismatched-tags warnings in stdlib headers

2020-07-13 Thread ian.s.mcinerney at ieee dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063

--- Comment #17 from Ian McInerney  ---
I think that r11-1899 is the more important one to backport, since that will
also allow for warnings that are generated by headers inside "-isystem" include
directories to not have the notes printed without the warning.

[Bug c++/96063] [10/11 Regression] mismatched-tags warnings in stdlib headers

2020-07-13 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063

--- Comment #16 from Jonathan Wakely  ---
One or both of r11-1853 and r11-1899 should be backported.

[Bug c++/96063] [10/11 Regression] mismatched-tags warnings in stdlib headers

2020-07-13 Thread ian.s.mcinerney at ieee dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063

--- Comment #15 from Ian McInerney  ---
Martin, can you backport you compiler patch to the GCC10 branch so it is fixed
there as well? As I said, this makes the warning essentially useless to use on
large codebases with the current release.

[Bug c++/96063] [10/11 Regression] mismatched-tags warnings in stdlib headers

2020-07-07 Thread ian.s.mcinerney at ieee dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063

--- Comment #14 from Ian McInerney  ---
Is it possible to backport this to the GCC 10 branch? The printing of these
notes makes this warning almost impossible to use on any large project that
uses the standard library.

[Bug c++/96063] [10/11 Regression] mismatched-tags warnings in stdlib headers

2020-07-07 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063

--- Comment #13 from Martin Sebor  ---
Jon, is there anything else to do here or can we resolve this as fixed?

[Bug c++/96063] [10/11 Regression] mismatched-tags warnings in stdlib headers

2020-07-07 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063

--- Comment #12 from CVS Commits  ---
The master branch has been updated by Martin Sebor :

https://gcc.gnu.org/g:6f9c9ea40a1e937ea1b549625cf7762d4a8a2078

commit r11-1899-g6f9c9ea40a1e937ea1b549625cf7762d4a8a2078
Author: Martin Sebor 
Date:   Tue Jul 7 11:23:50 2020 -0600

Avoid printing informational notes when -Wmismatched-tags is suppressed in
system headers (PR c++/96063)

Related:
PR c++/96063 - mismatched-tags warnings in stdlib headers

gcc/cp/ChangeLog:

PR c++/96063
* parser.c (class_decl_loc_t::diag_mismatched_tags): Print notes
only
if warning_at returns nonzero.

gcc/testsuite/ChangeLog:

PR c++/96063
* g++.dg/warn/Wmismatched-tags-7.C: New test.
* g++.dg/warn/Wmismatched-tags-8.C: New test.

[Bug c++/96063] [10/11 Regression] mismatched-tags warnings in stdlib headers

2020-07-07 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063

Martin Sebor  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #11 from Martin Sebor  ---
Checking the return value is good -- it's also what I did in the patch I
submitted yesterday:
https://gcc.gnu.org/pipermail/gcc-patches/2020-July/549476.html (I had
overlooked your patch in comment #8.)  What I was saying is that taking the
value of a warn_xxx variable as an indication of thew result of a warning()
call is wrong because the former doesn't reflect all the machinations the
warning() call goes through to decide whether or not to issue a warning.

[Bug c++/96063] [10/11 Regression] mismatched-tags warnings in stdlib headers

2020-07-07 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063

--- Comment #10 from Jonathan Wakely  ---
What's wrong with checking the return value of warning_at as in the patch in
comment 8?

[Bug c++/96063] [10/11 Regression] mismatched-tags warnings in stdlib headers

2020-07-06 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063

Martin Sebor  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |msebor at gcc dot 
gnu.org
 Status|REOPENED|ASSIGNED

--- Comment #9 from Martin Sebor  ---
The warning routine checks the warning state and returns without doing anything
when it's set:

  if (!warn_mismatched_tags)
return;

It then calls warning_at() assuming the calls necessarily succeed, and doesn't
check their return value before calling inform().  That only works for global
settings of the warnings but not for local overrides via #pragmas.  Let me fix
it.  Longer term, we need a functional API to query whether warnings are
enabled, one that takes their context into consideration.  Checking the global
variable is almost never right.

[Bug c++/96063] [10/11 Regression] mismatched-tags warnings in stdlib headers

2020-07-06 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063

--- Comment #8 from Jonathan Wakely  ---
Created attachment 48838
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48838&action=edit
Fix orphaned notes.

[Bug c++/96063] [10/11 Regression] mismatched-tags warnings in stdlib headers

2020-07-06 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96063

Jonathan Wakely  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
  Component|libstdc++   |c++
Summary|mismatched-tags warnings in |[10/11 Regression]
   |stdlib headers  |mismatched-tags warnings in
   ||stdlib headers
  Known to fail||10.1.0, 11.0
   Target Milestone|11.0|10.2
 Resolution|FIXED   |---
  Known to work||9.3.0
 CC||msebor at gcc dot gnu.org

--- Comment #7 from Jonathan Wakely  ---
Gah, that's a compiler bug.

Martin, the -Wmismatched-tags warning adds loads of notes which are printed
unconditionally when -Wmismatched-tags is used. They need to be gated on
whether the actual warning is printed, so that you don't get orphaned notes for
warnings that are suppressed due to occurring in system headers.

I've changed the libstdc++ headers on trunk, but not on gcc-10, so you can
still reproduce it easily on that branch.