Hi,

while working on cp_build_binary_op I noticed that the testsuite wasn't exercising the warnings in case RROTATE_EXPR / LROTATE_EXPR, even more the code handling those tree codes seemed completely unused. Turned out that the C front-end doesn't handle those tree codes at all: I'm coming to the conclusion that the C++ front-end bits too are now obsolete and may be removed, because only the middle-end generates those codes in order to implement optimizations. Anything I'm missing? Any additional testing? Tested x86_64-linux.

Thanks, Paolo.

///////////////////

2019-10-10  Paolo Carlini  <paolo.carl...@oracle.com>

        * typeck.c (cp_build_binary_op): Do not handle RROTATE_EXPR and
        LROTATE_EXPR.
        * constexpr.c (cxx_eval_constant_expression): Likewise.
        (potential_constant_expression_1): Likewise.
        * cp-gimplify.c (cp_fold): Likewise.
        * pt.c (tsubst_copy): Likewise.
Index: constexpr.c
===================================================================
--- constexpr.c (revision 276805)
+++ constexpr.c (working copy)
@@ -5115,8 +5115,6 @@ cxx_eval_constant_expression (const constexpr_ctx
     case MAX_EXPR:
     case LSHIFT_EXPR:
     case RSHIFT_EXPR:
-    case LROTATE_EXPR:
-    case RROTATE_EXPR:
     case BIT_IOR_EXPR:
     case BIT_XOR_EXPR:
     case BIT_AND_EXPR:
@@ -7103,8 +7101,6 @@ potential_constant_expression_1 (tree t, bool want
     case MAX_EXPR:
     case LSHIFT_EXPR:
     case RSHIFT_EXPR:
-    case LROTATE_EXPR:
-    case RROTATE_EXPR:
     case BIT_IOR_EXPR:
     case BIT_XOR_EXPR:
     case BIT_AND_EXPR:
Index: cp-gimplify.c
===================================================================
--- cp-gimplify.c       (revision 276805)
+++ cp-gimplify.c       (working copy)
@@ -2468,8 +2468,6 @@ cp_fold (tree x)
     case MAX_EXPR:
     case LSHIFT_EXPR:
     case RSHIFT_EXPR:
-    case LROTATE_EXPR:
-    case RROTATE_EXPR:
     case BIT_AND_EXPR:
     case BIT_IOR_EXPR:
     case BIT_XOR_EXPR:
Index: pt.c
===================================================================
--- pt.c        (revision 276805)
+++ pt.c        (working copy)
@@ -16308,8 +16308,6 @@ tsubst_copy (tree t, tree args, tsubst_flags_t com
     case TRUTH_OR_EXPR:
     case RSHIFT_EXPR:
     case LSHIFT_EXPR:
-    case RROTATE_EXPR:
-    case LROTATE_EXPR:
     case EQ_EXPR:
     case NE_EXPR:
     case MAX_EXPR:
@@ -18913,8 +18911,6 @@ tsubst_copy_and_build (tree t,
     case TRUTH_OR_EXPR:
     case RSHIFT_EXPR:
     case LSHIFT_EXPR:
-    case RROTATE_EXPR:
-    case LROTATE_EXPR:
     case EQ_EXPR:
     case NE_EXPR:
     case MAX_EXPR:
Index: typeck.c
===================================================================
--- typeck.c    (revision 276805)
+++ typeck.c    (working copy)
@@ -4896,35 +4896,6 @@ cp_build_binary_op (const op_location_t &location,
        }
       break;
 
-    case RROTATE_EXPR:
-    case LROTATE_EXPR:
-      if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
-       {
-         result_type = type0;
-         if (TREE_CODE (op1) == INTEGER_CST)
-           {
-             if (tree_int_cst_lt (op1, integer_zero_node))
-               {
-                 if (complain & tf_warning)
-                   warning (0, (code == LROTATE_EXPR)
-                                 ? G_("left rotate count is negative")
-                                 : G_("right rotate count is negative"));
-               }
-             else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
-               {
-                 if (complain & tf_warning)
-                   warning (0, (code == LROTATE_EXPR) 
-                                  ? G_("left rotate count >= width of type")
-                                  : G_("right rotate count >= width of type"));
-               }
-           }
-         /* Convert the shift-count to an integer, regardless of
-            size of value being shifted.  */
-         if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
-           op1 = cp_convert (integer_type_node, op1, complain);
-       }
-      break;
-
     case EQ_EXPR:
     case NE_EXPR:
       if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE)

Reply via email to