diff --git a/changelog/dmd.isCOMClass.dd b/changelog/dmd.isCOMClass.dd new file mode 100644 index 0000000000..31e0e9a403 --- /dev/null +++ b/changelog/dmd.isCOMClass.dd @@ -0,0 +1,5 @@ +New trait isCOMClass to detect if a type is a COM class + +A COM class inherits from a possibly user defined interface called ``IUnknown``. +To detect this during compilation use the trait ``__traits(isCOMClass, Type)``. +Or for during runtime use the ``TypeInfo_Class`` flag. diff --git a/compiler/src/dmd/backend/x86/cod2.d b/compiler/src/dmd/backend/x86/cod2.d index 4bf010a8db..38a33bd1e3 100644 --- a/compiler/src/dmd/backend/x86/cod2.d +++ b/compiler/src/dmd/backend/x86/cod2.d @@ -4176,6 +4176,7 @@ void cdmemset(ref CGstate cg, ref CodeBuilder cdb,elem *e,ref regm_t pretregs) if (valueIsConst) { regwithvalue(cdb, mAX, value, I64?64:0); + getregs(cdb, mAX); freenode(evalue); } else diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index d5a8c81020..616266d99f 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -5650,7 +5650,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (exp.fd.ident != Id.empty) return; - const(char)[] s; + string s; if (exp.fd.fes) s = "__foreachbody"; else if (exp.fd.tok == TOK.reserved) @@ -5684,7 +5684,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor symtab = sds.symtab; } assert(symtab); - Identifier id = Identifier.generateId(s, symtab.length() + 1); + Identifier id = Identifier.generateIdWithLoc(s, exp.loc); exp.fd.ident = id; if (exp.td) exp.td.ident = id; diff --git a/compiler/src/dmd/frontend.h b/compiler/src/dmd/frontend.h index a77f064576..5d6d623a19 100644 --- a/compiler/src/dmd/frontend.h +++ b/compiler/src/dmd/frontend.h @@ -8919,6 +8919,7 @@ struct Id final static Identifier* isRef; static Identifier* isOut; static Identifier* isLazy; + static Identifier* isCOMClass; static Identifier* hasMember; static Identifier* identifier; static Identifier* fullyQualifiedName; diff --git a/compiler/src/dmd/id.d b/compiler/src/dmd/id.d index 3aacc9cc98..aae07bc153 100644 --- a/compiler/src/dmd/id.d +++ b/compiler/src/dmd/id.d @@ -482,6 +482,7 @@ immutable Msgtable[] msgtable = { "isRef" }, { "isOut" }, { "isLazy" }, + { "isCOMClass" }, { "hasMember" }, { "identifier" }, { "fullyQualifiedName" }, diff --git a/compiler/src/dmd/traits.d b/compiler/src/dmd/traits.d index 4218e5f14a..f7f4cd2bb5 100644 --- a/compiler/src/dmd/traits.d +++ b/compiler/src/dmd/traits.d @@ -701,6 +701,26 @@ Expression semanticTraits(TraitsExp e, Scope* sc) return isDeclX(d => (d.storage_class & STC.lazy_) != 0); } + if (e.ident == Id.isCOMClass) + { + if (dim != 1) + return dimError(1); + + auto o = (*e.args)[0]; + auto s = getDsymbol(o); + AggregateDeclaration agg; + + if (!s || ((agg = s.isAggregateDeclaration()) is null)) + { + error(e.loc, "argument to `__traits(isCOMClass, %s)` is not a declaration", o.toChars()); + return ErrorExp.get(); + } + + if (ClassDeclaration cd = agg.isClassDeclaration()) + return cd.com ? True() : False(); + else + return False(); + } if (e.ident == Id.identifier) { // Get identifier for symbol as a string literal diff --git a/compiler/test/fail_compilation/b19523.d b/compiler/test/fail_compilation/b19523.d index d2a05c73dc..3b2a5e0f22 100644 --- a/compiler/test/fail_compilation/b19523.d +++ b/compiler/test/fail_compilation/b19523.d @@ -3,7 +3,7 @@ TEST_OUTPUT: ---- fail_compilation/b19523.d(13): Error: undefined identifier `SomeStruct` fail_compilation/b19523.d(14): Error: function `foo` is not callable using argument types `(_error_)` -fail_compilation/b19523.d(14): cannot pass argument `__lambda2` of type `_error_` to parameter `int delegate() arg` +fail_compilation/b19523.d(14): cannot pass argument `__lambda_L14_C6` of type `_error_` to parameter `int delegate() arg` fail_compilation/b19523.d(19): `b19523.foo(int delegate() arg)` declared here ---- */ diff --git a/compiler/test/fail_compilation/bug9631.d b/compiler/test/fail_compilation/bug9631.d index 02fc7db061..60828bef17 100644 --- a/compiler/test/fail_compilation/bug9631.d +++ b/compiler/test/fail_compilation/bug9631.d @@ -65,7 +65,7 @@ TEST_OUTPUT: fail_compilation/bug9631.d(80): Error: function `f` is not callable using argument types `(int, S)` fail_compilation/bug9631.d(80): cannot pass argument `y` of type `bug9631.tem!().S` to parameter `bug9631.S s` fail_compilation/bug9631.d(79): `bug9631.arg.f(int i, S s)` declared here -fail_compilation/bug9631.d(81): Error: function literal `__lambda4(S s)` is not callable using argument types `(S)` +fail_compilation/bug9631.d(81): Error: function literal `__lambda_L81_C5(S s)` is not callable using argument types `(S)` fail_compilation/bug9631.d(81): cannot pass argument `x` of type `bug9631.S` to parameter `bug9631.tem!().S s` fail_compilation/bug9631.d(87): Error: constructor `bug9631.arg.A.this(S __param_0)` is not callable using argument types `(S)` fail_compilation/bug9631.d(87): cannot pass argument `S(0)` of type `bug9631.tem!().S` to parameter `bug9631.S __param_0` diff --git a/compiler/test/fail_compilation/constraints_defs.d b/compiler/test/fail_compilation/constraints_defs.d index 7515208643..b3a335b4e2 100755 --- a/compiler/test/fail_compilation/constraints_defs.d +++ b/compiler/test/fail_compilation/constraints_defs.d @@ -5,7 +5,7 @@ TEST_OUTPUT: fail_compilation/constraints_defs.d(49): Error: template instance `constraints_defs.main.def!(int, 0, (a) => a)` does not match template declaration `def(T, int i = 5, alias R)()` with `T = int, i = 0, - R = __lambda1` + R = __lambda_L49_C18` must satisfy the following constraint: ` N!T` fail_compilation/constraints_defs.d(50): Error: template instance `imports.constraints.defa!int` does not match template declaration `defa(T, U = int)()` diff --git a/compiler/test/fail_compilation/constraints_tmpl.d b/compiler/test/fail_compilation/constraints_tmpl.d index 06caa52493..fee7a3e3e7 100755 --- a/compiler/test/fail_compilation/constraints_tmpl.d +++ b/compiler/test/fail_compilation/constraints_tmpl.d @@ -22,7 +22,7 @@ fail_compilation/constraints_tmpl.d(41): Error: template instance `imports.const ` N!T N!U` fail_compilation/constraints_tmpl.d(43): Error: template instance `constraints_tmpl.main.lambda!((a) => a)` does not match template declaration `lambda(alias pred)()` - with `pred = __lambda1` + with `pred = __lambda_L43_C13` must satisfy the following constraint: ` N!int` --- diff --git a/compiler/test/fail_compilation/cppvar.d b/compiler/test/fail_compilation/cppvar.d index 885a55547c..213b54d10f 100644 --- a/compiler/test/fail_compilation/cppvar.d +++ b/compiler/test/fail_compilation/cppvar.d @@ -9,7 +9,7 @@ fail_compilation/cppvar.d(21): Error: variable `cppvar.staticVar` cannot have `e fail_compilation/cppvar.d(21): perhaps declare it as `__gshared` instead fail_compilation/cppvar.d(22): Error: variable `cppvar.sharedVar` cannot have `extern(C++)` linkage because it is `shared` fail_compilation/cppvar.d(22): perhaps declare it as `__gshared` instead -fail_compilation/cppvar.d(30): Error: delegate `cppvar.__lambda7` cannot return type `bool[3]` because its linkage is `extern(C++)` +fail_compilation/cppvar.d(30): Error: delegate `cppvar.__lambda_L30_C46` cannot return type `bool[3]` because its linkage is `extern(C++)` --- */ #line 10 diff --git a/compiler/test/fail_compilation/diag12829.d b/compiler/test/fail_compilation/diag12829.d index aaedd0f721..0ed04d3a74 100644 --- a/compiler/test/fail_compilation/diag12829.d +++ b/compiler/test/fail_compilation/diag12829.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/diag12829.d(15): Error: function `diag12829.test1` is `@nogc` yet allocates closure for `test1()` with the GC -fail_compilation/diag12829.d(18): delegate `diag12829.test1.__lambda2` closes over variable `x` +fail_compilation/diag12829.d(18): delegate `diag12829.test1.__lambda_L18_C33` closes over variable `x` fail_compilation/diag12829.d(17): `x` declared here fail_compilation/diag12829.d(22): function `diag12829.test1.bar` closes over variable `x` fail_compilation/diag12829.d(17): `x` declared here diff --git a/compiler/test/fail_compilation/diag15411.d b/compiler/test/fail_compilation/diag15411.d index 8b18c19d02..51060b8ffc 100644 --- a/compiler/test/fail_compilation/diag15411.d +++ b/compiler/test/fail_compilation/diag15411.d @@ -2,9 +2,9 @@ /* TEST_OUTPUT: --- -fail_compilation/diag15411.d(17): Error: function `diag15411.test15411.__funcliteral2` cannot access variable `i` in frame of function `diag15411.test15411` +fail_compilation/diag15411.d(17): Error: function `diag15411.test15411.__funcliteral_L17_C15` cannot access variable `i` in frame of function `diag15411.test15411` fail_compilation/diag15411.d(16): `i` declared here -fail_compilation/diag15411.d(18): Error: function `diag15411.test15411.__funcliteral4` cannot access variable `i` in frame of function `diag15411.test15411` +fail_compilation/diag15411.d(18): Error: function `diag15411.test15411.__funcliteral_L18_C15` cannot access variable `i` in frame of function `diag15411.test15411` fail_compilation/diag15411.d(16): `i` declared here fail_compilation/diag15411.d(26): Error: `static` function `diag15411.testNestedFunction.myFunc2` cannot access function `myFunc1` in frame of function `diag15411.testNestedFunction` fail_compilation/diag15411.d(25): `myFunc1` declared here diff --git a/compiler/test/fail_compilation/diag20268.d b/compiler/test/fail_compilation/diag20268.d index 0653490267..5504aad0c7 100644 --- a/compiler/test/fail_compilation/diag20268.d +++ b/compiler/test/fail_compilation/diag20268.d @@ -3,8 +3,8 @@ /* TEST_OUTPUT: --- -fail_compilation/diag20268.d(12): Error: template `__lambda4` is not callable using argument types `!()(int)` -fail_compilation/diag20268.d(11): Candidate is: `__lambda4(__T1, __T2)(x, y)` +fail_compilation/diag20268.d(12): Error: template `__lambda_L11_C1` is not callable using argument types `!()(int)` +fail_compilation/diag20268.d(11): Candidate is: `__lambda_L11_C1(__T1, __T2)(x, y)` --- */ diff --git a/compiler/test/fail_compilation/diag9831.d b/compiler/test/fail_compilation/diag9831.d index c93a06a465..13995d4b6a 100644 --- a/compiler/test/fail_compilation/diag9831.d +++ b/compiler/test/fail_compilation/diag9831.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/diag9831.d(13): Error: function `diag9831.main.__lambda3(__T1)(x)` cannot access variable `c` in frame of function `D main` +fail_compilation/diag9831.d(13): Error: function `diag9831.main.__lambda_L13_C12(__T1)(x)` cannot access variable `c` in frame of function `D main` fail_compilation/diag9831.d(11): `c` declared here --- */ diff --git a/compiler/test/fail_compilation/diag_funclit.d b/compiler/test/fail_compilation/diag_funclit.d index f00f91a1fc..0173d4b78e 100644 --- a/compiler/test/fail_compilation/diag_funclit.d +++ b/compiler/test/fail_compilation/diag_funclit.d @@ -1,19 +1,19 @@ /** TEST_OUTPUT: --- -fail_compilation/diag_funclit.d(103): Error: function literal `__lambda1(x, y, z)` is not callable using argument types `()` +fail_compilation/diag_funclit.d(103): Error: function literal `__lambda_L103_C5(x, y, z)` is not callable using argument types `()` fail_compilation/diag_funclit.d(103): too few arguments, expected 3, got 0 -fail_compilation/diag_funclit.d(106): Error: function literal `__lambda2(x, y, z)` is not callable using argument types `(int, string, int, int)` +fail_compilation/diag_funclit.d(106): Error: function literal `__lambda_L106_C5(x, y, z)` is not callable using argument types `(int, string, int, int)` fail_compilation/diag_funclit.d(106): too many arguments, expected 3, got 4 -fail_compilation/diag_funclit.d(108): Error: function literal `__lambda3(x, y, string z = "Hello")` is not callable using argument types `(int, int, string, string)` +fail_compilation/diag_funclit.d(108): Error: function literal `__lambda_L108_C5(x, y, string z = "Hello")` is not callable using argument types `(int, int, string, string)` fail_compilation/diag_funclit.d(108): too many arguments, expected 3, got 4 -fail_compilation/diag_funclit.d(110): Error: function literal `__lambda4(x, y, string z = "Hello")` is not callable using argument types `(int)` +fail_compilation/diag_funclit.d(110): Error: function literal `__lambda_L110_C5(x, y, string z = "Hello")` is not callable using argument types `(int)` fail_compilation/diag_funclit.d(110): too few arguments, expected 3, got 1 -fail_compilation/diag_funclit.d(112): Error: function literal `__lambda5(x, y, z)` is not callable using argument types `(int)` +fail_compilation/diag_funclit.d(112): Error: function literal `__lambda_L112_C5(x, y, z)` is not callable using argument types `(int)` fail_compilation/diag_funclit.d(112): too few arguments, expected 3, got 1 -fail_compilation/diag_funclit.d(115): Error: function literal `__lambda6(x, y, ...)` is not callable using argument types `(int)` +fail_compilation/diag_funclit.d(115): Error: function literal `__lambda_L115_C5(x, y, ...)` is not callable using argument types `(int)` fail_compilation/diag_funclit.d(115): too few arguments, expected 2, got 1 -fail_compilation/diag_funclit.d(117): Error: function literal `__lambda7(x, y, string z = "Hey", ...)` is not callable using argument types `(int)` +fail_compilation/diag_funclit.d(117): Error: function literal `__lambda_L117_C5(x, y, string z = "Hey", ...)` is not callable using argument types `(int)` fail_compilation/diag_funclit.d(117): too few arguments, expected 3, got 1 --- */ diff --git a/compiler/test/fail_compilation/fail11125.d b/compiler/test/fail_compilation/fail11125.d index 1a682cd197..4349755519 100644 --- a/compiler/test/fail_compilation/fail11125.d +++ b/compiler/test/fail_compilation/fail11125.d @@ -2,11 +2,11 @@ TEST_OUTPUT: --- fail_compilation/fail11125.d(26): Error: template instance `fail11125.filter!(function (int a) pure nothrow @nogc @safe => a + 1)` does not match template declaration `filter(alias predfun)` - with `predfun = __lambda1` + with `predfun = __lambda_L26_C13` must satisfy the following constraint: ` is(ReturnType!predfun == bool)` fail_compilation/fail11125.d(27): Error: template instance `fail11125.filter!(function (int a) pure nothrow @nogc @safe => a + 1)` does not match template declaration `filter(alias predfun)` - with `predfun = __lambda2` + with `predfun = __lambda_L27_C17` must satisfy the following constraint: ` is(ReturnType!predfun == bool)` --- diff --git a/compiler/test/fail_compilation/fail12236.d b/compiler/test/fail_compilation/fail12236.d index 824f5e48db..f27cc2a521 100644 --- a/compiler/test/fail_compilation/fail12236.d +++ b/compiler/test/fail_compilation/fail12236.d @@ -6,8 +6,8 @@ fail_compilation/fail12236.d(16): while evaluating `pragma(msg, f1.mangle fail_compilation/fail12236.d(21): Error: forward reference to inferred return type of function `f2` fail_compilation/fail12236.d(21): while evaluating `pragma(msg, f2(T)(T).mangleof)` fail_compilation/fail12236.d(27): Error: template instance `fail12236.f2!int` error instantiating -fail_compilation/fail12236.d(31): Error: forward reference to inferred return type of function `__lambda1` -fail_compilation/fail12236.d(31): while evaluating `pragma(msg, __lambda1(__T1)(a).mangleof)` +fail_compilation/fail12236.d(31): Error: forward reference to inferred return type of function `__lambda_L29_C5` +fail_compilation/fail12236.d(31): while evaluating `pragma(msg, __lambda_L29_C5(__T1)(a).mangleof)` --- */ diff --git a/compiler/test/fail_compilation/fail12378.d b/compiler/test/fail_compilation/fail12378.d index 77678ebc0f..5a0f9e05ab 100644 --- a/compiler/test/fail_compilation/fail12378.d +++ b/compiler/test/fail_compilation/fail12378.d @@ -5,7 +5,7 @@ fail_compilation/fail12378.d(18): Error: undefined identifier `ANYTHING` fail_compilation/fail12378.d(18): Error: undefined identifier `GOES` fail_compilation/fail12378.d(91): instantiated from here: `MapResultS!((x0) => ANYTHING - GOES, Result)` fail_compilation/fail12378.d(17): instantiated from here: `mapS!(Result)` -fail_compilation/fail12378.d(100): instantiated from here: `__lambda1!int` +fail_compilation/fail12378.d(100): instantiated from here: `__lambda_L16_C19!int` fail_compilation/fail12378.d(91): instantiated from here: `MapResultS!((y0) => iota(2).mapS!((x0) => ANYTHING - GOES), Result)` fail_compilation/fail12378.d(16): instantiated from here: `mapS!(Result)` --- @@ -27,7 +27,7 @@ fail_compilation/fail12378.d(40): Error: undefined identifier `ANYTHING` fail_compilation/fail12378.d(40): Error: undefined identifier `GOES` fail_compilation/fail12378.d(112): instantiated from here: `MapResultC!((x0) => ANYTHING - GOES, Result)` fail_compilation/fail12378.d(39): instantiated from here: `mapC!(Result)` -fail_compilation/fail12378.d(123): instantiated from here: `__lambda1!int` +fail_compilation/fail12378.d(123): instantiated from here: `__lambda_L38_C19!int` fail_compilation/fail12378.d(112): instantiated from here: `MapResultC!((y0) => iota(2).mapC!((x0) => ANYTHING - GOES), Result)` fail_compilation/fail12378.d(38): instantiated from here: `mapC!(Result)` --- @@ -49,7 +49,7 @@ fail_compilation/fail12378.d(64): Error: undefined identifier `ANYTHING` fail_compilation/fail12378.d(64): Error: undefined identifier `GOES` fail_compilation/fail12378.d(135): instantiated from here: `MapResultI!((x0) => ANYTHING - GOES, Result)` fail_compilation/fail12378.d(63): instantiated from here: `mapI!(Result)` -fail_compilation/fail12378.d(143): instantiated from here: `__lambda1!int` +fail_compilation/fail12378.d(143): instantiated from here: `__lambda_L62_C19!int` fail_compilation/fail12378.d(135): instantiated from here: `MapResultI!((y0) => iota(2).mapI!((x0) => ANYTHING - GOES), Result)` fail_compilation/fail12378.d(62): instantiated from here: `mapI!(Result)` --- diff --git a/compiler/test/fail_compilation/fail12908.d b/compiler/test/fail_compilation/fail12908.d index 67ea6cefb2..3cc6306a80 100644 --- a/compiler/test/fail_compilation/fail12908.d +++ b/compiler/test/fail_compilation/fail12908.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail12908.d(14): Error: `pure` delegate `fail12908.main.__foreachbody1` cannot call impure function `fail12908.g` +fail_compilation/fail12908.d(14): Error: `pure` delegate `fail12908.main.__foreachbody_L12_C5` cannot call impure function `fail12908.g` --- */ diff --git a/compiler/test/fail_compilation/fail13120.d b/compiler/test/fail_compilation/fail13120.d index 6a1335eebd..1d1127c4c3 100644 --- a/compiler/test/fail_compilation/fail13120.d +++ b/compiler/test/fail_compilation/fail13120.d @@ -1,8 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail13120.d(13): Error: `pure` delegate `fail13120.g1.__foreachbody2` cannot call impure function `fail13120.f1` -fail_compilation/fail13120.d(13): Error: `@nogc` delegate `fail13120.g1.__foreachbody2` cannot call non-@nogc function `fail13120.f1` +fail_compilation/fail13120.d(13): Error: `pure` delegate `fail13120.g1.__foreachbody_L12_C5` cannot call impure function `fail13120.f1` +fail_compilation/fail13120.d(13): Error: `@nogc` delegate `fail13120.g1.__foreachbody_L12_C5` cannot call non-@nogc function `fail13120.f1` --- */ void f1() {} diff --git a/compiler/test/fail_compilation/fail13424.d b/compiler/test/fail_compilation/fail13424.d index dcec523a01..1a7f16b55c 100644 --- a/compiler/test/fail_compilation/fail13424.d +++ b/compiler/test/fail_compilation/fail13424.d @@ -1,9 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/fail13424.d(12): Error: delegate `fail13424.S.__lambda2` cannot be struct members -fail_compilation/fail13424.d(17): Error: delegate `fail13424.U.__lambda2` cannot be union members -fail_compilation/fail13424.d(22): Error: delegate `fail13424.C.__lambda2` cannot be class members +fail_compilation/fail13424.d(12): Error: delegate `fail13424.S.__lambda_L12_C35` cannot be struct members +fail_compilation/fail13424.d(17): Error: delegate `fail13424.U.__lambda_L17_C35` cannot be union members +fail_compilation/fail13424.d(22): Error: delegate `fail13424.C.__lambda_L22_C35` cannot be class members --- */ diff --git a/compiler/test/fail_compilation/fail17969.d b/compiler/test/fail_compilation/fail17969.d index 29bc3f448d..8272fb0b18 100644 --- a/compiler/test/fail_compilation/fail17969.d +++ b/compiler/test/fail_compilation/fail17969.d @@ -1,6 +1,6 @@ /* TEST_OUTPUT: --- -fail_compilation/fail17969.d(10): Error: no property `sum` for type `fail17969.__lambda6!(int[]).__lambda6.MapResult2!((b) => b)` +fail_compilation/fail17969.d(10): Error: no property `sum` for type `fail17969.__lambda_L10_C1!(int[]).__lambda_L10_C1.MapResult2!((b) => b)` fail_compilation/fail17969.d(16): struct `MapResult2` defined here --- * https://issues.dlang.org/show_bug.cgi?id=17969 diff --git a/compiler/test/fail_compilation/fail39.d b/compiler/test/fail_compilation/fail39.d index c0bb0e16a0..f740dda98f 100644 --- a/compiler/test/fail_compilation/fail39.d +++ b/compiler/test/fail_compilation/fail39.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail39.d(12): Error: function `fail39.main.__funcliteral2` cannot access function `foo` in frame of function `D main` +fail_compilation/fail39.d(12): Error: function `fail39.main.__funcliteral_L12_C27` cannot access function `foo` in frame of function `D main` fail_compilation/fail39.d(11): `foo` declared here --- */ diff --git a/compiler/test/fail_compilation/iasm1.d b/compiler/test/fail_compilation/iasm1.d index bac97ef378..4fd1a39d78 100644 --- a/compiler/test/fail_compilation/iasm1.d +++ b/compiler/test/fail_compilation/iasm1.d @@ -117,7 +117,7 @@ void test5() /* TEST_OUTPUT: --- -fail_compilation/iasm1.d(615): Error: delegate `iasm1.test6.__foreachbody1` label `L1` is undefined +fail_compilation/iasm1.d(615): Error: delegate `iasm1.test6.__foreachbody_L611_C5` label `L1` is undefined --- */ diff --git a/compiler/test/fail_compilation/ice10922.d b/compiler/test/fail_compilation/ice10922.d index 552a9824f3..fc6c593ae0 100644 --- a/compiler/test/fail_compilation/ice10922.d +++ b/compiler/test/fail_compilation/ice10922.d @@ -1,9 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/ice10922.d(11): Error: function `__lambda4` is not callable using argument types `()` +fail_compilation/ice10922.d(11): Error: function `__lambda_L10_C12` is not callable using argument types `()` fail_compilation/ice10922.d(11): too few arguments, expected 1, got 0 -fail_compilation/ice10922.d(10): `ice10922.__lambda4(in uint n)` declared here +fail_compilation/ice10922.d(10): `ice10922.__lambda_L10_C12(in uint n)` declared here --- */ diff --git a/compiler/test/fail_compilation/ice11822.d b/compiler/test/fail_compilation/ice11822.d index 830af212cb..a673a6b2dd 100644 --- a/compiler/test/fail_compilation/ice11822.d +++ b/compiler/test/fail_compilation/ice11822.d @@ -5,8 +5,8 @@ TEST_OUTPUT: --- fail_compilation/ice11822.d(33): Deprecation: function `ice11822.d` is deprecated -fail_compilation/ice11822.d(16): instantiated from here: `__lambda2!int` -fail_compilation/ice11822.d(22): instantiated from here: `S!(__lambda2)` +fail_compilation/ice11822.d(16): instantiated from here: `__lambda_L33_C15!int` +fail_compilation/ice11822.d(22): instantiated from here: `S!(__lambda_L33_C15)` fail_compilation/ice11822.d(33): instantiated from here: `g!((n) => d(i))` --- */ diff --git a/compiler/test/fail_compilation/ice11850.d b/compiler/test/fail_compilation/ice11850.d index d33549a27f..510fe0aae8 100644 --- a/compiler/test/fail_compilation/ice11850.d +++ b/compiler/test/fail_compilation/ice11850.d @@ -3,7 +3,7 @@ EXTRA_FILES: imports/a11850.d TEST_OUTPUT: --- fail_compilation/ice11850.d(15): Error: incompatible types for `(a) < ([0])`: `uint[]` and `int[]` -fail_compilation/imports/a11850.d(9): instantiated from here: `FilterResult!(__lambda1, uint[][])` +fail_compilation/imports/a11850.d(9): instantiated from here: `FilterResult!(__lambda_L15_C13, uint[][])` fail_compilation/ice11850.d(15): instantiated from here: `filter!(uint[][])` --- */ diff --git a/compiler/test/fail_compilation/ice12235.d b/compiler/test/fail_compilation/ice12235.d index 8f2fefd099..ca453e0928 100644 --- a/compiler/test/fail_compilation/ice12235.d +++ b/compiler/test/fail_compilation/ice12235.d @@ -1,9 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/ice12235.d(14): Error: forward reference to inferred return type of function `__lambda1` -fail_compilation/ice12235.d(15): Error: forward reference to inferred return type of function `__lambda1` -fail_compilation/ice12235.d(15): while evaluating `pragma(msg, __lambda1.mangleof)` +fail_compilation/ice12235.d(14): Error: forward reference to inferred return type of function `__lambda_L12_C5` +fail_compilation/ice12235.d(15): Error: forward reference to inferred return type of function `__lambda_L12_C5` +fail_compilation/ice12235.d(15): while evaluating `pragma(msg, __lambda_L12_C5.mangleof)` --- */ diff --git a/compiler/test/fail_compilation/ice8309.d b/compiler/test/fail_compilation/ice8309.d index 2446914477..a9f6f7253a 100644 --- a/compiler/test/fail_compilation/ice8309.d +++ b/compiler/test/fail_compilation/ice8309.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/ice8309.d(10): Error: incompatible types for `(__lambda1) : (__lambda2)`: `double function() pure nothrow @nogc @safe` and `int function() pure nothrow @nogc @safe` +fail_compilation/ice8309.d(10): Error: incompatible types for `(__lambda_L10_C15) : (__lambda_L10_C24)`: `double function() pure nothrow @nogc @safe` and `int function() pure nothrow @nogc @safe` --- */ diff --git a/compiler/test/fail_compilation/misc1.d b/compiler/test/fail_compilation/misc1.d index 95bcc6d03d..90e42d83e9 100644 --- a/compiler/test/fail_compilation/misc1.d +++ b/compiler/test/fail_compilation/misc1.d @@ -5,7 +5,7 @@ fail_compilation/misc1.d(109): Error: `5` has no effect fail_compilation/misc1.d(110): Error: `1 + 2` has no effect fail_compilation/misc1.d(111): Error: `x` has no effect fail_compilation/misc1.d(117): Deprecation: `1 * 1` has no effect -fail_compilation/misc1.d(118): Deprecation: `__lambda3` has no effect +fail_compilation/misc1.d(118): Deprecation: `__lambda_L118_C34` has no effect fail_compilation/misc1.d(124): Deprecation: `false` has no effect fail_compilation/misc1.d(127): Deprecation: `*sp++` has no effect fail_compilation/misc1.d(128): Deprecation: `j` has no effect diff --git a/compiler/test/fail_compilation/opapplyscope.d b/compiler/test/fail_compilation/opapplyscope.d index 8414bf1284..3eef0f9293 100644 --- a/compiler/test/fail_compilation/opapplyscope.d +++ b/compiler/test/fail_compilation/opapplyscope.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- fail_compilation/opapplyscope.d(113): Error: function `opapplyscope.S.opApply(scope int delegate(scope int* ptr) @safe dg)` is not callable using argument types `(int delegate(int* x) nothrow @nogc @safe)` -fail_compilation/opapplyscope.d(113): cannot pass argument `__foreachbody3` of type `int delegate(int* x) nothrow @nogc @safe` to parameter `scope int delegate(scope int* ptr) @safe dg` +fail_compilation/opapplyscope.d(113): cannot pass argument `__foreachbody_L113_C5` of type `int delegate(int* x) nothrow @nogc @safe` to parameter `scope int delegate(scope int* ptr) @safe dg` --- */ diff --git a/compiler/test/fail_compilation/previewin.d b/compiler/test/fail_compilation/previewin.d index 486dcd5244..c3d11cbfd0 100644 --- a/compiler/test/fail_compilation/previewin.d +++ b/compiler/test/fail_compilation/previewin.d @@ -3,13 +3,13 @@ REQUIRED_ARGS: -preview=in -preview=dip1000 TEST_OUTPUT: ---- fail_compilation/previewin.d(4): Error: function `takeFunction` is not callable using argument types `(void function(real x) pure nothrow @nogc @safe)` -fail_compilation/previewin.d(4): cannot pass argument `__lambda1` of type `void function(real x) pure nothrow @nogc @safe` to parameter `void function(in real) f` +fail_compilation/previewin.d(4): cannot pass argument `__lambda_L4_C18` of type `void function(real x) pure nothrow @nogc @safe` to parameter `void function(in real) f` fail_compilation/previewin.d(11): `previewin.takeFunction(void function(in real) f)` declared here fail_compilation/previewin.d(5): Error: function `takeFunction` is not callable using argument types `(void function(scope const(real) x) pure nothrow @nogc @safe)` -fail_compilation/previewin.d(5): cannot pass argument `__lambda2` of type `void function(scope const(real) x) pure nothrow @nogc @safe` to parameter `void function(in real) f` +fail_compilation/previewin.d(5): cannot pass argument `__lambda_L5_C18` of type `void function(scope const(real) x) pure nothrow @nogc @safe` to parameter `void function(in real) f` fail_compilation/previewin.d(11): `previewin.takeFunction(void function(in real) f)` declared here fail_compilation/previewin.d(6): Error: function `takeFunction` is not callable using argument types `(void function(ref scope const(real) x) pure nothrow @nogc @safe)` -fail_compilation/previewin.d(6): cannot pass argument `__lambda3` of type `void function(ref scope const(real) x) pure nothrow @nogc @safe` to parameter `void function(in real) f` +fail_compilation/previewin.d(6): cannot pass argument `__lambda_L6_C18` of type `void function(ref scope const(real) x) pure nothrow @nogc @safe` to parameter `void function(in real) f` fail_compilation/previewin.d(11): `previewin.takeFunction(void function(in real) f)` declared here fail_compilation/previewin.d(15): Error: scope variable `arg` assigned to global variable `myGlobal` fail_compilation/previewin.d(16): Error: scope variable `arg` assigned to global variable `myGlobal` diff --git a/compiler/test/fail_compilation/retscope.d b/compiler/test/fail_compilation/retscope.d index 919d9401cd..acad99bdaf 100644 --- a/compiler/test/fail_compilation/retscope.d +++ b/compiler/test/fail_compilation/retscope.d @@ -55,7 +55,7 @@ void test2(scope int* p, int[] a ...) @safe TEST_OUTPUT: --- fail_compilation/retscope.d(75): Error: function `retscope.HTTP.Impl.onReceive` is `@nogc` yet allocates closure for `onReceive()` with the GC -fail_compilation/retscope.d(77): delegate `retscope.HTTP.Impl.onReceive.__lambda1` closes over variable `this` +fail_compilation/retscope.d(77): delegate `retscope.HTTP.Impl.onReceive.__lambda_L77_C23` closes over variable `this` --- */ @@ -234,10 +234,10 @@ void* funretscope(scope dg_t ptr) @safe /* TEST_OUTPUT: --- -fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `__lambda2` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` -fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `__lambda2` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` -fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda4` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` -fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda4` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` +fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `__lambda_L248_C21` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` +fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `__lambda_L248_C21` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` +fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda_L249_C21` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` +fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda_L249_C21` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` --- */ diff --git a/compiler/test/fail_compilation/test15306.d b/compiler/test/fail_compilation/test15306.d index ff532aea22..a60e274042 100644 --- a/compiler/test/fail_compilation/test15306.d +++ b/compiler/test/fail_compilation/test15306.d @@ -1,8 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/test15306.d(15): Error: `immutable` delegate `test15306.main.__dgliteral2` cannot access mutable data `i` -fail_compilation/test15306.d(19): Error: `shared` delegate `test15306.main.__dgliteral5` cannot access non-shared data `p` +fail_compilation/test15306.d(15): Error: `immutable` delegate `test15306.main.__dgliteral_L15_C16` cannot access mutable data `i` +fail_compilation/test15306.d(19): Error: `shared` delegate `test15306.main.__dgliteral_L19_C16` cannot access non-shared data `p` --- */ diff --git a/compiler/test/fail_compilation/test16193.d b/compiler/test/fail_compilation/test16193.d index 39399cf01d..84dc7d1c6d 100644 --- a/compiler/test/fail_compilation/test16193.d +++ b/compiler/test/fail_compilation/test16193.d @@ -3,7 +3,7 @@ REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test16193.d(39): Error: function `test16193.abc` is `@nogc` yet allocates closure for `abc()` with the GC -fail_compilation/test16193.d(41): delegate `test16193.abc.__foreachbody2` closes over variable `x` +fail_compilation/test16193.d(41): delegate `test16193.abc.__foreachbody_L41_C5` closes over variable `x` fail_compilation/test16193.d(40): `x` declared here --- */ diff --git a/compiler/test/fail_compilation/test17451.d b/compiler/test/fail_compilation/test17451.d index b0cda2105a..7df77f591f 100644 --- a/compiler/test/fail_compilation/test17451.d +++ b/compiler/test/fail_compilation/test17451.d @@ -2,7 +2,7 @@ --- fail_compilation/test17451.d(22): Error: undefined identifier `allocator` fail_compilation/test17451.d(23): Error: `false` has no effect -fail_compilation/test17451.d(30): Error: variable `test17451.HashMap!(ThreadSlot).HashMap.__lambda2.v` - size of type `ThreadSlot` is invalid +fail_compilation/test17451.d(30): Error: variable `test17451.HashMap!(ThreadSlot).HashMap.__lambda_L30_C20.v` - size of type `ThreadSlot` is invalid fail_compilation/test17451.d(44): Error: template instance `test17451.HashMap!(ThreadSlot)` error instantiating --- */ diff --git a/compiler/test/fail_compilation/test19107.d b/compiler/test/fail_compilation/test19107.d index 9a6e335864..8bbfa82717 100644 --- a/compiler/test/fail_compilation/test19107.d +++ b/compiler/test/fail_compilation/test19107.d @@ -4,7 +4,7 @@ TEST_OUTPUT: --- fail_compilation/test19107.d(24): Error: template `all` is not callable using argument types `!((c) => c)(string[])` fail_compilation/test19107.d(18): Candidate is: `all(alias pred, T)(T t)` - with `pred = __lambda2, + with `pred = __lambda_L24_C15, T = string[]` must satisfy the following constraint: ` is(typeof(I!pred(t)))` diff --git a/compiler/test/fail_compilation/test19971.d b/compiler/test/fail_compilation/test19971.d index 3d46eeb82e..b99afddbdd 100644 --- a/compiler/test/fail_compilation/test19971.d +++ b/compiler/test/fail_compilation/test19971.d @@ -3,7 +3,7 @@ fail_compilation/test19971.d(16): Error: function `f` is not callable using argument types `(string)` fail_compilation/test19971.d(16): cannot pass argument `"%s"` of type `string` to parameter `int x` fail_compilation/test19971.d(13): `test19971.f(int x)` declared here -fail_compilation/test19971.d(17): Error: function literal `__lambda1(int x)` is not callable using argument types `(string)` +fail_compilation/test19971.d(17): Error: function literal `__lambda_L17_C5(int x)` is not callable using argument types `(string)` fail_compilation/test19971.d(17): cannot pass argument `"%s"` of type `string` to parameter `int x` --- */ diff --git a/compiler/test/fail_compilation/test20719.d b/compiler/test/fail_compilation/test20719.d index b9305f20f8..4db59d62ae 100644 --- a/compiler/test/fail_compilation/test20719.d +++ b/compiler/test/fail_compilation/test20719.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- fail_compilation/test20719.d(13): Error: struct `test20719.SumType` no size because of forward reference -fail_compilation/test20719.d(32): Error: variable `test20719.isCopyable!(SumType).__lambda2.foo` - size of type `SumType` is invalid +fail_compilation/test20719.d(32): Error: variable `test20719.isCopyable!(SumType).__lambda_L32_C22.foo` - size of type `SumType` is invalid fail_compilation/test20719.d(18): Error: template instance `test20719.isCopyable!(SumType)` error instantiating --- */ diff --git a/compiler/test/fail_compilation/test21912.d b/compiler/test/fail_compilation/test21912.d index f8bcb40b5d..7e236c8a33 100644 --- a/compiler/test/fail_compilation/test21912.d +++ b/compiler/test/fail_compilation/test21912.d @@ -3,16 +3,16 @@ PERMUTE_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test21912.d(28): Error: function `test21912.escapeParam` is `@nogc` yet allocates closure for `escapeParam()` with the GC -fail_compilation/test21912.d(30): delegate `test21912.escapeParam.__lambda2` closes over variable `i` +fail_compilation/test21912.d(30): delegate `test21912.escapeParam.__lambda_L30_C21` closes over variable `i` fail_compilation/test21912.d(28): `i` declared here fail_compilation/test21912.d(33): Error: function `test21912.escapeAssign` is `@nogc` yet allocates closure for `escapeAssign()` with the GC -fail_compilation/test21912.d(35): delegate `test21912.escapeAssign.__lambda3` closes over variable `i` +fail_compilation/test21912.d(35): delegate `test21912.escapeAssign.__lambda_L35_C10` closes over variable `i` fail_compilation/test21912.d(33): `i` declared here fail_compilation/test21912.d(44): Error: function `test21912.escapeAssignRef` is `@nogc` yet allocates closure for `escapeAssignRef()` with the GC -fail_compilation/test21912.d(46): delegate `test21912.escapeAssignRef.__lambda3` closes over variable `i` +fail_compilation/test21912.d(46): delegate `test21912.escapeAssignRef.__lambda_L46_C10` closes over variable `i` fail_compilation/test21912.d(44): `i` declared here fail_compilation/test21912.d(55): Error: function `test21912.escapeParamInferred` is `@nogc` yet allocates closure for `escapeParamInferred()` with the GC -fail_compilation/test21912.d(57): delegate `test21912.escapeParamInferred.__lambda2` closes over variable `i` +fail_compilation/test21912.d(57): delegate `test21912.escapeParamInferred.__lambda_L57_C29` closes over variable `i` fail_compilation/test21912.d(55): `i` declared here --- */ diff --git a/compiler/test/fail_compilation/test23170.d b/compiler/test/fail_compilation/test23170.d index eb79cd8156..fedf31b5fc 100644 --- a/compiler/test/fail_compilation/test23170.d +++ b/compiler/test/fail_compilation/test23170.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/test23170.d(10): Error: array literal in `@nogc` delegate `test23170.__lambda5` may cause a GC allocation +fail_compilation/test23170.d(10): Error: array literal in `@nogc` delegate `test23170.__lambda_L10_C15` may cause a GC allocation --- */ // https://issues.dlang.org/show_bug.cgi?id=23170 diff --git a/compiler/test/fail_compilation/testInference.d b/compiler/test/fail_compilation/testInference.d index 145fc9e8b9..b3a8a561cf 100644 --- a/compiler/test/fail_compilation/testInference.d +++ b/compiler/test/fail_compilation/testInference.d @@ -138,7 +138,7 @@ immutable(void)* g10063(inout int* p) pure TEST_OUTPUT: --- fail_compilation/testInference.d(154): Error: `pure` function `testInference.bar14049` cannot call impure function `testInference.foo14049!int.foo14049` -fail_compilation/testInference.d(149): which calls `testInference.foo14049!int.foo14049.__lambda2` +fail_compilation/testInference.d(149): which calls `testInference.foo14049!int.foo14049.__lambda_L147_C14` fail_compilation/testInference.d(148): which calls `testInference.impure14049` fail_compilation/testInference.d(143): which wasn't inferred `pure` because of: fail_compilation/testInference.d(143): `pure` function `testInference.impure14049` cannot access mutable static data `i` diff --git a/compiler/test/fail_compilation/var_func_attr.d b/compiler/test/fail_compilation/var_func_attr.d index 8609d29b58..0753b13f31 100644 --- a/compiler/test/fail_compilation/var_func_attr.d +++ b/compiler/test/fail_compilation/var_func_attr.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/var_func_attr.d(19): Error: cannot implicitly convert expression `__lambda8` of type `void function() nothrow @nogc @safe` to `void function() pure` +fail_compilation/var_func_attr.d(19): Error: cannot implicitly convert expression `__lambda_L19_C27` of type `void function() nothrow @nogc @safe` to `void function() pure` --- */ diff --git a/compiler/test/runnable/imports/test23722b.d b/compiler/test/runnable/imports/test23722b.d new file mode 100644 index 0000000000..1c77bc6845 --- /dev/null +++ b/compiler/test/runnable/imports/test23722b.d @@ -0,0 +1,6 @@ +auto f(string s, alias g)() { + return true; +} + +alias a = f!("a", output => output); +alias b = f!("b", output => true); diff --git a/compiler/test/runnable/mangle.d b/compiler/test/runnable/mangle.d index 53d7648099..76a4adfab7 100644 --- a/compiler/test/runnable/mangle.d +++ b/compiler/test/runnable/mangle.d @@ -448,11 +448,11 @@ void test11776() if (1) { auto s = S11776!(a => 1)(); - static assert(typeof(s).mangleof == - "S"~"6mangle"~tl!("56")~ + enum expected = "S"~"6mangle"~tl!("56")~ ("__T"~"6S11776"~"S"~tl!("42")~ - (id!("6mangle","Qs")~"9test11776"~"FZ"~"9__lambda1MFZ"~id!("9__lambda1","Qn"))~"Z" - )~id!("6S11776", "QBm")); + (id!("6mangle","Qs")~"9test11776"~"FZ"~"17__lambda_L444_C14MFZ17__lambda_L450_C30")~"Z" + )~id!("6S11776", "QCm"); + static assert(typeof(s).mangleof == expected); } }; } @@ -509,7 +509,7 @@ void func12231a()() if (is(typeof({ class C {} static assert(C.mangleof == - "C6mangle"~tl!("16")~"__U10func12231aZ"~id!("10func12231a","Qn")~"FZ9__lambda1MFZ1C"); + "C6mangle"~tl!("16")~"__U10func12231aZ"~id!("10func12231a","Qn")~"FZ17__lambda_L509_C15MFZ1C"); // ### L # }))) {} @@ -517,13 +517,13 @@ if (is(typeof({ void func12231b()() if (is(typeof({ class C {} static assert(C.mangleof == - "C6mangle"~tl!("16")~"__U10func12231bZ"~id!("10func12231b","Qn")~"FZ9__lambda1MFZ1C"); + "C6mangle"~tl!("16")~"__U10func12231bZ"~id!("10func12231b","Qn")~"FZ17__lambda_L518_C15MFZ1C"); // L__L L LL })) && is(typeof({ class C {} static assert(C.mangleof == - "C6mangle"~tl!("16")~"__U10func12231bZ"~id!("10func12231b","Qn")~"FZ9__lambda2MFZ1C"); + "C6mangle"~tl!("16")~"__U10func12231bZ"~id!("10func12231b","Qn")~"FZ17__lambda_L523_C15MFZ1C"); // L__L L LL }))) {} @@ -532,14 +532,14 @@ void func12231c()() if (is(typeof({ class C {} static assert(C.mangleof == - "C6mangle"~tl!("16")~"__U10func12231cZ"~id!("10func12231c","Qn")~"FZ9__lambda1MFZ1C"); + "C6mangle"~tl!("16")~"__U10func12231cZ"~id!("10func12231c","Qn")~"FZ17__lambda_L532_C15MFZ1C"); // L__L L LL }))) { (){ class C {} static assert(C.mangleof == - "C6mangle"~tl!("16")~"__T10func12231cZ"~id!("10func12231c","Qn")~"FZ9__lambda1MFZ1C"); + "C6mangle"~tl!("16")~"__T10func12231cZ"~id!("10func12231c","Qn")~"FZ16__lambda_L539_C5MFZ1C"); // L__L L LL }(); } @@ -548,14 +548,14 @@ void func12231c(X)() if (is(typeof({ class C {} static assert(C.mangleof == - "C6mangle"~tl!("20")~"__U10func12231cTAyaZ"~id!("10func12231c","Qr")~"FZ9__lambda1MFZ1C"); + "C6mangle"~tl!("20")~"__U10func12231cTAyaZ"~id!("10func12231c","Qr")~"FZ17__lambda_L548_C15MFZ1C"); // L__L L___L LL }))) { (){ class C {} static assert(C.mangleof == - "C6mangle"~tl!("20")~"__T10func12231cTAyaZ"~id!("10func12231c","Qr")~"FZ9__lambda1MFZ1C"); + "C6mangle"~tl!("20")~"__T10func12231cTAyaZ"~id!("10func12231c","Qr")~"FZ16__lambda_L555_C5MFZ1C"); // L__L L___L LL }(); } @@ -616,7 +616,7 @@ static assert(funcd.mangleof == "_D6mangle5funcdFPFZNnZi"); struct S21753 { void function() f1; } void fun21753(S21753 v)() {} alias fl21753 = (){}; -static assert((fun21753!(S21753(fl21753))).mangleof == "_D6mangle__T8fun21753VSQv6S21753S1f_DQBj10" ~ fl21753.stringof ~ "MFNaNbNiNfZvZQCbQp"); +static assert((fun21753!(S21753(fl21753))).mangleof == "_D6mangle__T8fun21753VSQv6S21753S1f_DQBj16" ~ fl21753.stringof ~ "MFNaNbNiNfZvZQChQp"); /***************************************************/ void main() diff --git a/compiler/test/runnable/test23722.d b/compiler/test/runnable/test23722.d new file mode 100644 index 0000000000..2904a95656 --- /dev/null +++ b/compiler/test/runnable/test23722.d @@ -0,0 +1,12 @@ +// COMPILE_SEPARATELY: +// EXTRA_SOURCES: imports/test23722b.d +// REQUIRED_ARGS: -betterC +// https://issues.dlang.org/show_bug.cgi?id=23722 +// Lambdas are mangled incorrectly when using multiple compilation units, resulting in incorrect code +import imports.test23722b; + +bool f() { + return b; +} + +void main() {} diff --git a/compiler/test/runnable/test24884.d b/compiler/test/runnable/test24884.d new file mode 100644 index 0000000000..0070d2b932 --- /dev/null +++ b/compiler/test/runnable/test24884.d @@ -0,0 +1,34 @@ +/* +REQUIRED_ARGS: -inline +*/ + +// https://issues.dlang.org/show_bug.cgi?id=24884 + +pragma(inline, false) +bool norm(int a) => 0; + +pragma(inline, false) +void inlinebug(ref double[4] point1, ref double[4] point2, ref double[4] point3, ref double[4] abcd) +{ + double[4] v1 = 0.0; + double[4] v2 = 0.0; + + v1[0] = point1[0] - point2[0]; + v1[1] = point1[1] - point2[1]; + v1[2] = point1[2] - point2[2]; + v1[3] = point1[3]; + v2[0] = point2[0] - point3[0]; + v2[1] = point2[1] - point3[1]; + v2[2] = point2[2] - point3[2]; + + int p = cast(int) &abcd; + int q = cast(int) &point1; + abcd[0] = norm(7) + p; + abcd[1] = q + p; +} + +extern(C) void main() +{ + double[4] a = 0.0; + inlinebug(a, a, a, a); +} diff --git a/compiler/test/runnable/test36.d b/compiler/test/runnable/test36.d index 5470db47b9..1403154a77 100644 --- a/compiler/test/runnable/test36.d +++ b/compiler/test/runnable/test36.d @@ -12,6 +12,10 @@ extern (Windows): {printf(`comobject\n`); } } + +// https://issues.dlang.org/show_bug.cgi?id=24882 +static assert(__traits(isCOMClass, ComObject)); + interface IDataObject: IUnknown { extern(Windows): diff --git a/compiler/test/runnable/testkeyword.d b/compiler/test/runnable/testkeyword.d index 5fb4d44203..7f8bded254 100644 --- a/compiler/test/runnable/testkeyword.d +++ b/compiler/test/runnable/testkeyword.d @@ -97,8 +97,8 @@ void main(string[] args) nothrow auto funcLiteral = (int x, int y) { - enum thisFunc = "testkeyword.main.__lambda5"; - enum thisFunc2 = "testkeyword.main.__lambda5(int x, int y)"; + enum thisFunc = "testkeyword.main.__lambda_L98_C24"; + enum thisFunc2 = "testkeyword.main.__lambda_L98_C24(int x, int y)"; static assert(getFuncArgFile() == thisFile); static assert(getFuncArgLine() == 104); diff --git a/compiler/test/runnable/traits.d b/compiler/test/runnable/traits.d index 5186987dea..7722d9dd6d 100644 --- a/compiler/test/runnable/traits.d +++ b/compiler/test/runnable/traits.d @@ -10,7 +10,7 @@ Creating library {{RESULTS_DIR}}/runnable/traits_0.lib and object {{RESULTS_DIR} TRANSFORM_OUTPUT: remove_lines("Creating library") TEST_OUTPUT: --- -__lambda1 +__lambda_L1073_C5 --- */ diff --git a/druntime/src/core/internal/array/arrayassign.d b/druntime/src/core/internal/array/arrayassign.d index 6e3c1fdc3e..21690caf5d 100644 --- a/druntime/src/core/internal/array/arrayassign.d +++ b/druntime/src/core/internal/array/arrayassign.d @@ -347,7 +347,7 @@ Tarr _d_arraysetassign(Tarr : T[], T)(return scope Tarr to, scope ref T value) @ static if (__traits(isCopyable, T)) copyEmplace(value, dst); else - memcpy(cast(void*) &value, cast(void*) &dst, elemSize); + memcpy(cast(void*) &dst, cast(void*) &value, elemSize); auto elem = cast(Unqual!T*) &tmp; destroy(*elem); } @@ -395,6 +395,20 @@ Tarr _d_arraysetassign(Tarr : T[], T)(return scope Tarr to, scope ref T value) @ assert(arr == [S(1234), S(1234), S(1234), S(1234)]); } +// disabled copy constructor +@safe unittest +{ + static struct S + { + int val; + @disable this(ref S); + } + S[1] arr; + S s = S(1234); + _d_arraysetassign(arr[], s); + assert(arr[0].val == 1234); +} + // throwing and `nothrow` @safe nothrow unittest { diff --git a/druntime/src/core/lifetime.d b/druntime/src/core/lifetime.d index 7010d2ad3b..84ffdde7a2 100644 --- a/druntime/src/core/lifetime.d +++ b/druntime/src/core/lifetime.d @@ -2739,8 +2739,11 @@ if (is(T == class)) auto init = __traits(initSymbol, T); void* p; - static if (__traits(getLinkage, T) == "Windows") + static if (__traits(isCOMClass, T)) { + // If this is a COM class we allocate it using malloc. + // This allows the reference counting to outlive the reference known about by the GC. + p = pureMalloc(init.length); if (!p) onOutOfMemoryError();