d: Fix undefined reference to pragma(inline) symbol (PR106563)
authorIain Buclaw <ibuclaw@gdcproject.org>
Tue, 9 Aug 2022 10:48:14 +0000 (12:48 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Tue, 9 Aug 2022 12:42:11 +0000 (14:42 +0200)
commit79a86a608691621659b3ce3a24a72aeea4054668
tree378b5d5ac01360635712fcc5c99ae43fcc2a7ff4
parente62a644fb3bcc9c67c97ea28a3c441fb144a56a4
d: Fix undefined reference to pragma(inline) symbol (PR106563)

Functions that are declared `pragma(inline)' should be treated as if
they are defined in every translation unit they are referenced from,
regardless of visibility protection.  Ensure they always get
DECL_ONE_ONLY linkage, and start emitting them into other modules that
import them.

PR d/106563

gcc/d/ChangeLog:

* decl.cc (DeclVisitor::visit (FuncDeclaration *)): Set semanticRun
before generating its symbol.
(function_defined_in_root_p): New function.
(function_needs_inline_definition_p): New function.
(maybe_build_decl_tree): New function.
(get_symbol_decl): Call maybe_build_decl_tree before returning symbol.
(start_function): Use function_defined_in_root_p instead of inline
test for locally defined symbols.
(set_linkage_for_decl): Check for inline functions before private or
protected symbols.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/torture.exp (srcdir): New proc.
* gdc.dg/torture/imports/pr106563math.d: New test.
* gdc.dg/torture/imports/pr106563regex.d: New test.
* gdc.dg/torture/imports/pr106563uni.d: New test.
* gdc.dg/torture/pr106563.d: New test.

(cherry picked from commit 04284176d549ff2565406406a6d53ab4ba8e507d)
gcc/d/decl.cc
gcc/testsuite/gdc.dg/torture/imports/pr106563math.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/torture/imports/pr106563regex.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/torture/imports/pr106563uni.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/torture/pr106563.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/torture/torture.exp