From patchwork Tue Jun 6 13:41:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 103830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3403798vqr; Tue, 6 Jun 2023 06:42:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Cy2jOraf1h0lLlcRf60z5l2ZIwmbcr7WM8xd9g1pQnT+u5bxqEZ5cKJXQeDOZs+gRWbjB X-Received: by 2002:a17:907:7b9b:b0:974:5e14:29c5 with SMTP id ne27-20020a1709077b9b00b009745e1429c5mr2797575ejc.32.1686058963020; Tue, 06 Jun 2023 06:42:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686058963; cv=none; d=google.com; s=arc-20160816; b=y1cK9sv0Bbexmz/7EWQBjV2HFF+WKKqZkBzXVGw36EDTir6PSXM0+dPM35x0E3g/WN 1H+ClWARqf9fafNOBNlXrPg0f2sqtNcG3Q3sstzRY6z2GXhwI3SKrTBtO0JB0qphVU7U 9uiHralu66A0DBUA+rjI9eW5Kgsi0BYjRnE98ubEQw8iSWf6xMxeDzsZWPbaU6ZbDz8j GtDhY2cpFN06W6pgZzG4kLsfcdZlY12DpcHT20sG3L1bND4FWLODFCu3BUhkP8xlbtLn d0mJMk9xvskaTLZuDfRordSDtZRs6VDhWjL39IgILRrlFRWqxjjgrvRXiqPtXYePZCzE 92ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=VgX2v1MQaiDqSn7RvNY0vmd5Fi9Oax+wa7RfZeI68Rg=; b=W0veF6k9C2I9sAp3Ziqx1ic7PHNGXlTpjjkkk3HL++MHbq1oHjFie8zg8O94yimrzP 4Hjs8XzYSoWR4L5ffCB9ahymnoe0ZAVLeDu86zoeE+xape0nbnFsZH1hoNz21R88k4QX hrk2TLUqsJsr/T88PARMfUYzYpIBj06I2bZ0A/XFv13xWWrdkreTbF4wXqAwi43cwckp pdU+phpdbd9kWlekBek4RGjOZ0PsDXldi/VBlPKr3vIqECt4s0vT5DmeNMGwftJI+Wut /AAY88UF3bL84sCxU1qTWL/vVYvSWp+rIjscYQs6kBAAboLAvzFhpKT0Hshl+JdFEn7p vniw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kVpS2bXj; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id y10-20020a17090614ca00b0097454835fb5si6012591ejc.378.2023.06.06.06.42.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 06:42:43 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kVpS2bXj; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AB63A3858005 for ; Tue, 6 Jun 2023 13:42:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB63A3858005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686058961; bh=VgX2v1MQaiDqSn7RvNY0vmd5Fi9Oax+wa7RfZeI68Rg=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=kVpS2bXjhHVnuP3QPippngGFq7BQbx0xtTQfuFgQYXvaopYm2a0Y9CcoQZdRi6GKp 5vgCaaVo6te0Eg4sh3TmY+fiS4IjlDYFI+Ry/Z3aLzwVe/66rXgNbElK/jnLrsm+9M bEiPT0zvfR3OlBPGSrzfrtuC8t2CD1XoDAdzT+eo= 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 CEE2F3858D33 for ; Tue, 6 Jun 2023 13:41:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CEE2F3858D33 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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-102.mailbox.org (Postfix) with ESMTPS id 4QbBTv3HrNz9smT; Tue, 6 Jun 2023 15:41:55 +0200 (CEST) To: gcc-patches@gcc.gnu.org Cc: Iain Buclaw Subject: [GCC 12, committed] d: Merge upstream dmd 316b89f1e3, phobos 8e8aaae50. Date: Tue, 6 Jun 2023 15:41:53 +0200 Message-Id: <20230606134153.1592417-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767960963239020166?= X-GMAIL-MSGID: =?utf-8?q?1767960963239020166?= Hi, This patch merges the D front-end with upstream dmd 316b89f1e3, and standard library with phobos 8e8aaae50. Updates the D language version to v2.100.2 in the GCC 12 release branch. Phobos changes: - Fix instantiating std.container.array.Array!T where T is a shared class. - Fix calling toString on a const std.typecons.Nullable type. Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed to releases/gcc-12. Regards, Iain. --- gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 316b89f1e3. * dmd/VERSION: Bump version to v2.100.2. libphobos/ChangeLog: * src/MERGE: Merge upstream phobos 8e8aaae50. --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/VERSION | 2 +- libphobos/src/MERGE | 2 +- libphobos/src/std/container/array.d | 31 ++++++++++++++++------ libphobos/src/std/typecons.d | 40 +++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 11 deletions(-) diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index d79ebfae806..51736565a57 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -76e3b41375e3e1cb4dbca692b587d8e916c0b49f +316b89f1e3dffcad488c26f56f58c8adfcb84b26 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/VERSION b/gcc/d/dmd/VERSION index 83a14f57e16..868f8007d2f 100644 --- a/gcc/d/dmd/VERSION +++ b/gcc/d/dmd/VERSION @@ -1 +1 @@ -v2.100.1 +v2.100.2 diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index f2678185f39..8c570369602 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -5fef0d28fc873fb5a0dbfb9149759d76a7b9f1b7 +8e8aaae5080ccc2e0a2202cbe9778dca96496a95 The first line of this file holds the git revision number of the last merge done from the dlang/phobos repository. diff --git a/libphobos/src/std/container/array.d b/libphobos/src/std/container/array.d index 08f9ead196e..ecc45996925 100644 --- a/libphobos/src/std/container/array.d +++ b/libphobos/src/std/container/array.d @@ -412,9 +412,9 @@ if (!is(immutable T == immutable bool)) .destroy(e); static if (hasIndirections!T) - GC.removeRange(_payload.ptr); + GC.removeRange(cast(void*) _payload.ptr); - free(_payload.ptr); + free(cast(void*) _payload.ptr); } this(this) @disable; @@ -489,14 +489,14 @@ if (!is(immutable T == immutable bool)) auto newPayload = newPayloadPtr[0 .. oldLength]; // copy old data over to new array - memcpy(newPayload.ptr, _payload.ptr, T.sizeof * oldLength); + memcpy(cast(void*) newPayload.ptr, cast(void*) _payload.ptr, T.sizeof * oldLength); // Zero out unused capacity to prevent gc from seeing false pointers - memset(newPayload.ptr + oldLength, + memset( cast(void*) (newPayload.ptr + oldLength), 0, (elements - oldLength) * T.sizeof); - GC.addRange(newPayload.ptr, sz); - GC.removeRange(_payload.ptr); - free(_payload.ptr); + GC.addRange(cast(void*) newPayload.ptr, sz); + GC.removeRange(cast(void*) _payload.ptr); + free(cast(void*) _payload.ptr); _payload = newPayload; } else @@ -611,12 +611,17 @@ if (!is(immutable T == immutable bool)) return opEquals(rhs); } + // fix https://issues.dlang.org/show_bug.cgi?23140 + private alias Unshared(T) = T; + private alias Unshared(T: shared U, U) = U; + /// ditto bool opEquals(ref const Array rhs) const { if (empty) return rhs.empty; if (rhs.empty) return false; - return _data._payload == rhs._data._payload; + + return cast(Unshared!(T)[]) _data._payload == cast(Unshared!(T)[]) rhs._data._payload; } /** @@ -1740,6 +1745,16 @@ if (!is(immutable T == immutable bool)) assertThrown!AssertError(array.length = 5); } +// https://issues.dlang.org/show_bug.cgi?id=23140 +@system unittest +{ + shared class C + { + } + + Array!C ac; + ac = Array!C([new C]); +} //////////////////////////////////////////////////////////////////////////////// // Array!bool //////////////////////////////////////////////////////////////////////////////// diff --git a/libphobos/src/std/typecons.d b/libphobos/src/std/typecons.d index fb15001233a..34e884cac8a 100644 --- a/libphobos/src/std/typecons.d +++ b/libphobos/src/std/typecons.d @@ -3793,8 +3793,28 @@ Params: sink.formatValue(_value, fmt); } } + + void toString()(scope void delegate(const(char)[]) sink, scope const ref FormatSpec!char fmt) const + { + if (isNull) + { + sink.formatValue("Nullable.null", fmt); + } + else + { + sink.formatValue(_value, fmt); + } + } } +@system unittest +{ + import std.conv : to; + + const Nullable!(ulong, 0) x = 1; + assert(x.to!string == "1"); +} + /** Check if `this` is in the null state. @@ -4320,8 +4340,28 @@ Params: sink.formatValue(*_value, fmt); } } + + void toString()(scope void delegate(const(char)[]) sink, scope const ref FormatSpec!char fmt) const + { + if (isNull) + { + sink.formatValue("Nullable.null", fmt); + } + else + { + sink.formatValue(*_value, fmt); + } + } } +@system unittest +{ + import std.conv : to; + + const NullableRef!(ulong) x = new ulong(1); + assert(x.to!string == "1"); +} + /** Binds the internal state to `value`.