Skip to content

Commit c719c85

Browse files
authored
Merge pull request #5076 from kinke/merge_stable
Merge upstream stable
2 parents 84fdde0 + 7c534d7 commit c719c85

6 files changed

Lines changed: 96 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# LDC master
22

33
#### Big news
4-
- Frontend, druntime and Phobos are at version [2.112.1+](https://dlang.org/changelog/2.112.0.html), incl. new command-line options `-extI`, `-dllimport=externalOnly` and `-edition`. (#4949, #4962, #4988, #5029, #5042, #5046, #5051, #5061, #5067, #5069)
4+
- Frontend, druntime and Phobos are at version [2.112.1+](https://dlang.org/changelog/2.112.0.html), incl. new command-line options `-extI`, `-dllimport=externalOnly` and `-edition`. (#4949, #4962, #4988, #5029, #5042, #5046, #5051, #5061, #5067, #5069, #5076)
55
- Support for [LLVM 21](https://releases.llvm.org/21.1.0/docs/ReleaseNotes.html). The prebuilt packages use v21.1.8. (#4950, #5033)
66
- New prebuilt package for Alpine Linux aarch64 with musl libc, analogous to the existing x86_64 package. (#4943)
77
- **Breaking change for dcompute**: The special `@kernel` UDA is now a function and _**requires**_ parentheses as in `@kernel() void foo(){}`. Optionally you can provide launch dimensions, `@kernel([2,4,8])`, to specify to the compute runtime how the kernel is intended to be launched.

dmd/expressionsem.d

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18912,6 +18912,26 @@ Expression revertIndexAssignToRvalues(IndexExp ie, Scope* sc)
1891218912
return lowerAAIndexRead(ie, sc);
1891318913
}
1891418914

18915+
// Ditto, but traverses DotVarExp from `alias this` rewrites.
18916+
private Expression revertModifiableAAIndexReads(Expression e, Scope* sc)
18917+
{
18918+
// Recurse through dot-accesses (alias this produces DotVarExp on an inner IndexExp)
18919+
if (auto dve = e.isDotVarExp())
18920+
{
18921+
dve.e1 = revertModifiableAAIndexReads(dve.e1, sc);
18922+
return e;
18923+
}
18924+
if (auto ie = e.isIndexExp())
18925+
{
18926+
// Recurse first to handle deeper nesting
18927+
ie.e1 = revertModifiableAAIndexReads(ie.e1, sc);
18928+
// Lower a modifiable AA IndexExp to an rvalue read
18929+
if (ie.modifiable && ie.e1.type.isTypeAArray())
18930+
return lowerAAIndexRead(ie, sc);
18931+
}
18932+
return e;
18933+
}
18934+
1891518935
// helper for rewriteAAIndexAssign
1891618936
private Expression implicitConvertToStruct(Expression ev, StructDeclaration sd, Scope* sc)
1891718937
{
@@ -18962,6 +18982,7 @@ private Expression rewriteAAIndexAssign(BinExp exp, Scope* sc, ref Type[2] alias
1896218982
// find the AA of multi dimensional access
1896318983
for (auto ieaa = ie.e1.isIndexExp(); ieaa && ieaa.e1.type.isTypeAArray(); ieaa = ieaa.e1.isIndexExp())
1896418984
eaa = ieaa.e1;
18985+
eaa = revertModifiableAAIndexReads(eaa, sc);
1896518986
eaa = extractSideEffect(sc, "__aatmp", e0, eaa);
1896618987
// collect all keys of multi dimensional access
1896718988
Expressions ekeys;

runtime/druntime/src/core/sys/posix/netinet/in_.d

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -547,77 +547,77 @@ version (CRuntime_Glibc)
547547
}
548548

549549
// macros
550-
extern (D) int IN6_IS_ADDR_UNSPECIFIED()(const scope in6_addr* add) pure
550+
extern (D) int IN6_IS_ADDR_UNSPECIFIED()(const scope in6_addr* addr) pure
551551
{
552552
return (cast(uint32_t*) addr)[0] == 0 &&
553553
(cast(uint32_t*) addr)[1] == 0 &&
554554
(cast(uint32_t*) addr)[2] == 0 &&
555555
(cast(uint32_t*) addr)[3] == 0;
556556
}
557557

558-
extern (D) int IN6_IS_ADDR_LOOPBACK()(const scope in6_addr* add) pure
558+
extern (D) int IN6_IS_ADDR_LOOPBACK()(const scope in6_addr* addr) pure
559559
{
560560
return (cast(uint32_t*) addr)[0] == 0 &&
561561
(cast(uint32_t*) addr)[1] == 0 &&
562562
(cast(uint32_t*) addr)[2] == 0 &&
563563
(cast(uint32_t*) addr)[3] == htonl( 1 );
564564
}
565565

566-
extern (D) int IN6_IS_ADDR_MULTICAST()(const scope in6_addr* add) pure
566+
extern (D) int IN6_IS_ADDR_MULTICAST()(const scope in6_addr* addr) pure
567567
{
568568
return (cast(uint8_t*) addr)[0] == 0xff;
569569
}
570570

571-
extern (D) int IN6_IS_ADDR_LINKLOCAL()(const scope in6_addr* add) pure
571+
extern (D) int IN6_IS_ADDR_LINKLOCAL()(const scope in6_addr* addr) pure
572572
{
573573
return ((cast(uint32_t*) addr)[0] & htonl( 0xffc00000 )) == htonl( 0xfe800000 );
574574
}
575575

576-
extern (D) int IN6_IS_ADDR_SITELOCAL()(const scope in6_addr* add) pure
576+
extern (D) int IN6_IS_ADDR_SITELOCAL()(const scope in6_addr* addr) pure
577577
{
578578
return ((cast(uint32_t*) addr)[0] & htonl( 0xffc00000 )) == htonl( 0xfec00000 );
579579
}
580580

581-
extern (D) int IN6_IS_ADDR_V4MAPPED()(const scope in6_addr* add) pure
581+
extern (D) int IN6_IS_ADDR_V4MAPPED()(const scope in6_addr* addr) pure
582582
{
583583
return (cast(uint32_t*) addr)[0] == 0 &&
584584
(cast(uint32_t*) addr)[1] == 0 &&
585585
(cast(uint32_t*) addr)[2] == htonl( 0xffff );
586586
}
587587

588-
extern (D) int IN6_IS_ADDR_V4COMPAT()(const scope in6_addr* add) pure
588+
extern (D) int IN6_IS_ADDR_V4COMPAT()(const scope in6_addr* addr) pure
589589
{
590590
return (cast(uint32_t*) addr)[0] == 0 &&
591591
(cast(uint32_t*) addr)[1] == 0 &&
592592
(cast(uint32_t*) addr)[2] == 0 &&
593593
ntohl( (cast(uint32_t*) addr)[3] ) > 1;
594594
}
595595

596-
extern (D) int IN6_IS_ADDR_MC_NODELOCAL()(const scope in6_addr* add) pure
596+
extern (D) int IN6_IS_ADDR_MC_NODELOCAL()(const scope in6_addr* addr) pure
597597
{
598598
return IN6_IS_ADDR_MULTICAST( addr ) &&
599599
((cast(uint8_t*) addr)[1] & 0xf) == 0x1;
600600
}
601601

602-
extern (D) int IN6_IS_ADDR_MC_LINKLOCAL()(const scope in6_addr* add) pure
602+
extern (D) int IN6_IS_ADDR_MC_LINKLOCAL()(const scope in6_addr* addr) pure
603603
{
604604
return IN6_IS_ADDR_MULTICAST( addr ) &&
605605
((cast(uint8_t*) addr)[1] & 0xf) == 0x2;
606606
}
607607

608-
extern (D) int IN6_IS_ADDR_MC_SITELOCAL()(const scope in6_addr* add) pure
608+
extern (D) int IN6_IS_ADDR_MC_SITELOCAL()(const scope in6_addr* addr) pure
609609
{
610610
return IN6_IS_ADDR_MULTICAST(addr) &&
611611
((cast(uint8_t*) addr)[1] & 0xf) == 0x5;
612612
}
613613

614-
extern (D) int IN6_IS_ADDR_MC_ORGLOCAL()(const scope in6_addr* add) pure
614+
extern (D) int IN6_IS_ADDR_MC_ORGLOCAL()(const scope in6_addr* addr) pure
615615
{
616616
return IN6_IS_ADDR_MULTICAST( addr) &&
617617
((cast(uint8_t*) addr)[1] & 0xf) == 0x8;
618618
}
619619

620-
extern (D) int IN6_IS_ADDR_MC_GLOBAL()(const scope in6_addr* add) pure
620+
extern (D) int IN6_IS_ADDR_MC_GLOBAL()(const scope in6_addr* addr) pure
621621
{
622622
return IN6_IS_ADDR_MULTICAST( addr ) &&
623623
((cast(uint8_t*) addr)[1] & 0xf) == 0xe;
@@ -670,45 +670,45 @@ else version (Darwin)
670670
}
671671

672672
// macros
673-
extern (D) int IN6_IS_ADDR_UNSPECIFIED()(const scope in6_addr* add) pure
673+
extern (D) int IN6_IS_ADDR_UNSPECIFIED()(const scope in6_addr* addr) pure
674674
{
675675
return (cast(uint32_t*) addr)[0] == 0 &&
676676
(cast(uint32_t*) addr)[1] == 0 &&
677677
(cast(uint32_t*) addr)[2] == 0 &&
678678
(cast(uint32_t*) addr)[3] == 0;
679679
}
680680

681-
extern (D) int IN6_IS_ADDR_LOOPBACK()(const scope in6_addr* add) pure
681+
extern (D) int IN6_IS_ADDR_LOOPBACK()(const scope in6_addr* addr) pure
682682
{
683683
return (cast(uint32_t*) addr)[0] == 0 &&
684684
(cast(uint32_t*) addr)[1] == 0 &&
685685
(cast(uint32_t*) addr)[2] == 0 &&
686686
(cast(uint32_t*) addr)[3] == ntohl( 1 );
687687
}
688688

689-
extern (D) int IN6_IS_ADDR_MULTICAST()(const scope in6_addr* add) pure
689+
extern (D) int IN6_IS_ADDR_MULTICAST()(const scope in6_addr* addr) pure
690690
{
691691
return addr.s6_addr[0] == 0xff;
692692
}
693693

694-
extern (D) int IN6_IS_ADDR_LINKLOCAL()(const scope in6_addr* add) pure
694+
extern (D) int IN6_IS_ADDR_LINKLOCAL()(const scope in6_addr* addr) pure
695695
{
696696
return addr.s6_addr[0] == 0xfe && (addr.s6_addr[1] & 0xc0) == 0x80;
697697
}
698698

699-
extern (D) int IN6_IS_ADDR_SITELOCAL()(const scope in6_addr* add) pure
699+
extern (D) int IN6_IS_ADDR_SITELOCAL()(const scope in6_addr* addr) pure
700700
{
701701
return addr.s6_addr[0] == 0xfe && (addr.s6_addr[1] & 0xc0) == 0xc0;
702702
}
703703

704-
extern (D) int IN6_IS_ADDR_V4MAPPED()(const scope in6_addr* add) pure
704+
extern (D) int IN6_IS_ADDR_V4MAPPED()(const scope in6_addr* addr) pure
705705
{
706706
return (cast(uint32_t*) addr)[0] == 0 &&
707707
(cast(uint32_t*) addr)[1] == 0 &&
708708
(cast(uint32_t*) addr)[2] == ntohl( 0x0000ffff );
709709
}
710710

711-
extern (D) int IN6_IS_ADDR_V4COMPAT()(const scope in6_addr* add) pure
711+
extern (D) int IN6_IS_ADDR_V4COMPAT()(const scope in6_addr* addr) pure
712712
{
713713
return (cast(uint32_t*) addr)[0] == 0 &&
714714
(cast(uint32_t*) addr)[1] == 0 &&
@@ -717,31 +717,31 @@ else version (Darwin)
717717
(cast(uint32_t*) addr)[3] != ntohl( 1 );
718718
}
719719

720-
extern (D) int IN6_IS_ADDR_MC_NODELOCAL()(const scope in6_addr* add) pure
720+
extern (D) int IN6_IS_ADDR_MC_NODELOCAL()(const scope in6_addr* addr) pure
721721
{
722722
return IN6_IS_ADDR_MULTICAST( addr ) &&
723723
((cast(uint8_t*) addr)[1] & 0xf) == 0x1;
724724
}
725725

726-
extern (D) int IN6_IS_ADDR_MC_LINKLOCAL()(const scope in6_addr* add) pure
726+
extern (D) int IN6_IS_ADDR_MC_LINKLOCAL()(const scope in6_addr* addr) pure
727727
{
728728
return IN6_IS_ADDR_MULTICAST( addr ) &&
729729
((cast(uint8_t*) addr)[1] & 0xf) == 0x2;
730730
}
731731

732-
extern (D) int IN6_IS_ADDR_MC_SITELOCAL()(const scope in6_addr* add) pure
732+
extern (D) int IN6_IS_ADDR_MC_SITELOCAL()(const scope in6_addr* addr) pure
733733
{
734734
return IN6_IS_ADDR_MULTICAST(addr) &&
735735
((cast(uint8_t*) addr)[1] & 0xf) == 0x5;
736736
}
737737

738-
extern (D) int IN6_IS_ADDR_MC_ORGLOCAL()(const scope in6_addr* add) pure
738+
extern (D) int IN6_IS_ADDR_MC_ORGLOCAL()(const scope in6_addr* addr) pure
739739
{
740740
return IN6_IS_ADDR_MULTICAST( addr) &&
741741
((cast(uint8_t*) addr)[1] & 0xf) == 0x8;
742742
}
743743

744-
extern (D) int IN6_IS_ADDR_MC_GLOBAL()(const scope in6_addr* add) pure
744+
extern (D) int IN6_IS_ADDR_MC_GLOBAL()(const scope in6_addr* addr) pure
745745
{
746746
return IN6_IS_ADDR_MULTICAST( addr ) &&
747747
((cast(uint8_t*) addr)[1] & 0xf) == 0xe;

runtime/druntime/src/object.d

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3034,16 +3034,30 @@ alias AssociativeArray(Key, Value) = Value[Key];
30343034
* aa = The associative array.
30353035
*/
30363036
void clear(Value, Key)(Value[Key] aa) @trusted
3037+
if (!is(Value == shared))
30373038
{
30383039
_aaClear(aa);
30393040
}
30403041

30413042
/** ditto */
30423043
void clear(Value, Key)(Value[Key]* aa) @trusted
3044+
if (!is(Value == shared))
30433045
{
30443046
(*aa).clear();
30453047
}
30463048

3049+
/** ditto */
3050+
void clear(Value, Key)(shared(Value)[Key] aa)
3051+
{
3052+
return (cast(Value[Key])aa).clear();
3053+
}
3054+
3055+
/** ditto */
3056+
void clear(Value, Key)(shared(Value)[Key]* aa)
3057+
{
3058+
(cast(Value[Key])*aa).clear();
3059+
}
3060+
30473061
///
30483062
@safe unittest
30493063
{

runtime/phobos

tests/dmd/runnable/testaa3.d

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,39 @@ void testShared()
427427
assert(2 in iprocesses);
428428
}
429429

430+
// https://github.com/dlang/dmd/issues/22556
431+
void test22556()
432+
{
433+
static struct RefCounted(T)
434+
{
435+
this(this) {}
436+
}
437+
struct S {}
438+
alias R = RefCounted!S;
439+
shared R[string] foo;
440+
441+
(cast (R[string]) foo).clear; // WORKS
442+
(cast() foo).clear; // FAILS with 2.112.0, WORKS with 2.111.0
443+
static assert(!__traits(compiles, foo.clear));
444+
}
445+
446+
/***************************************************/
447+
448+
// https://github.com/dlang/dmd/issues/22567
449+
void test22567()
450+
{
451+
struct S
452+
{
453+
string[string] data;
454+
alias this = data;
455+
}
456+
457+
S[string] foo;
458+
foo["bar"] = S();
459+
foo["bar"]["baz"] = "boom";
460+
assert(foo["bar"]["baz"] == "boom");
461+
}
462+
430463
/***************************************************/
431464

432465
void main()
@@ -456,4 +489,6 @@ void main()
456489
test21066();
457490
test22354();
458491
testShared();
492+
test22567();
493+
test22556();
459494
}

0 commit comments

Comments
 (0)