From e2aab13d8a41cc85fbfd055fe0d4c4a2f803c6d5 Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Fri, 14 Aug 1992 23:45:09 +0000 Subject: [PATCH] (truthvalue_conversion): Optionally warn if an unparenthesized assignment is used as a truth value. From-SVN: r1853 --- gcc/c-common.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/c-common.c b/gcc/c-common.c index 50aa60e90ae..33804c41a8d 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -901,6 +901,11 @@ truthvalue_conversion (expr) fold (build1 (NOP_EXPR, TREE_TYPE (TREE_OPERAND (expr, 0)), TREE_OPERAND (expr, 1))), 1); + + case MODIFY_EXPR: + if (warn_parentheses && C_EXP_ORIGINAL_CODE (expr) == MODIFY_EXPR) + warning ("suggest parentheses around assignment used as truth value"); + break; } return build_binary_op (NE_EXPR, expr, integer_zero_node, 1);