Skip to content

Commit

Permalink
fix Issue 13043 - Redundant linking to TypeInfo in non-root module
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Jul 4, 2014
1 parent 1cccc74 commit 896c180
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/typinf.c
Expand Up @@ -131,11 +131,19 @@ void Type::genTypeInfo(Scope *sc)
// Generate COMDAT
if (sc) // if in semantic() pass
{
// Find module that will go all the way to an object file
Module *m = sc->module->importedFrom;
m->members->push(t->vtinfo);
if (sc->func && !sc->func->isInstantiated() && sc->func->inNonRoot())
{
// Bugzilla 13043: Avoid linking TypeInfo if it's not
// necessary for root module compilation
}
else
{
// Find module that will go all the way to an object file
Module *m = sc->module->importedFrom;
m->members->push(t->vtinfo);

semanticTypeInfo(sc, t);
semanticTypeInfo(sc, t);
}
}
else // if in obj generation pass
{
Expand Down
17 changes: 17 additions & 0 deletions test/runnable/imports/link13043a.d
@@ -0,0 +1,17 @@
module imports.lin13043a;

struct QualifiedNameTests
{
struct Inner
{
const int opCmp(ref const Inner) { return 0; }
}

shared(const(Inner[string])[]) data;

version(bug)
size_t toHash() const
{
return typeid(typeof(data)).getHash(cast(const void*)&data);
}
}
5 changes: 5 additions & 0 deletions test/runnable/link13043.d
@@ -0,0 +1,5 @@
// PERMUTE_ARGS: -g -inline -version=bug -release -O

import imports.link13043a;

void main() {}

0 comments on commit 896c180

Please sign in to comment.