diff options
author | Jason Merrill <jason@redhat.com> | 2016-03-18 11:31:35 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2016-03-18 11:31:35 -0400 |
commit | b5a28d803116ee10c88e0f762fdc427974b9b4fd (patch) | |
tree | 3ddc03dbda1ee4d2d03b3baf2c409380bbc15d4e /gcc/cp/cp-ubsan.c | |
parent | bf08acdaa570ae61e86b92660ddee07d20948919 (diff) | |
download | gcc-b5a28d803116ee10c88e0f762fdc427974b9b4fd.zip gcc-b5a28d803116ee10c88e0f762fdc427974b9b4fd.tar.gz gcc-b5a28d803116ee10c88e0f762fdc427974b9b4fd.tar.bz2 |
PR c++/70147 - handle primary virtual bases
* class.c (vptr_via_virtual_p): New.
(most_primary_binfo): Factor out of build_rtti_vtbl_entries.
* cp-ubsan.c (cp_ubsan_dfs_initialize_vtbl_ptrs): Don't clear
a vptr from any virtual base in a not-in-charge 'structor.
From-SVN: r234335
Diffstat (limited to 'gcc/cp/cp-ubsan.c')
-rw-r--r-- | gcc/cp/cp-ubsan.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/gcc/cp/cp-ubsan.c b/gcc/cp/cp-ubsan.c index 75aeeb8..be24a5c 100644 --- a/gcc/cp/cp-ubsan.c +++ b/gcc/cp/cp-ubsan.c @@ -283,7 +283,7 @@ cp_ubsan_dfs_initialize_vtbl_ptrs (tree binfo, void *data) if (!TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo))) return dfs_skip_bases; - if (!BINFO_PRIMARY_P (binfo) || BINFO_VIRTUAL_P (binfo)) + if (!BINFO_PRIMARY_P (binfo)) { tree base_ptr = TREE_VALUE ((tree) data); @@ -301,11 +301,10 @@ cp_ubsan_dfs_initialize_vtbl_ptrs (tree binfo, void *data) tree vtbl = build_zero_cst (TREE_TYPE (vtbl_ptr)); tree stmt = cp_build_modify_expr (vtbl_ptr, NOP_EXPR, vtbl, tf_warning_or_error); - if (BINFO_VIRTUAL_P (binfo)) - stmt = build3 (COND_EXPR, void_type_node, - build2 (NE_EXPR, boolean_type_node, - current_in_charge_parm, integer_zero_node), - stmt, void_node); + if (vptr_via_virtual_p (binfo)) + /* If this vptr comes from a virtual base of the complete object, only + clear it if we're in charge of virtual bases. */ + stmt = build_if_in_charge (stmt); finish_expr_stmt (stmt); } |