From 94b2a1e543ca20ed5e0468a186b27822d98b81b8 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 30 Apr 2018 11:20:46 -0400 Subject: [PATCH] tree.c (build_clobber): New. * tree.c (build_clobber): New. * tree.h: Declare it. * gimplify.c (gimplify_bind_expr, gimplify_target_expr): Use it. From-SVN: r259770 --- gcc/ChangeLog | 6 ++++++ gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl.c | 3 +-- gcc/gimplify.c | 7 ++----- gcc/tree.c | 10 ++++++++++ gcc/tree.h | 1 + 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 74ac8b441f1..eccb89aa39b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-04-30 Jason Merrill + + * tree.c (build_clobber): New. + * tree.h: Declare it. + * gimplify.c (gimplify_bind_expr, gimplify_target_expr): Use it. + 2018-04-30 David Malcolm * diagnostic-show-locus.c (layout::layout): Update for diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6253c9b91a0..7e32e75d2c6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2018-04-30 Jason Merrill + + * decl.c (build_clobber_this): Use build_clobber. + 2018-04-27 Jakub Jelinek PR c++/85553 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 03bc041780f..07f3a61fed6 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -14874,8 +14874,7 @@ build_clobber_this () if (!vbases) ctype = CLASSTYPE_AS_BASE (ctype); - tree clobber = build_constructor (ctype, NULL); - TREE_THIS_VOLATILE (clobber) = true; + tree clobber = build_clobber (ctype); tree thisref = current_class_ref; if (ctype != current_class_type) diff --git a/gcc/gimplify.c b/gcc/gimplify.c index c32869b4c59..b5b80ab7d98 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1379,9 +1379,8 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p) && !is_gimple_reg (t) && flag_stack_reuse != SR_NONE) { - tree clobber = build_constructor (TREE_TYPE (t), NULL); + tree clobber = build_clobber (TREE_TYPE (t)); gimple *clobber_stmt; - TREE_THIS_VOLATILE (clobber) = 1; clobber_stmt = gimple_build_assign (t, clobber); gimple_set_location (clobber_stmt, end_locus); gimplify_seq_add_stmt (&cleanup, clobber_stmt); @@ -6603,9 +6602,7 @@ gimplify_target_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) { if (flag_stack_reuse == SR_ALL) { - tree clobber = build_constructor (TREE_TYPE (temp), - NULL); - TREE_THIS_VOLATILE (clobber) = true; + tree clobber = build_clobber (TREE_TYPE (temp)); clobber = build2 (MODIFY_EXPR, TREE_TYPE (temp), temp, clobber); gimple_push_cleanup (temp, clobber, false, pre_p, true); } diff --git a/gcc/tree.c b/gcc/tree.c index e93f24dd4d3..b661d3d0dcd 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -2059,6 +2059,16 @@ build_constructor_va (tree type, int nelts, ...) return build_constructor (type, v); } +/* Return a node of type TYPE for which TREE_CLOBBER_P is true. */ + +tree +build_clobber (tree type) +{ + tree clobber = build_constructor (type, NULL); + TREE_THIS_VOLATILE (clobber) = true; + return clobber; +} + /* Return a new FIXED_CST node whose type is TYPE and value is F. */ tree diff --git a/gcc/tree.h b/gcc/tree.h index 1e14d9f5866..74a0d1881a6 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4173,6 +4173,7 @@ extern tree build_constructor (tree, vec *); extern tree build_constructor_single (tree, tree, tree); extern tree build_constructor_from_list (tree, tree); extern tree build_constructor_va (tree, int, ...); +extern tree build_clobber (tree); extern tree build_real_from_int_cst (tree, const_tree); extern tree build_complex (tree, tree, tree); extern tree build_complex_inf (tree, bool); -- 2.30.2