From: Jakub Jelinek Date: Thu, 9 Feb 2012 17:28:22 +0000 (+0100) Subject: backport: re PR middle-end/52074 (ICE: RTL flag check: MEM_VOLATILE_P used with unexp... X-Git-Tag: releases/gcc-4.6.3~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d999eebe24ca6ec4ea588dcdb6a06dc81567307;p=thirdparty%2Fgcc.git backport: re PR middle-end/52074 (ICE: RTL flag check: MEM_VOLATILE_P used with unexpected rtx code 'plus' in extract_fixed_bit_field, at expmed.c:1734) Backported from mainline 2012-02-07 Jakub Jelinek PR middle-end/52074 * expr.c (expand_expr_addr_expr_1): For CONSTANT_CLASS_P or CONST_DECL if modifier < EXPAND_SUM call force_operand on the result. * gcc.c-torture/compile/pr52074.c: New test. From-SVN: r184060 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8c2554be0c24..55a63722b40c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,12 @@ 2012-02-09 Jakub Jelinek Backported from mainline + 2012-02-07 Jakub Jelinek + + PR middle-end/52074 + * expr.c (expand_expr_addr_expr_1): For CONSTANT_CLASS_P or CONST_DECL + if modifier < EXPAND_SUM call force_operand on the result. + 2012-02-06 Jakub Jelinek PR target/52129 diff --git a/gcc/expr.c b/gcc/expr.c index 818ae161fcc6..0ccdd2e00dba 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -7015,7 +7015,12 @@ expand_expr_addr_expr_1 (tree exp, rtx target, enum machine_mode tmode, generating ADDR_EXPR of something that isn't an LVALUE. The only exception here is STRING_CST. */ if (CONSTANT_CLASS_P (exp)) - return XEXP (expand_expr_constant (exp, 0, modifier), 0); + { + result = XEXP (expand_expr_constant (exp, 0, modifier), 0); + if (modifier < EXPAND_SUM) + result = force_operand (result, target); + return result; + } /* Everything must be something allowed by is_gimple_addressable. */ switch (TREE_CODE (exp)) @@ -7036,7 +7041,11 @@ expand_expr_addr_expr_1 (tree exp, rtx target, enum machine_mode tmode, case CONST_DECL: /* Expand the initializer like constants above. */ - return XEXP (expand_expr_constant (DECL_INITIAL (exp), 0, modifier), 0); + result = XEXP (expand_expr_constant (DECL_INITIAL (exp), + 0, modifier), 0); + if (modifier < EXPAND_SUM) + result = force_operand (result, target); + return result; case REALPART_EXPR: /* The real part of the complex number is always first, therefore diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1a7c32951eee..1f3cc37a573d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2012-02-09 Jakub Jelinek Backported from mainline + 2012-02-07 Jakub Jelinek + + PR middle-end/52074 + * gcc.c-torture/compile/pr52074.c: New test. + 2012-02-06 Jakub Jelinek PR target/52129 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr52074.c b/gcc/testsuite/gcc.c-torture/compile/pr52074.c new file mode 100644 index 000000000000..92a2096f0556 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr52074.c @@ -0,0 +1,10 @@ +/* PR middle-end/52074 */ + +struct S { const char *d, *e; } __attribute__((packed)); + +void +foo (const char **p, struct S *q) +{ + *p = "abcdef"; + q->d = "ghijk"; +}