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) <case COMPOUND_LITERAL_EXPR>: Mark
	not just the COMPOUND_LITERAL_EXPR node itself addressable, but also
	its COMPOUND_LITERAL_EXPR_DECL.

From-SVN: r259641
This commit is contained in:
Jakub Jelinek 2018-04-25 12:02:24 +02:00 committed by Jakub Jelinek
parent 87ed4159ac
commit b33a0cb323
3 changed files with 15 additions and 0 deletions

View 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> 2018-03-21 Joseph Myers <joseph@codesourcery.com>
* c-parser.c (c_parser_postfix_expression): For __builtin_tgmath * c-parser.c (c_parser_postfix_expression): For __builtin_tgmath

View File

@ -5348,6 +5348,8 @@ build_compound_literal (location_t loc, tree type, tree init, bool non_const,
pushdecl (decl); pushdecl (decl);
rest_of_decl_compilation (decl, 1, 0); rest_of_decl_compilation (decl, 1, 0);
} }
else
pushdecl (decl);
if (non_const) if (non_const)
{ {

View File

@ -4821,6 +4821,10 @@ c_mark_addressable (tree exp, bool array_ref_p)
break; break;
case COMPOUND_LITERAL_EXPR: case COMPOUND_LITERAL_EXPR:
TREE_ADDRESSABLE (x) = 1;
TREE_ADDRESSABLE (COMPOUND_LITERAL_EXPR_DECL (x)) = 1;
return true;
case CONSTRUCTOR: case CONSTRUCTOR:
TREE_ADDRESSABLE (x) = 1; TREE_ADDRESSABLE (x) = 1;
return true; return true;