Commit 60a23e2e by Olivier Hainque Committed by Eric Botcazou

re PR middle-end/14997 (ncurses build fails with Ada)

	PR middle-end/14997
	* expr.c (expand_expr_real) <normal_inner_ref>: Force op0 to mem
	when we would be extracting outside its bit span (bitpos+bitsize
	larger than its mode), possible with some VIEW_CONVERT_EXPRs from
	Ada unchecked conversions.

Co-Authored-By: Eric Botcazou <ebotcazou@adacore.com>

From-SVN: r103963
parent 29a15393
2005-09-06 Olivier Hainque <hainque@adacore.com>
Eric Botcazou <ebotcazou@adacore.com>
PR middle-end/14997
* expr.c (expand_expr_real) <normal_inner_ref>: Force op0 to mem
when we would be extracting outside its bit span (bitpos+bitsize
larger than its mode), possible with some VIEW_CONVERT_EXPRs from
Ada unchecked conversions.
2005-09-06 Steven Bosscher <stevenb@suse.de> 2005-09-06 Steven Bosscher <stevenb@suse.de>
* tree-ssa-pre.c (try_look_through_load): New function. * tree-ssa-pre.c (try_look_through_load): New function.
......
...@@ -7178,25 +7178,30 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, ...@@ -7178,25 +7178,30 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
|| modifier == EXPAND_STACK_PARM) || modifier == EXPAND_STACK_PARM)
? modifier : EXPAND_NORMAL); ? modifier : EXPAND_NORMAL);
/* If this is a constant, put it into a register if it is a /* If this is a constant, put it into a register if it is a legitimate
legitimate constant and OFFSET is 0 and memory if it isn't. */ constant, OFFSET is 0, and we won't try to extract outside the
register (in case we were passed a partially uninitialized object
or a view_conversion to a larger size). Force the constant to
memory otherwise. */
if (CONSTANT_P (op0)) if (CONSTANT_P (op0))
{ {
enum machine_mode mode = TYPE_MODE (TREE_TYPE (tem)); enum machine_mode mode = TYPE_MODE (TREE_TYPE (tem));
if (mode != BLKmode && LEGITIMATE_CONSTANT_P (op0) if (mode != BLKmode && LEGITIMATE_CONSTANT_P (op0)
&& offset == 0) && offset == 0
&& bitpos + bitsize <= GET_MODE_BITSIZE (mode))
op0 = force_reg (mode, op0); op0 = force_reg (mode, op0);
else else
op0 = validize_mem (force_const_mem (mode, op0)); op0 = validize_mem (force_const_mem (mode, op0));
} }
/* Otherwise, if this object not in memory and we either have an /* Otherwise, if this object not in memory and we either have an
offset or a BLKmode result, put it there. This case can't occur in offset, a BLKmode result, or a reference outside the object, put it
C, but can in Ada if we have unchecked conversion of an expression there. Such cases can occur in Ada if we have unchecked conversion
from a scalar type to an array or record type or for an of an expression from a scalar type to an array or record type or
ARRAY_RANGE_REF whose type is BLKmode. */ for an ARRAY_RANGE_REF whose type is BLKmode. */
else if (!MEM_P (op0) else if (!MEM_P (op0)
&& (offset != 0 && (offset != 0
|| (bitpos + bitsize > GET_MODE_BITSIZE (GET_MODE (op0)))
|| (code == ARRAY_RANGE_REF && mode == BLKmode))) || (code == ARRAY_RANGE_REF && mode == BLKmode)))
{ {
tree nt = build_qualified_type (TREE_TYPE (tem), tree nt = build_qualified_type (TREE_TYPE (tem),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment