Replace unreachable code with an assert.
authorMartin Sebor <msebor@redhat.com>
Tue, 11 May 2021 19:58:48 +0000 (13:58 -0600)
committerMartin Sebor <msebor@redhat.com>
Tue, 11 May 2021 19:58:48 +0000 (13:58 -0600)
Resolves:
PR middle-end/21433 - The COMPONENT_REF case of expand_expr_real_1 is probably wrong

gcc/ChangeLog:

PR middle-end/21433
* expr.c (expand_expr_real_1): Replace unreachable code with an assert.

gcc/expr.c

index 1b65f6b..d09ee42 100644 (file)
@@ -10949,61 +10949,8 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
       goto normal_inner_ref;
 
     case COMPONENT_REF:
-      /* If the operand is a CONSTRUCTOR, we can just extract the
-        appropriate field if it is present.  */
-      if (TREE_CODE (treeop0) == CONSTRUCTOR)
-       {
-         unsigned HOST_WIDE_INT idx;
-         tree field, value;
-         scalar_int_mode field_mode;
-
-         FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (treeop0),
-                                   idx, field, value)
-           if (field == treeop1
-               /* We can normally use the value of the field in the
-                  CONSTRUCTOR.  However, if this is a bitfield in
-                  an integral mode that we can fit in a HOST_WIDE_INT,
-                  we must mask only the number of bits in the bitfield,
-                  since this is done implicitly by the constructor.  If
-                  the bitfield does not meet either of those conditions,
-                  we can't do this optimization.  */
-               && (! DECL_BIT_FIELD (field)
-                   || (is_int_mode (DECL_MODE (field), &field_mode)
-                       && (GET_MODE_PRECISION (field_mode)
-                           <= HOST_BITS_PER_WIDE_INT))))
-             {
-               if (DECL_BIT_FIELD (field)
-                   && modifier == EXPAND_STACK_PARM)
-                 target = 0;
-               op0 = expand_expr (value, target, tmode, modifier);
-               if (DECL_BIT_FIELD (field))
-                 {
-                   HOST_WIDE_INT bitsize = TREE_INT_CST_LOW (DECL_SIZE (field));
-                   scalar_int_mode imode
-                     = SCALAR_INT_TYPE_MODE (TREE_TYPE (field));
-
-                   if (TYPE_UNSIGNED (TREE_TYPE (field)))
-                     {
-                       op1 = gen_int_mode ((HOST_WIDE_INT_1 << bitsize) - 1,
-                                           imode);
-                       op0 = expand_and (imode, op0, op1, target);
-                     }
-                   else
-                     {
-                       int count = GET_MODE_PRECISION (imode) - bitsize;
-
-                       op0 = expand_shift (LSHIFT_EXPR, imode, op0, count,
-                                           target, 0);
-                       op0 = expand_shift (RSHIFT_EXPR, imode, op0, count,
-                                           target, 0);
-                     }
-                 }
-
-               return op0;
-             }
-       }
-      goto normal_inner_ref;
-
+      gcc_assert (TREE_CODE (treeop0) != CONSTRUCTOR);
+      /* Fall through.  */
     case BIT_FIELD_REF:
     case ARRAY_RANGE_REF:
     normal_inner_ref: