]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/52074 (ICE: RTL flag check: MEM_VOLATILE_P used with unexp...
authorJakub Jelinek <jakub@redhat.com>
Thu, 9 Feb 2012 17:28:22 +0000 (18:28 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 9 Feb 2012 17:28:22 +0000 (18:28 +0100)
Backported from mainline
2012-02-07  Jakub Jelinek  <jakub@redhat.com>

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

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr52074.c [new file with mode: 0644]

index 8c2554be0c24330bcb0f194c62d0eca7b64b7c6c..55a63722b40c92aade2c905d35ad94ac36515dba 100644 (file)
@@ -1,6 +1,12 @@
 2012-02-09  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2012-02-07  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <jakub@redhat.com>
 
        PR target/52129
index 818ae161fcc604837363a6592f80ca4e604a4ef8..0ccdd2e00dba43d3c2a4cfb28e5c6acc196e59fc 100644 (file)
@@ -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
index 1a7c32951eee381fab50ceb70afac7558ba2b53c..1f3cc37a573dc5ae01b4cb1dd7782b418520790d 100644 (file)
@@ -1,6 +1,11 @@
 2012-02-09  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2012-02-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/52074
+       * gcc.c-torture/compile/pr52074.c: New test.
+
        2012-02-06  Jakub Jelinek  <jakub@redhat.com>
 
        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 (file)
index 0000000..92a2096
--- /dev/null
@@ -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";
+}