From 9335e9a3a17d7efe7d095eb6ac7f8c45133159c2 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Wed, 7 Oct 1998 09:30:50 +0000 Subject: [PATCH] * class.c (finish_struct_1): Add commentary on prevous change. From-SVN: r22884 --- gcc/cp/ChangeLog | 2 ++ gcc/cp/class.c | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0ca49d21659..fc4ce6230e2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,7 @@ 1998-10-07 Mark Mitchell + * class.c (finish_struct_1): Add commentary on prevous change. + * cp-tree.h (vtbl_ptr_type_node): New variable. * class.c (build_vtbl_ref): Don't indirect through the vptr; it's already of the right type. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index da331fa251e..cd16b59c97e 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3777,8 +3777,25 @@ finish_struct_1 (t, warn_anon) if (vfield == NULL_TREE && has_virtual) { - /* We build this decl with ptr_type_node, and - change the type when we know what it should be. */ + /* We build this decl with vtbl_ptr_type_node, which is a + `vtable_entry_type*'. It might seem more precise to use + `vtable_entry_type (*)[N]' where N is the number of firtual + functions. However, that would require the vtable pointer in + base classes to have a different type than the vtable pointer + in derived classes. We could make that happen, but that + still wouldn't solve all the problems. In particular, the + type-based alias analysis code would decide that assignments + to the base class vtable pointer can't alias assignments to + the derived class vtable pointer, since they have different + types. Thus, in an derived class destructor, where the base + class constructor was inlined, we could generate bad code for + setting up the vtable pointer. + + Therefore, we use one type for all vtable pointers. We still + use a type-correct type; it's just doesn't indicate the array + bounds. That's better than using `void*' or some such; it's + cleaner, and it let's the alias analysis code know that these + stores cannot alias stores to void*! */ vfield = build_lang_field_decl (FIELD_DECL, get_vfield_name (t), vtbl_ptr_type_node); /* If you change any of the below, take a look at all the