Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Don't add __monitor field for extern(C++) classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Jan 5, 2014
1 parent faac13e commit a6464b9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
3 changes: 3 additions & 0 deletions gcc/d/ChangeLog
@@ -1,5 +1,8 @@
2014-01-06 Iain Buclaw <ibuclaw@gdcproject.org>

* d-ctype.cc(TypeClass::toCtype): Don't add __monitor field for
extern(C++) classes.

* d-builtins.c(d_gcc_magic_module): Remove tdata.
* d-codegen.cc(build_interface_binfo): Likewise.
* d-ctype.cc(TypeEnum::toCtype): Likewise.
Expand Down
39 changes: 22 additions & 17 deletions gcc/d/d-ctype.cc
Expand Up @@ -622,12 +622,13 @@ TypeClass::toCtype (void)
// Add the virtual table pointer
tree decl = build_decl (UNKNOWN_LOCATION, FIELD_DECL,
get_identifier ("__vptr"), d_vtbl_ptr_type_node);
agg_layout.addField (decl, 0); // %% target stuff..
agg_layout.addField (decl, 0);

if (inherited)
{
vfield = copy_node (decl);
DECL_ARTIFICIAL (decl) = DECL_IGNORED_P (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
}
else
{
Expand All @@ -637,29 +638,33 @@ TypeClass::toCtype (void)
TYPE_VFIELD (rec_type) = vfield;
TREE_ADDRESSABLE (rec_type) = 1;

if (!sym->isInterfaceDeclaration())
if (sym->isInterfaceDeclaration())
{
tree obj_rec_type = TREE_TYPE (build_object_type()->toCtype());
DECL_FCONTEXT (vfield) = obj_rec_type;
ClassDeclaration *p = sym;

// Add the monitor
decl = build_decl (UNKNOWN_LOCATION, FIELD_DECL,
get_identifier ("__monitor"), ptr_type_node);
DECL_FCONTEXT (decl) = obj_rec_type;
DECL_ARTIFICIAL (decl) = DECL_IGNORED_P (decl) = inherited;
agg_layout.addField (decl, Target::ptrsize);
while (p->baseclasses->dim)
p = (*p->baseclasses)[0]->base;

// Add the fields of each base class
agg_layout.go();
DECL_FCONTEXT (vfield) = TREE_TYPE (p->type->toCtype());
}
else
{
ClassDeclaration *p = sym;
tree obj_type = TREE_TYPE (build_object_type()->toCtype());
DECL_FCONTEXT (vfield) = obj_type;

while (p->baseclasses->dim)
p = (*p->baseclasses)[0]->base;
if (!sym->cpp)
{
// Add the monitor
decl = build_decl (UNKNOWN_LOCATION, FIELD_DECL,
get_identifier ("__monitor"), ptr_type_node);
DECL_FCONTEXT (decl) = obj_type;
DECL_ARTIFICIAL (decl) = inherited;
DECL_IGNORED_P (decl) = inherited;
agg_layout.addField (decl, Target::ptrsize);
}

DECL_FCONTEXT (vfield) = TREE_TYPE (p->type->toCtype());
// Add the fields of each base class
agg_layout.go();
}

agg_layout.finish (sym->userAttributes);
Expand Down

0 comments on commit a6464b9

Please sign in to comment.