This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50012] [4.5/4.6/4.7 Regression] C++ front end misses -Wsign-compare warnings when extraneous parentheses are present
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 19 Dec 2011 14:43:05 +0000
- Subject: [Bug c++/50012] [4.5/4.6/4.7 Regression] C++ front end misses -Wsign-compare warnings when extraneous parentheses are present
- Auto-submitted: auto-generated
- References: <bug-50012-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50012
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-12-19 14:43:05 UTC ---
This has been introduced with
http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01402.html
which has been written as a better way of:
http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01393.html
Perhaps the older patch is a better way than this one, which, if I understand
it right, is that ignoring of the promotion at the -Wsign-compare handling
spot?
Setting TREE_NO_WARNING, at least until we have a way to say which warnings we
want to prohibit and which should be kept, is an ugly hack and shouldn't be
taken lightly.
While Ian's patch doesn't set TREE_NO_WARNING in this testcase, it just
disables the warning if any of the operands is TREE_NO_WARNING and uses this
bit for yet another purpose. The TREE_NO_WARNING bit in this case is set by
finish_parenthesized_expr:
1504 if (EXPR_P (expr))
1505 /* This inhibits warnings in c_common_truthvalue_conversion. */
1506 TREE_NO_WARNING (expr) = 1;
So, what was wrong with the first approach?
And, perhaps for 4.8 we want to turn TREE_NO_WARNING bit into a bit that just
tells us whether that tree in question is in some hash table (see e.g.
DECL_HAS_VALUE_EXPR_P etc.) and that hash table would contain details what
warnings are we supposed to ignore. This isn't the only problematic spot.