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
This commit is contained in:
parent
58e9ddb14d
commit
a2d5091a51
@ -1,3 +1,9 @@
|
||||
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))
|
||||
|
@ -1,3 +1,9 @@
|
||||
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
|
||||
|
4
gcc/testsuite/gcc.c-torture/compile/pr50565-1.c
Normal file
4
gcc/testsuite/gcc.c-torture/compile/pr50565-1.c
Normal file
@ -0,0 +1,4 @@
|
||||
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;
|
4
gcc/testsuite/gcc.c-torture/compile/pr50565-2.c
Normal file
4
gcc/testsuite/gcc.c-torture/compile/pr50565-2.c
Normal file
@ -0,0 +1,4 @@
|
||||
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;
|
Loading…
Reference in New Issue
Block a user