aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-03-09 19:26:52 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2015-03-09 19:26:52 +0100
commit01177669b2eabfb1ddb3290c35bc110980b44d62 (patch)
tree2111b63d7da0a0531f8135d1ab1f64662e3887af /gcc/cp
parentee876e59156337667c4945c3346c0c7876f3a98c (diff)
downloadgcc-01177669b2eabfb1ddb3290c35bc110980b44d62.zip
gcc-01177669b2eabfb1ddb3290c35bc110980b44d62.tar.gz
gcc-01177669b2eabfb1ddb3290c35bc110980b44d62.tar.bz2
re PR c/65120 (Wlogical-not-parentheses should not warn about double exclamation !!)
PR c/65120 * c-typeck.c (parser_build_binary_op): Don't warn for !!x == y or !b == y where b is _Bool. * parser.c (cp_parser_binary_expression): Don't warn for !!x == y or !b == y where b is bool. * c-c++-common/pr49706.c: Adjust tests for not warning about !!x == y or !b == y where b is boolean, and add some further tests. * c-c++-common/pr62199-2.c: Likewise. From-SVN: r221284
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c15
2 files changed, 20 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1e19d6d..cd2d076 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/65120
+ * parser.c (cp_parser_binary_expression): Don't warn for
+ !!x == y or !b == y where b is bool.
+
2015-03-06 Aldy Hernandez <aldyh@redhat.com>
* ptree.c (cxx_print_lambda_node): New.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index e0b455c..2a3578f 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -8270,7 +8270,20 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p,
c_inhibit_evaluation_warnings -= current.lhs == truthvalue_true_node;
if (warn_logical_not_paren
- && current.lhs_type == TRUTH_NOT_EXPR)
+ && current.lhs_type == TRUTH_NOT_EXPR
+ /* Avoid warning for !!x == y. */
+ && (TREE_CODE (current.lhs) != NE_EXPR
+ || !integer_zerop (TREE_OPERAND (current.lhs, 1)))
+ && (TREE_CODE (current.lhs) != TRUTH_NOT_EXPR
+ || (TREE_CODE (TREE_OPERAND (current.lhs, 0)) != TRUTH_NOT_EXPR
+ /* Avoid warning for !b == y where b is boolean. */
+ && (TREE_TYPE (TREE_OPERAND (current.lhs, 0)) == NULL_TREE
+ || (TREE_CODE (TREE_TYPE (TREE_OPERAND (current.lhs, 0)))
+ != BOOLEAN_TYPE))))
+ /* Avoid warning for !!b == y where b is boolean. */
+ && (!DECL_P (current.lhs)
+ || TREE_TYPE (current.lhs) == NULL_TREE
+ || TREE_CODE (TREE_TYPE (current.lhs)) != BOOLEAN_TYPE))
warn_logical_not_parentheses (current.loc, current.tree_type, rhs);
overload = NULL;