From 447d196e75d97a9ac7c6a548dc9d0fe367adf6be Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 16 Mar 2020 23:04:49 +0100 Subject: 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. --- gcc/d/ChangeLog | 6 ++++++ gcc/d/decl.cc | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'gcc/d') diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog index fbd56b7..d9c7657 100644 --- a/gcc/d/ChangeLog +++ b/gcc/d/ChangeLog @@ -1,3 +1,9 @@ +2020-03-16 Iain Buclaw + + 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 Update copyright years. diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 3824060..7afb1aa 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -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. */ -- cgit v1.1