aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@markmitchell.com>1998-10-07 09:30:50 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1998-10-07 09:30:50 +0000
commit9335e9a3a17d7efe7d095eb6ac7f8c45133159c2 (patch)
tree421f6b9e631147d714230b0fb5cf9f1daeaba6f9 /gcc
parent39828aec68c58a3d2b8c0d7f5d0e48e088df367a (diff)
downloadgcc-9335e9a3a17d7efe7d095eb6ac7f8c45133159c2.zip
gcc-9335e9a3a17d7efe7d095eb6ac7f8c45133159c2.tar.gz
gcc-9335e9a3a17d7efe7d095eb6ac7f8c45133159c2.tar.bz2
* class.c (finish_struct_1): Add commentary on prevous change.
From-SVN: r22884
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog2
-rw-r--r--gcc/cp/class.c21
2 files changed, 21 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0ca49d2..fc4ce62 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,7 @@
1998-10-07 Mark Mitchell <mark@markmitchell.com>
+ * 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 da331fa..cd16b59 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