Skip to content

Commit

Permalink
Merge pull request #4916 from WalterBright/classcomdat
Browse files Browse the repository at this point in the history
use COMDATs for class info
  • Loading branch information
andralex committed Sep 9, 2015
2 parents 1fcabd1 + ceea6ac commit 23f4c59
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 @@ -270,9 +270,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 @@ -368,7 +366,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 @@ -643,6 +644,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 @@ -668,9 +677,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 23f4c59

Please sign in to comment.