| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // PERMUTE_ARGS: | ||
|
|
||
| template AddField(T) | ||
| { | ||
| T b; | ||
| this(Args...)(T b, auto ref Args args) | ||
| { | ||
| this.b = b; | ||
| this(args); | ||
| } | ||
| } | ||
|
|
||
| template construcotrs() | ||
| { | ||
| int a; | ||
| this(int a) | ||
| { | ||
| this.a = a; | ||
| } | ||
| } | ||
|
|
||
| class B | ||
| { | ||
| mixin construcotrs; | ||
| mixin AddField!(string); | ||
| } | ||
|
|
||
| class C : B | ||
| { | ||
| this(A...)(A args) | ||
| { | ||
| // The called super ctor is an overload set. | ||
| super(args); | ||
| } | ||
| } | ||
|
|
||
| struct S | ||
| { | ||
| mixin construcotrs; | ||
| mixin AddField!(string); | ||
| } | ||
|
|
||
| void main() | ||
| { | ||
| auto s = S("bar", 15); | ||
| auto c = new C("bar", 15); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -763,6 +763,71 @@ void test14200() | |
| test14200b(1.0f, 1, 1.0); | ||
| } | ||
|
|
||
| /****************************************/ | ||
| // 15579 | ||
|
|
||
| extern (C++) | ||
| { | ||
| class Base | ||
| { | ||
| //~this() {} | ||
| void based() { } | ||
| ubyte x = 4; | ||
| } | ||
|
|
||
| interface Interface | ||
| { | ||
| int MethodCPP(); | ||
| int MethodD(); | ||
| } | ||
|
|
||
| class Derived : Base, Interface | ||
| { | ||
| short y = 5; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ibuclaw
Author
Member
|
||
| int MethodCPP(); | ||
| int MethodD() { | ||
| printf("Derived.MethodD(): this = %p, x = %d, y = %d\n", this, x, y); | ||
| Derived p = this; | ||
| //p = cast(Derived)(cast(void*)p - 16); | ||
| assert(p.x == 4 || p.x == 7); | ||
| assert(p.y == 5 || p.y == 8); | ||
| return 3; | ||
| } | ||
| int Method() { return 6; } | ||
| } | ||
|
|
||
| Derived cppfoo(Derived); | ||
| Interface cppfooi(Interface); | ||
| } | ||
|
|
||
| void test15579() | ||
| { | ||
| Derived d = new Derived(); | ||
| printf("d = %p\n", d); | ||
| assert(d.x == 4); | ||
| assert(d.y == 5); | ||
| assert((cast(Interface)d).MethodCPP() == 30); | ||
| assert((cast(Interface)d).MethodD() == 3); | ||
| assert(d.MethodCPP() == 30); | ||
| assert(d.MethodD() == 3); | ||
| assert(d.Method() == 6); | ||
|
|
||
| d = cppfoo(d); | ||
| assert(d.x == 7); | ||
| assert(d.y == 8); | ||
|
|
||
| printf("d2 = %p\n", d); | ||
| assert((cast(Interface)d).MethodD() == 3); | ||
| assert((cast(Interface)d).MethodCPP() == 30); | ||
| assert(d.Method() == 6); | ||
|
|
||
| printf("d = %p, i = %p\n", d, cast(Interface)d); | ||
| Interface i = cppfooi(d); | ||
| printf("i2: %p\n", i); | ||
| assert(i.MethodD() == 3); | ||
| assert(i.MethodCPP() == 30); | ||
| } | ||
|
|
||
| /****************************************/ | ||
|
|
||
| void main() | ||
|
|
@@ -794,6 +859,7 @@ void main() | |
| foo13337(S13337()); | ||
| test14195(); | ||
| test14200(); | ||
| test15579(); | ||
|
|
||
| printf("Success\n"); | ||
| } | ||
@ibuclaw This can't be supported in GCC <= 4.9, correct?
This test is the only failing test on the GCC 4.9 backport. The thunk for this function is not emitted as weak/comdat in these older GCCs. In newer GCCs
finish_thunkexpands thunks in gimple so I guess this is a requirement for this testcase to work?I guess it's basically the same problem as #97 (comment) ?