public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] cp: More explicit null-derivation
@ 2022-04-06  9:58 Matthew Malcomson
  0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2022-04-06  9:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0f06ab8bcb4cf51a863c637aa9b5b4abc182070b

commit 0f06ab8bcb4cf51a863c637aa9b5b4abc182070b
Author: Alex Coplan <alex.coplan@arm.com>
Date:   Tue Feb 15 12:08:31 2022 +0000

    cp: More explicit null-derivation
    
    Again we have vtable code that wants to stuff offsets into a vtable slot
    (where we expect a pointer). Explicitly null-derive these to avoid
    ICEing.
    
    gcc/cp/ChangeLog:
    
            * class.c (build_vbase_offset_vtbl_entries): Explicitly
            null-derive delta before converting to a capability.
            (add_vcall_offset): Likewise.

Diff:
---
 gcc/cp/class.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 0202216ad39..2be6a731c81 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -10015,6 +10015,9 @@ build_vbase_offset_vtbl_entries (tree binfo, vtbl_init_data* vid)
       delta = size_diffop_loc (input_location,
 			   BINFO_OFFSET (b), BINFO_OFFSET (non_primary_binfo));
 
+      if (capability_type_p (vtable_entry_type))
+	delta = fold_build_pointer_plus (null_pointer_node, delta);
+
       CONSTRUCTOR_APPEND_ELT (vid->inits, NULL_TREE,
 			      fold_build1_loc (input_location, NOP_EXPR,
 					       vtable_entry_type, delta));
@@ -10175,6 +10178,11 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid)
 	  vcall_offset = size_diffop_loc (input_location,
 				      BINFO_OFFSET (base),
 				      BINFO_OFFSET (vid->binfo));
+
+	  if (capability_type_p (vtable_entry_type))
+	    vcall_offset = fold_build_pointer_plus (null_pointer_node,
+						    vcall_offset);
+
 	  vcall_offset = fold_build1_loc (input_location,
 				      NOP_EXPR, vtable_entry_type,
 				      vcall_offset);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-06  9:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06  9:58 [gcc(refs/vendors/ARM/heads/morello)] cp: More explicit null-derivation Matthew Malcomson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).