re PR middle-end/87647 (ICE on valid code in decode_addr_const, at varasm.c:2958)
authorJakub Jelinek <jakub@redhat.com>
Sat, 20 Oct 2018 08:58:00 +0000 (10:58 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 20 Oct 2018 08:58:00 +0000 (10:58 +0200)
PR middle-end/87647
* varasm.c (decode_addr_const): Handle COMPOUND_LITERAL_EXPR.

* gcc.c-torture/compile/pr87647.c: New test.

From-SVN: r265341

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

index 622765db0521493a05d8db99e3aec797d60cae16..f59167cca8980a1804dd37cd56feaf0c9b3e9b5e 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/87647
+       * varasm.c (decode_addr_const): Handle COMPOUND_LITERAL_EXPR.
+
 2018-10-20  Andreas Schwab  <schwab@linux-m68k.org>
 
        * doc/ux.texi: Move @section directly after @node.
index 3000e214a1649e5c2de8ba15b73e46f69e16c5f9..86fa75673efcc603281114ed5e1decd1cc6807fd 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/87647
+       * gcc.c-torture/compile/pr87647.c: New test.
+
 2018-10-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/85488
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr87647.c b/gcc/testsuite/gcc.c-torture/compile/pr87647.c
new file mode 100644 (file)
index 0000000..67f9d87
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR middle-end/87647 */
+
+struct A {};
+struct A *const b = &(struct A) {};
+struct B { char *s; struct A *t; };
+void bar (struct B *);
+
+void
+foo (void)
+{
+  struct B a[] = { "", b, "", b, "", b, "", b, "", b, "", b, "", b, "", b,
+                  "", b, "", b, "", b, "", b, "", b, "", b, "", b, "", b,
+                  "", b };
+  bar (a);
+}
index 78cb000ca04ae5918dd29a990d0e6147838232ae..91650eea9f70982fedf5880dede5503d9d3121a1 100644 (file)
@@ -2953,6 +2953,11 @@ decode_addr_const (tree exp, struct addr_const *value)
                       gen_rtx_SYMBOL_REF (Pmode, "origin of addresses"));
       break;
 
+    case COMPOUND_LITERAL_EXPR:
+      gcc_assert (COMPOUND_LITERAL_EXPR_DECL (target));
+      x = DECL_RTL (COMPOUND_LITERAL_EXPR_DECL (target));
+      break;
+
     default:
       gcc_unreachable ();
     }