Hi, This patch is part of merging the D front-end implementation with upstream dmd 3b808e838. These changes are specific to the D2 testsuite in testsuite/gdc.test, and cover all fixes issues.
Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32 and committed to mainline. Regards, Iain. --- gcc/testsuite/gdc.test/compilable/bug20796.d | 2 + gcc/testsuite/gdc.test/compilable/cppmangle.d | 18 +++ .../gdc.test/compilable/ddocunittest.d | 1 + .../serenity7190/core/Controller.d | 8 +- .../compilable/extra-files/test20280a.d | 12 ++ gcc/testsuite/gdc.test/compilable/fix21585.d | 24 +++ gcc/testsuite/gdc.test/compilable/fix21647.d | 30 ++++ gcc/testsuite/gdc.test/compilable/ice10598.d | 3 - .../gdc.test/compilable/imports/issue21614a.d | 22 +++ .../compilable/imports/pkg20537/package.d | 0 .../compilable/imports/test17991a/a.d | 0 .../compilable/imports/test17991a/package.d | 0 .../compilable/imports/test20151a/b/c/c.d | 0 .../gdc.test/compilable/imports/test20530a.d | 0 .../gdc.test/compilable/imports/test21501b.d | 7 + .../gdc.test/compilable/imports/test21501c.d | 4 + .../gdc.test/compilable/issue16020.d | 39 +++++ .../gdc.test/compilable/issue21614.d | 10 ++ .../gdc.test/compilable/issue21726.d | 2 + gcc/testsuite/gdc.test/compilable/mixintype.d | 55 +++++++ .../gdc.test/compilable/mixintype2.d | 68 +++++++++ gcc/testsuite/gdc.test/compilable/noreturn1.d | 21 +++ .../protection/issue20796/package.d | 5 + .../protection/issue21726/format/package.d | 7 + .../protection/issue21726/package.d | 1 + .../protection/issue21726/typecons.d | 6 + gcc/testsuite/gdc.test/compilable/test16002.d | 3 + gcc/testsuite/gdc.test/compilable/test17991.d | 3 + gcc/testsuite/gdc.test/compilable/test19292.d | 15 ++ .../gdc.test/compilable/test20151a.d | 3 + gcc/testsuite/gdc.test/compilable/test20280.d | 8 + gcc/testsuite/gdc.test/compilable/test20530.d | 46 ++++++ gcc/testsuite/gdc.test/compilable/test20537.d | 10 ++ gcc/testsuite/gdc.test/compilable/test20692.d | 18 +++ .../gdc.test/compilable/test21501a.d | 19 +++ gcc/testsuite/gdc.test/compilable/test9029.d | 39 +++++ .../gdc.test/fail_compilation/bug15613.d | 18 +++ .../gdc.test/fail_compilation/bug16165.d | 18 +++ .../gdc.test/fail_compilation/bug9631.d | 100 +++++++++++++ .../gdc.test/fail_compilation/chkformat.d | 139 ++++++++++++++++++ .../gdc.test/fail_compilation/cppmangle.d | 2 +- .../gdc.test/fail_compilation/diag11819b.d | 2 +- .../gdc.test/fail_compilation/diag13082.d | 6 +- .../gdc.test/fail_compilation/diag16271.d | 12 ++ .../gdc.test/fail_compilation/diag8101.d | 47 +++--- .../gdc.test/fail_compilation/diag8101b.d | 17 ++- .../gdc.test/fail_compilation/diag9420.d | 3 +- .../gdc.test/fail_compilation/fail11038.d | 17 +++ .../gdc.test/fail_compilation/fail11445.d | 2 +- .../gdc.test/fail_compilation/fail15361.d | 8 + .../gdc.test/fail_compilation/fail15896.d | 18 +++ .../gdc.test/fail_compilation/fail17630.d | 15 ++ .../gdc.test/fail_compilation/fail18219.d | 20 +++ .../gdc.test/fail_compilation/fail19107.d | 21 +++ .../gdc.test/fail_compilation/fail263.d | 3 +- .../gdc.test/fail_compilation/fail3.d | 3 +- .../gdc.test/fail_compilation/fail322.d | 7 +- .../gdc.test/fail_compilation/fail332.d | 45 +++++- .../gdc.test/fail_compilation/fail347.d | 2 +- .../gdc.test/fail_compilation/fail53.d | 3 +- .../gdc.test/fail_compilation/fail55.d | 3 +- .../gdc.test/fail_compilation/fail79.d | 2 +- .../gdc.test/fail_compilation/fail99.d | 3 +- .../gdc.test/fail_compilation/fix21585.d | 19 +++ .../gdc.test/fail_compilation/format.d | 44 ++++++ .../gdc.test/fail_compilation/ice10598.d | 10 ++ .../gdc.test/fail_compilation/ice10922.d | 3 +- .../gdc.test/fail_compilation/ice12497.d | 18 --- .../gdc.test/fail_compilation/ice12501.d | 8 +- .../gdc.test/fail_compilation/ice14907.d | 22 +++ .../gdc.test/fail_compilation/ice14923.d | 5 +- .../gdc.test/fail_compilation/ice8255.d | 5 +- .../gdc.test/fail_compilation/ice9540.d | 5 +- .../fail_compilation/imports/a17630.d | 3 + .../fail_compilation/imports/a18219.d | 6 + .../fail_compilation/imports/b17630.d | 3 + .../fail_compilation/imports/b18219.d | 15 ++ .../imports/ice10598a.d | 0 .../imports/ice10598b.d | 0 .../fail_compilation/imports/imp15896.d | 4 + .../fail_compilation/imports/test21651b.d | 3 + .../gdc.test/fail_compilation/issue16020.d | 13 ++ .../gdc.test/fail_compilation/mixintype2.d | 16 ++ .../gdc.test/fail_compilation/test16002.d | 15 -- .../gdc.test/fail_compilation/test21651.d | 11 ++ .../gdc.test/fail_compilation/warn12809.d | 41 ++++++ gcc/testsuite/gdc.test/runnable/funclit.d | 61 ++++++++ gcc/testsuite/gdc.test/runnable/mangle.d | 6 + gcc/testsuite/gdc.test/runnable/noreturn1.d | 74 ++++++++++ gcc/testsuite/gdc.test/runnable_cxx/cppa.d | 29 +++- .../runnable_cxx/extra-files/cppb.cpp | 4 + .../runnable_cxx/extra-files/test21515.cpp | 82 +++++++++++ .../gdc.test/runnable_cxx/test21515.d | 104 +++++++++++++ 93 files changed, 1572 insertions(+), 102 deletions(-) create mode 100644 gcc/testsuite/gdc.test/compilable/bug20796.d create mode 100644 gcc/testsuite/gdc.test/compilable/extra-files/test20280a.d create mode 100644 gcc/testsuite/gdc.test/compilable/fix21585.d create mode 100644 gcc/testsuite/gdc.test/compilable/fix21647.d delete mode 100644 gcc/testsuite/gdc.test/compilable/ice10598.d create mode 100644 gcc/testsuite/gdc.test/compilable/imports/issue21614a.d create mode 100644 gcc/testsuite/gdc.test/compilable/imports/pkg20537/package.d create mode 100644 gcc/testsuite/gdc.test/compilable/imports/test17991a/a.d create mode 100644 gcc/testsuite/gdc.test/compilable/imports/test17991a/package.d create mode 100644 gcc/testsuite/gdc.test/compilable/imports/test20151a/b/c/c.d create mode 100644 gcc/testsuite/gdc.test/compilable/imports/test20530a.d create mode 100644 gcc/testsuite/gdc.test/compilable/imports/test21501b.d create mode 100644 gcc/testsuite/gdc.test/compilable/imports/test21501c.d create mode 100644 gcc/testsuite/gdc.test/compilable/issue16020.d create mode 100644 gcc/testsuite/gdc.test/compilable/issue21614.d create mode 100644 gcc/testsuite/gdc.test/compilable/issue21726.d create mode 100644 gcc/testsuite/gdc.test/compilable/mixintype.d create mode 100644 gcc/testsuite/gdc.test/compilable/mixintype2.d create mode 100644 gcc/testsuite/gdc.test/compilable/noreturn1.d create mode 100644 gcc/testsuite/gdc.test/compilable/protection/issue20796/package.d create mode 100644 gcc/testsuite/gdc.test/compilable/protection/issue21726/format/package.d create mode 100644 gcc/testsuite/gdc.test/compilable/protection/issue21726/package.d create mode 100644 gcc/testsuite/gdc.test/compilable/protection/issue21726/typecons.d create mode 100644 gcc/testsuite/gdc.test/compilable/test17991.d create mode 100644 gcc/testsuite/gdc.test/compilable/test19292.d create mode 100644 gcc/testsuite/gdc.test/compilable/test20151a.d create mode 100644 gcc/testsuite/gdc.test/compilable/test20280.d create mode 100644 gcc/testsuite/gdc.test/compilable/test20530.d create mode 100644 gcc/testsuite/gdc.test/compilable/test20537.d create mode 100644 gcc/testsuite/gdc.test/compilable/test20692.d create mode 100644 gcc/testsuite/gdc.test/compilable/test21501a.d create mode 100644 gcc/testsuite/gdc.test/compilable/test9029.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/bug15613.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/bug16165.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/bug9631.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/chkformat.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/diag16271.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/fail11038.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/fail15361.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/fail15896.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/fail17630.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/fail18219.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/fail19107.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/fix21585.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/format.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/ice10598.d delete mode 100644 gcc/testsuite/gdc.test/fail_compilation/ice12497.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/ice14907.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/imports/a17630.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/imports/a18219.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/imports/b17630.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/imports/b18219.d rename gcc/testsuite/gdc.test/{compilable => fail_compilation}/imports/ice10598a.d (100%) rename gcc/testsuite/gdc.test/{compilable => fail_compilation}/imports/ice10598b.d (100%) create mode 100644 gcc/testsuite/gdc.test/fail_compilation/imports/imp15896.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/imports/test21651b.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/issue16020.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/mixintype2.d delete mode 100644 gcc/testsuite/gdc.test/fail_compilation/test16002.d create mode 100644 gcc/testsuite/gdc.test/fail_compilation/test21651.d create mode 100644 gcc/testsuite/gdc.test/runnable/noreturn1.d create mode 100644 gcc/testsuite/gdc.test/runnable_cxx/extra-files/test21515.cpp create mode 100644 gcc/testsuite/gdc.test/runnable_cxx/test21515.d diff --git a/gcc/testsuite/gdc.test/compilable/bug20796.d b/gcc/testsuite/gdc.test/compilable/bug20796.d new file mode 100644 index 00000000000..00d00c840c4 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/bug20796.d @@ -0,0 +1,2 @@ +// EXTRA_SOURCES: protection/issue20796/package.d +// https://issues.dlang.org/show_bug.cgi?id=20796 diff --git a/gcc/testsuite/gdc.test/compilable/cppmangle.d b/gcc/testsuite/gdc.test/compilable/cppmangle.d index 7fcd41ab214..954a9bee72e 100644 --- a/gcc/testsuite/gdc.test/compilable/cppmangle.d +++ b/gcc/testsuite/gdc.test/compilable/cppmangle.d @@ -372,3 +372,21 @@ version (Posix) static assert(T.boo.mangleof == "_ZN1T3booE"); } +/*****************************************/ + +alias noreturn = typeof(*null); + +extern (C++) +{ + alias fpcpp = noreturn function(); + int funccpp(fpcpp); + + version (Posix) + static assert(funccpp.mangleof == "_Z7funccppPFvvE"); + + version (Win32) + static assert(funccpp.mangleof == "?funccpp@@YAHP6AXXZ@Z"); + + version (Win64) + static assert(funccpp.mangleof == "?funccpp@@YAHP6AXXZ@Z"); +} diff --git a/gcc/testsuite/gdc.test/compilable/ddocunittest.d b/gcc/testsuite/gdc.test/compilable/ddocunittest.d index 940ef1caf34..8c691b6ffd9 100644 --- a/gcc/testsuite/gdc.test/compilable/ddocunittest.d +++ b/gcc/testsuite/gdc.test/compilable/ddocunittest.d @@ -357,6 +357,7 @@ auto redBlackTree(bool allowDuplicates, E)(E[] elems...) } /// ditto auto redBlackTree(alias less, E)(E[] elems...) +if (__traits(compiles, (E a, E b) => mixin(less))) { return 3; } diff --git a/gcc/testsuite/gdc.test/compilable/extra-files/serenity7190/core/Controller.d b/gcc/testsuite/gdc.test/compilable/extra-files/serenity7190/core/Controller.d index 9ade3170ee2..62de518aa99 100644 --- a/gcc/testsuite/gdc.test/compilable/extra-files/serenity7190/core/Controller.d +++ b/gcc/testsuite/gdc.test/compilable/extra-files/serenity7190/core/Controller.d @@ -3,6 +3,12 @@ class Controller { enum _s_pkg = __traits(parent, __traits(parent, __traits(parent, T))).stringof["package ".length .. $]; enum _s_model = T.stringof[0 .. $-`Controller`.length] ~ `Model`; + + import serenity7190.core.Model; + // expands to "import example7190.models.HomeModel;" + mixin(q{import } ~ _s_pkg ~ q{.models.} ~ _s_model ~ q{;}); + + // "enum _ = is(example7190.models.HomeModel.HomeModel : serenity7190.core.Model.Model);" mixin(q{enum _ = is(} ~ _s_pkg ~ q{.models.} ~ _s_model ~ q{.} ~ _s_model ~ q{ : serenity7190.core.Model.Model);}); } -} \ No newline at end of file +} diff --git a/gcc/testsuite/gdc.test/compilable/extra-files/test20280a.d b/gcc/testsuite/gdc.test/compilable/extra-files/test20280a.d new file mode 100644 index 00000000000..edb409540c7 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/extra-files/test20280a.d @@ -0,0 +1,12 @@ +module test20280a; + +struct Alpha(uint _) +{ + import test20280a; +} + +struct Foxtrot(uint _) +{ + alias Attributes = Alpha!10; + enum A = 10; +} diff --git a/gcc/testsuite/gdc.test/compilable/fix21585.d b/gcc/testsuite/gdc.test/compilable/fix21585.d new file mode 100644 index 00000000000..a83fb899708 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/fix21585.d @@ -0,0 +1,24 @@ +/* TEST_OUTPUT: +--- +i int +d double +Pi int* +--- +*/ + +pragma(msg, 1.mangleof, " ", __traits(toType, 1.mangleof)); +pragma(msg, (1.0).mangleof, " ", __traits(toType, (1.0).mangleof)); +pragma(msg, (int*).mangleof, " ", __traits(toType, (int*).mangleof)); + +template Type(T) { alias Type = T; } + +Type!(__traits(toType, 1.mangleof)) j = 3; + +alias T = Type!(__traits(toType, 1.mangleof)); +static assert(is(T == int)); + +__traits(toType, "i") x = 7; + +static assert(is(Type!(__traits(toType, 1.mangleof)) == int)); +static assert(is(Type!(__traits(toType, (1.0).mangleof)) == double)); +static assert(is(Type!(__traits(toType, (int*).mangleof)) == int*)); diff --git a/gcc/testsuite/gdc.test/compilable/fix21647.d b/gcc/testsuite/gdc.test/compilable/fix21647.d new file mode 100644 index 00000000000..c129fa013a1 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/fix21647.d @@ -0,0 +1,30 @@ +/* +REQUIRED_ARGS: +TEST_OUTPUT: +--- +cast(void)0 +cast(void)0 +void +cast(void)0 +cast(void)0 +cast(void)0 +void +--- +*/ + + +// https://issues.dlang.org/show_bug.cgi?id=21647 + +void foo() { return cast(void)1; } + +void main(){} + +alias V = void; + +void test1() { pragma(msg, foo()); } +void test2() { pragma(msg, main()); } +void test3() { pragma(msg, V); } + +pragma(msg, foo()); +pragma(msg, main()); +pragma(msg, V); diff --git a/gcc/testsuite/gdc.test/compilable/ice10598.d b/gcc/testsuite/gdc.test/compilable/ice10598.d deleted file mode 100644 index 58a7c3be5f5..00000000000 --- a/gcc/testsuite/gdc.test/compilable/ice10598.d +++ /dev/null @@ -1,3 +0,0 @@ -// EXTRA_SOURCES: imports/ice10598a.d imports/ice10598b.d - -void main() {} diff --git a/gcc/testsuite/gdc.test/compilable/imports/issue21614a.d b/gcc/testsuite/gdc.test/compilable/imports/issue21614a.d new file mode 100644 index 00000000000..ee3c9eb2965 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/imports/issue21614a.d @@ -0,0 +1,22 @@ +module imports.issue21614a; + +struct FormatSpec(Char) +{ + import imports.issue21614a; +} + +template Tuple(Specs...) +{ + struct Tuple + { + alias spec = FormatSpec!char(); + this(Specs) + { + } + } +} + +auto findRoot(T)(T) +{ + return Tuple!(T)(); +} diff --git a/gcc/testsuite/gdc.test/compilable/imports/pkg20537/package.d b/gcc/testsuite/gdc.test/compilable/imports/pkg20537/package.d new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gcc/testsuite/gdc.test/compilable/imports/test17991a/a.d b/gcc/testsuite/gdc.test/compilable/imports/test17991a/a.d new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gcc/testsuite/gdc.test/compilable/imports/test17991a/package.d b/gcc/testsuite/gdc.test/compilable/imports/test17991a/package.d new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gcc/testsuite/gdc.test/compilable/imports/test20151a/b/c/c.d b/gcc/testsuite/gdc.test/compilable/imports/test20151a/b/c/c.d new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gcc/testsuite/gdc.test/compilable/imports/test20530a.d b/gcc/testsuite/gdc.test/compilable/imports/test20530a.d new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gcc/testsuite/gdc.test/compilable/imports/test21501b.d b/gcc/testsuite/gdc.test/compilable/imports/test21501b.d new file mode 100644 index 00000000000..c1f8fab982f --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/imports/test21501b.d @@ -0,0 +1,7 @@ +module imports.test21501b; +import test21501a; + +struct B +{ + A data; +} diff --git a/gcc/testsuite/gdc.test/compilable/imports/test21501c.d b/gcc/testsuite/gdc.test/compilable/imports/test21501c.d new file mode 100644 index 00000000000..cc1f95f3fc9 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/imports/test21501c.d @@ -0,0 +1,4 @@ +module imports.test21501c; + +alias C = int; +const D = 1; diff --git a/gcc/testsuite/gdc.test/compilable/issue16020.d b/gcc/testsuite/gdc.test/compilable/issue16020.d new file mode 100644 index 00000000000..cfd078cdcd1 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/issue16020.d @@ -0,0 +1,39 @@ +module issue16020; + +alias F1 = const(int)(); const(int) f1(){return 42;} +static assert (is(F1 == typeof(f1))); + +alias F2 = float(float); float f2(float p){return p;} +static assert (is(F2 == typeof(f2))); + +alias F3 = void(); void f3(){} +static assert (is(F3 == typeof(f3))); + +alias void F41() @safe; +alias F42 = void() @safe; +alias F43 = @safe void(); +static assert (is(F41 == F42)); +static assert (is(F43 == F42)); + +alias void F51() @system; +alias F52 = void() @safe; +static assert (!is(F51 == F52)); + +alias F61 = int() const shared; +alias int F62() const shared ; +alias F63 = const shared int(); +static assert (is(F61 == F62)); +static assert (is(F63 == F62)); + +alias F71 = int() immutable inout; +alias int F72() immutable inout; +alias F73 = immutable inout int(); +static assert (is(F71 == F72)); +static assert (is(F73 == F72)); + +alias FunTemplate(T) = void(T t); +alias Specialized = FunTemplate!int; +alias Compared = void(int); +static assert(is(Specialized == Compared)); + +void main() {} diff --git a/gcc/testsuite/gdc.test/compilable/issue21614.d b/gcc/testsuite/gdc.test/compilable/issue21614.d new file mode 100644 index 00000000000..1843fe6ec36 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/issue21614.d @@ -0,0 +1,10 @@ +// EXTRA_FILES: imports/issue21614a.d +// REQUIRED_ARGS: -i + +// https://issues.dlang.org/show_bug.cgi?id=21614 + +void logmdigammaInverse(real y) +{ + import imports.issue21614a; + findRoot(y); +} diff --git a/gcc/testsuite/gdc.test/compilable/issue21726.d b/gcc/testsuite/gdc.test/compilable/issue21726.d new file mode 100644 index 00000000000..c8a86752a56 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/issue21726.d @@ -0,0 +1,2 @@ +// EXTRA_SOURCES: protection/issue21726/typecons.d +// https://issues.dlang.org/show_bug.cgi?id=21726 diff --git a/gcc/testsuite/gdc.test/compilable/mixintype.d b/gcc/testsuite/gdc.test/compilable/mixintype.d new file mode 100644 index 00000000000..abbf85a9528 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/mixintype.d @@ -0,0 +1,55 @@ + +alias Int = mixin("int"); +alias Lint = mixin("Int"); + +int test1(mixin("int")* p) +{ + mixin("int")[] a; + mixin("int[]") b; + mixin("int[] c;"); + mixin("*p = c[0];"); + *p = mixin("c[0]"); + return *p + a[0] + b[0] + c[0]; +} + +/******************************************/ + +void test2() +{ + auto a = __traits(allMembers, mixin(__MODULE__)); +} + +/*****************************************/ + +void test3() +{ + char val; + int mod; + enum b = __traits(compiles, mixin("*cast(int*)&val + mod")); + static assert(b == true); +} + +/********************************************/ + + +struct S +{ + int fielda; + int fieldb; +} + +template Foo4(alias T) +{ + enum Foo4 = true; +} + +void test4() +{ + S sa; + auto a = Foo4!( __traits(getMember,sa,"fielda") ); + + S sb; + enum getStuff = q{ __traits(getMember,sb,"fieldb") }; + auto b = Foo4!(mixin(getStuff)); +} + diff --git a/gcc/testsuite/gdc.test/compilable/mixintype2.d b/gcc/testsuite/gdc.test/compilable/mixintype2.d new file mode 100644 index 00000000000..43803df12cf --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/mixintype2.d @@ -0,0 +1,68 @@ + +alias fun = mixin("(){}"); + +void test1() +{ + int x = 1; + static immutable c = 2; + + fun(); + foo!(mixin("int"))(); + foo!(mixin("long*"))(); + foo!(mixin("ST!(int, S.T)"))(); + foo!(mixin(ST!(int, S.T)))(); + + int[mixin("string")] a1; + int[mixin("5")] a2; + int[mixin("c")] a3; + int[] v1 = new int[mixin("3")]; + auto v2 = new int[mixin("x")]; + + mixin(q{__traits(getMember, S, "T")}) ftv; + + alias T = int*; + static assert(__traits(compiles, mixin("int"))); + static assert(__traits(compiles, mixin(q{int[mixin("string")]}))); + static assert(__traits(compiles, mixin(q{int[mixin("2")]}))); + static assert(__traits(compiles, mixin(T))); + static assert(__traits(compiles, mixin("int*"))); + static assert(__traits(compiles, mixin(typeof(0)))); +} + +struct S { alias T = float*; } + +struct ST(X,Y) {} + +void foo(alias t)() {} + +/**************************************************/ +// https://issues.dlang.org/show_bug.cgi?id=21074 + +alias Byte = ubyte; +alias Byte2(A) = ubyte; +alias T0 = mixin(q{const(Byte)})*; +alias T1 = mixin(q{const(Byte[1])})*; +alias T2 = mixin(q{const(Byte2!int)})*; +alias T3 = mixin(q{const(mixin(Byte2!int))})*; +alias T4 = mixin(q{const(mixin("__traits(getMember, S, \"T\")"))})*; +alias T5 = const(mixin(q{Byte}))*; +alias T6 = const(mixin(q{immutable(Byte)}))*; +alias T7 = const(mixin(q{shared(Byte)}))*; +alias T8 = const(mixin(q{Byte*})); + +// the following tests now work +static assert(is(T0 == const(ubyte)*)); +static assert(is(T1 == const(ubyte[1])*)); +static assert(is(T2 == const(ubyte)*)); +static assert(is(T3 == const(ubyte)*)); +static assert(is(T4 == const(float*)*)); +static assert(is(T5 == const(ubyte)*)); +static assert(is(T6 == immutable(ubyte)*)); +static assert(is(T7 == const(shared(ubyte))*)); +static assert(is(T8 == const(ubyte*))); + +// this doesn't work but I'll file a new issue +/* +alias T8 = mixin(q{immutable(__traits(getMember, S, "T"))})*; +static assert(is(T8 == immutable(float*)*)); +*/ diff --git a/gcc/testsuite/gdc.test/compilable/noreturn1.d b/gcc/testsuite/gdc.test/compilable/noreturn1.d new file mode 100644 index 00000000000..e21adc476c9 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/noreturn1.d @@ -0,0 +1,21 @@ +/* +TEST_OUTPUT: +--- +noreturn +--- +*/ + +alias noreturn = typeof(*null); +pragma(msg, noreturn); + +noreturn exits(int* p) { *p = 3; } + +noreturn exit(); + +int test1(int i) +{ + if (exit()) + return i + 1; + return i - 1; +} + diff --git a/gcc/testsuite/gdc.test/compilable/protection/issue20796/package.d b/gcc/testsuite/gdc.test/compilable/protection/issue20796/package.d new file mode 100644 index 00000000000..d0b5f5a7860 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/protection/issue20796/package.d @@ -0,0 +1,5 @@ +module issue20796; + +package(issue20796) void foo() +{ +} diff --git a/gcc/testsuite/gdc.test/compilable/protection/issue21726/format/package.d b/gcc/testsuite/gdc.test/compilable/protection/issue21726/format/package.d new file mode 100644 index 00000000000..e0f6ba7d263 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/protection/issue21726/format/package.d @@ -0,0 +1,7 @@ +module protection.issue21726.format; + +package(protection.issue21726.format): + +package(protection.issue21726) int issuePkgSym; +package(protection) int protectionPkgSym(); +int formatPkgSym; diff --git a/gcc/testsuite/gdc.test/compilable/protection/issue21726/package.d b/gcc/testsuite/gdc.test/compilable/protection/issue21726/package.d new file mode 100644 index 00000000000..f8986c949bd --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/protection/issue21726/package.d @@ -0,0 +1 @@ +module protection.issue21726; diff --git a/gcc/testsuite/gdc.test/compilable/protection/issue21726/typecons.d b/gcc/testsuite/gdc.test/compilable/protection/issue21726/typecons.d new file mode 100644 index 00000000000..faed95e5f5e --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/protection/issue21726/typecons.d @@ -0,0 +1,6 @@ +module protection.issue21726.typecons; + +import protection.issue21726.format : issuePkgSym; +import protection.issue21726.format : protectionPkgSym; +static assert(!__traits(compiles, + { import protection.issue21726.format : formatPkgSym; })); diff --git a/gcc/testsuite/gdc.test/compilable/test16002.d b/gcc/testsuite/gdc.test/compilable/test16002.d index f3303c0e310..f7b4c2e96a8 100644 --- a/gcc/testsuite/gdc.test/compilable/test16002.d +++ b/gcc/testsuite/gdc.test/compilable/test16002.d @@ -22,3 +22,6 @@ static assert(is(b == module)); // This is supposed to work even though we haven't directly imported imports.pkgmodule. static assert(is(imports.pkgmodule == module)); static assert(!is(MyStruct == module)); + +static assert(!is(imports.nonexistent == package)); +static assert(!is(imports.nonexistent == module)); diff --git a/gcc/testsuite/gdc.test/compilable/test17991.d b/gcc/testsuite/gdc.test/compilable/test17991.d new file mode 100644 index 00000000000..8bc9fa94f5f --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/test17991.d @@ -0,0 +1,3 @@ +// https://issues.dlang.org/show_bug.cgi?id=17991 +// EXTRA_FILES: imports/test17991a/package.d imports/test17991a/a.d +import imports.test17991a, imports.test17991a.a; diff --git a/gcc/testsuite/gdc.test/compilable/test19292.d b/gcc/testsuite/gdc.test/compilable/test19292.d new file mode 100644 index 00000000000..8122851c6ca --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/test19292.d @@ -0,0 +1,15 @@ +// https://issues.dlang.org/show_bug.cgi?id=19292 + +mixin("enum a = ", 87, ";"); +static assert(a == 87); + +int test() +{ + mixin("enum x = ", 7, ";"); + return mixin("1", x, 2U); +} + +void testit() +{ + static assert(test() == 172); +} diff --git a/gcc/testsuite/gdc.test/compilable/test20151a.d b/gcc/testsuite/gdc.test/compilable/test20151a.d new file mode 100644 index 00000000000..d9ae28fabe1 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/test20151a.d @@ -0,0 +1,3 @@ +// EXTRA_FILES: imports/test20151a/b/c/c.d +module imports.test20151a; +import imports.test20151a.b.c.c; diff --git a/gcc/testsuite/gdc.test/compilable/test20280.d b/gcc/testsuite/gdc.test/compilable/test20280.d new file mode 100644 index 00000000000..76a10823e49 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/test20280.d @@ -0,0 +1,8 @@ +// PERMUTE_ARGS: +// REQUIRED_ARGS: -Icompilable/extra-files +// EXTRA_FILES: extra-files/test20280a.d +module test20280; + +import test20280a; + +alias Charlie = Foxtrot!(0); diff --git a/gcc/testsuite/gdc.test/compilable/test20530.d b/gcc/testsuite/gdc.test/compilable/test20530.d new file mode 100644 index 00000000000..be80dbb34d1 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/test20530.d @@ -0,0 +1,46 @@ +// EXTRA_FILES: imports/test20530a.d imports/plainpackage/plainmodule.d imports/pkgmodule/package.d imports/pkgmodule/plainmodule.d +module mod; +static assert(is(mod == module)); +static assert(is(mixin("mod") == module)); +static assert(!is(mod == package)); +static assert(!is(mixin("mod") == package)); + +import imports.test20530a; +static assert(is(imports == package)); +static assert(is(mixin("imports") == package)); +static assert(!is(imports == module)); +static assert(!is(mixin("imports") == module)); + +import imports.plainpackage.plainmodule; +import imports.pkgmodule.plainmodule; + +struct MyStruct; + +alias a = mixin("imports.plainpackage"); +alias b = mixin("imports.pkgmodule.plainmodule"); + +static assert(is(mixin("imports.plainpackage") == package)); +static assert(is(mixin("a") == package)); +static assert(!is(mixin("imports.plainpackage.plainmodule") == package)); +static assert(!is(mixin("b") == package)); +static assert(is(mixin("imports.pkgmodule") == package)); +mixin("static assert(is(imports.pkgmodule == package));"); + +static assert(!is(mixin("MyStruct") == package)); + +static assert(!is(mixin("imports.plainpackage") == module)); +static assert(!is(mixin("a") == module)); +static assert(is(mixin("imports.plainpackage.plainmodule") == module)); +static assert(is(mixin("b") == module)); +static assert(is(mixin("imports.pkgmodule") == module)); +mixin("static assert(is(imports.pkgmodule == module));"); + +static assert(!is(mixin("MyStruct") == module)); + +static assert(!is(mixin("imports.nonexistent") == package)); +static assert(!is(mixin("imports.nonexistent") == module)); + +// this won't work due to mixin argument .stringof expansion, +// it will expand to mixin(package imports.pkgmodule). Issue 20519. +//static assert(is(mixin(imports.pkgmodule) == package)); +//static assert(is(mixin(imports.pkgmodule) == module)); diff --git a/gcc/testsuite/gdc.test/compilable/test20537.d b/gcc/testsuite/gdc.test/compilable/test20537.d new file mode 100644 index 00000000000..f2d05d26fee --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/test20537.d @@ -0,0 +1,10 @@ +// REQUIRED_ARGS: -Icompilable/imports +// EXTRA_FILES: imports/pkg20537/package.d +import pkg20537; + +static assert(is(pkg20537 == module)); +static assert(__traits(isModule, pkg20537)); +static assert(is(mixin("pkg20537") == module)); +static assert(is(pkg20537 == package)); +static assert(__traits(isPackage, pkg20537)); +static assert(is(mixin("pkg20537") == package)); diff --git a/gcc/testsuite/gdc.test/compilable/test20692.d b/gcc/testsuite/gdc.test/compilable/test20692.d new file mode 100644 index 00000000000..2d67211c74d --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/test20692.d @@ -0,0 +1,18 @@ +// https://issues.dlang.org/show_bug.cgi?id=20692 + +struct S() { + void fun() { + gun(""); + } + void gun(T)(T) { + alias buggy = bug; + } +} + +alias X = S!(); + +void main() { + X().gun(0); +} + +alias bug = __traits(getMember, X, "fun"); diff --git a/gcc/testsuite/gdc.test/compilable/test21501a.d b/gcc/testsuite/gdc.test/compilable/test21501a.d new file mode 100644 index 00000000000..096fd51b653 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/test21501a.d @@ -0,0 +1,19 @@ +// EXTRA_SOURCES: imports/test21501b.d imports/test21501c.d +// https://issues.dlang.org/show_bug.cgi?id=21501 + +module test21501a; +import imports.test21501b; +import imports.test21501c; + +alias Identity(alias T) = T; + +struct A +{ + alias a = imports.test21501c.C; + const int b = imports.test21501c.D; // fixed + alias c = Identity!(mixin(q{imports.test21501c.C})); // fixed + const int d = Identity!(mixin(q{imports.test21501c.D})); // fixed + + static assert(is(a == c) && is(a == int)); + static assert(b == d && b == 1); +} diff --git a/gcc/testsuite/gdc.test/compilable/test9029.d b/gcc/testsuite/gdc.test/compilable/test9029.d new file mode 100644 index 00000000000..bbbd98a729c --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/test9029.d @@ -0,0 +1,39 @@ +// https://issues.dlang.org/show_bug.cgi?id=9029 +enum NameOf(alias S) = S.stringof; + +static assert(NameOf!int == "int"); + +enum BothMatch(alias S) = "alias"; +enum BothMatch(T) = "type"; + +void foo9029() { } + +struct Struct { } + +static assert(BothMatch!int == "type"); +static assert(BothMatch!(void function()) == "type"); +static assert(BothMatch!BothMatch == "alias"); +static assert(BothMatch!Struct == "type"); +static assert(BothMatch!foo9029 == "alias"); +static assert(BothMatch!5 == "alias"); + +// https://issues.dlang.org/show_bug.cgi?id=19884 +mixin template genCtEvaluate() +{ + void evaluate(alias op)() { } +} +struct S +{ + mixin genCtEvaluate!() mixinEval; + alias evaluate = mixinEval.evaluate; + void evaluate() { } +} +alias List(Ops...) = Ops; +void main() +{ + S g; + foreach (op; List!(0)) + { + g.evaluate!op(); + } +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/bug15613.d b/gcc/testsuite/gdc.test/fail_compilation/bug15613.d new file mode 100644 index 00000000000..e8072fdbaf8 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/bug15613.d @@ -0,0 +1,18 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/bug15613.d(16): Error: function `bug15613.f(int...)` is not callable using argument types `(typeof(null))` +fail_compilation/bug15613.d(16): cannot pass argument `null` of type `typeof(null)` to parameter `int...` +fail_compilation/bug15613.d(17): Error: function `bug15613.g(Object, ...)` is not callable using argument types `(int)` +fail_compilation/bug15613.d(17): cannot pass argument `8` of type `int` to parameter `Object` +--- +*/ + +void f(int...); +void g(Object, ...); + +void main() +{ + f(null); + g(8); +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/bug16165.d b/gcc/testsuite/gdc.test/fail_compilation/bug16165.d new file mode 100644 index 00000000000..fdfbf73f415 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/bug16165.d @@ -0,0 +1,18 @@ +void f(int x, Object y); + +void g() +{ + Object o; + f(o, o, 404); + f(5, 6, 404); +} + +/* +TEST_OUTPUT: +--- +fail_compilation/bug16165.d(6): Error: function `bug16165.f(int x, Object y)` is not callable using argument types `(Object, Object, int)` +fail_compilation/bug16165.d(6): cannot pass argument `o` of type `object.Object` to parameter `int x` +fail_compilation/bug16165.d(7): Error: function `bug16165.f(int x, Object y)` is not callable using argument types `(int, int, int)` +fail_compilation/bug16165.d(7): cannot pass argument `6` of type `int` to parameter `Object y` +--- + */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/bug9631.d b/gcc/testsuite/gdc.test/fail_compilation/bug9631.d new file mode 100644 index 00000000000..852eaae7479 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/bug9631.d @@ -0,0 +1,100 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/bug9631.d(20): Error: cannot implicitly convert expression `F()` of type `bug9631.T1!().F` to `bug9631.T2!().F` +--- +*/ + +template T1() +{ + struct F { } +} + +template T2() +{ + struct F { } +} + +void main() +{ + T2!().F x = T1!().F(); +} + +/* +TEST_OUTPUT: +--- +fail_compilation/bug9631.d(41): Error: incompatible types for ((x) == (y)): 'bug9631.S' and 'bug9631.tem! +).S' +--- +*/ + +struct S { char c; } + +template tem() +{ + struct S { int i; } +} + +void equal() +{ + S x; + auto y = tem!().S(); + bool b = x == y; +} + +/* +TEST_OUTPUT: +--- +fail_compilation/bug9631.d(79): Error: function `bug9631.arg.f(int i, S s)` is not callable using argumen + types `(int, S)` +fail_compilation/bug9631.d(79): cannot pass argument `y` of type `bug9631.tem!().S` to parameter ` +ug9631.S s` +fail_compilation/bug9631.d(80): Error: function literal `__lambda2(S s)` is not callable using argument t +pes `(S)` +fail_compilation/bug9631.d(80): cannot pass argument `x` of type `bug9631.S` to parameter `bug9631 +tem!().S s` +fail_compilation/bug9631.d(86): Error: constructor `bug9631.arg.A.this(S _param_0)` is not callable using +argument types `(S)` +fail_compilation/bug9631.d(86): cannot pass argument `S(0)` of type `bug9631.tem!().S` to paramete + `bug9631.S _param_0` +--- +*/ +void arg() +{ + S x; + tem!().S y; + + void f(int i, S s); + f(4, y); + (tem!().S s){}(x); + + struct A + { + this(S){} + } + A(tem!().S()); +} + +/* +TEST_OUTPUT: +--- +fail_compilation/bug9631.d(106): Error: function `bug9631.targ.ft!().ft(S _param_0)` is not callable using argument types `(S)` +fail_compilation/bug9631.d(106): cannot pass argument `x` of type `bug9631.S` to parameter `bug9631.tem!().S _param_0` +fail_compilation/bug9631.d(107): Error: template `bug9631.targ.ft` cannot deduce function from argument types `!()(S)`, candidates are: +fail_compilation/bug9631.d(105): `bug9631.targ.ft()(tem!().S)` +fail_compilation/bug9631.d(109): Error: template `bug9631.targ.ft2` cannot deduce function from argument types `!()(S, int)`, candidates are: +fail_compilation/bug9631.d(108): `bug9631.targ.ft2(T)(S, T)` +--- +*/ +void targ() +{ + S x; + tem!().S y; + + void ft()(tem!().S){} + ft!()(x); + ft(x); + void ft2(T)(S, T){} + ft2(y, 1); +} + diff --git a/gcc/testsuite/gdc.test/fail_compilation/chkformat.d b/gcc/testsuite/gdc.test/fail_compilation/chkformat.d new file mode 100644 index 00000000000..7451b3f506b --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/chkformat.d @@ -0,0 +1,139 @@ +/* +REQUIRED_ARGS: -de +TEST_OUTPUT: +--- +fail_compilation/chkformat.d(101): Deprecation: width argument `0L` for format specification `"%*.*d"` must be `int`, not `long` +fail_compilation/chkformat.d(101): Deprecation: precision argument `1L` for format specification `"%*.*d"` must be `int`, not `long` +fail_compilation/chkformat.d(101): Deprecation: argument `2L` for format specification `"%*.*d"` must be `int`, not `long` +fail_compilation/chkformat.d(104): Deprecation: argument `4` for format specification `"%lld"` must be `long`, not `int` +fail_compilation/chkformat.d(105): Deprecation: argument `5` for format specification `"%jd"` must be `core.stdc.stdint.intmax_t`, not `int` +fail_compilation/chkformat.d(106): Deprecation: argument `6.0` for format specification `"%zd"` must be `size_t`, not `double` +fail_compilation/chkformat.d(107): Deprecation: argument `7.0` for format specification `"%td"` must be `ptrdiff_t`, not `double` +fail_compilation/chkformat.d(108): Deprecation: argument `8.0L` for format specification `"%g"` must be `double`, not `real` +fail_compilation/chkformat.d(109): Deprecation: argument `9.0` for format specification `"%Lg"` must be `real`, not `double` +fail_compilation/chkformat.d(110): Deprecation: argument `10` for format specification `"%p"` must be `void*`, not `int` +fail_compilation/chkformat.d(111): Deprecation: argument `& u` for format specification `"%n"` must be `int*`, not `uint*` +fail_compilation/chkformat.d(113): Deprecation: argument `& u` for format specification `"%lln"` must be `long*`, not `int*` +fail_compilation/chkformat.d(114): Deprecation: argument `& u` for format specification `"%hn"` must be `short*`, not `int*` +fail_compilation/chkformat.d(115): Deprecation: argument `& u` for format specification `"%hhn"` must be `byte*`, not `int*` +fail_compilation/chkformat.d(116): Deprecation: argument `16L` for format specification `"%c"` must be `char`, not `long` +fail_compilation/chkformat.d(117): Deprecation: argument `17L` for format specification `"%c"` must be `char`, not `long` +fail_compilation/chkformat.d(118): Deprecation: argument `& u` for format specification `"%s"` must be `char*`, not `int*` +fail_compilation/chkformat.d(119): Deprecation: argument `& u` for format specification `"%ls"` must be `wchar_t*`, not `int*` +fail_compilation/chkformat.d(201): Deprecation: argument `0L` for format specification `"%d"` must be `int*`, not `long` +fail_compilation/chkformat.d(202): Deprecation: more format specifiers than 1 arguments +fail_compilation/chkformat.d(203): Deprecation: argument `0L` for format specification `"%d"` must be `int*`, not `long` +fail_compilation/chkformat.d(204): Deprecation: argument `0L` for format specification `"%3u"` must be `uint*`, not `long` +fail_compilation/chkformat.d(205): Deprecation: argument `u` for format specification `"%200u"` must be `uint*`, not `uint` +fail_compilation/chkformat.d(206): Deprecation: argument `3.0` for format specification `"%hhd"` must be `byte*`, not `double` +fail_compilation/chkformat.d(207): Deprecation: argument `4` for format specification `"%hd"` must be `short*`, not `int` +fail_compilation/chkformat.d(209): Deprecation: argument `4` for format specification `"%lld"` must be `long*`, not `int` +fail_compilation/chkformat.d(210): Deprecation: argument `5` for format specification `"%jd"` must be `core.stdc.stdint.intmax_t*`, not `int` +fail_compilation/chkformat.d(211): Deprecation: argument `6.0` for format specification `"%zd"` must be `size_t*`, not `double` +fail_compilation/chkformat.d(212): Deprecation: argument `7.0` for format specification `"%td"` must be `ptrdiff_t*`, not `double` +fail_compilation/chkformat.d(213): Deprecation: format specifier `"%Ld"` is invalid +fail_compilation/chkformat.d(214): Deprecation: argument `0` for format specification `"%u"` must be `uint*`, not `int` +fail_compilation/chkformat.d(215): Deprecation: argument `0` for format specification `"%hhu"` must be `ubyte*`, not `int` +fail_compilation/chkformat.d(216): Deprecation: argument `0` for format specification `"%hu"` must be `ushort*`, not `int` +fail_compilation/chkformat.d(218): Deprecation: argument `0` for format specification `"%llu"` must be `ulong*`, not `int` +fail_compilation/chkformat.d(219): Deprecation: argument `0` for format specification `"%ju"` must be `ulong*`, not `int` +fail_compilation/chkformat.d(220): Deprecation: argument `0` for format specification `"%zu"` must be `size_t*`, not `int` +fail_compilation/chkformat.d(221): Deprecation: argument `0` for format specification `"%tu"` must be `ptrdiff_t*`, not `int` +fail_compilation/chkformat.d(222): Deprecation: argument `8.0L` for format specification `"%g"` must be `float*`, not `real` +fail_compilation/chkformat.d(223): Deprecation: argument `8.0L` for format specification `"%lg"` must be `double*`, not `real` +fail_compilation/chkformat.d(224): Deprecation: argument `9.0` for format specification `"%Lg"` must be `real*`, not `double` +fail_compilation/chkformat.d(225): Deprecation: argument `& u` for format specification `"%s"` must be `char*`, not `int*` +fail_compilation/chkformat.d(226): Deprecation: argument `& u` for format specification `"%ls"` must be `wchar_t*`, not `int*` +fail_compilation/chkformat.d(227): Deprecation: argument `v` for format specification `"%p"` must be `void**`, not `void*` +fail_compilation/chkformat.d(228): Deprecation: argument `& u` for format specification `"%n"` must be `int*`, not `ushort*` +fail_compilation/chkformat.d(229): Deprecation: argument `& u` for format specification `"%hhn"` must be `byte*`, not `int*` +fail_compilation/chkformat.d(230): Deprecation: format specifier `"%[n"` is invalid +fail_compilation/chkformat.d(231): Deprecation: format specifier `"%]"` is invalid +fail_compilation/chkformat.d(232): Deprecation: argument `& u` for format specification `"%90s"` must be `char*`, not `int*` +fail_compilation/chkformat.d(233): Deprecation: argument `0L` for format specification `"%d"` must be `int*`, not `long` +fail_compilation/chkformat.d(234): Deprecation: argument `0L` for format specification `"%d"` must be `int*`, not `long` +--- +*/ + + +import core.stdc.stdio; + +#line 100 + +void test1() { printf("%*.*d\n", 0L, 1L, 2L); } +//void test2() { } +//void test3() { printf("%ld\n", 3.0); } +void test4() { printf("%lld\n", 4); } +void test5() { printf("%jd\n", 5); } +void test6() { printf("%zd\n", 6.0); } +void test7() { printf("%td\n", 7.0); } +void test8() { printf("%g\n", 8.0L); } +void test9() { printf("%Lg\n", 9.0); } +void test10() { printf("%p\n", 10); } +void test11() { uint u; printf("%n\n", &u); } +//void test12() { ushort u; printf("%ln\n", &u); } +void test13() { int u; printf("%lln\n", &u); } +void test14() { int u; printf("%hn\n", &u); } +void test15() { int u; printf("%hhn\n", &u); } +void test16() { printf("%c\n", 16L); } +void test17() { printf("%c\n", 17L); } +void test18() { int u; printf("%s\n", &u); } +void test19() { int u; printf("%ls\n", &u); } +//void test20() { int u; char[] s; sprintf(&s[0], "%d\n", &u); } +//void test21() { int u; fprintf(null, "%d\n", &u); } + +#line 200 + +void test31() { scanf("%d\n", 0L); } +void test32() { int i; scanf("%d %d\n", &i); } +void test33() { scanf("%d%*c\n", 0L); } +void test34() { scanf("%3u\n", 0L); } +void test35() { uint u; scanf("%200u%*s\n", u); } +void test36() { scanf("%hhd\n", 3.0); } +void test37() { scanf("%hd\n", 4); } +//void test38() { scanf("%ld\n", 3.0); } +void test39() { scanf("%lld\n", 4); } +void test40() { scanf("%jd\n", 5); } +void test41() { scanf("%zd\n", 6.0); } +void test42() { scanf("%td\n", 7.0); } +void test43() { scanf("%Ld\n", 0); } +void test44() { scanf("%u\n", 0); } +void test45() { scanf("%hhu\n", 0); } +void test46() { scanf("%hu\n", 0); } +//void test47() { scanf("%lu\n", 0); } +void test48() { scanf("%llu\n", 0); } +void test49() { scanf("%ju\n", 0); } +void test50() { scanf("%zu\n", 0); } +void test51() { scanf("%tu\n", 0); } +void test52() { scanf("%g\n", 8.0L); } +void test53() { scanf("%lg\n", 8.0L); } +void test54() { scanf("%Lg\n", 9.0); } +void test55() { int u; scanf("%s\n", &u); } +void test56() { int u; scanf("%ls\n", &u); } +void test57() { void* v; scanf("%p\n", v); } +void test58() { ushort u; scanf("%n\n", &u); } +void test59() { int u; scanf("%hhn\n", &u); } +void test60() { int u; scanf("%[n", &u); } +void test61() { int u; scanf("%]\n", &u); } +void test62() { int u; scanf("%90s\n", &u); } +void test63() { sscanf("1234", "%d\n", 0L); } +void test64() { fscanf(null, "%d\n", 0L); } + +/* TEST_OUTPUT: +--- +fail_compilation/chkformat.d(301): Deprecation: format specifier `"%K"` is invalid +fail_compilation/chkformat.d(302): Deprecation: format specifier `"%Q"` is invalid +--- +*/ + +import core.stdc.stdarg; + +#line 300 + +void test301() { va_list vargs; vprintf("%K", vargs); } +void test302() { va_list vargs; vscanf("%Q", vargs); } + +// TODO - C++ 11 only: +//void test() { vscanf(); } +//void test() { vfscanf(); } +//void test() { vsscanf(); } diff --git a/gcc/testsuite/gdc.test/fail_compilation/cppmangle.d b/gcc/testsuite/gdc.test/fail_compilation/cppmangle.d index b8b2f03f019..ca9ed9a71a7 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/cppmangle.d +++ b/gcc/testsuite/gdc.test/fail_compilation/cppmangle.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/cppmangle.d(10): Error: invalid zero length C++ namespace -fail_compilation/cppmangle.d(14): Error: expected valid identifer for C++ namespace but got `0num` +fail_compilation/cppmangle.d(14): Error: expected valid identifier for C++ namespace but got `0num` fail_compilation/cppmangle.d(18): Error: string expected following `,` for C++ namespace, not `)` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag11819b.d b/gcc/testsuite/gdc.test/fail_compilation/diag11819b.d index 2280691abf6..a5d6a14212e 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/diag11819b.d +++ b/gcc/testsuite/gdc.test/fail_compilation/diag11819b.d @@ -14,7 +14,7 @@ fail_compilation/diag11819b.d(37): Error: unrecognized trait `AllMembers`, did y fail_compilation/diag11819b.d(38): Error: unrecognized trait `DerivedMembers`, did you mean `derivedMembers`? fail_compilation/diag11819b.d(39): Error: unrecognized trait `IsSame`, did you mean `isSame`? fail_compilation/diag11819b.d(40): Error: unrecognized trait `Compiles`, did you mean `compiles`? -fail_compilation/diag11819b.d(41): Error: unrecognized trait `Parameters`, did you mean `parameters`? +fail_compilation/diag11819b.d(41): Error: unrecognized trait `Parameters` fail_compilation/diag11819b.d(42): Error: unrecognized trait `GetAliasThis`, did you mean `getAliasThis`? fail_compilation/diag11819b.d(43): Error: unrecognized trait `GetAttributes`, did you mean `getAttributes`? fail_compilation/diag11819b.d(44): Error: unrecognized trait `GetFunctionAttributes`, did you mean `getFunctionAttributes`? diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag13082.d b/gcc/testsuite/gdc.test/fail_compilation/diag13082.d index 13259cef004..7360a3df62f 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/diag13082.d +++ b/gcc/testsuite/gdc.test/fail_compilation/diag13082.d @@ -1,8 +1,10 @@ /* TEST_OUTPUT: --- -fail_compilation/diag13082.d(22): Error: constructor diag13082.C.this (int a) is not callable using argument types (string) -fail_compilation/diag13082.d(23): Error: constructor diag13082.S.this (int a) is not callable using argument types (string) +fail_compilation/diag13082.d(24): Error: constructor `diag13082.C.this(int a)` is not callable using argument types `(string)` +fail_compilation/diag13082.d(24): cannot pass argument `b` of type `string` to parameter `int a` +fail_compilation/diag13082.d(25): Error: constructor `diag13082.S.this(int a)` is not callable using argument types `(string)` +fail_compilation/diag13082.d(25): cannot pass argument `b` of type `string` to parameter `int a` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag16271.d b/gcc/testsuite/gdc.test/fail_compilation/diag16271.d new file mode 100644 index 00000000000..b85dc8d21bb --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/diag16271.d @@ -0,0 +1,12 @@ +/* +TEST_OUTPUT +--- +fail_compilation/diag16271.d(10): Error: found `x` when expecting function literal following `ref` +--- +*/ + +void main() +{ + auto fun = ref x; +} + diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag8101.d b/gcc/testsuite/gdc.test/fail_compilation/diag8101.d index 6fc38099048..3b2401ad8cf 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/diag8101.d +++ b/gcc/testsuite/gdc.test/fail_compilation/diag8101.d @@ -1,29 +1,30 @@ /* TEST_OUTPUT: --- -fail_compilation/diag8101.d(56): Error: function diag8101.f_0 (int) is not callable using argument types () -fail_compilation/diag8101.d(57): Error: none of the overloads of 'f_1' are callable using argument types (), candidates are: -fail_compilation/diag8101.d(32): diag8101.f_1(int) -fail_compilation/diag8101.d(33): diag8101.f_1(int, int) -fail_compilation/diag8101.d(58): Error: none of the overloads of 'f_2' are callable using argument types (), candidates are: -fail_compilation/diag8101.d(35): diag8101.f_2(int) -fail_compilation/diag8101.d(36): diag8101.f_2(int, int) -fail_compilation/diag8101.d(37): diag8101.f_2(int, int, int) -fail_compilation/diag8101.d(38): diag8101.f_2(int, int, int, int) -fail_compilation/diag8101.d(39): diag8101.f_2(int, int, int, int, int) -fail_compilation/diag8101.d(58): ... (1 more, -v to show) ... -fail_compilation/diag8101.d(60): Error: template diag8101.t_0 cannot deduce function from argument types !()(), candidates are: -fail_compilation/diag8101.d(42): diag8101.t_0(T1)() -fail_compilation/diag8101.d(61): Error: template diag8101.t_1 cannot deduce function from argument types !()(), candidates are: -fail_compilation/diag8101.d(44): diag8101.t_1(T1)() -fail_compilation/diag8101.d(45): diag8101.t_1(T1, T2)() -fail_compilation/diag8101.d(62): Error: template diag8101.t_2 cannot deduce function from argument types !()(), candidates are: -fail_compilation/diag8101.d(47): diag8101.t_2(T1)() -fail_compilation/diag8101.d(48): diag8101.t_2(T1, T2)() -fail_compilation/diag8101.d(49): diag8101.t_2(T1, T2, T3)() -fail_compilation/diag8101.d(50): diag8101.t_2(T1, T2, T3, T4)() -fail_compilation/diag8101.d(51): diag8101.t_2(T1, T2, T3, T4, T5)() -fail_compilation/diag8101.d(62): ... (1 more, -v to show) ... +fail_compilation/diag8101.d(57): Error: function `diag8101.f_0(int)` is not callable using argument types `()` +fail_compilation/diag8101.d(57): missing argument for parameter #1: `int` +fail_compilation/diag8101.d(58): Error: none of the overloads of `f_1` are callable using argument types `()`, candidates are: +fail_compilation/diag8101.d(33): `diag8101.f_1(int)` +fail_compilation/diag8101.d(34): `diag8101.f_1(int, int)` +fail_compilation/diag8101.d(59): Error: none of the overloads of `f_2` are callable using argument types `()`, candidates are: +fail_compilation/diag8101.d(36): `diag8101.f_2(int)` +fail_compilation/diag8101.d(37): `diag8101.f_2(int, int)` +fail_compilation/diag8101.d(38): `diag8101.f_2(int, int, int)` +fail_compilation/diag8101.d(39): `diag8101.f_2(int, int, int, int)` +fail_compilation/diag8101.d(40): `diag8101.f_2(int, int, int, int, int)` +fail_compilation/diag8101.d(59): ... (1 more, -v to show) ... +fail_compilation/diag8101.d(61): Error: template `diag8101.t_0` cannot deduce function from argument types `!()()`, candidates are: +fail_compilation/diag8101.d(43): `diag8101.t_0(T1)()` +fail_compilation/diag8101.d(62): Error: template `diag8101.t_1` cannot deduce function from argument types `!()()`, candidates are: +fail_compilation/diag8101.d(45): `diag8101.t_1(T1)()` +fail_compilation/diag8101.d(46): `diag8101.t_1(T1, T2)()` +fail_compilation/diag8101.d(63): Error: template `diag8101.t_2` cannot deduce function from argument types `!()()`, candidates are: +fail_compilation/diag8101.d(48): `diag8101.t_2(T1)()` +fail_compilation/diag8101.d(49): `diag8101.t_2(T1, T2)()` +fail_compilation/diag8101.d(50): `diag8101.t_2(T1, T2, T3)()` +fail_compilation/diag8101.d(51): `diag8101.t_2(T1, T2, T3, T4)()` +fail_compilation/diag8101.d(52): `diag8101.t_2(T1, T2, T3, T4, T5)()` +fail_compilation/diag8101.d(63): ... (1 more, -v to show) ... --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag8101b.d b/gcc/testsuite/gdc.test/fail_compilation/diag8101b.d index a3baa272fae..228ba169e8e 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/diag8101b.d +++ b/gcc/testsuite/gdc.test/fail_compilation/diag8101b.d @@ -1,14 +1,15 @@ /* TEST_OUTPUT: --- -fail_compilation/diag8101b.d(26): Error: none of the overloads of 'foo' are callable using argument types (double), candidates are: -fail_compilation/diag8101b.d(17): diag8101b.S.foo(int _param_0) -fail_compilation/diag8101b.d(18): diag8101b.S.foo(int _param_0, int _param_1) -fail_compilation/diag8101b.d(28): Error: function diag8101b.S.bar (int _param_0) is not callable using argument types (double) -fail_compilation/diag8101b.d(31): Error: none of the overloads of 'foo' are callable using a const object, candidates are: -fail_compilation/diag8101b.d(17): diag8101b.S.foo(int _param_0) -fail_compilation/diag8101b.d(18): diag8101b.S.foo(int _param_0, int _param_1) -fail_compilation/diag8101b.d(33): Error: mutable method diag8101b.S.bar is not callable using a const object +fail_compilation/diag8101b.d(27): Error: none of the overloads of `foo` are callable using argument types `(double)`, candidates are: +fail_compilation/diag8101b.d(18): `diag8101b.S.foo(int _param_0)` +fail_compilation/diag8101b.d(19): `diag8101b.S.foo(int _param_0, int _param_1)` +fail_compilation/diag8101b.d(29): Error: function `diag8101b.S.bar(int _param_0)` is not callable using argument types `(double)` +fail_compilation/diag8101b.d(29): cannot pass argument `1.00000` of type `double` to parameter `int _param_0` +fail_compilation/diag8101b.d(32): Error: none of the overloads of `foo` are callable using a `const` object, candidates are: +fail_compilation/diag8101b.d(18): `diag8101b.S.foo(int _param_0)` +fail_compilation/diag8101b.d(19): `diag8101b.S.foo(int _param_0, int _param_1)` +fail_compilation/diag8101b.d(34): Error: mutable method `diag8101b.S.bar` is not callable using a `const` object --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag9420.d b/gcc/testsuite/gdc.test/fail_compilation/diag9420.d index dfaf7c84a09..6b2577d910e 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/diag9420.d +++ b/gcc/testsuite/gdc.test/fail_compilation/diag9420.d @@ -1,7 +1,8 @@ /* TEST_OUTPUT --- -fail_compilation/diag9420.d(20): Error: function diag9420.S.t3!().tx () is not callable using argument types (int) +fail_compilation/diag9420.d(21): Error: function `diag9420.S.t3!().tx()` is not callable using argument types `(int)` +fail_compilation/diag9420.d(21): expected 0 argument(s), not 1 --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail11038.d b/gcc/testsuite/gdc.test/fail_compilation/fail11038.d new file mode 100644 index 00000000000..8f39ccc51eb --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/fail11038.d @@ -0,0 +1,17 @@ +// https://issues.dlang.org/show_bug.cgi?id=11038 +/* +TEST_OUTPUT: +--- +fail_compilation/fail11038.d(16): Error: `writeln` is not defined, perhaps `import std.stdio;` is needed? +--- +*/ + +static +{ + import std.stdio; +} + +void main() +{ + writeln("foo"); // compiles +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail11445.d b/gcc/testsuite/gdc.test/fail_compilation/fail11445.d index a3cfc11ed19..ed3f226e4f2 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail11445.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail11445.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail11445.d(11): Error: incompatible types for ((a) + (b)): 'double[string]' and 'double[string]' +fail_compilation/fail11445.d(11): Error: incompatible types for ((a) + (b)): both operands are of type 'double[string]' --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail15361.d b/gcc/testsuite/gdc.test/fail_compilation/fail15361.d new file mode 100644 index 00000000000..8e5f9800a81 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/fail15361.d @@ -0,0 +1,8 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/fail15361.d(8): Error: unexpected `(` after `errorize`, inside `is` expression. Try enclosing the contents of `is` with a `typeof` expression +--- +*/ + +enum isErrorizable(T) = is(errorize(T.init)); diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail15896.d b/gcc/testsuite/gdc.test/fail_compilation/fail15896.d new file mode 100644 index 00000000000..e52503d0975 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/fail15896.d @@ -0,0 +1,18 @@ +// REQUIRED_ARGS: -de +// EXTRA_FILES: imports/imp15896.d +/* +TEST_OUTPUT: +--- +fail_compilation/fail15896.d(11): Error: module `imports.imp15896` member `thebar` is not visible from module `fail15896` +fail_compilation/fail15896.d(11): Error: module `imports.imp15896` member `packagebar` is not visible from module `fail15896` +--- +*/ + +import imports.imp15896 : thebar, packagebar; + +int func() +{ + thebar +=1; + packagebar += 1; + return 0; +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail17630.d b/gcc/testsuite/gdc.test/fail_compilation/fail17630.d new file mode 100644 index 00000000000..9b6ed82d4b3 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/fail17630.d @@ -0,0 +1,15 @@ +// REQUIRED_ARGS: -de +// EXTRA_FILES: imports/a17630.d +// EXTRA_SOURCES: imports/b17630.d +/* +TEST_OUTPUT: +--- +fail_compilation/fail17630.d(13): Error: module `a17630` import `Erase` not found, did you mean variable `b17630.Erase`? +--- +*/ + +void main() +{ + import imports.a17630 : Erase; + assert(Erase == 2); +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail18219.d b/gcc/testsuite/gdc.test/fail_compilation/fail18219.d new file mode 100644 index 00000000000..f3ec6806f6b --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/fail18219.d @@ -0,0 +1,20 @@ +// EXTRA_SOURCES: imports/b18219.d +// EXTRA_FILES: imports/a18219.d +/* +TEST_OUTPUT: +--- +fail_compilation/fail18219.d(16): Error: no property `Foobar` for type `AST`, did you mean `b18219.Foobar`? +fail_compilation/fail18219.d(17): Error: no property `Bar` for type `a18219.AST` +fail_compilation/fail18219.d(18): Error: no property `fun` for type `AST`, did you mean `b18219.fun`? +fail_compilation/fail18219.d(19): Error: no property `Foobar` for type `AST`, did you mean `b18219.Foobar`? +--- +*/ +import imports.a18219; + +void main() +{ + AST.Foobar t; + AST.Bar l; + AST.fun(); + AST.Foobar.smeth(); +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail19107.d b/gcc/testsuite/gdc.test/fail_compilation/fail19107.d new file mode 100644 index 00000000000..c748650b2e4 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/fail19107.d @@ -0,0 +1,21 @@ +// REQUIRED_ARGS: +/* +TEST_OUTPUT: +--- +fail_compilation/test19107.d(20): Error: template `test19107.all` cannot deduce function from argument types `!((c) => c)(string[])`, candidates are: +fail_compilation/test19107.d(14): `test19107.all(alias pred, T)(T t) if (is(typeof(I!pred(t))))` +--- +*/ + +// https://issues.dlang.org/show_bug.cgi?id=19107 + +import imports.test19107b; + +void all(alias pred, T)(T t) + if (is(typeof(I!pred(t)))) +{ } + +void main(string[] args) +{ + args.all!(c => c); +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail263.d b/gcc/testsuite/gdc.test/fail_compilation/fail263.d index f7dfe21e336..8cf9b20ac2b 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail263.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail263.d @@ -1,7 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail263.d(18): Error: function fail263.f (byte* p) is not callable using argument types (const(byte)*) +fail_compilation/fail263.d(19): Error: function `fail263.f(byte* p)` is not callable using argument types `(const(byte)*)` +fail_compilation/fail263.d(19): cannot pass argument `cast(const(byte)*)A` of type `const(byte)*` to parameter `byte* p` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail3.d b/gcc/testsuite/gdc.test/fail_compilation/fail3.d index 332e561cd0c..0b7516cbc06 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail3.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail3.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail3.d(40): Error: incompatible types for ((a) + (b)): 'vec2' and 'vec2' +fail_compilation/fail3.d(41): Error: incompatible types for ((a) + (b)): both operands are of type 'vec2' --- */ @@ -14,6 +14,7 @@ template vector(T) T x, y; } + // not struct member vec2 opAdd(vec2 a, vec2 b) { vec2 r; diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail322.d b/gcc/testsuite/gdc.test/fail_compilation/fail322.d index 0ffa15a4875..491111fe610 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail322.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail322.d @@ -1,13 +1,18 @@ /* TEST_OUTPUT: --- -fail_compilation/fail322.d(10): Error: function fail322.digestToString2 (ref char[16] digest) is not callable using argument types (string) +fail_compilation/fail322.d(13): Error: function `fail322.digestToString2(ref char[16] digest)` is not callable using argument types `(string)` +fail_compilation/fail322.d(13): cannot pass rvalue argument `"1234567890123456"` of type `string` to parameter `ref char[16] digest` +fail_compilation/fail322.d(15): Error: function `fail322.digestToString2(ref char[16] digest)` is not callable using argument types `(const(char[16]))` +fail_compilation/fail322.d(15): cannot pass argument `s` of type `const(char[16])` to parameter `ref char[16] digest` --- */ void main() { digestToString2("1234567890123456"); + const char[16] s; + digestToString2(s); } void digestToString2(ref char[16] digest) diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail332.d b/gcc/testsuite/gdc.test/fail_compilation/fail332.d index 03f3706d696..91f80464705 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail332.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail332.d @@ -1,15 +1,56 @@ /* TEST_OUTPUT: --- -fail_compilation/fail332.d(14): Error: function fail332.foo (int _param_0, ...) is not callable using argument types () +fail_compilation/fail332.d(22): Error: function `fail332.foo(int _param_0, ...)` is not callable using argument types `()` +fail_compilation/fail332.d(22): missing argument for parameter #1: `int _param_0` +fail_compilation/fail332.d(23): Error: function `fail332.foo(int _param_0, ...)` is not callable using argument types `(typeof(null))` +fail_compilation/fail332.d(23): cannot pass argument `null` of type `typeof(null)` to parameter `int _param_0` +fail_compilation/fail332.d(25): Error: function `fail332.baz(int[] _param_0...)` is not callable using argument types `(string)` +fail_compilation/fail332.d(25): cannot pass argument `""` of type `string` to parameter `int[] _param_0...` +fail_compilation/fail332.d(26): Error: function `fail332.baz(int[] _param_0...)` is not callable using argument types `(int, typeof(null))` +fail_compilation/fail332.d(26): cannot pass argument `null` of type `typeof(null)` to parameter `int[] _param_0...` --- */ import core.vararg; void foo(int, ...) {} +void baz(int[]...) {} -void bar() +void test() { foo(); + foo(null); + + baz(""); + baz(3, null); +} + +/* +TEST_OUTPUT: +--- +fail_compilation/fail332.d(50): Error: function `fail332.bar(Object, int[2]...)` is not callable using argument types `()` +fail_compilation/fail332.d(50): missing argument for parameter #1: `Object` +fail_compilation/fail332.d(51): Error: function `fail332.bar(Object, int[2]...)` is not callable using argument types `(int)` +fail_compilation/fail332.d(51): cannot pass argument `4` of type `int` to parameter `Object` +fail_compilation/fail332.d(52): Error: function `fail332.bar(Object, int[2]...)` is not callable using argument types `(typeof(null))` +fail_compilation/fail332.d(52): expected 2 variadic argument(s), not 0 +fail_compilation/fail332.d(53): Error: function `fail332.bar(Object, int[2]...)` is not callable using argument types `(typeof(null), int)` +fail_compilation/fail332.d(53): expected 2 variadic argument(s), not 1 +fail_compilation/fail332.d(54): Error: function `fail332.bar(Object, int[2]...)` is not callable using argument types `(typeof(null), int, string)` +fail_compilation/fail332.d(54): cannot pass argument `""` of type `string` to parameter `int[2]...` +fail_compilation/fail332.d(55): Error: function `fail332.bar(Object, int[2]...)` is not callable using argument types `(typeof(null), int, int, int)` +fail_compilation/fail332.d(55): expected 2 variadic argument(s), not 3 +--- +*/ +void bar(Object, int[2]...); + +void test2() +{ + bar(); + bar(4); + bar(null); + bar(null, 2); + bar(null, 2, ""); + bar(null, 2,3,4); } diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail347.d b/gcc/testsuite/gdc.test/fail_compilation/fail347.d index 03ae7036d81..61718df59e2 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail347.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail347.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/fail347.d(21): Error: undefined identifier `bbr`, did you mean variable `bar`? -fail_compilation/fail347.d(22): Error: no property 'ofo' for type 'S', did you mean 'foo'? +fail_compilation/fail347.d(22): Error: no property 'ofo' for type 'S', did you mean 'fail347.S.foo'? fail_compilation/fail347.d(23): Error: undefined identifier `strlenx`, did you mean function `strlen`? --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail53.d b/gcc/testsuite/gdc.test/fail_compilation/fail53.d index 2570dd8939c..556896c76c3 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail53.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail53.d @@ -1,7 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail53.d(25): Error: function object.Object.opEquals (Object o) is not callable using argument types (int) +fail_compilation/fail53.d(26): Error: function `object.Object.opEquals(Object o)` is not callable using argument types `(int)` +fail_compilation/fail53.d(26): cannot pass argument `i` of type `int` to parameter `Object o` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail55.d b/gcc/testsuite/gdc.test/fail_compilation/fail55.d index 57117d86ee4..290c2b6695f 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail55.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail55.d @@ -1,7 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail55.d(22): Error: function object.Object.opCmp (Object o) is not callable using argument types (int) +fail_compilation/fail55.d(23): Error: function `object.Object.opCmp(Object o)` is not callable using argument types `(int)` +fail_compilation/fail55.d(23): cannot pass argument `0` of type `int` to parameter `Object o` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail79.d b/gcc/testsuite/gdc.test/fail_compilation/fail79.d index 46581d9d43c..da06984e9ef 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail79.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail79.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail79.d(13): Error: incompatible types for ((& a) + (& b)): 'int*' and 'int*' +fail_compilation/fail79.d(13): Error: incompatible types for ((& a) + (& b)): both operands are of type 'int*' --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail99.d b/gcc/testsuite/gdc.test/fail_compilation/fail99.d index da87ed66acb..c147b810ee6 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail99.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail99.d @@ -1,7 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail99.d(12): Error: delegate dg (int) is not callable using argument types () +fail_compilation/fail99.d(13): Error: delegate `dg(int)` is not callable using argument types `()` +fail_compilation/fail99.d(13): missing argument for parameter #1: `int` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fix21585.d b/gcc/testsuite/gdc.test/fail_compilation/fix21585.d new file mode 100644 index 00000000000..48c74cb3698 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/fix21585.d @@ -0,0 +1,19 @@ +/* https://issues.dlang.org/show_bug.cgi?id=21585 +TEST_OUTPUT: +--- +fail_compilation/fix21585.d(103): Error: expected 1 arguments for `toType` but had 0 +fail_compilation/fix21585.d(104): Error: expression expected as second argument of __traits `toType` +fail_compilation/fix21585.d(105): Error: `string` expected for __traits(toType, string), not `(1)` of type `int` +fail_compilation/fix21585.d(106): Error: cannot determine `__traits(toType, "hello betty")` +--- +*/ + +#line 100 + +template Type(T) { alias Type = T; } + +alias T1 = Type!(__traits(toType)); +alias T2 = Type!(__traits(toType, int)); +alias T3 = Type!(__traits(toType, 1)); +alias T4 = Type!(__traits(toType, "hello betty")); + diff --git a/gcc/testsuite/gdc.test/fail_compilation/format.d b/gcc/testsuite/gdc.test/fail_compilation/format.d new file mode 100644 index 00000000000..3a2422791f7 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/format.d @@ -0,0 +1,44 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/format.d(101): Error: function `format.printf1` `pragma(printf)` functions must be `extern(C) void printf1([parameters...], const(char)*, ...)` not `void(const(char)*, ...)` +fail_compilation/format.d(102): Error: function `format.printf2` `pragma(printf)` functions must be `extern(C) int printf2([parameters...], const(char)*, ...)` not `extern (C) int(const(int)*, ...)` +fail_compilation/format.d(103): Error: function `format.printf3` `pragma(printf)` functions must be `extern(C) int printf3([parameters...], const(char)*, va_list)` +fail_compilation/format.d(104): Error: function `format.printf4` `pragma(printf)` functions must be `extern(C) int printf4([parameters...], const(char)*, ...)` not `extern (C) int(const(char)*, int, ...)` +--- + */ + +#line 100 + +pragma(printf) void printf1(const(char)*, ...); +pragma(printf) extern (C) int printf2(const(int )*, ...); +pragma(printf) extern (C) int printf3(const(char)*); +pragma(printf) extern (C) int printf4(const(char)*, int, ...); + +pragma(printf) extern (C) int printf5(const(char)*, ...); +pragma(printf) extern (C) int printf6(immutable(char)*, ...); +pragma(printf) extern (C) int printf7(char*, ...); + +/* +TEST_OUTPUT: +--- +fail_compilation/format.d(203): Error: function `format.vprintf1` `pragma(printf)` functions must be `extern(C) void vprintf1([parameters...], const(char)*, va_list)` +fail_compilation/format.d(204): Error: function `format.vprintf2` `pragma(printf)` functions must be `extern(C) int vprintf2([parameters...], const(char)*, va_list)` +fail_compilation/format.d(205): Error: function `format.vprintf3` `pragma(printf)` functions must be `extern(C) int vprintf3([parameters...], const(char)*, va_list)` +fail_compilation/format.d(206): Error: function `format.vprintf4` `pragma(printf)` functions must be `extern(C) int vprintf4([parameters...], const(char)*, va_list)` +--- + */ + +#line 200 + +import core.stdc.stdarg; + +pragma(printf) void vprintf1(const(char)*, va_list); +pragma(printf) extern (C) int vprintf2(const(int )*, va_list); +pragma(printf) extern (C) int vprintf3(const(char)*); +pragma(printf) extern (C) int vprintf4(const(char)*, int, va_list); + +pragma(printf) extern (C) int vprintf5(const(char)*, va_list); +pragma(printf) extern (C) int vprintf6(immutable(char)*, va_list); +pragma(printf) extern (C) int vprintf7(char*, va_list); + diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice10598.d b/gcc/testsuite/gdc.test/fail_compilation/ice10598.d new file mode 100644 index 00000000000..ba6cdf73211 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/ice10598.d @@ -0,0 +1,10 @@ +// REQUIRED_ARGS: -de +// EXTRA_SOURCES: imports/ice10598a.d imports/ice10598b.d +/* TEST_OUTPUT: +--- +fail_compilation/imports/ice10598a.d(5): Deprecation: module imports.ice10598b is not accessible here, perhaps add 'static import imports.ice10598b;' +fail_compilation/imports/ice10598a.d(5): Deprecation: module imports.ice10598b is not accessible here, perhaps add 'static import imports.ice10598b;' +--- +*/ + +void main() {} diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice10922.d b/gcc/testsuite/gdc.test/fail_compilation/ice10922.d index 1ddad18eba5..9eeb622300a 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice10922.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice10922.d @@ -1,7 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/ice10922.d(9): Error: function ice10922.__lambda4 (const(uint) n) is not callable using argument types () +fail_compilation/ice10922.d(10): Error: function `ice10922.__lambda4(const(uint) n)` is not callable using argument types `()` +fail_compilation/ice10922.d(10): missing argument for parameter #1: `const(uint) n` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice12497.d b/gcc/testsuite/gdc.test/fail_compilation/ice12497.d deleted file mode 100644 index ab95e81d5b7..00000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/ice12497.d +++ /dev/null @@ -1,18 +0,0 @@ -/* -TEST_OUTPUT: ---- -fail_compilation/ice12497.d(15): Error: string expected for argument to mixin, not (foo()) of type void -fail_compilation/ice12497.d(17): Error: string expected for argument to mixin, not (foo()) of type void ---- -*/ - -void foo() {} - -void main() -{ - struct S - { - mixin(foo()); // MixinDeclaration - } - mixin(foo()); // MixinStatement -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice12501.d b/gcc/testsuite/gdc.test/fail_compilation/ice12501.d index f57980d7bc3..2c45c8a359d 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice12501.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice12501.d @@ -1,9 +1,11 @@ /* TEST_OUTPUT: --- -fail_compilation/ice12501.d(29): Error: function ice12501.foo (int value) is not callable using argument types (int, int) -fail_compilation/ice12501.d(29): Error: function ice12501.foo (int value) is not callable using argument types (int, int) -fail_compilation/ice12501.d(43): Error: template instance ice12501.reduce!(foo, foo).reduce!(Tuple!(int, int), int[]) error instantiating +fail_compilation/ice12501.d(31): Error: function `ice12501.foo(int value)` is not callable using argument types `(int, int)` +fail_compilation/ice12501.d(31): expected 1 argument(s), not 2 +fail_compilation/ice12501.d(31): Error: function `ice12501.foo(int value)` is not callable using argument types `(int, int)` +fail_compilation/ice12501.d(31): expected 1 argument(s), not 2 +fail_compilation/ice12501.d(45): Error: template instance `ice12501.reduce!(foo, foo).reduce!(Tuple!(int, int), int[])` error instantiating --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice14907.d b/gcc/testsuite/gdc.test/fail_compilation/ice14907.d new file mode 100644 index 00000000000..6d9edf0c903 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/ice14907.d @@ -0,0 +1,22 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/ice14907.d(14): Error: struct ice14907.S(int v = S) recursive template expansion +fail_compilation/ice14907.d(19): while looking for match for `S!()` +fail_compilation/ice14907.d(15): Error: template ice14907.f(int v = f)() recursive template expansion +fail_compilation/ice14907.d(20): while looking for match for `f!()` +fail_compilation/ice14907.d(15): Error: template ice14907.f(int v = f)() recursive template expansion +fail_compilation/ice14907.d(21): Error: template `ice14907.f` cannot deduce function from argument types `!()()`, candidates are: +fail_compilation/ice14907.d(15): `ice14907.f(int v = f)()` +--- +*/ + +struct S(int v = S) {} +void f(int v = f)() {} + +void main() +{ + S!() s; // OK <- ICE + f!()(); // OK <- ICE + f(); // OK <- ICE +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice14923.d b/gcc/testsuite/gdc.test/fail_compilation/ice14923.d index 86e3b2a2071..e3b677e2cdb 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice14923.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice14923.d @@ -1,8 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/ice14923.d(21): Error: function ice14923.parse (C a) is not callable using argument types (A) -fail_compilation/ice14923.d(21): instantiated from here: bar!((b) => parse(b)) +fail_compilation/ice14923.d(22): Error: function `ice14923.parse(C a)` is not callable using argument types `(A)` +fail_compilation/ice14923.d(22): cannot pass argument `b` of type `ice14923.A` to parameter `C a` +fail_compilation/ice14923.d(22): instantiated from here: `bar!((b) => parse(b))` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice8255.d b/gcc/testsuite/gdc.test/fail_compilation/ice8255.d index d98e38ad9a4..0db3abc395f 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice8255.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice8255.d @@ -1,8 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/ice8255.d(10): Error: function ice8255.F!(G).F.f (ref G _param_0) is not callable using argument types (G) -fail_compilation/ice8255.d(10): while evaluating pragma(msg, F().f(G())) +fail_compilation/ice8255.d(11): Error: function `ice8255.F!(G).F.f(ref G _param_0)` is not callable using argument types `(G)` +fail_compilation/ice8255.d(11): cannot pass rvalue argument `G()` of type `G` to parameter `ref G _param_0` +fail_compilation/ice8255.d(11): while evaluating `pragma(msg, F().f(G()))` --- */ struct G {} diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice9540.d b/gcc/testsuite/gdc.test/fail_compilation/ice9540.d index d6c9cdae0f3..f95cb974c79 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice9540.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice9540.d @@ -1,8 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/ice9540.d(34): Error: function ice9540.A.test.AddFront!(this, f).AddFront.dg (int _param_0) is not callable using argument types () -fail_compilation/ice9540.d(25): Error: template instance ice9540.A.test.AddFront!(this, f) error instantiating +fail_compilation/ice9540.d(35): Error: function `ice9540.A.test.AddFront!(this, f).AddFront.dg(int _param_0)` is not callable using argument types `()` +fail_compilation/ice9540.d(35): missing argument for parameter #1: `int _param_0` +fail_compilation/ice9540.d(26): Error: template instance `ice9540.A.test.AddFront!(this, f)` error instantiating --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/a17630.d b/gcc/testsuite/gdc.test/fail_compilation/imports/a17630.d new file mode 100644 index 00000000000..c10484175d4 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/imports/a17630.d @@ -0,0 +1,3 @@ +module a17630; + +import b17630; diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/a18219.d b/gcc/testsuite/gdc.test/fail_compilation/imports/a18219.d new file mode 100644 index 00000000000..1a88493ef15 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/imports/a18219.d @@ -0,0 +1,6 @@ +module a18219; + +struct AST +{ + import b18219; +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/b17630.d b/gcc/testsuite/gdc.test/fail_compilation/imports/b17630.d new file mode 100644 index 00000000000..5ad5f9917f7 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/imports/b17630.d @@ -0,0 +1,3 @@ +module b17630; + +int Erase; diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/b18219.d b/gcc/testsuite/gdc.test/fail_compilation/imports/b18219.d new file mode 100644 index 00000000000..6008c8a1e21 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/imports/b18219.d @@ -0,0 +1,15 @@ +module b18219; + +class Foobar +{ + int a; + this(int a) + { + this.a = a; + } + static int smeth() + { + return 1; + } +} +void fun() {} diff --git a/gcc/testsuite/gdc.test/compilable/imports/ice10598a.d b/gcc/testsuite/gdc.test/fail_compilation/imports/ice10598a.d similarity index 100% rename from gcc/testsuite/gdc.test/compilable/imports/ice10598a.d rename to gcc/testsuite/gdc.test/fail_compilation/imports/ice10598a.d diff --git a/gcc/testsuite/gdc.test/compilable/imports/ice10598b.d b/gcc/testsuite/gdc.test/fail_compilation/imports/ice10598b.d similarity index 100% rename from gcc/testsuite/gdc.test/compilable/imports/ice10598b.d rename to gcc/testsuite/gdc.test/fail_compilation/imports/ice10598b.d diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/imp15896.d b/gcc/testsuite/gdc.test/fail_compilation/imports/imp15896.d new file mode 100644 index 00000000000..d7edcc1bcc1 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/imports/imp15896.d @@ -0,0 +1,4 @@ +module imports.imp15896; + +private int thebar=4; +package int packagebar=3; diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/test21651b.d b/gcc/testsuite/gdc.test/fail_compilation/imports/test21651b.d new file mode 100644 index 00000000000..4c85aade3bc --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/imports/test21651b.d @@ -0,0 +1,3 @@ +module imports.test21651b; + +alias T = int; diff --git a/gcc/testsuite/gdc.test/fail_compilation/issue16020.d b/gcc/testsuite/gdc.test/fail_compilation/issue16020.d new file mode 100644 index 00000000000..75e3b9f0b81 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/issue16020.d @@ -0,0 +1,13 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/issue16020.d(12): Error: user-defined attributes not allowed for `alias` declarations +fail_compilation/issue16020.d(13): Error: semicolon expected to close `alias` declaration +fail_compilation/issue16020.d(13): Error: declaration expected, not `(` +--- +*/ +module issue16020; + +struct UDA{} +alias Fun = @UDA void(); +alias FunTemplate = void(T)(T t); diff --git a/gcc/testsuite/gdc.test/fail_compilation/mixintype2.d b/gcc/testsuite/gdc.test/fail_compilation/mixintype2.d new file mode 100644 index 00000000000..b18627dd879 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/mixintype2.d @@ -0,0 +1,16 @@ + +/* TEST_OUTPUT: +--- +fail_compilation/mixintype2.d(10): Error: alias `mixintype2.Foo.T` recursive alias declaration +fail_compilation/mixintype2.d(16): Error: `mixin(0)` does not give a valid type +--- +*/ + +struct Foo { + alias T = mixin("T2"); +} +alias T1 = mixin("Foo.T"); +alias T2 = mixin("T1"); +void func (T2 p) {} + +enum mixin(0) a = 0; diff --git a/gcc/testsuite/gdc.test/fail_compilation/test16002.d b/gcc/testsuite/gdc.test/fail_compilation/test16002.d deleted file mode 100644 index 80ae40b6b88..00000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/test16002.d +++ /dev/null @@ -1,15 +0,0 @@ -/* -REQUIRED_ARGS: -PERMUTE_ARGS: -TEST_OUTPUT: ---- -fail_compilation/test16002.d(100): Error: undefined identifier `imports.nonexistent` -fail_compilation/test16002.d(101): Error: undefined identifier `imports.nonexistent` ---- -*/ - -module test.fail_compilation.test16002; - -#line 100 -enum A = is(imports.nonexistent == package); -enum B = is(imports.nonexistent == module); diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21651.d b/gcc/testsuite/gdc.test/fail_compilation/test21651.d new file mode 100644 index 00000000000..a4d959f4626 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/test21651.d @@ -0,0 +1,11 @@ +// REQUIRED_ARGS: -de +// EXTRA_SOURCES: imports/test21651b.d +/* TEST_OUTPUT: +--- +fail_compilation/test21651.d(11): Deprecation: module imports.test21651b is not accessible here, perhaps add 'static import imports.test21651b;' +--- +*/ + +module imports.test21651; + +imports.test21651b.T a; diff --git a/gcc/testsuite/gdc.test/fail_compilation/warn12809.d b/gcc/testsuite/gdc.test/fail_compilation/warn12809.d index 100f0fb9f33..06c998d6005 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/warn12809.d +++ b/gcc/testsuite/gdc.test/fail_compilation/warn12809.d @@ -32,3 +32,44 @@ void test_unrachable3() int x = 1; // unreachable } + +/********************************************/ + +/* +TEST_OUTPUT: +--- +fail_compilation/warn12809.d(108): Warning: statement is not reachable +fail_compilation/warn12809.d(115): Warning: statement is not reachable +fail_compilation/warn12809.d(122): Warning: statement is not reachable +Error: warnings are treated as errors + Use -wi if you wish to treat warnings only as informational. +--- +*/ + +#line 100 + +alias noreturn = typeof(*null); + +noreturn foo(); + +void test1(ref int i) +{ + foo(); + i = 3; +} + +void test2() +{ + try foo(); + finally { } + int x = 1; +} + +void test3() +{ + try { } + finally foo(); + int x = 1; +} + + diff --git a/gcc/testsuite/gdc.test/runnable/funclit.d b/gcc/testsuite/gdc.test/runnable/funclit.d index d45e3e6ddfd..c299badec15 100644 --- a/gcc/testsuite/gdc.test/runnable/funclit.d +++ b/gcc/testsuite/gdc.test/runnable/funclit.d @@ -1241,6 +1241,66 @@ void test15794() gun15794!(() => 0)(); // Line 26 } +/***************************************************/ +// https://issues.dlang.org/show_bug.cgi?id=16271 + +ref auto funa16271(alias dg, T)(ref T a) +{ + return dg(a); +} + +ref auto func16271(alias dg)() +{ + return dg(); +} + +void assign16271(T)(ref T a, T b) +{ + alias fun = ref (ref a) => a; + fun(a) = b; +} + +void test16271() +{ + int x; + (ref () => x )() = 1; assert(x == 1); + func16271!(ref () => x) = 2; assert(x == 2); + assign16271(x, 3); assert(x == 3); + + alias alx = func16271!(ref () => x); + alx = 4; assert(x == 4); + + alias alf = ref (ref a) => a; + auto auf = ref (ref int a) => a; + alf(x) = 5; assert(x == 5); + auf(x) = 6; assert(x == 6); + + assert((funa16271!( ref (ref a) => a)(x) += 1) == 7 ); + assert((funa16271!(function ref (ref a) => a)(x) += 1) == 8 ); + assert((funa16271!(function ref int(ref a) => a)(x) += 1) == 9 ); + assert((funa16271!(delegate ref (ref a) => a)(x) += 1) == 10); + assert((funa16271!(delegate ref int(ref a) => a)(x) += 1) == 11); + assert(x == 11); + + alias aldc = ref () @trusted @nogc { return x; }; + auto audc = ref () @safe nothrow { return x; }; + alias alfuc = function ref (ref x) @trusted { return x; }; + alias aldec = delegate ref () @trusted { return x; }; + aldc() = 12; assert(x == 12); + audc() = 13; assert(x == 13); + alfuc(x) = 14; assert(x == 14); + aldec() = 15; assert(x == 15); + + template T() + { + int x; + alias alf = ref () => x; + auto auf = ref () => x; + } + T!().alf() = 1; assert(T!().x == 1); + T!().auf() = 2; assert(T!().x == 2); +} + /***************************************************/ int main() @@ -1299,6 +1359,7 @@ int main() test13879(); test14745(); test15794(); + test16271(); printf("Success\n"); return 0; diff --git a/gcc/testsuite/gdc.test/runnable/mangle.d b/gcc/testsuite/gdc.test/runnable/mangle.d index e6d36453d88..9a8420aa20b 100644 --- a/gcc/testsuite/gdc.test/runnable/mangle.d +++ b/gcc/testsuite/gdc.test/runnable/mangle.d @@ -599,6 +599,12 @@ void fooB(void delegate (void delegate()) scope dg) //pragma(msg, fooB.mangleof); static assert(typeof(fooA).mangleof != typeof(fooB).mangleof); +/***************************************************/ + +alias noreturn = typeof(*null); +alias fpd = noreturn function(); +int funcd(fpd); +static assert(funcd.mangleof == "_D6mangle5funcdFPFZNnZi"); /***************************************************/ diff --git a/gcc/testsuite/gdc.test/runnable/noreturn1.d b/gcc/testsuite/gdc.test/runnable/noreturn1.d new file mode 100644 index 00000000000..447ea28294c --- /dev/null +++ b/gcc/testsuite/gdc.test/runnable/noreturn1.d @@ -0,0 +1,74 @@ +alias noreturn = typeof(*null); + +extern (C) noreturn exit(); + +/*****************************************/ + +bool testf(int i) +{ + return i && assert(0); +} + +bool testt(int i) +{ + return i || assert(0); +} + +int testa(int i) +{ + if (i && exit()) + return i + 1; + return i - 1; +} + +int testb(int i) +{ + if (i || exit()) + return i + 1; + return i - 1; +} + +void test1() +{ + assert(testf(0) == false); + assert(testt(1) == true); + + assert(testa(0) == -1); + assert(testb(3) == 4); +} + +/*****************************************/ + +noreturn exit1() { assert(0); } +noreturn exit2() { assert(0); } + + +int heli1(int i) +{ + return i ? exit1() : i - 1; +} + +int heli2(int i) +{ + return i ? i - 1 : exit1(); +} + +noreturn heli3(int i) +{ + return i ? exit1() : exit2(); +} + +void test2() +{ + assert(heli1(0) == -1); + assert(heli2(1) == 0); +} + +/*****************************************/ + +int main() +{ + test1(); + test2(); + return 0; +} diff --git a/gcc/testsuite/gdc.test/runnable_cxx/cppa.d b/gcc/testsuite/gdc.test/runnable_cxx/cppa.d index b9b4832991e..cb576ba59a8 100644 --- a/gcc/testsuite/gdc.test/runnable_cxx/cppa.d +++ b/gcc/testsuite/gdc.test/runnable_cxx/cppa.d @@ -571,18 +571,20 @@ void test13289() assert(f13289_cpp_test()); } +version(Posix) +{ + enum __c_wchar_t : dchar; +} +else version(Windows) +{ + enum __c_wchar_t : wchar; +} +alias wchar_t = __c_wchar_t; extern(C++) { bool f13289_cpp_test(); - version(Posix) - { - dchar f13289_cpp_wchar_t(dchar); - } - else version(Windows) - { - wchar f13289_cpp_wchar_t(wchar); - } + wchar_t f13289_cpp_wchar_t(wchar_t); wchar f13289_d_wchar(wchar ch) { @@ -606,6 +608,17 @@ extern(C++) return ch; } } + wchar_t f13289_d_wchar_t(wchar_t ch) + { + if (ch <= 'z' && ch >= 'a') + { + return cast(wchar_t)(ch - ('a' - 'A')); + } + else + { + return ch; + } + } } /****************************************/ diff --git a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cppb.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cppb.cpp index 587145c61c3..823c6603878 100644 --- a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cppb.cpp +++ b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cppb.cpp @@ -412,8 +412,12 @@ wchar_t f13289_d_wchar(wchar_t ch); unsigned int f13289_d_dchar(unsigned int ch); #endif +wchar_t f13289_d_wchar_t(wchar_t ch); + bool f13289_cpp_test() { + if (!(f13289_d_wchar_t(L'e') == L'E')) return false; + if (!(f13289_d_wchar_t(L'F') == L'F')) return false; #if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __NetBSD__ if (!(f13289_d_wchar((unsigned short)'c') == (unsigned short)'C')) return false; if (!(f13289_d_wchar((unsigned short)'D') == (unsigned short)'D')) return false; diff --git a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/test21515.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/test21515.cpp new file mode 100644 index 00000000000..076777a268b --- /dev/null +++ b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/test21515.cpp @@ -0,0 +1,82 @@ +#include <assert.h> +#include <complex.h> + +// Use custom types for inspecting parts instead of including tgmath.h +union cfloat_t { _Complex float z; struct { float re; float im; }; }; +union cdouble_t { _Complex double z; struct { double re; double im; }; }; +union creal_t { _Complex long double z; struct { long double re; long double im; }; }; + +// extern(C) tests +extern "C" _Complex float ccomplexf() { return 2.0f+I; } +extern "C" _Complex double ccomplex() { return 2.0+I; } +extern "C" _Complex long double ccomplexl() { return 2.0L+I; } +extern "C" void ccomplexf2(_Complex float c) { cfloat_t z = {c}; assert(z.re == 2 && z.im == 1); } +extern "C" void ccomplex2(_Complex double c) { cdouble_t z = {c}; assert(z.re == 2 && z.im == 1); } +extern "C" void ccomplexl2(_Complex long double c) { creal_t z = {c}; assert(z.re == 2 && z.im == 1); } + +// extern(C++) tests +_Complex float cpcomplexf() { return 2.0f+I; } +_Complex double cpcomplex() { return 2.0+I; } +_Complex long double cpcomplexl() { return 2.0L+I; } +void cpcomplexf(_Complex float c) { cfloat_t z = {c}; assert(z.re == 2 && z.im == 1); } +void cpcomplex(_Complex double c) { cdouble_t z = {c}; assert(z.re == 2 && z.im == 1); } +void cpcomplexl(_Complex long double c) { creal_t z = {c}; assert(z.re == 2 && z.im == 1); } + +// Struct tests +struct wrap_complexf { _Complex float c; }; +struct wrap_complex { _Complex double c; }; +struct wrap_complexl { _Complex long double c; }; + +wrap_complexf wcomplexf() +{ + wrap_complexf s; + s.c = 2.0f+I; + return s; +} + +wrap_complex wcomplex() +{ + wrap_complex s; + s.c = 2.0+I; + return s; +} + +wrap_complexl wcomplexl() +{ + wrap_complexl s; + s.c = 2.0L+I; + return s; +} + +void wcomplexf(wrap_complexf s) { cfloat_t z = {s.c}; assert(z.re == 2 && z.im == 1); } +void wcomplex(wrap_complex s) { cdouble_t z = {s.c}; assert(z.re == 2 && z.im == 1); } +void wcomplexl(wrap_complexl s) { creal_t z = {s.c}; assert(z.re == 2 && z.im == 1); } + +struct soft_complexf { float re; float im; }; +struct soft_complex { double re; double im; }; +struct soft_complexl { long double re; long double im; }; + +soft_complexf scomplexf() +{ + soft_complexf s; + s.re = 2.0f; s.im = 1.0f; + return s; +} + +soft_complex scomplex() +{ + soft_complex s; + s.re = 2.0; s.im = 1.0; + return s; +} + +soft_complexl scomplexl() +{ + soft_complexl s; + s.re = 2.0L; s.im = 1.0L; + return s; +} + +void scomplexf(soft_complexf s) { assert(s.re == 2 && s.im == 1); } +void scomplex(soft_complex s) { assert(s.re == 2 && s.im == 1); } +void scomplexl(soft_complexl s) { assert(s.re == 2 && s.im == 1); } diff --git a/gcc/testsuite/gdc.test/runnable_cxx/test21515.d b/gcc/testsuite/gdc.test/runnable_cxx/test21515.d new file mode 100644 index 00000000000..cc4420734a6 --- /dev/null +++ b/gcc/testsuite/gdc.test/runnable_cxx/test21515.d @@ -0,0 +1,104 @@ +// https://issues.dlang.org/show_bug.cgi?id=21515 +// EXTRA_CPP_SOURCES: test21515.cpp +// DISABLED: win32 win64 + +// ABI layout of native complex +struct _Complex(T) { T re; T im; } + +// Special enum definitions. +version (Posix) +{ + align(float.alignof) enum __c_complex_float : _Complex!float; + align(double.alignof) enum __c_complex_double : _Complex!double; + align(real.alignof) enum __c_complex_real : _Complex!real; +} +else +{ + align(float.sizeof * 2) enum __c_complex_float : _Complex!float; + align(double.sizeof * 2) enum __c_complex_double : _Complex!double; + align(real.alignof) enum __c_complex_real : _Complex!real; +} +alias complex_float = __c_complex_float; +alias complex_double = __c_complex_double; +alias complex_real = __c_complex_real; + +extern(C) complex_float ccomplexf(); +extern(C) complex_double ccomplex(); +extern(C) complex_real ccomplexl(); +extern(C) void ccomplexf2(complex_float c); +extern(C) void ccomplex2(complex_double c); +extern(C) void ccomplexl2(complex_real c); + +extern(C++) complex_float cpcomplexf(); +extern(C++) complex_double cpcomplex(); +extern(C++) complex_real cpcomplexl(); +extern(C++) void cpcomplexf(complex_float c); +extern(C++) void cpcomplex(complex_double c); +extern(C++) void cpcomplexl(complex_real c); + +struct wrap_complexf { complex_float c; alias c this; }; +struct wrap_complex { complex_double c; alias c this; }; +struct wrap_complexl { complex_real c; alias c this; }; + +extern(C++) wrap_complexf wcomplexf(); +extern(C++) wrap_complex wcomplex(); +extern(C++) wrap_complexl wcomplexl(); +extern(C++) void wcomplexf(wrap_complexf c); +extern(C++) void wcomplex(wrap_complex c); +extern(C++) void wcomplexl(wrap_complexl c); + +struct soft_complexf { float re; float im; }; +struct soft_complex { double re; double im; }; +struct soft_complexl { real re; real im; }; + +extern(C++) soft_complexf scomplexf(); +extern(C++) soft_complex scomplex(); +extern(C++) soft_complexl scomplexl(); +extern(C++) void scomplexf(soft_complexf c); +extern(C++) void scomplex(soft_complex c); +extern(C++) void scomplexl(soft_complexl c); + +int main() +{ + auto a1 = ccomplexf(); + auto b1 = ccomplex(); + auto c1 = ccomplexl(); + assert(a1.re == 2 && a1.im == 1); + assert(b1.re == 2 && b1.im == 1); + assert(c1.re == 2 && c1.im == 1); + ccomplexf2(a1); + ccomplex2(b1); + ccomplexl2(c1); + + auto a2 = cpcomplexf(); + auto b2 = cpcomplex(); + auto c2 = cpcomplexl(); + assert(a2.re == 2 && a2.im == 1); + assert(b2.re == 2 && b2.im == 1); + assert(c2.re == 2 && c2.im == 1); + cpcomplexf(a2); + cpcomplex(b2); + cpcomplexl(c2); + + auto a3 = wcomplexf(); + auto b3 = wcomplex(); + auto c3 = wcomplexl(); + assert(a3.re == 2 && a3.im == 1); + assert(b3.re == 2 && b3.im == 1); + assert(c3.re == 2 && c3.im == 1); + wcomplexf(a3); + wcomplex(b3); + wcomplexl(c3); + + auto a4 = scomplexf(); + auto b4 = scomplex(); + auto c4 = scomplexl(); + assert(a4.re == 2 && a4.im == 1); + assert(b4.re == 2 && b4.im == 1); + assert(c4.re == 2 && c4.im == 1); + scomplexf(a4); + scomplex(b4); + scomplexl(c4); + + return 0; +} -- 2.27.0