summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2008-10-24 10:09:06 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2008-10-24 10:09:06 +0000
commit100d537d7a7b5c0ef775d568ce3eefffa72f2c41 (patch)
tree700b750bc17a07e7749365330c49e0f595aaa435 /gcc/cp
parent950d63e12fd0a69731a4c1ae313135f2d47d30a9 (diff)
downloadgcc-100d537d7a7b5c0ef775d568ce3eefffa72f2c41.tar.gz
re PR c/7543 (no warning for always-false "if (!a & 0x4)" bitwise and on boolean value)
2008-10-24 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c/7543 * value-prof.c (gimple_stringop_fixed_value): Use parentheses around bit operation. * profile.c (is_edge_inconsistent): Likewise. * fold-const.c (truth_value_p): Move from here... * tree.h (truth_value_p): ... to here. * c-tree.h (c_expr): Update description of original_code. * c-typeck.c (parser_build_unary_op): Set original_code. (parser_build_binary_op): Update call to warn_about_parentheses. * c-common.c (warn_about_parentheses): Take two additional arguments of the operands. Use a switch. Quote operators appropriately. Define macro APPEARS_TO_BE_BOOLEAN_EXPR_P. Add warning about !x | y and !x & y. * c-common.h (warn_about_parentheses): Update declaration. cp/ * typeck.c (build_x_binary_op): Update call to warn_about_parentheses. * parser.c (cp_parser_binary_expression): Add note about passing the correct code for unary expressions. testsuite/ * gcc.dg/Wparentheses-11.c: New. * g++.dg/warn/Wparentheses-25.C: New. XFAILED. From-SVN: r141340
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/parser.c7
-rw-r--r--gcc/cp/typeck.c2
3 files changed, 16 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ee09f159394..0293d49e833 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-24 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR c/7543
+ * typeck.c (build_x_binary_op): Update call to
+ warn_about_parentheses.
+ * parser.c (cp_parser_binary_expression): Add note about passing
+ the correct code for unary expressions.
+
2008-10-24 Jakub Jelinek <jakub@redhat.com>
* Make-lang.in (check-c++-subtargets): New alias for
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 519c1d601d1..75960483974 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -6205,6 +6205,13 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p,
}
overloaded_p = false;
+ /* ??? Currently we pass lhs_type == ERROR_MARK and rhs_type ==
+ ERROR_MARK for everything that is not a binary expression.
+ This makes warn_about_parentheses miss some warnings that
+ involve unary operators. For unary expressions we should
+ pass the correct tree_code unless the unary expression was
+ surrounded by parentheses.
+ */
lhs = build_x_binary_op (tree_type, lhs, lhs_type, rhs, rhs_type,
&overloaded_p, tf_warning_or_error);
lhs_type = tree_type;
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 9e65bdd3a11..84ebc953a9a 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3158,7 +3158,7 @@ build_x_binary_op (enum tree_code code, tree arg1, enum tree_code arg1_code,
&& !error_operand_p (arg2)
&& (code != LSHIFT_EXPR
|| !CLASS_TYPE_P (TREE_TYPE (arg1))))
- warn_about_parentheses (code, arg1_code, arg2_code);
+ warn_about_parentheses (code, arg1_code, orig_arg1, arg2_code, orig_arg2);
if (processing_template_decl && expr != error_mark_node)
return build_min_non_dep (code, expr, orig_arg1, orig_arg2);