This is the mail archive of the
mailing list for the GCC project.
Re: [C/C++ PATCH] Add -Wlogical-not-parentheses (PR c/49706)
- From: Jason Merrill <jason at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Mon, 02 Jun 2014 10:08:24 -0400
- Subject: Re: [C/C++ PATCH] Add -Wlogical-not-parentheses (PR c/49706)
- Authentication-results: sourceware.org; auth=none
- References: <20140602065052 dot GE31671 at redhat dot com>
On 06/02/2014 02:50 AM, Marek Polacek wrote:
+ && TREE_CODE (arg1.value) == EQ_EXPR)
+ && TREE_CODE (current.lhs) == EQ_EXPR
It seems like your version only warns about ==, while the clang version
warns about all comparisons.
+ && (complain_flags (decltype_p) & tf_warning)
Let's not call complain_flags multiple times in the function. In fact
this will always be true, so you could just drop it.
Also for C++, I think we don't want this warning to trigger when the
operator (==, !=, >, <, <=, >=) is overloaded. But I admit
I haven't even tried that, and I don't know how to detect overloaded
operators except DECL_OVERLOADED_OPERATOR_P.
Overloaded operators have the same precedence, so I think it's
appropriate to give the warning whether or not the operators are overloaded.