This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix bogus warning with -Wlogical-not-parentheses (PR c/77292)


On Fri, Aug 26, 2016 at 10:57 AM, Marek Polacek <polacek@redhat.com> wrote:
> On Fri, Aug 26, 2016 at 10:53:01AM +0200, Richard Biener wrote:
>> On Thu, Aug 25, 2016 at 3:39 PM, Marek Polacek <polacek@redhat.com> wrote:
>> > On Thu, Aug 25, 2016 at 11:17:37AM +0200, Richard Biener wrote:
>> >> On Wed, Aug 24, 2016 at 7:43 PM, Marek Polacek <polacek@redhat.com> wrote:
>> >> > The -Wlogical-not-parentheses deliberately doesn't warn when the RHS has
>> >> > boolean type.  But since in C the type of a comparison is int, we need
>> >> > to check for tcc_comparison, too.
>> >> >
>> >> > Bootstrapped/regtested on x86_64-linux and ppc64le-redhat-linux, ok for trunk?
>> >>
>> >> What about using truth_value_p ()?  That also includes && and || (just
>> >> in case those
>> >> do not have boolean type).
>> >
>> > You're right that I should also handle || and && (done in this patch).  But I
>> > can't use truth_value_p because we want to warn for e.g. "!a == (a & b)".
>>
>> But a & b isn't truth_value_p.  a && b is.  Do we want to warn about
>> !a == (a && b)?
>
> We don't want to warn about !a == (a && b), I think.  But truth_value_p returns
> true for both TRUTH_AND_EXPR and TRUTH_ANDIF_EXPR.  I find that confusing, and
> I can't use it in the current form because of that.

Note that a & b would be BIT_AND_EXPR, TRUTH_AND_EXPR is just
non-short-circuiting
&&

Richard.

>         Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]