Commit 447d196e by Iain Buclaw

d: Fix multiple definition error when using mixins and interfaces.

gcc/d/ChangeLog:

	PR d/92216
	* decl.cc (make_thunk): Don't set TREE_PUBLIC on thunks if the target
	function is external to the current compilation.

gcc/testsuite/ChangeLog:

	PR d/92216
	* gdc.dg/imports/pr92216.d: New.
	* gdc.dg/pr92216.d: New test.
parent c015ff8c
2020-03-16 Iain Buclaw <ibuclaw@gdcproject.org>
PR d/92216
* decl.cc (make_thunk): Don't set TREE_PUBLIC on thunks if the target
function is external to the current compilation.
2020-01-01 Jakub Jelinek <jakub@redhat.com>
Update copyright years.
......
......@@ -1803,8 +1803,11 @@ make_thunk (FuncDeclaration *decl, int offset)
DECL_CONTEXT (thunk) = d_decl_context (decl);
/* Thunks inherit the public access of the function they are targetting. */
TREE_PUBLIC (thunk) = TREE_PUBLIC (function);
/* Thunks inherit the public access of the function they are targetting.
When the function is outside the current compilation unit however, then the
thunk must be kept private to not conflict. */
TREE_PUBLIC (thunk) = TREE_PUBLIC (function) && !DECL_EXTERNAL (function);
DECL_EXTERNAL (thunk) = 0;
/* Thunks are always addressable. */
......
2020-03-16 Iain Buclaw <ibuclaw@gdcproject.org>
PR d/92216
* gdc.dg/imports/pr92216.d: New.
* gdc.dg/pr92216.d: New test.
2020-03-16 Jakub Jelinek <jakub@redhat.com>
PR c/94179
......
module imports.pr92216;
class B : I
{
protected override void getStruct(){}
mixin A!();
}
mixin template A()
{
public void* getS()
{
return null;
}
}
public interface I
{
public void* getS();
protected void getStruct();
}
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92216
// { dg-options "-I $srcdir/gdc.dg" }
// { dg-do compile }
// { dg-final { scan-assembler "_DT16_D7imports7pr922161B8__mixin24getSMFZPv\[: \t\n\]" } }
// { dg-final { scan-assembler-not "(.globl|.global)\[ \]+_DT16_D7imports7pr922161B8__mixin24getSMFZPv" } }
module pr92216;
private import imports.pr92216;
class C : B
{
protected override void getStruct() {}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment