diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2023-11-02 13:24:07 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2023-11-02 14:54:13 +0100 |
commit | 04802ed3b94bdc3083547ac08bca71764a004d01 (patch) | |
tree | 2d492f8013b9bdb4af409c973fdd3990ab34dd31 /libphobos/src | |
parent | 8a4cde6319b40802a842a8fe71267524dd8af828 (diff) | |
download | gcc-04802ed3b94bdc3083547ac08bca71764a004d01.zip gcc-04802ed3b94bdc3083547ac08bca71764a004d01.tar.gz gcc-04802ed3b94bdc3083547ac08bca71764a004d01.tar.bz2 |
d: Merge upstream dmd, druntime 643b1261bb, phobos 1c98326e7
D front-end changes:
- Suggested preview switches now give gdc flags (PR109681).
- `new S[10]' is now lowered to `_d_newarrayT!S(10)'.
D runtime changes:
- Runtime compiler library functions `_d_newarrayU', `_d_newarrayT',
`_d_newarrayiT' have been converted to templates.
Phobos changes:
- Add new `std.traits.Unshared' template.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd 643b1261bb.
* d-attribs.cc (build_attributes): Update for new front-end interface.
* d-lang.cc (d_post_options): Likewise.
* decl.cc (layout_class_initializer): Likewise.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime 643b1261bb.
* libdruntime/Makefile.am (DRUNTIME_DSOURCES_FREEBSD): Add
core/sys/freebsd/ifaddrs.d, core/sys/freebsd/net/if_dl.d,
core/sys/freebsd/sys/socket.d, core/sys/freebsd/sys/types.d.
(DRUNTIME_DSOURCES_LINUX): Add core/sys/linux/linux/if_arp.d,
core/sys/linux/linux/if_packet.d.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos 1c98326e7.
Diffstat (limited to 'libphobos/src')
-rw-r--r-- | libphobos/src/MERGE | 2 | ||||
-rw-r--r-- | libphobos/src/std/parallelism.d | 4 | ||||
-rw-r--r-- | libphobos/src/std/range/primitives.d | 17 | ||||
-rw-r--r-- | libphobos/src/std/traits.d | 41 |
4 files changed, 54 insertions, 10 deletions
diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index a7bf856..8c536ce 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -2458e8f82e3004197d8a66239a6b72e17264bb26 +1c98326e787e504d9045004e593273ec99b13121 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/parallelism.d b/libphobos/src/std/parallelism.d index 3fe8cd6..fadb4c1 100644 --- a/libphobos/src/std/parallelism.d +++ b/libphobos/src/std/parallelism.d @@ -418,8 +418,8 @@ Bugs: Changes to `ref` and `out` arguments are not propagated to the */ struct Task(alias fun, Args...) { - AbstractTask base = {runTask : &impl}; - alias base this; + private AbstractTask base = {runTask : &impl}; + private alias base this; private @property AbstractTask* basePtr() { diff --git a/libphobos/src/std/range/primitives.d b/libphobos/src/std/range/primitives.d index 1a3fb06..89cfa07 100644 --- a/libphobos/src/std/range/primitives.d +++ b/libphobos/src/std/range/primitives.d @@ -165,21 +165,24 @@ See_Also: Params: R = type to be tested - E = the type of the elements of the range if not `void` + E = if present, the elements of the range must be + $(DDSUBLINK spec/const3, implicit_qualifier_conversions, qualifier-convertible) + to this type Returns: `true` if R is an input range (possibly with element type `E`), `false` if not */ -enum bool isInputRange(R, E = void) = +enum bool isInputRange(R) = is(typeof(R.init) == R) && is(typeof((R r) { return r.empty; } (R.init)) == bool) && (is(typeof((return ref R r) => r.front)) || is(typeof(ref (return ref R r) => r.front))) && !is(typeof((R r) { return r.front; } (R.init)) == void) - && is(typeof((R r) => r.popFront)) - && (is(E == void) || - is(ElementType!R == E) || - is(const(ElementType!R) == E) || - (is(const(ElementType!R) == immutable E) && is(const(E) == E))); + && is(typeof((R r) => r.popFront)); + +/// ditto +enum bool isInputRange(R, E) = + .isInputRange!R && isQualifierConvertible!(ElementType!R, E); + /// @safe unittest { diff --git a/libphobos/src/std/traits.d b/libphobos/src/std/traits.d index aa69aac..2e7a4f6 100644 --- a/libphobos/src/std/traits.d +++ b/libphobos/src/std/traits.d @@ -132,6 +132,7 @@ * $(LREF PointerTarget) * $(LREF Signed) * $(LREF Unconst) + * $(LREF Unshared) * $(LREF Unqual) * $(LREF Unsigned) * $(LREF ValueType) @@ -7848,6 +7849,46 @@ else static assert(is(Unconst!ImmIntArr == immutable(int)[])); } +/++ + Removes `shared` qualifier, if any, from type `T`. + + Note that while `immutable` is implicitly `shared`, it is unaffected by + Unshared. Only explict `shared` is removed. + +/ +template Unshared(T) +{ + static if (is(T == shared U, U)) + alias Unshared = U; + else + alias Unshared = T; +} + +/// +@safe unittest +{ + static assert(is(Unshared!int == int)); + static assert(is(Unshared!(const int) == const int)); + static assert(is(Unshared!(immutable int) == immutable int)); + + static assert(is(Unshared!(shared int) == int)); + static assert(is(Unshared!(shared(const int)) == const int)); + + static assert(is(Unshared!(shared(int[])) == shared(int)[])); +} + +@safe unittest +{ + static assert(is(Unshared!( int) == int)); + static assert(is(Unshared!( const int) == const int)); + static assert(is(Unshared!( inout int) == inout int)); + static assert(is(Unshared!( inout const int) == inout const int)); + static assert(is(Unshared!(shared int) == int)); + static assert(is(Unshared!(shared const int) == const int)); + static assert(is(Unshared!(shared inout int) == inout int)); + static assert(is(Unshared!(shared inout const int) == inout const int)); + static assert(is(Unshared!( immutable int) == immutable int)); +} + version (StdDdoc) { /** |