re PR sanitizer/84307 (asan blocks dead-store elimination)
authorJakub Jelinek <jakub@redhat.com>
Wed, 25 Apr 2018 10:02:24 +0000 (12:02 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 25 Apr 2018 10:02:24 +0000 (12:02 +0200)
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) <case COMPOUND_LITERAL_EXPR>: Mark
not just the COMPOUND_LITERAL_EXPR node itself addressable, but also
its COMPOUND_LITERAL_EXPR_DECL.

From-SVN: r259641

gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/c/c-typeck.c

index fc077a881347bdf7dbc517d3cce516d5e306d3c3..7a3cf3f93ebe6b2b2b956111162624c1cb8c66be 100644 (file)
@@ -1,3 +1,12 @@
+2018-04-25  Jakub Jelinek  <jakub@redhat.com>
+
+       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) <case COMPOUND_LITERAL_EXPR>: Mark
+       not just the COMPOUND_LITERAL_EXPR node itself addressable, but also
+       its COMPOUND_LITERAL_EXPR_DECL.
+
 2018-03-21  Joseph Myers  <joseph@codesourcery.com>
 
        * c-parser.c (c_parser_postfix_expression): For __builtin_tgmath
index f0198ec81c36aaa8a3b0f589b5a7336a6b8734ca..7255588ac1e0f87a581b52ce1129ea916109877c 100644 (file)
@@ -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)
     {
index ffd06447f1b555ca84e00b40bce0d00ad0433bb1..5b3ea28af064b02085cbad498fc3d8016ecd77ce 100644 (file)
@@ -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;