From 541e35a6a3f8ca2d9877ea6c477e765e1d0a9497 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 28 Nov 2014 09:06:48 +0000 Subject: re PR c/63862 (C frontend converts shift-count to int while standard wants integer promotions) PR c/63862 c-family/ * c-ubsan.c (ubsan_instrument_shift): Change the type of a MINUS_EXPR to op1_utype. * c-gimplify.c (c_gimplify_expr): Convert right operand of a shift expression to unsigned_type_node. c/ * c-typeck.c (build_binary_op) : Don't convert the right operand to integer type. cp/ * typeck.c (cp_build_binary_op) : Don't convert the right operand to integer type. testsuite/ * gcc.c-torture/execute/shiftopt-1.c: Don't XFAIL anymore. * c-c++-common/ubsan/shift-7.c: New test. From-SVN: r218142 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-typeck.c | 10 ---------- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index e2a9630..0f42b10 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2014-11-28 Marek Polacek + + PR c/63862 + * c-typeck.c (build_binary_op) : Don't + convert the right operand to integer type. + 2014-11-25 Marek Polacek PR c/63877 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 67efb46..bf0f306 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -10513,11 +10513,6 @@ build_binary_op (location_t location, enum tree_code code, /* Use the type of the value to be shifted. */ result_type = type0; - /* Convert the non vector shift-count to an integer, regardless - of size of value being shifted. */ - if (TREE_CODE (TREE_TYPE (op1)) != VECTOR_TYPE - && TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node) - op1 = convert (integer_type_node, op1); /* Avoid converting op1 to result_type later. */ converted = 1; } @@ -10563,11 +10558,6 @@ build_binary_op (location_t location, enum tree_code code, /* Use the type of the value to be shifted. */ result_type = type0; - /* Convert the non vector shift-count to an integer, regardless - of size of value being shifted. */ - if (TREE_CODE (TREE_TYPE (op1)) != VECTOR_TYPE - && TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node) - op1 = convert (integer_type_node, op1); /* Avoid converting op1 to result_type later. */ converted = 1; } -- cgit v1.1