Commit a2d5091a by Joseph Myers Committed by Joseph Myers

re PR c/50565 (initializer element is not computable at load time)

	PR c/50565
	* convert.c (convert_to_integer): Do not narrow operands of
	pointer subtraction.

testsuite:
	* gcc.c-torture/compile/pr50565-1.c,
	gcc.c-torture/compile/pr50565-2.c: New tests.

From-SVN: r179845
parent 58e9ddb1
2011-10-12 Joseph Myers <joseph@codesourcery.com>
PR c/50565
* convert.c (convert_to_integer): Do not narrow operands of
pointer subtraction.
2011-10-12 Nick Clifton <nickc@redhat.com>
* config/arm/arm.h (EMIT_EABI_ATTRIBUTE): New macro. Used to
......@@ -745,6 +745,15 @@ convert_to_integer (tree type, tree expr)
tree arg0 = get_unwidened (TREE_OPERAND (expr, 0), type);
tree arg1 = get_unwidened (TREE_OPERAND (expr, 1), type);
/* Do not try to narrow operands of pointer subtraction;
that will interfere with other folding. */
if (ex_form == MINUS_EXPR
&& CONVERT_EXPR_P (arg0)
&& CONVERT_EXPR_P (arg1)
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (arg0, 0)))
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (arg1, 0))))
break;
if (outprec >= BITS_PER_WORD
|| TRULY_NOOP_TRUNCATION (outprec, inprec)
|| inprec > TYPE_PRECISION (TREE_TYPE (arg0))
......
2011-10-12 Joseph Myers <joseph@codesourcery.com>
PR c/50565
* gcc.c-torture/compile/pr50565-1.c,
gcc.c-torture/compile/pr50565-2.c: New tests.
2011-10-11 Jason Merrill <jason@redhat.com>
PR c++/49855
......
struct s { char p[2]; };
static struct s v;
const int o0 = (int) ((void *) &v.p[0] - (void *) &v) + 0U;
const int o1 = (int) ((void *) &v.p[0] - (void *) &v) + 1U;
struct s { char p[2]; };
static struct s v;
const int o0 = (int) ((void *) &v.p[0] - (void *) &v) + 0;
const int o1 = (int) ((void *) &v.p[0] - (void *) &v) + 1;
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