From 28a7222c2e8b6f01bfe7cd27c874987a60388de7 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 6 Feb 2023 16:07:57 +0100 Subject: [PATCH 1/6] =?UTF-8?q?fix=20Issue=C2=A023672=20-=20importC:=20Inf?= =?UTF-8?q?inite=20recursion:=20Error:=20found=20'End=20of=20File'=20when?= =?UTF-8?q?=20expecting=20','?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compiler/src/dmd/cparse.d | 4 ++-- compiler/test/fail_compilation/test23672.i | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 compiler/test/fail_compilation/test23672.i diff --git a/compiler/src/dmd/cparse.d b/compiler/src/dmd/cparse.d index a6bc42b10140..34146df56394 100644 --- a/compiler/src/dmd/cparse.d +++ b/compiler/src/dmd/cparse.d @@ -2991,11 +2991,11 @@ final class CParser(AST) : Parser!AST auto param = new AST.Parameter(specifiersToSTC(LVL.parameter, specifier), t, id, null, null); parameters.push(param); - if (token.value == TOK.rightParenthesis) + if (token.value == TOK.rightParenthesis || token.value == TOK.endOfFile) break; check(TOK.comma); } - nextToken(); + check(TOK.rightParenthesis); return finish(); } diff --git a/compiler/test/fail_compilation/test23672.i b/compiler/test/fail_compilation/test23672.i new file mode 100644 index 000000000000..fd406bd95507 --- /dev/null +++ b/compiler/test/fail_compilation/test23672.i @@ -0,0 +1,8 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/test23672.i(9): Error: found `End of File` when expecting `)` +fail_compilation/test23672.i(9): Error: `=`, `;` or `,` expected to end declaration instead of `End of File` +--- +*/ +extern int feof (FILE *__strea From f08dd665d4e951a95757836a58329531122b0469 Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 8 Feb 2023 08:50:17 +0100 Subject: [PATCH 2/6] Fix 23679 - off-by-one error for static array size limit (#14867) --- compiler/src/dmd/toobj.d | 2 +- compiler/src/dmd/typesem.d | 2 +- compiler/test/compilable/test23679.d | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 compiler/test/compilable/test23679.d diff --git a/compiler/src/dmd/toobj.d b/compiler/src/dmd/toobj.d index b855d95e0219..e93cd6c2c88e 100644 --- a/compiler/src/dmd/toobj.d +++ b/compiler/src/dmd/toobj.d @@ -587,7 +587,7 @@ void toObjFile(Dsymbol ds, bool multiobj) vd.error("size overflow"); return; } - if (sz64 >= target.maxStaticDataSize) + if (sz64 > target.maxStaticDataSize) { vd.error("size of 0x%llx exceeds max allowed size 0x%llx", sz64, target.maxStaticDataSize); } diff --git a/compiler/src/dmd/typesem.d b/compiler/src/dmd/typesem.d index 3a2705d0f968..b6d460ba43ff 100644 --- a/compiler/src/dmd/typesem.d +++ b/compiler/src/dmd/typesem.d @@ -593,7 +593,7 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc) * run on them for the size, since they may be forward referenced. */ bool overflow = false; - if (mulu(tbn.size(loc), d2, overflow) >= target.maxStaticDataSize || overflow) + if (mulu(tbn.size(loc), d2, overflow) > target.maxStaticDataSize || overflow) return overflowError(); } } diff --git a/compiler/test/compilable/test23679.d b/compiler/test/compilable/test23679.d new file mode 100644 index 000000000000..9264d01928dc --- /dev/null +++ b/compiler/test/compilable/test23679.d @@ -0,0 +1,3 @@ +// DISABLED: win32 +// https://issues.dlang.org/show_bug.cgi?id=23679 +ubyte [0x7fff_ffffU] arr; From 582dd6c1a1c8f2fc07498c3787dd5b878dac79b3 Mon Sep 17 00:00:00 2001 From: Dmytro Katyukha Date: Thu, 9 Feb 2023 12:50:15 +0200 Subject: [PATCH 3/6] Fix Issue 23662: ImportC bad handling of enum arguments for a function (#14859) * Added testcase for Issue 23662 See: https://issues.dlang.org/show_bug.cgi?id=23662 * Fix Issue 23662 --- compiler/src/dmd/cparse.d | 2 ++ compiler/test/compilable/imports/imp23662.c | 6 ++++++ compiler/test/compilable/test23662.d | 8 ++++++++ 3 files changed, 16 insertions(+) create mode 100644 compiler/test/compilable/imports/imp23662.c create mode 100644 compiler/test/compilable/test23662.d diff --git a/compiler/src/dmd/cparse.d b/compiler/src/dmd/cparse.d index 34146df56394..1c3d928bd342 100644 --- a/compiler/src/dmd/cparse.d +++ b/compiler/src/dmd/cparse.d @@ -1823,6 +1823,8 @@ final class CParser(AST) : Parser!AST { if (tt.id || tt.tok == TOK.enum_) { + if (!tt.id && id) + tt.id = id; /* `struct tag;` and `struct tag { ... };` * always result in a declaration in the current scope */ diff --git a/compiler/test/compilable/imports/imp23662.c b/compiler/test/compilable/imports/imp23662.c new file mode 100644 index 000000000000..1556bc9e3d98 --- /dev/null +++ b/compiler/test/compilable/imports/imp23662.c @@ -0,0 +1,6 @@ +// https://issues.dlang.org/show_bug.cgi?id=23662 +typedef enum {A} E; + +E func(E v) { + return v; +} diff --git a/compiler/test/compilable/test23662.d b/compiler/test/compilable/test23662.d new file mode 100644 index 000000000000..884c3995925f --- /dev/null +++ b/compiler/test/compilable/test23662.d @@ -0,0 +1,8 @@ +// https://issues.dlang.org/show_bug.cgi?id=23662 +// EXTRA_FILES: imports/imp23662.c +import imports.imp23662; + +void main(string[] args) { + auto r = func(A); + assert(r == A); +} From 4463cfd129a480c0d758276db10135acb0c55e28 Mon Sep 17 00:00:00 2001 From: Razvan Nitu Date: Fri, 10 Feb 2023 21:01:19 +0800 Subject: [PATCH 4/6] Fix Issue 23674 - incompatible types for array comparison: string and string (#14868) --- compiler/src/dmd/expressionsem.d | 9 +++++++++ compiler/test/fail_compilation/test23674.d | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 compiler/test/fail_compilation/test23674.d diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index ea83871d4697..9ae3940fe2d8 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -12042,6 +12042,15 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor __equals = new DotIdExp(exp.loc, __equals, Id.object); __equals = new DotIdExp(exp.loc, __equals, id); + /* https://issues.dlang.org/show_bug.cgi?id=23674 + * + * Optimize before creating the call expression to the + * druntime hook as the optimizer may output errors + * that will get swallowed otherwise. + */ + exp.e1 = exp.e1.optimize(WANTvalue); + exp.e2 = exp.e2.optimize(WANTvalue); + auto arguments = new Expressions(2); (*arguments)[0] = exp.e1; (*arguments)[1] = exp.e2; diff --git a/compiler/test/fail_compilation/test23674.d b/compiler/test/fail_compilation/test23674.d new file mode 100644 index 000000000000..0f11de94d9da --- /dev/null +++ b/compiler/test/fail_compilation/test23674.d @@ -0,0 +1,15 @@ +// https://issues.dlang.org/show_bug.cgi?id=23674 + +/* +TEST_OUTPUT: +--- +fail_compilation/test23674.d(14): Error: array index 2 is out of bounds `arr[0 .. 2]` +fail_compilation/test23674.d(14): Error: array index 3 is out of bounds `arr[0 .. 2]` +--- +*/ + +void main() +{ + string[2] arr; + assert(arr[2] == arr[3]); +} From 9307b8fd4fdf3ef83985ecbb03245ff449283d7f Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Sun, 12 Feb 2023 16:16:12 +0000 Subject: [PATCH 5/6] bump VERSION to v2.102.1-beta.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index bb2ac29e6440..a619f742fcc5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.102.0 +v2.102.1-beta.1 From 113c62bb3636e30e55d65ea759c9a21198cc1199 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sun, 12 Feb 2023 19:25:24 +0100 Subject: [PATCH 6/6] Fix core.demangle compile error for non-macOS Darwin targets A v2.102 regression. --- druntime/src/core/demangle.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/druntime/src/core/demangle.d b/druntime/src/core/demangle.d index fe273319f213..a68e509c7220 100644 --- a/druntime/src/core/demangle.d +++ b/druntime/src/core/demangle.d @@ -2933,7 +2933,7 @@ CXX_DEMANGLER getCXXDemangler() nothrow @trusted version (linux) import core.sys.linux.dlfcn : RTLD_DEFAULT; version (NetBSD) import core.sys.netbsd.dlfcn : RTLD_DEFAULT; version (OpenBSD) import core.sys.openbsd.dlfcn : RTLD_DEFAULT; - version (OSX) import core.sys.darwin.dlfcn : RTLD_DEFAULT; + version (Darwin) import core.sys.darwin.dlfcn : RTLD_DEFAULT; version (Solaris) import core.sys.solaris.dlfcn : RTLD_DEFAULT; if (auto found = cast(CXX_DEMANGLER) dlsym(RTLD_DEFAULT, "__cxa_demangle"))