re PR middle-end/52074 (ICE: RTL flag check: MEM_VOLATILE_P used with unexpected...
authorJakub Jelinek <jakub@redhat.com>
Tue, 7 Feb 2012 09:22:51 +0000 (10:22 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 7 Feb 2012 09:22:51 +0000 (10:22 +0100)
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

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

index 2821874c007705bdafaf9dec22ada99946b0d0e9..b3662384cd76e31f8d6b9c9ceef3aeb607fd9926 100644 (file)
@@ -1,3 +1,9 @@
+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-07  Joern Rennecke  <joern.rennecke@embecosm.com>
 
        * config/epiphany/epiphany.h (ASM_DECLARE_FUNCTION_SIZE): Redefine,
index ff88fcd356f726cc0f02d9d4d2c40b9f4b502097..fcf177b956a017937196e3910ebbed74f6352669 100644 (file)
@@ -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
index a004ee1fdbf72bcbd31595c2c5780c898f9f6a17..fca230fbb6326b5599b70f911b20dae8f99a3d61 100644 (file)
@@ -1,3 +1,8 @@
+2012-02-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/52074
+       * gcc.c-torture/compile/pr52074.c: New test.
+
 2012-02-07  Tobias Burnus  <burnus@net-b.de>
 
        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 (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";
+}