This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/17896] The expression (a>0 & b>0) should give clearer warning message (-Wparentheses)
- From: "trt at acm dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Oct 2004 20:00:05 -0000
- Subject: [Bug c/17896] The expression (a>0 & b>0) should give clearer warning message (-Wparentheses)
- References: <20041008195551.17896.trt@acm.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From trt at acm dot org 2004-10-08 20:00 -------
Created an attachment (id=7310)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7310&action=view)
proposed patch
I've attached a proposed patch for gcc to issue alternate warnings:
suggest && instead of & when joining booleans
suggest || instead of | when joining booleans
The patched gcc continues to warn (or not) as before, but with different text
when the operands are boolean-valued and without side effects.
I used COMPARISON_CLASS_P (t) as an approximation to "boolean-valued".
truth_value_p (TREE_CODE (t)) would be better but is unavailable.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17896