aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-04-10 12:49:01 +0200
committerJakub Jelinek <jakub@redhat.com>2021-04-10 12:49:01 +0200
commit22aede7a1228617661105048a91fddd8797e141b (patch)
tree4149a06f234a6599a9c32dad657b87d382c5fa88 /gcc/expr.c
parent3e350d8539a4e28ddc30d0f08a4040f10b699135 (diff)
downloadgcc-22aede7a1228617661105048a91fddd8797e141b.zip
gcc-22aede7a1228617661105048a91fddd8797e141b.tar.gz
gcc-22aede7a1228617661105048a91fddd8797e141b.tar.bz2
expand: Fix up LTO ICE with COMPOUND_LITERAL_EXPR [PR99849]
The gimplifier optimizes away COMPOUND_LITERAL_EXPRs, but they can remain in the form of ADDR_EXPR of COMPOUND_LITERAL_EXPRs in static initializers. By the TREE_STATIC check I meant to check that the underlying decl of the compound literal is a global rather than automatic variable which obviously can't be referenced in static initializers, but unfortunately with LTO it might end up in another partition and thus be DECL_EXTERNAL instead. 2021-04-10 Jakub Jelinek <jakub@redhat.com> PR lto/99849 * expr.c (expand_expr_addr_expr_1): Test is_global_var rather than just TREE_STATIC on COMPOUND_LITERAL_EXPR_DECLs. * gcc.dg/lto/pr99849_0.c: New test.
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 92035c7..a0e1946 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -8204,7 +8204,7 @@ expand_expr_addr_expr_1 (tree exp, rtx target, scalar_int_mode tmode,
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)))
+ && is_global_var (COMPOUND_LITERAL_EXPR_DECL (exp)))
return expand_expr_addr_expr_1 (COMPOUND_LITERAL_EXPR_DECL (exp),
target, tmode, modifier, as);
/* FALLTHRU */