From: Iain Buclaw Date: Tue, 6 Jun 2023 13:25:59 +0000 (+0200) Subject: d: Merge upstream dmd 316b89f1e3, phobos 8e8aaae50. X-Git-Tag: vendors/ARM/release-12.3.rel1~50 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6a204757ffc734de7e7794e337cd6d387cf18a48;p=thirdparty%2Fgcc.git d: Merge upstream dmd 316b89f1e3, phobos 8e8aaae50. Updates D language version to v2.100.2. 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. 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. --- diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index d79ebfae806f..51736565a57e 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 83a14f57e169..868f8007d2f6 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 f2678185f39d..8c5703696026 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 08f9ead196ee..ecc459969254 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 fb15001233ae..34e884cac8a6 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`.