Revised patch for comobject attributes (Win32)
Antonio Mendes de Oliveira Neto
anmendes@splicenet.com.br
Mon Nov 30 19:16:00 GMT 1998
Nov 30 20:10:00 1998 Antonio Mendes de Oliveira Neto
(anmendes@splicenet.com.br)
* gcc/config/i386/winnt.c (i386_pe_valid_type_attribute_p):
added the "comobject" attribute.
* gcc/cp/class.c : Added the variable flag_win32_thunks that
when it adjusts for 1, it removes the first
two entrances of the vtable.
------------------------------------------------------------------------------------
diff -c3p -r egcs-1.1b-old/gcc/config/i386/winnt.c
egcs-1.1b/gcc/config/i386/winnt.c
*** egcs-1.1b-old/gcc/config/i386/winnt.c Thu Aug 20 08:01:57 1998
--- egcs-1.1b/gcc/config/i386/winnt.c Sat Sep 05 16:31:31 1998
*************** i386_pe_valid_type_attribute_p (type, at
*** 79,84 ****
--- 79,86 ----
return 1;
if (is_attribute_p ("dllimport", attr))
return 1;
+ if (is_attribute_p ("comobject", attr))
+ return 1;
}
return i386_valid_type_attribute_p (type, attributes, attr, args);
diff -c3p -r egcs-1.1b-old/gcc/cp/class.c egcs-1.1b/gcc/cp/class.c
*** egcs-1.1b-old/gcc/cp/class.c Tue Jul 28 11:00:09 1998
--- egcs-1.1b/gcc/cp/class.c Sat Sep 05 16:32:05 1998
*************** int n_build_method_call = 0;
*** 163,168 ****
--- 163,171 ----
int n_inner_fields_searched = 0;
#endif
+ /* Flag for improvements of the vtabe-thunks for Win32 */
+ int flag_win32_thunks = 0;
+
/* Virtual baseclass things. */
static tree
*************** set_rtti_entry (virtuals, offset, type)
*** 647,652 ****
--- 650,658 ----
{
tree vfn;
+ if (flag_win32_thunks)
+ return;
+
if (flag_rtti)
vfn = build1 (ADDR_EXPR, vfunc_ptr_type_node, get_tinfo_fn
(type));
else
*************** add_virtual_function (pv, phv, has_virtu
*** 1014,1020 ****
/* If we are using thunks, use two slots at the front, one
for the offset pointer, one for the tdesc pointer. */
! if (*has_virtual == 0 && flag_vtable_thunks)
{
*has_virtual = 1;
}
--- 1020,1026 ----
/* If we are using thunks, use two slots at the front, one
for the offset pointer, one for the tdesc pointer. */
! if (*has_virtual == 0 && flag_vtable_thunks &&
!flag_win32_thunks)
{
*has_virtual = 1;
}
*************** add_virtual_function (pv, phv, has_virtu
*** 1024,1030 ****
static tree index_table[256];
tree idx;
/* We skip a slot for the offset/tdesc entry. */
! int i = ++(*has_virtual);
if (i >= 256 || index_table[i] == 0)
{
--- 1030,1036 ----
static tree index_table[256];
tree idx;
/* We skip a slot for the offset/tdesc entry. */
! int i = flag_win32_thunks ? (*has_virtual)++ : ++(*has_virtual);
if (i >= 256 || index_table[i] == 0)
{
*************** skip_rtti_stuff (virtuals)
*** 2352,2369 ****
int n;
n = 0;
! if (*virtuals)
! {
! /* We always reserve a slot for the offset/tdesc entry. */
! ++n;
! *virtuals = TREE_CHAIN (*virtuals);
! }
! if (flag_vtable_thunks && *virtuals)
{
! /* The second slot is reserved for the tdesc pointer when thunks
! are used. */
! ++n;
! *virtuals = TREE_CHAIN (*virtuals);
}
return n;
}
--- 2358,2379 ----
int n;
n = 0;
!
! if (!flag_win32_thunks)
{
! if (*virtuals)
! {
! /* We always reserve a slot for the offset/tdesc entry. */
! ++n;
! *virtuals = TREE_CHAIN (*virtuals);
! }
! if (flag_vtable_thunks && *virtuals)
! {
! /* The second slot is reserved for the tdesc pointer when
thunks
! are used. */
! ++n;
! *virtuals = TREE_CHAIN (*virtuals);
! }
}
return n;
}
*************** finish_struct_1 (t, warn_anon)
*** 3988,3998 ****
if (first_vfn_base_index < 0)
{
/* The second slot is for the tdesc pointer when thunks are used.
*/
! if (flag_vtable_thunks)
pending_virtuals = tree_cons (NULL_TREE, NULL_TREE,
pending_virtuals);
/* The first slot is for the rtti offset. */
! pending_virtuals = tree_cons (NULL_TREE, NULL_TREE,
pending_virtuals);
set_rtti_entry (pending_virtuals,
convert (ssizetype, integer_zero_node), t);
--- 3998,4009 ----
if (first_vfn_base_index < 0)
{
/* The second slot is for the tdesc pointer when thunks are used.
*/
! if (flag_vtable_thunks && !flag_win32_thunks)
pending_virtuals = tree_cons (NULL_TREE, NULL_TREE,
pending_virtuals);
/* The first slot is for the rtti offset. */
! if (!flag_win32_thunks)
! pending_virtuals = tree_cons (NULL_TREE, NULL_TREE,
pending_virtuals);
set_rtti_entry (pending_virtuals,
convert (ssizetype, integer_zero_node), t);
*************** finish_struct (t, list_of_fieldlists, at
*** 4251,4256 ****
--- 4262,4274 ----
tree access;
tree dummy = NULL_TREE;
tree next_x = NULL_TREE;
+
+ flag_win32_thunks = 0;
+ if (lookup_attribute ("comobject", attributes))
+ if (flag_vtable_thunks)
+ flag_win32_thunks = 1;
+ else
+ cp_warning_at("'comobject' attribute ignored in `%D'", t);
if (TREE_CODE (name) == TYPE_DECL)
{
More information about the Gcc-patches
mailing list