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`. -- 2.39.2