diff mbox series

[committed,07/12] d: Set COMDAT and visibility of thunks only if they are public.

Message ID 20210730110111.569140-7-ibuclaw@gdcproject.org
State New
Headers show
Series d: Series of refactorings to the D front-end | expand

Commit Message

Iain Buclaw July 30, 2021, 11:01 a.m. UTC
It is not expected to have a member function that can be non-public, but
this guards against any internal errors that might occur should that
ever change in the front-end.

gcc/d/ChangeLog:

	* decl.cc (make_thunk): Set COMDAT and visibility of thunks only if
	they are public.
---
 gcc/d/decl.cc | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 59991c3c255..cf61cd49159 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -1781,9 +1781,12 @@  make_thunk (FuncDeclaration *decl, int offset)
   DECL_ARTIFICIAL (thunk) = 1;
   DECL_DECLARED_INLINE_P (thunk) = 0;
 
-  DECL_VISIBILITY (thunk) = DECL_VISIBILITY (function);
-  DECL_COMDAT (thunk) = DECL_COMDAT (function);
-  DECL_WEAK (thunk) = DECL_WEAK (function);
+  if (TREE_PUBLIC (thunk))
+    {
+      DECL_VISIBILITY (thunk) = DECL_VISIBILITY (function);
+      DECL_COMDAT (thunk) = DECL_COMDAT (function);
+      DECL_WEAK (thunk) = DECL_WEAK (function);
+    }
 
   /* When the thunk is for an extern C++ function, let C++ do the thunk
      generation and just reference the symbol as extern, instead of