From 752c9c6c22df493bdd2d3242411e9fe051a82238 Mon Sep 17 00:00:00 2001 From: RazvanN7 Date: Wed, 11 Sep 2024 16:04:08 +0300 Subject: [PATCH 1/9] Fix Bugzilla Issue 24760 - ICE on variadic after default argument --- dmd/typesem.d | 4 +++- tests/dmd/compilable/test24760.d | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/compilable/test24760.d diff --git a/dmd/typesem.d b/dmd/typesem.d index a909fcf14c..3933d7dfdd 100644 --- a/dmd/typesem.d +++ b/dmd/typesem.d @@ -835,7 +835,9 @@ extern (D) MATCH callMatch(TypeFunction tf, Type tthis, ArgumentList argumentLis L1: if (parameterList.varargs == VarArg.typesafe && u + 1 == nparams) // if last varargs param { - auto trailingArgs = args[u .. $]; + Expression[] trailingArgs; + if (args.length >= u) + trailingArgs = args[u .. $]; if (auto vmatch = matchTypeSafeVarArgs(tf, p, trailingArgs, pMessage)) return vmatch < match ? vmatch : match; // Error message was already generated in `matchTypeSafeVarArgs` diff --git a/tests/dmd/compilable/test24760.d b/tests/dmd/compilable/test24760.d new file mode 100644 index 0000000000..7c84848a6f --- /dev/null +++ b/tests/dmd/compilable/test24760.d @@ -0,0 +1,4 @@ +// https://issues.dlang.org/show_bug.cgi?id=24760 + +long f(int e = 0, uint[] optional...) => optional.length; +long f0() => f(); // compiler segfaults From adc9ff13ce862d4b9568bace7e466d953a3adca1 Mon Sep 17 00:00:00 2001 From: Dennis Date: Thu, 3 Oct 2024 13:46:41 +0200 Subject: [PATCH 2/9] Fix bugzilla 24790 - -vcg-ast ICE on lowered assign exp (dlang/dmd!16914) Co-authored-by: Dennis Korpel --- dmd/parse.d | 1 + tests/dmd/compilable/vcg-ast-arraylength.d | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/dmd/parse.d b/dmd/parse.d index a7a930335a..757aefb26b 100644 --- a/dmd/parse.d +++ b/dmd/parse.d @@ -9749,6 +9749,7 @@ immutable PREC[EXP.max + 1] precedence = EXP.assign : PREC.assign, EXP.construct : PREC.assign, EXP.blit : PREC.assign, + EXP.loweredAssignExp : PREC.assign, EXP.addAssign : PREC.assign, EXP.minAssign : PREC.assign, EXP.concatenateAssign : PREC.assign, diff --git a/tests/dmd/compilable/vcg-ast-arraylength.d b/tests/dmd/compilable/vcg-ast-arraylength.d index 8fdd7808f7..8c44421c61 100644 --- a/tests/dmd/compilable/vcg-ast-arraylength.d +++ b/tests/dmd/compilable/vcg-ast-arraylength.d @@ -23,4 +23,9 @@ void main() static assert(is(typeof(a.length = 0) == size_t)); static assert(is(typeof(a.length = f.length = 0) == size_t)); + + // https://issues.dlang.org/show_bug.cgi?id=24790 + struct S { int[] payload; } + S s; + s.payload.length += 3; } From abb8d41196b2fe7b4bb6fec8d705dc1ea0c49536 Mon Sep 17 00:00:00 2001 From: Dennis Date: Thu, 3 Oct 2024 13:47:19 +0200 Subject: [PATCH 3/9] Fix bugzilla 24764 - ICE when -vcg-ast prints imported invariant (dlang/dmd!16917) Co-authored-by: Dennis Korpel --- dmd/hdrgen.d | 4 ++-- tests/dmd/compilable/extra-files/vcg-ast.d.cg | 22 ++++++++++++++++++- tests/dmd/compilable/imports/vcg_ast_import.d | 4 ++++ tests/dmd/compilable/vcg-ast.d | 12 ++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 tests/dmd/compilable/imports/vcg_ast_import.d diff --git a/dmd/hdrgen.d b/dmd/hdrgen.d index a44fb2877a..f3c6bbb56b 100644 --- a/dmd/hdrgen.d +++ b/dmd/hdrgen.d @@ -1858,9 +1858,9 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs) if (stcToBuffer(buf, d.storage_class)) buf.writeByte(' '); buf.writestring("invariant"); - if(auto es = d.fbody.isExpStatement()) + auto es = d.fbody.isExpStatement(); + if (es && es.exp && es.exp.op == EXP.assert_) { - assert(es.exp && es.exp.op == EXP.assert_); buf.writestring(" ("); (cast(AssertExp)es.exp).e1.expressionToBuffer(buf, hgs); buf.writestring(");"); diff --git a/tests/dmd/compilable/extra-files/vcg-ast.d.cg b/tests/dmd/compilable/extra-files/vcg-ast.d.cg index 640cba43ed..e6a9ca384f 100644 --- a/tests/dmd/compilable/extra-files/vcg-ast.d.cg +++ b/tests/dmd/compilable/extra-files/vcg-ast.d.cg @@ -100,6 +100,12 @@ void main() values(); return 0; } +import imports.vcg_ast_import; +template imported() +{ + import imported = imports.vcg_ast_import; +} +alias myImport = vcg_ast_import; R!int { struct _R @@ -126,6 +132,21 @@ mixin _d_cmain!(); } } } +imported!() +{ + import object; + struct O + { + invariant + { + } + invariant + { + __invariant0(); + } + } + +} RTInfo!(C) { enum immutable(void)* RTInfo = null; @@ -150,4 +171,3 @@ RTInfo!(_R) enum immutable(void)* RTInfo = null; } - diff --git a/tests/dmd/compilable/imports/vcg_ast_import.d b/tests/dmd/compilable/imports/vcg_ast_import.d new file mode 100644 index 0000000000..a2064c0d17 --- /dev/null +++ b/tests/dmd/compilable/imports/vcg_ast_import.d @@ -0,0 +1,4 @@ +struct O +{ + invariant() {} +} diff --git a/tests/dmd/compilable/vcg-ast.d b/tests/dmd/compilable/vcg-ast.d index 4a7b8bc33c..9197441aff 100644 --- a/tests/dmd/compilable/vcg-ast.d +++ b/tests/dmd/compilable/vcg-ast.d @@ -2,6 +2,7 @@ REQUIRED_ARGS: -vcg-ast -o- PERMUTE_ARGS: OUTPUT_FILES: compilable/vcg-ast.d.cg +EXTRA_FILES: imports/vcg_ast_import.d TEST_OUTPUT_FILE: extra-files/vcg-ast.d.cg */ @@ -63,3 +64,14 @@ void main() { values!wchar_t; } + +// https://issues.dlang.org/show_bug.cgi?id=24764 + +import imports.vcg_ast_import; + +template imported() +{ + import imported = imports.vcg_ast_import; +} + +alias myImport = imported!(); From ae8a2ebef847172a129142138ade1bf343a2b174 Mon Sep 17 00:00:00 2001 From: Dennis Date: Fri, 4 Oct 2024 01:47:09 +0200 Subject: [PATCH 4/9] =?UTF-8?q?Fix=20bugzilla=2024431=20-=20dmd=20-vcg-ast?= =?UTF-8?q?=20crashes=20printing=20failed=20template=20in=E2=80=A6=20(dlan?= =?UTF-8?q?g/dmd!16916)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dmd/hdrgen.d | 4 +- tests/dmd/compilable/vcg_ast_compilable.d | 69 +++++++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 tests/dmd/compilable/vcg_ast_compilable.d diff --git a/dmd/hdrgen.d b/dmd/hdrgen.d index f3c6bbb56b..013a081534 100644 --- a/dmd/hdrgen.d +++ b/dmd/hdrgen.d @@ -1720,10 +1720,10 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs) //printf("FuncDeclaration::toCBuffer() '%s'\n", f.toChars()); if (stcToBuffer(buf, f.storage_class)) buf.writeByte(' '); + typeToBuffer(f.type, f.ident, buf, hgs); auto tf = f.type.isTypeFunction(); - typeToBuffer(tf, f.ident, buf, hgs); - if (hgs.hdrgen) + if (hgs.hdrgen && tf) { // if the return type is missing (e.g. ref functions or auto) // https://issues.dlang.org/show_bug.cgi?id=20090 diff --git a/tests/dmd/compilable/vcg_ast_compilable.d b/tests/dmd/compilable/vcg_ast_compilable.d new file mode 100644 index 0000000000..e84846dfbe --- /dev/null +++ b/tests/dmd/compilable/vcg_ast_compilable.d @@ -0,0 +1,69 @@ +/* +REQUIRED_ARGS: -vcg-ast -o- +OUTPUT_FILES: compilable/vcg_ast_compilable.d.cg +TEST_OUTPUT: +--- +=== compilable/vcg_ast_compilable.d.cg +import object; +auto binaryFun(E)(E b) +{ + return 'a' == b; +} +void find(Element)(Element needle) if (is(typeof(binaryFun(needle)))) +{ +} +void find()(string needle) +{ +} +void splitter() +{ + find(3); + find(""); +} +binaryFun!int +{ + auto pure nothrow @nogc @safe bool binaryFun(int b) + { + return 97 == b; + } + +} +find!int +{ + pure nothrow @nogc @safe void find(int needle) + { + } + +} +binaryFun!string +{ + auto _error_ binaryFun + { + __error__ + } + +} +find!() +{ + pure nothrow @nogc @safe void find(string needle) + { + } + +} +--- +*/ + +// https://issues.dlang.org/show_bug.cgi?id=24431 +auto binaryFun(E)(E b) +{ + return 'a' == b; +} + +void find(Element)(Element needle) if (is(typeof(binaryFun(needle)))) { } +void find()(string needle) { } + +void splitter() +{ + find!int(3); + find!()(""); +} From 602caab9bd494f3d70b6b906b0bada1be998dfe2 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Mon, 7 Oct 2024 13:08:42 +0800 Subject: [PATCH 5/9] [importc.h] #define __typeof__ typeof --- runtime/druntime/src/importc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/druntime/src/importc.h b/runtime/druntime/src/importc.h index 858e502b99..b7b82dbe6b 100644 --- a/runtime/druntime/src/importc.h +++ b/runtime/druntime/src/importc.h @@ -41,6 +41,7 @@ #define __alignof _Alignof #define __vector_size__ vector_size #define __typeof typeof +#define __typeof__ typeof /******************** * Clang nullability extension used by macOS headers. From 24b56d8e73fc10a36402880ff1d2c36ca8a88cc1 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Mon, 14 Oct 2024 19:03:17 +0800 Subject: [PATCH 6/9] Fix bugzilla issue 24812 - Incorrect highlighting when diagnosing an empty enum declaration (dlang/dmd!17004) --- dmd/enumsem.d | 2 +- tests/dmd/fail_compilation/diag24812.d | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/dmd/fail_compilation/diag24812.d diff --git a/dmd/enumsem.d b/dmd/enumsem.d index c67ac618ec..0aa26cf47b 100644 --- a/dmd/enumsem.d +++ b/dmd/enumsem.d @@ -186,7 +186,7 @@ void enumSemantic(Scope* sc, EnumDeclaration ed) if (ed.members.length == 0) { - .error(ed.loc, "%s `%s enum `%s` must have at least one member", ed.kind, ed.toPrettyChars, ed.toChars()); + .error(ed.loc, "%s `%s` enum `%s` must have at least one member", ed.kind, ed.toPrettyChars, ed.toChars()); ed.errors = true; ed.semanticRun = PASS.semanticdone; return; diff --git a/tests/dmd/fail_compilation/diag24812.d b/tests/dmd/fail_compilation/diag24812.d new file mode 100644 index 0000000000..626f47ebf0 --- /dev/null +++ b/tests/dmd/fail_compilation/diag24812.d @@ -0,0 +1,7 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/diag24812.d(7): Error: enum `diag24812.Foo` enum `Foo` must have at least one member +--- +*/ +enum Foo {} From ebafa4e40ea938fed5b23e46da1793c7bf24e944 Mon Sep 17 00:00:00 2001 From: Dennis Date: Thu, 24 Oct 2024 19:45:57 +0200 Subject: [PATCH 7/9] Fix bugzilla 24832 - Segfault in hex string (dlang/dmd!17024) * Fix bugzilla 24832 - Segfault in hex string * Fix lack of camelcasing on stable branch --- dmd/dcast.d | 2 +- dmd/dinterpret.d | 2 +- tests/dmd/fail_compilation/hexstring.d | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dmd/dcast.d b/dmd/dcast.d index b682c75429..ce51c28f6e 100644 --- a/dmd/dcast.d +++ b/dmd/dcast.d @@ -2336,7 +2336,7 @@ Expression castTo(Expression e, Scope* sc, Type t, Type att = null) Type tb = t.toBasetype(); Type typeb = e.type.toBasetype(); - if (e.hexString && !e.committed) + if (e.hexString && !e.committed && tb.nextOf().isintegral) { const szx = cast(ubyte) tb.nextOf().size(); if (szx != se.sz && (e.len % szx) == 0) diff --git a/dmd/dinterpret.d b/dmd/dinterpret.d index 52520be01d..967e83106f 100644 --- a/dmd/dinterpret.d +++ b/dmd/dinterpret.d @@ -6107,7 +6107,7 @@ public: { auto se = e1.isStringExp(); // Allow casting a hex string literal to short[], int[] or long[] - if (se && se.hexString && se.postfix == StringExp.NoPostfix) + if (se && se.hexString && se.postfix == StringExp.NoPostfix && e.to.nextOf().isintegral) { const sz = cast(size_t) e.to.nextOf().size; if ((se.len % sz) != 0) diff --git a/tests/dmd/fail_compilation/hexstring.d b/tests/dmd/fail_compilation/hexstring.d index 0f23f44438..edbb4e67bc 100644 --- a/tests/dmd/fail_compilation/hexstring.d +++ b/tests/dmd/fail_compilation/hexstring.d @@ -14,6 +14,7 @@ fail_compilation/hexstring.d(39): perhaps remove postfix `c` from hex str fail_compilation/hexstring.d(40): Error: hex string with `dstring` type needs to be multiple of 4 bytes, not 5 fail_compilation/hexstring.d(41): Error: cannot implicitly convert expression `x"11223344"d` of type `dstring` to `immutable(float[])` fail_compilation/hexstring.d(42): Error: cannot implicitly convert expression `x"1122"w` of type `wstring` to `immutable(ubyte[])` +fail_compilation/hexstring.d(50): Error: array cast from `string` to `S[]` is not supported at compile time fail_compilation/hexstring.d(28): Error: cannot implicitly convert expression `x"123F"` of type `string` to `ubyte[]` --- */ @@ -21,7 +22,6 @@ immutable ubyte[] s0 = x"123F"; static assert(s0[0] == 0x12); static assert(s0[1] == 0x3F); immutable byte[] s1 = x"123F"; - enum E(X) = cast(X[]) x"AABBCCDD"; static assert(E!int[0] == 0xAABBCCDD); @@ -40,3 +40,11 @@ immutable uint[] f11 = cast(immutable uint[]) x"AABBCCDD"c; immutable uint[] f12 = x"1122334455"d; immutable float[] f13 = x"11223344"d; immutable ubyte[] f14 = x"1122"w; + +// https://issues.dlang.org/show_bug.cgi?id=24832 +struct S +{ + ushort l0, l1, l2, l3, l4, l5; +} + +immutable S[] returnValues = cast(S[]) x"FFFFFFFFFFFFFFFFFFFFFFFF"; From d957fbfe41fc894e5592e3732eb2d46ae886db63 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 24 Oct 2024 04:01:19 -0700 Subject: [PATCH 8/9] fix bugzilla Issue 24819 - Optimizer changes result of float calculations on 32-bit (dlang/dmd!17023) (cherry picked from commit 88d1e8fc37428b873f59d87f8dff1f40fbd3e7a3) --- tests/dmd/runnable/test24819.d | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/dmd/runnable/test24819.d diff --git a/tests/dmd/runnable/test24819.d b/tests/dmd/runnable/test24819.d new file mode 100644 index 0000000000..3ba374bed3 --- /dev/null +++ b/tests/dmd/runnable/test24819.d @@ -0,0 +1,18 @@ +import core.stdc.stdio; + +pragma(inline, true) +double sqrt(double x) +{ + static import core.math; + return core.math.sqrt(x); +} + +int main() +{ + double q = -5.0; + double r = q + 1.0; + double result = sqrt(-r); + //printf("%f\n", result); + assert(result == 2); + return 0; +} From aab27131a2c922d1abb62cee07fe223875b20f8e Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Mon, 28 Oct 2024 15:02:51 +0100 Subject: [PATCH 9/9] Bump Phobos --- CHANGELOG.md | 2 +- runtime/phobos | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25202c8ae8..59847a88a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # LDC master #### Big news -- Frontend, druntime and Phobos are at version [2.110.0](https://dlang.org/changelog/2.110.0.html). (#4707, #4737, #4749) +- Frontend, druntime and Phobos are at version [2.110.0](https://dlang.org/changelog/2.110.0.html). (#4707, #4737, #4749, #4768) - LLVM for prebuilt packages bumped to v18.1.8 (incl. macOS arm64). (#4712) - Android: NDK for prebuilt package bumped from r26d to r27. (#4711) - ldc2.conf: %%ldcconfigpath%% placeholder added - specifies the directory where current configuration file is located. (#4717) diff --git a/runtime/phobos b/runtime/phobos index a1a756a828..b7faca1c9b 160000 --- a/runtime/phobos +++ b/runtime/phobos @@ -1 +1 @@ -Subproject commit a1a756a828f29b3fbab062d1cc7857b59105f699 +Subproject commit b7faca1c9bca5ed31ab82b0700ae45ca312727d7