From patchwork Wed Apr 14 12:46:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1466224 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=xgiTw9rY; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FL2L15wvbz9sWK for ; Wed, 14 Apr 2021 22:47:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC651388C005; Wed, 14 Apr 2021 12:47:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC651388C005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1618404423; bh=/qtJbBOhNbleCnCH4o4EGYMj/oc98cIEV0MZJPFtJAQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xgiTw9rYIXcpSKbjR1zuELIuokzI1y1YYSqerWj+9bZ8wWiQ539DaeB2uRmxV7MGq lyuReW0uqM0zZswdO8gvAUwqz+8S6Us1NZWQ2dxE3h17W0CSD5+vZn1r9LOlJ8sVgJ J0ML9WC2KYC8oZTpV+rU5MNwSteBgxj04FCNOvqE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by sourceware.org (Postfix) with ESMTPS id 6C734385E013 for ; Wed, 14 Apr 2021 12:47:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6C734385E013 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4FL2Kt6mvNzQk14; Wed, 14 Apr 2021 14:46:58 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id On4uA4mIHrs6; Wed, 14 Apr 2021 14:46:52 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Move call to set_linkage_for_decl to declare_extern_var. Date: Wed, 14 Apr 2021 14:46:50 +0200 Message-Id: <20210414124650.400420-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-MBO-SPAM-Probability: ****** X-Rspamd-Score: 8.63 / 15.00 / 15.00 X-Rspamd-Queue-Id: F252F183D X-Rspamd-UID: 12b469 X-Spam-Status: No, score=-15.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch moves the call to the newly introduced set_linkage_for_decl in the D front-end from d_finish_decl to declare_extern_var. This both prevents against it being called twice for declarations that are defined, and fixes an issue where variables defined in the compilation get one kind of linkage (weak), and the same variables declared via declare_extern_var get another (extern). Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32, as well as testing on port of x86_64-mingw32. Committed to mainline. Regards, Iain. --- gcc/d/ChangeLog: PR d/99914 * decl.cc (DeclVisitor::visit (StructDeclaration *)): Don't set DECL_INSTANTIATED on static initializer declarations. (DeclVisitor::visit (ClassDeclaration *)): Likewise. (DeclVisitor::visit (EnumDeclaration *)): Likewise. (d_finish_decl): Move call to set_linkage_for_decl to... (declare_extern_var): ...here. --- gcc/d/decl.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index b07068ed6ca..8948e40e902 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -387,7 +387,6 @@ public: /* Generate static initializer. */ d->sinit = aggregate_initializer_decl (d); DECL_INITIAL (d->sinit) = layout_struct_initializer (d); - DECL_INSTANTIATED (d->sinit) = (d->isInstantiated () != NULL); d_finish_decl (d->sinit); /* Put out the members. There might be static constructors in the members @@ -500,7 +499,6 @@ public: /* Generate static initializer. */ DECL_INITIAL (d->sinit) = layout_class_initializer (d); - DECL_INSTANTIATED (d->sinit) = (d->isInstantiated () != NULL); d_finish_decl (d->sinit); /* Put out the TypeInfo. */ @@ -611,7 +609,6 @@ public: /* Generate static initializer. */ d->sinit = enum_initializer_decl (d); DECL_INITIAL (d->sinit) = build_expr (tc->sym->defaultval, true); - DECL_INSTANTIATED (d->sinit) = (d->isInstantiated () != NULL); d_finish_decl (d->sinit); } @@ -1379,6 +1376,8 @@ declare_extern_var (tree ident, tree type) /* The decl has not been defined -- yet. */ DECL_EXTERNAL (decl) = 1; + set_linkage_for_decl (decl); + return decl; } @@ -1540,7 +1539,6 @@ d_finish_decl (tree decl) set_decl_tls_model (decl, decl_default_tls_model (decl)); relayout_decl (decl); - set_linkage_for_decl (decl); if (flag_checking && DECL_INITIAL (decl)) {