From patchwork Thu Jun 25 15:38:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1317010 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; dmarc=none (p=none dis=none) header.from=gcc.gnu.org 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=msZOPFh/; dkim-atps=neutral Received: from sourceware.org (server2.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 49t41m6H6Vz9sRW for ; Fri, 26 Jun 2020 01:39:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1DDFB388A80D; Thu, 25 Jun 2020 15:39:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DDFB388A80D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593099544; bh=vl2jrNdHIhXcRDHeHnJu0aJBnaOQ5TJ5diocBF+csuQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=msZOPFh/EX3hOjn9/2aMugovIkTOFXz/IJIOlwkUOeCW1NVhaYavyzojO2oXLfr/Z yY4iQ7DeYQR+Z52O3JW3FK5+RTzRyBqjJZDhIbKaj1zl+AqLBW7uXYQS4MobEF/Rfp VComi+Bb8d46Rf2c7N/j6bAfJvMwPsV/JNX0vdVU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by sourceware.org (Postfix) with ESMTPS id D3E7F388A806 for ; Thu, 25 Jun 2020 15:39:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D3E7F388A806 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 49t41b3gCpzKmgv; Thu, 25 Jun 2020 17:38:59 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id yEuge8_N5Hcp; Thu, 25 Jun 2020 17:38:56 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Merge upstream dmd 4be011355. Date: Thu, 25 Jun 2020 17:38:21 +0200 Message-Id: <20200625153828.2304469-4-ibuclaw@gdcproject.org> In-Reply-To: <20200625153828.2304469-1-ibuclaw@gdcproject.org> References: <20200625153828.2304469-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-MBO-SPAM-Probability: 8 X-Rspamd-Score: 1.28 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5B58A1800 X-Rspamd-UID: a7a37f X-Spam-Status: No, score=-17.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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 merges the D front-end implementation with upstream dmd 4be011355. Fixes self-assignment warnings seen when compiling with clang. Bootstrapped and regression tested on x86_64-linux-gnu, and committed to mainline. Regards Iain. --- gcc/d/ChangeLog: PR d/95075 * dmd/MERGE: Merge upstream dmd 4be011355. --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/dscope.c | 98 +++++++++++++++++++++++++--------------------- 2 files changed, 55 insertions(+), 45 deletions(-) diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 0d50149a750..7de89351482 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -90450f3ef6ab8551b5f383d8c6190f80034dbf93 +4be011355dd2c5e2e54b99f9369d5faeabca2ca5 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/dscope.c b/gcc/d/dmd/dscope.c index 32aa965a932..32caf7d2409 100644 --- a/gcc/d/dmd/dscope.c +++ b/gcc/d/dmd/dscope.c @@ -291,54 +291,64 @@ unsigned *Scope::saveFieldInit() return fi; } -static bool mergeFieldInit(unsigned &fieldInit, unsigned fi, bool mustInit) +/**************************************** + * Merge `b` flow analysis results into `a`. + * Params: + * a = the path to merge fi into + * b = the other path + * Returns: + * false means either `a` or `b` skips initialization + */ +static bool mergeFieldInit(unsigned &a, const unsigned b) { - if (fi != fieldInit) - { - // Have any branches returned? - bool aRet = (fi & CSXreturn) != 0; - bool bRet = (fieldInit & CSXreturn) != 0; + if (b == a) + return true; - // Have any branches halted? - bool aHalt = (fi & CSXhalt) != 0; - bool bHalt = (fieldInit & CSXhalt) != 0; + // Have any branches returned? + bool aRet = (a & CSXreturn) != 0; + bool bRet = (b & CSXreturn) != 0; - bool ok; + // Have any branches halted? + bool aHalt = (a & CSXhalt) != 0; + bool bHalt = (b & CSXhalt) != 0; - if (aHalt && bHalt) - { - ok = true; - fieldInit = CSXhalt; - } - else if (!aHalt && aRet) - { - ok = !mustInit || (fi & CSXthis_ctor); - fieldInit = fieldInit; - } - else if (!bHalt && bRet) - { - ok = !mustInit || (fieldInit & CSXthis_ctor); - fieldInit = fi; - } - else if (aHalt) - { - ok = !mustInit || (fieldInit & CSXthis_ctor); - fieldInit = fieldInit; - } - else if (bHalt) - { - ok = !mustInit || (fi & CSXthis_ctor); - fieldInit = fi; - } - else - { - ok = !mustInit || !((fieldInit ^ fi) & CSXthis_ctor); - fieldInit |= fi; - } + if (aHalt && bHalt) + { + a = CSXhalt; + return true; + } - return ok; + // The logic here is to prefer the branch that neither halts nor returns. + bool ok; + if (!bHalt && bRet) + { + // Branch b returns, no merging required. + ok = (b & CSXthis_ctor); + } + else if (!aHalt && aRet) + { + // Branch a returns, but b doesn't, b takes precedence. + ok = (a & CSXthis_ctor); + a = b; + } + else if (bHalt) + { + // Branch b halts, no merging required. + ok = (a & CSXthis_ctor); + } + else if (aHalt) + { + // Branch a halts, but b doesn't, b takes precedence + ok = (b & CSXthis_ctor); + a = b; + } + else + { + // Neither branch returns nor halts, merge flags + ok = !((a ^ b) & CSXthis_ctor); + a |= b; } - return true; + return ok; } void Scope::mergeFieldInit(Loc loc, unsigned *fies) @@ -356,9 +366,9 @@ void Scope::mergeFieldInit(Loc loc, unsigned *fies) bool mustInit = (v->storage_class & STCnodefaultctor || v->type->needsNested()); - if (!::mergeFieldInit(fieldinit[i], fies[i], mustInit)) + if (!::mergeFieldInit(fieldinit[i], fies[i]) && mustInit) { - ::error(loc, "one path skips field %s", ad->fields[i]->toChars()); + ::error(loc, "one path skips field %s", v->toChars()); } } }