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

Commit

Permalink
Merge pull request #245 from jpf91/231
Browse files Browse the repository at this point in the history
Fix issue 231 (mixin template emitted into multiple object files)
  • Loading branch information
jpf91 authored Oct 1, 2016
2 parents 4191dbf + 66396eb commit ef3141d
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 11 deletions.
4 changes: 4 additions & 0 deletions gcc/d/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2016-09-26 Johannes Pfau <johannespfau@gmail.com>

* d-objfile.cc (d_finish_function): Handle template mixins (issue 231).

2016-09-18 Iain Buclaw <ibuclaw@gdcproject.org>

* imports.cc (ImportVisitor::visit(ScopeDsymbol)): New visit method.
Expand Down
14 changes: 3 additions & 11 deletions gcc/d/d-objfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1897,18 +1897,10 @@ d_finish_function(FuncDeclaration *fd)
// If we generated the function, but it's really extern.
// Such as external inlinable functions or thunk aliases.
bool extern_p = false;
for (FuncDeclaration *fdp = fd; fdp != NULL;)
{
if (fdp->inNonRoot())
{
extern_p = true;
break;
}

if (!fdp->isNested())
break;

fdp = fdp->toParent2()->isFuncDeclaration();
if (!fd->isInstantiated() && fd->getModule() && !fd->getModule()->isRoot())
{
extern_p = true;
}

if (extern_p)
Expand Down
16 changes: 16 additions & 0 deletions gcc/testsuite/gdc.test/compilable/gdc231.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// EXTRA_SOURCES: imports/gdc231a.d
module gdc231;

import imports.gdc231a;

class Range : Widget
{
void* getStruct()
{
return null;
}
}

void main()
{
}
18 changes: 18 additions & 0 deletions gcc/testsuite/gdc.test/compilable/gdc27.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// EXTRA_SOURCES: imports/gdc27a.d
module gdc27;

import imports.gdc27a;

interface I_B : I_A
{
void b();
}

abstract class C_B : C_A, I_B
{
abstract void b();
}

void main()
{
}
24 changes: 24 additions & 0 deletions gcc/testsuite/gdc.test/compilable/imports/gdc231a.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module imports.gdc231a;

interface ImplementorIF
{
void* getImplementorStruct();
void* getStruct();
}

template ImplementorT()
{
void* getImplementorStruct()
{
return null;
}
}

class Widget : ImplementorIF
{
mixin ImplementorT;
void* getStruct()
{
return null;
}
}
14 changes: 14 additions & 0 deletions gcc/testsuite/gdc.test/compilable/imports/gdc27a.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module imports.gdc27a;

interface I_A
{
bool a();
}

class C_A : I_A
{
bool a()
{
return false;
}
}

0 comments on commit ef3141d

Please sign in to comment.