From b33a0cb323fa000f8fe50b8ad844fda2bda47c1d Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 25 Apr 2018 12:02:24 +0200 Subject: [PATCH] re PR sanitizer/84307 (asan blocks dead-store elimination) PR sanitizer/84307 * c-decl.c (build_compound_literal): Call pushdecl (decl) even when it is not TREE_STATIC. * c-typeck.c (c_mark_addressable) : Mark not just the COMPOUND_LITERAL_EXPR node itself addressable, but also its COMPOUND_LITERAL_EXPR_DECL. From-SVN: r259641 --- gcc/c/ChangeLog | 9 +++++++++ gcc/c/c-decl.c | 2 ++ gcc/c/c-typeck.c | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index fc077a8..7a3cf3f 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2018-04-25 Jakub Jelinek + + PR sanitizer/84307 + * c-decl.c (build_compound_literal): Call pushdecl (decl) even when + it is not TREE_STATIC. + * c-typeck.c (c_mark_addressable) : Mark + not just the COMPOUND_LITERAL_EXPR node itself addressable, but also + its COMPOUND_LITERAL_EXPR_DECL. + 2018-03-21 Joseph Myers * c-parser.c (c_parser_postfix_expression): For __builtin_tgmath diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index f0198ec..7255588 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -5348,6 +5348,8 @@ build_compound_literal (location_t loc, tree type, tree init, bool non_const, pushdecl (decl); rest_of_decl_compilation (decl, 1, 0); } + else + pushdecl (decl); if (non_const) { diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index ffd0644..5b3ea28 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -4821,6 +4821,10 @@ c_mark_addressable (tree exp, bool array_ref_p) break; case COMPOUND_LITERAL_EXPR: + TREE_ADDRESSABLE (x) = 1; + TREE_ADDRESSABLE (COMPOUND_LITERAL_EXPR_DECL (x)) = 1; + return true; + case CONSTRUCTOR: TREE_ADDRESSABLE (x) = 1; return true; -- 2.7.4