From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7948) id 63FEC3858D34; Sun, 14 Apr 2024 10:58:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63FEC3858D34 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713092295; bh=jGOQJF1QNtK7vA9THhAlbjrOmMwb6UCjlJQbW2gYwvs=; h=From:To:Subject:Date:From; b=QZFBnuL+FPgLJv+9AS19rxZl9Wd8+FpnwM9kjyuZbbPeNaIMKVGatiKUa7JfqkLzH NUfNj/u38tSQJN5Kr/paM5tkMMETAqOuYS+AQ3wz4Oea7KxX9br2R0F68IB2BusEUy UGdCtNO4RhpyKQpoiLJOGCneW4fVYhRgCAy00nh8= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Nathaniel Shead To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-9959] c++: Setup aliases imported from modules [PR106820] X-Act-Checkin: gcc X-Git-Author: Nathaniel Shead X-Git-Refname: refs/heads/master X-Git-Oldrev: 3319d1a4aa5ccadc22dcb80252ab884c792b263b X-Git-Newrev: 62a0ef0d02cbb74cd865c1db2ecb7ca1b11f87cd Message-Id: <20240414105815.63FEC3858D34@sourceware.org> Date: Sun, 14 Apr 2024 10:58:15 +0000 (GMT) List-Id: https://gcc.gnu.org/g:62a0ef0d02cbb74cd865c1db2ecb7ca1b11f87cd commit r14-9959-g62a0ef0d02cbb74cd865c1db2ecb7ca1b11f87cd Author: Nathaniel Shead Date: Sat Feb 17 23:10:49 2024 +1100 c++: Setup aliases imported from modules [PR106820] I wonder if more generally we need to be doing more work when importing definitions from header units especially to handle all the work that 'make_rtl_for_nonlocal_decl' and 'rest_of_decl_compilation' would have been performing. But this patch fixes at least one missing step. PR c++/106820 gcc/cp/ChangeLog: * module.cc (trees_in::decl_value): Assemble alias when needed. gcc/testsuite/ChangeLog: * g++.dg/modules/pr106820_a.H: New test. * g++.dg/modules/pr106820_b.C: New test. Signed-off-by: Nathaniel Shead Diff: --- gcc/cp/module.cc | 9 +++++++++ gcc/testsuite/g++.dg/modules/pr106820_a.H | 5 +++++ gcc/testsuite/g++.dg/modules/pr106820_b.C | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index c6f71e11515..001430a4a8f 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -219,6 +219,7 @@ Classes used: #include "dumpfile.h" #include "bitmap.h" #include "cgraph.h" +#include "varasm.h" #include "tree-iterator.h" #include "cpplib.h" #include "mkdeps.h" @@ -8414,6 +8415,14 @@ trees_in::decl_value () if (state->is_header () && decl_tls_wrapper_p (decl)) note_vague_linkage_fn (decl); + + /* Setup aliases for the declaration. */ + if (tree alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl))) + { + alias = TREE_VALUE (TREE_VALUE (alias)); + alias = get_identifier (TREE_STRING_POINTER (alias)); + assemble_alias (decl, alias); + } } else { diff --git a/gcc/testsuite/g++.dg/modules/pr106820_a.H b/gcc/testsuite/g++.dg/modules/pr106820_a.H new file mode 100644 index 00000000000..7d32d4e5fc3 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/pr106820_a.H @@ -0,0 +1,5 @@ +// PR c++/106820 +// { dg-additional-options "-fmodules-ts" } +// { dg-module-cmi {} } + +static int __gthrw___pthread_key_create() __attribute__((__weakref__("foo"))); diff --git a/gcc/testsuite/g++.dg/modules/pr106820_b.C b/gcc/testsuite/g++.dg/modules/pr106820_b.C new file mode 100644 index 00000000000..247fe26e778 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/pr106820_b.C @@ -0,0 +1,8 @@ +// PR c++/106820 +// { dg-additional-options "-fmodules-ts" } + +import "pr106820_a.H"; + +int main() { + __gthrw___pthread_key_create(); +}