From: Jakub Jelinek Date: Tue, 7 Feb 2012 09:22:51 +0000 (+0100) Subject: re PR middle-end/52074 (ICE: RTL flag check: MEM_VOLATILE_P used with unexpected... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b1b95093addde97a78ec59fef4c6930847f84566;p=gcc.git 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) 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: r183956 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2821874c007..b3662384cd7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +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-07 Joern Rennecke * config/epiphany/epiphany.h (ASM_DECLARE_FUNCTION_SIZE): Redefine, diff --git a/gcc/expr.c b/gcc/expr.c index ff88fcd356f..fcf177b956a 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -7414,7 +7414,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)) @@ -7433,7 +7438,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 a004ee1fdbf..fca230fbb63 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-02-07 Jakub Jelinek + + PR middle-end/52074 + * gcc.c-torture/compile/pr52074.c: New test. + 2012-02-07 Tobias Burnus PR fortran/51514 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 00000000000..92a2096f055 --- /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"; +}