2018-11-05 Jakub Jelinek Backported from mainline 2018-10-20 Jakub Jelinek PR middle-end/87647 * varasm.c (decode_addr_const): Handle COMPOUND_LITERAL_EXPR. * gcc.c-torture/compile/pr87647.c: New test. --- gcc/varasm.c (revision 265340) +++ gcc/varasm.c (revision 265341) @@ -2953,6 +2953,11 @@ decode_addr_const (tree exp, struct addr 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 (); } --- gcc/testsuite/gcc.c-torture/compile/pr87647.c (nonexistent) +++ gcc/testsuite/gcc.c-torture/compile/pr87647.c (revision 265341) @@ -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); +}