Skip to content

Commit

Permalink
use COMDATs for class info
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Aug 23, 2015
1 parent 4fe3fb8 commit ceea6ac
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/toobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@ void toObjFile(Dsymbol *ds, bool multiobj)

assert(!cd->scope); // semantic() should have been run to completion

enum_SC scclass = SCglobal;
if (cd->isInstantiated())
scclass = SCcomdat;
enum_SC scclass = SCcomdat;

// Put out the members
for (size_t i = 0; i < cd->members->dim; i++)
Expand Down Expand Up @@ -367,7 +365,10 @@ void toObjFile(Dsymbol *ds, bool multiobj)

// vtbl[]
dtsize_t(&dt, cd->vtbl.dim);
dtxoff(&dt, cd->vtblsym, 0, TYnptr);
if (cd->vtbl.dim)
dtxoff(&dt, cd->vtblsym, 0, TYnptr);
else
dtsize_t(&dt, 0);

// interfaces[]
dtsize_t(&dt, cd->vtblInterfaces->dim);
Expand Down Expand Up @@ -642,6 +643,14 @@ void toObjFile(Dsymbol *ds, bool multiobj)
else
dtsize_t(&dt, 0);
}
if (!dt)
{
/* Someone made an 'extern (C++) class C { }' with no virtual functions.
* But making an empty vtbl[] causes linking problems, so make a dummy
* entry.
*/
dtsize_t(&dt, 0);
}
cd->vtblsym->Sdt = dt;
cd->vtblsym->Sclass = scclass;
cd->vtblsym->Sfl = FLdata;
Expand All @@ -667,9 +676,7 @@ void toObjFile(Dsymbol *ds, bool multiobj)
if (global.params.symdebug)
toDebug(id);

enum_SC scclass = SCglobal;
if (id->isInstantiated())
scclass = SCcomdat;
enum_SC scclass = SCcomdat;

// Put out the members
for (size_t i = 0; i < id->members->dim; i++)
Expand Down

0 comments on commit ceea6ac

Please sign in to comment.