+2015-10-11 Jason Merrill <jason@redhat.com>
+
+ PR c++/67557
+ * expr.c (store_field): Call store_constructor directly when
+ storing a CONSTRUCTOR into a target smaller than its type.
+ Guard against unsafe bitwise copy.
+
2015-10-11 Jan Hubicka <hubicka@ucw.cz>
* cgraphbuild.c (compute_call_stmt_bb_frequency): Use
operations. */
|| (bitsize >= 0
&& TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST
- && compare_tree_int (TYPE_SIZE (TREE_TYPE (exp)), bitsize) != 0)
+ && compare_tree_int (TYPE_SIZE (TREE_TYPE (exp)), bitsize) != 0
+ /* Except for initialization of full bytes from a CONSTRUCTOR, which
+ we will handle specially below. */
+ && !(TREE_CODE (exp) == CONSTRUCTOR
+ && bitsize % BITS_PER_UNIT == 0))
/* If we are expanding a MEM_REF of a non-BLKmode non-addressable
decl we must use bitfield operations. */
|| (bitsize >= 0
rtx temp;
gimple *nop_def;
+ /* Using bitwise copy is not safe for TREE_ADDRESSABLE types. */
+ gcc_assert (!TREE_ADDRESSABLE (TREE_TYPE (exp)));
+
/* If EXP is a NOP_EXPR of precision less than its mode, then that
implies a mask operation. If the precision is the same size as
the field we're storing into, that mask is redundant. This is
if (!MEM_KEEP_ALIAS_SET_P (to_rtx) && MEM_ALIAS_SET (to_rtx) != 0)
set_mem_alias_set (to_rtx, alias_set);
+ /* Above we avoided using bitfield operations for storing a CONSTRUCTOR
+ into a target smaller than its type; handle that case now. */
+ if (TREE_CODE (exp) == CONSTRUCTOR && bitsize >= 0)
+ {
+ gcc_assert (bitsize % BITS_PER_UNIT == 0);
+ store_constructor (exp, to_rtx, 0, bitsize/BITS_PER_UNIT);
+ return to_rtx;
+ }
+
return store_expr (exp, to_rtx, 0, nontemporal);
}
}