public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] cp: Another capability vtable fix
@ 2022-06-13 10:14 Alex Coplan
  0 siblings, 0 replies; only message in thread
From: Alex Coplan @ 2022-06-13 10:14 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:53e245a972259a371500222549d64d73a09f8c27

commit 53e245a972259a371500222549d64d73a09f8c27
Author: Alex Coplan <alex.coplan@arm.com>
Date:   Tue May 10 10:02:33 2022 +0100

    cp: Another capability vtable fix
    
    Make sure to use capabilities consistently in vtable entries. This fixes
    ICEs in varasm.c:output_constructor_regular_field.

Diff:
---
 gcc/cp/class.c   | 6 +++---
 gcc/cp/cp-tree.h | 2 ++
 gcc/cp/decl.c    | 1 +
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 99c4c0c8745..cf69361b86a 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -9818,7 +9818,7 @@ build_vtbl_initializer (tree binfo,
 	 with erroneous values (though harmless, apart from relocation
 	 costs).  */
       if (BV_LOST_PRIMARY (v))
-	init = size_zero_node;
+	init = null_vtable_entry;
 
       if (! init)
 	{
@@ -9885,7 +9885,7 @@ build_vtbl_initializer (tree binfo,
 	      if (DECL_DESTRUCTOR_P (fn_original)
 		  && (CLASSTYPE_PURE_VIRTUALS (DECL_CONTEXT (fn_original))
 		      || orig_binfo != binfo))
-		init = size_zero_node;
+		init = null_vtable_entry;
 	    }
 	}
 
@@ -9893,7 +9893,7 @@ build_vtbl_initializer (tree binfo,
       if (TARGET_VTABLE_USES_DESCRIPTORS)
 	{
 	  int i;
-	  if (init == size_zero_node)
+	  if (init == null_vtable_entry)
 	    for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i)
 	      CONSTRUCTOR_APPEND_ELT (*inits, size_int (jx++), init);
 	  else
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 5a0c77b118d..af71fac2441 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -117,6 +117,7 @@ enum cp_tree_index
 {
     CPTI_WCHAR_DECL,
     CPTI_VTABLE_ENTRY_TYPE,
+    CPTI_NULL_VTABLE_ENTRY,
     CPTI_DELTA_TYPE,
     CPTI_VTABLE_INDEX_TYPE,
     CPTI_CLEANUP_TYPE,
@@ -221,6 +222,7 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
 
 #define wchar_decl_node			cp_global_trees[CPTI_WCHAR_DECL]
 #define vtable_entry_type		cp_global_trees[CPTI_VTABLE_ENTRY_TYPE]
+#define null_vtable_entry		cp_global_trees[CPTI_NULL_VTABLE_ENTRY]
 /* The type used to represent an offset by which to adjust the `this'
    pointer in pointer-to-member types.  */
 #define delta_type_node			cp_global_trees[CPTI_DELTA_TYPE]
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index fc88567a3cf..b647e925ab7 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4377,6 +4377,7 @@ cxx_init_decl_processing (void)
     layout_type (vfunc_type);
 
     vtable_entry_type = build_pointer_type (vfunc_type);
+    null_vtable_entry = build_int_cst (vtable_entry_type, 0);
   }
   record_builtin_type (RID_MAX, "__vtbl_ptr_type", vtable_entry_type);


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

only message in thread, other threads:[~2022-06-13 10:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 10:14 [gcc(refs/vendors/ARM/heads/morello)] cp: Another capability vtable fix Alex Coplan

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).