diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-09-14 16:59:10 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-09-14 16:59:10 +0000 |
commit | bb554051056e54cf82993d6680c3f3c2aabaf85b (patch) | |
tree | 95a34b6ced24ac7d8b25b3d0768dbbb429f9ac2e /gcc/c | |
parent | 79256e60cf0e2c0ac194fb454918f52559c988e1 (diff) | |
download | gcc-bb554051056e54cf82993d6680c3f3c2aabaf85b.tar.gz |
c:
PR c/54103
* c-typeck.c (build_unary_op): Pass original argument of
TRUTH_NOT_EXPR to c_objc_common_truthvalue_conversion, then remove
any C_MAYBE_CONST_EXPR, if it has integer operands.
(build_binary_op): Pass original arguments of TRUTH_ANDIF_EXPR,
TRUTH_ORIF_EXPR, TRUTH_AND_EXPR, TRUTH_OR_EXPR and TRUTH_XOR_EXPR
to c_objc_common_truthvalue_conversion, then remove any
C_MAYBE_CONST_EXPR, if they have integer operands. Use
c_objc_common_truthvalue_conversion not
c_common_truthvalue_conversion.
(c_objc_common_truthvalue_conversion): Build NE_EXPR directly and
call note_integer_operands for arguments with integer operands
that are not integer constants.
testsuite:
* gcc.c-torture/compile/pr54103-1.c,
gcc.c-torture/compile/pr54103-2.c,
gcc.c-torture/compile/pr54103-3.c,
gcc.c-torture/compile/pr54103-4.c,
gcc.c-torture/compile/pr54103-5.c,
gcc.c-torture/compile/pr54103-6.c: New tests.
* gcc.dg/c90-const-expr-8.c: Update expected column number.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191304 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 41 |
2 files changed, 48 insertions, 9 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index f075776c39b..bd6ef8fbf98 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,19 @@ +2012-09-14 Joseph Myers <joseph@codesourcery.com> + + PR c/54103 + * c-typeck.c (build_unary_op): Pass original argument of + TRUTH_NOT_EXPR to c_objc_common_truthvalue_conversion, then remove + any C_MAYBE_CONST_EXPR, if it has integer operands. + (build_binary_op): Pass original arguments of TRUTH_ANDIF_EXPR, + TRUTH_ORIF_EXPR, TRUTH_AND_EXPR, TRUTH_OR_EXPR and TRUTH_XOR_EXPR + to c_objc_common_truthvalue_conversion, then remove any + C_MAYBE_CONST_EXPR, if they have integer operands. Use + c_objc_common_truthvalue_conversion not + c_common_truthvalue_conversion. + (c_objc_common_truthvalue_conversion): Build NE_EXPR directly and + call note_integer_operands for arguments with integer operands + that are not integer constants. + 2012-09-13 Jakub Jelinek <jakub@redhat.com> PR c/54559 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 2d74da8cde4..628857c38b2 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -3553,7 +3553,13 @@ build_unary_op (location_t location, "wrong type argument to unary exclamation mark"); return error_mark_node; } - arg = c_objc_common_truthvalue_conversion (location, arg); + if (int_operands) + { + arg = c_objc_common_truthvalue_conversion (location, xarg); + arg = remove_c_maybe_const_expr (arg); + } + else + arg = c_objc_common_truthvalue_conversion (location, arg); ret = invert_truthvalue_loc (location, arg); /* If the TRUTH_NOT_EXPR has been folded, reset the location. */ if (EXPR_P (ret) && EXPR_HAS_LOCATION (ret)) @@ -9807,8 +9813,20 @@ build_binary_op (location_t location, enum tree_code code, but that does not mean the operands should be converted to ints! */ result_type = integer_type_node; - op0 = c_common_truthvalue_conversion (location, op0); - op1 = c_common_truthvalue_conversion (location, op1); + if (op0_int_operands) + { + op0 = c_objc_common_truthvalue_conversion (location, orig_op0); + op0 = remove_c_maybe_const_expr (op0); + } + else + op0 = c_objc_common_truthvalue_conversion (location, op0); + if (op1_int_operands) + { + op1 = c_objc_common_truthvalue_conversion (location, orig_op1); + op1 = remove_c_maybe_const_expr (op1); + } + else + op1 = c_objc_common_truthvalue_conversion (location, op1); converted = 1; boolean_op = true; } @@ -10520,12 +10538,17 @@ c_objc_common_truthvalue_conversion (location_t location, tree expr) int_const = (TREE_CODE (expr) == INTEGER_CST && !TREE_OVERFLOW (expr)); int_operands = EXPR_INT_CONST_OPERANDS (expr); - if (int_operands) - expr = remove_c_maybe_const_expr (expr); - - /* ??? Should we also give an error for vectors rather than leaving - those to give errors later? */ - expr = c_common_truthvalue_conversion (location, expr); + if (int_operands && TREE_CODE (expr) != INTEGER_CST) + { + expr = remove_c_maybe_const_expr (expr); + expr = build2 (NE_EXPR, integer_type_node, expr, + convert (TREE_TYPE (expr), integer_zero_node)); + expr = note_integer_operands (expr); + } + else + /* ??? Should we also give an error for vectors rather than leaving + those to give errors later? */ + expr = c_common_truthvalue_conversion (location, expr); if (TREE_CODE (expr) == INTEGER_CST && int_operands && !int_const) { |