From 30d5d8c5189064c8ae30a4af232642077105ed80 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 27 Nov 2014 12:04:16 +0100 Subject: re PR middle-end/64067 (ICE in expand_expr_real_1, at expr.c:10540, involving compound literal shenanigans) PR middle-end/64067 * expr.c (expand_expr_addr_expr_1) : Handle it by returning address of COMPOUND_LITERAL_EXPR_DECL not only if modifier is EXPAND_INITIALIZER, but whenever COMPOUND_LITERAL_EXPR_DECL is non-NULL and TREE_STATIC. * gcc.c-torture/compile/pr64067.c: New test. From-SVN: r218121 --- gcc/expr.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'gcc/expr.c') diff --git a/gcc/expr.c b/gcc/expr.c index c7621b0..3d2ff6e 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -7677,11 +7677,13 @@ expand_expr_addr_expr_1 (tree exp, rtx target, machine_mode tmode, 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)) + /* Allow COMPOUND_LITERAL_EXPR in initializers or coming from + initializers, if e.g. rtl_for_decl_init is called on DECL_INITIAL + with COMPOUND_LITERAL_EXPRs in it, or ARRAY_REF on a const static + array with address of COMPOUND_LITERAL_EXPR in DECL_INITIAL; + the initializers aren't gimplified. */ + if (COMPOUND_LITERAL_EXPR_DECL (exp) + && TREE_STATIC (COMPOUND_LITERAL_EXPR_DECL (exp))) return expand_expr_addr_expr_1 (COMPOUND_LITERAL_EXPR_DECL (exp), target, tmode, modifier, as); /* FALLTHRU */ -- cgit v1.1