Hi!

We ICE on the following testcase, because DECL_INITIAL contains
COMPOUND_LITERAL_EXPR, which expr.c assumes has been gimplified, but
initializers aren't gimplified.  Fixed thusly, bootstrapped/regtested on
x86_64-linux and i686-linux, ok for trunk/4.8?

2013-05-06  Jakub Jelinek  <ja...@redhat.com>

        PR debug/57184
        * expr.c (expand_expr_addr_expr_1): Handle COMPOUND_LITERAL_EXPR
        for modifier == EXPAND_INITIALIZER.

        * gcc.dg/pr57184.c: New test.

--- gcc/expr.c.jj       2013-05-03 14:55:04.000000000 +0200
+++ gcc/expr.c  2013-05-06 13:41:03.274302405 +0200
@@ -7561,6 +7561,15 @@ expand_expr_addr_expr_1 (tree exp, rtx t
       inner = TREE_OPERAND (exp, 0);
       break;
 
+    case COMPOUND_LITERAL_EXPR:
+      /* Allow COMPOUND_LITERAL_EXPR in initializers, if e.g.
+        rtl_for_decl_init is called on DECL_INITIAL with
+        COMPOUNT_LITERAL_EXPRs in it, they aren't gimplified.  */
+      if (modifier == EXPAND_INITIALIZER
+         && COMPOUND_LITERAL_EXPR_DECL (exp))
+       return expand_expr_addr_expr_1 (COMPOUND_LITERAL_EXPR_DECL (exp),
+                                       target, tmode, modifier, as);
+      /* FALLTHRU */
     default:
       /* If the object is a DECL, then expand it for its rtl.  Don't bypass
         expand_expr, as that can have various side effects; LABEL_DECLs for
--- gcc/testsuite/gcc.dg/pr57184.c.jj   2013-05-06 13:42:12.514923650 +0200
+++ gcc/testsuite/gcc.dg/pr57184.c      2013-05-06 13:41:55.000000000 +0200
@@ -0,0 +1,13 @@
+/* PR debug/57184 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g" } */
+
+struct S {};
+void bar (struct S *const);
+static struct S *const c = &(struct S) {};
+
+void
+foo (void)
+{
+  bar (c);
+}

        Jakub

Reply via email to