./ldc-1.42.0-src/0000755000175000017500000000000015205374133012207 5ustar fabiofabio./ldc-1.42.0-src/tests/0000755000175000017500000000000015205374130013346 5ustar fabiofabio./ldc-1.42.0-src/tests/dynamiccompile/0000755000175000017500000000000015205374122016344 5ustar fabiofabio./ldc-1.42.0-src/tests/dynamiccompile/inputs/0000755000175000017500000000000015205374122017666 5ustar fabiofabio./ldc-1.42.0-src/tests/dynamiccompile/inputs/rtconst_user.d0000644000175000017500000000021315205374122022561 0ustar fabiofabiomodule inputs.rtconst_user; import inputs.rtconst_owner; import ldc.attributes; @dynamicCompile int getValue() { return 10 + value; } ./ldc-1.42.0-src/tests/dynamiccompile/inputs/rtconst_owner.d0000644000175000017500000000014415205374122022740 0ustar fabiofabiomodule inputs.rtconst_owner; import ldc.attributes; @dynamicCompileConst __gshared int value = 1; ./ldc-1.42.0-src/tests/dynamiccompile/inputs/module3.d0000644000175000017500000000016615205374122021406 0ustar fabiofabiomodule inputs.module3; import ldc.attributes; @dynamicCompile int get1() { return 3; } int get2() { return 4; }./ldc-1.42.0-src/tests/dynamiccompile/inputs/module1.d0000644000175000017500000000024215205374122021377 0ustar fabiofabiomodule inputs.module1; import inputs.module3; import ldc.attributes; @dynamicCompile int get() { return 3 + inputs.module3.get1() + inputs.module3.get2(); } ./ldc-1.42.0-src/tests/dynamiccompile/inputs/module2.d0000644000175000017500000000024215205374122021400 0ustar fabiofabiomodule inputs.module2; import inputs.module3; import ldc.attributes; @dynamicCompile int get() { return 4 + inputs.module3.get1() + inputs.module3.get2(); } ./ldc-1.42.0-src/tests/dynamiccompile/options_multiple_changes.d0000644000175000017500000000217715205374122023616 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.stdio; import std.array; import std.string; import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile int foo() { int* i = new int; *i = 42; return *i; } void main(string[] args) { foreach (bool add_opt; [false, true, false, true, false]) { auto dump = appender!string(); CompilerSettings settings; settings.optLevel = 3; settings.dumpHandler = (DumpStage stage, in char[] str) { if (DumpStage.OptimizedModule == stage) { write(str); dump.put(str); } }; writeln("==========================================="); if (add_opt) { auto res = setDynamicCompilerOptions(["-disable-gc2stack"]); assert(res); } else { auto res = setDynamicCompilerOptions([]); assert(res); } compileDynamicCode(settings); writeln(); writeln("==========================================="); stdout.flush(); if (add_opt) { assert(count(dump.data, "_d_allocmemoryT") > 0); } else { assert(count(dump.data, "_d_allocmemoryT") == 0); } } } ./ldc-1.42.0-src/tests/dynamiccompile/calls.d0000644000175000017500000000114515205374122017610 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile int foo() { return 5; } int bar() { return 7; } @dynamicCompile int baz() { return foo() + bar(); } alias fptr = int function(); @dynamicCompile { fptr get_foo_ptr() { return &foo; } fptr get_bar_ptr() { return &bar; } fptr get_baz_ptr() { return &baz; } } void main(string[] args) { compileDynamicCode(); assert(5 == foo()); assert(7 == bar()); assert(12 == baz()); assert(5 == get_foo_ptr()()); assert(7 == get_bar_ptr()()); assert(12 == get_baz_ptr()()); } ./ldc-1.42.0-src/tests/dynamiccompile/inline_asm.d0000644000175000017500000000251615205374122020633 0ustar fabiofabio// RUN: %ldc -enable-dynamic-compile -run %s import std.array; import std.string; import std.stdio; import ldc.attributes; import ldc.dynamic_compile; import ldc.intrinsics; import ldc.llvmasm; version (ARM) version = ARM_Any; version (AArch64) version = ARM_Any; version (MIPS32) version = MIPS_Any; version (MIPS64) version = MIPS_Any; version (PPC) version = PPC_Any; version (PPC64) version = PPC_Any; version (RISCV32) version = RISCV_Any; version (RISCV64) version = RISCV_Any; @dynamicCompile void* foo() { version (X86) return __asm!(void*)("movl %esp, $0", "=r"); else version (X86_64) return __asm!(void*)("movq %rsp, $0", "=r"); else version (ARM_Any) return __asm!(void*)("mov $0, sp", "=r"); else version (PPC_Any) return __asm!(void*)("mr $0, 1", "=r"); else version (MIPS_Any) return __asm!(void*)("move $0, $$sp", "=r"); else return llvm_frameaddress(0); // soft-skip the test } void main(string[] args) { auto dump = appender!(char[])(); CompilerSettings settings; settings.optLevel = 3; settings.dumpHandler = (DumpStage stage, in char[] str) { if (DumpStage.FinalAsm == stage) { dump.put(str); write(str); } }; compileDynamicCode(settings); void* result = foo(); assert(result != null); } ./ldc-1.42.0-src/tests/dynamiccompile/emit.d0000644000175000017500000000167115205374122017454 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.stdio; import std.array; import std.string; import ldc.attributes; import ldc.dynamic_compile; int foo() { return 42; } @dynamicCompileEmit int bar() { return 43; } @dynamicCompileEmit @dynamicCompile int baz() { return 44; } void main(string[] args) { assert(43 == bar()); auto dump = appender!string(); CompilerSettings settings; settings.dumpHandler = (DumpStage stage, in char[] str) { if (DumpStage.OriginalModule == stage) { write(str); dump.put(str); } }; writeln("==========================================="); compileDynamicCode(settings); writeln(); writeln("==========================================="); stdout.flush(); assert(44 == baz()); // Check function name in original IR assert(count(dump.data, foo.mangleof) == 0); assert(count(dump.data, bar.mangleof) > 0); assert(count(dump.data, baz.mangleof) > 0); } ./ldc-1.42.0-src/tests/dynamiccompile/bind.d0000644000175000017500000000677715205374122017446 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile int foo(int a, int b, int c) { return a + b * 10 + c * 100; } int bar(int a, int b, int c) { return a + b * 10 + c * 100; } struct Foo { int i; int j; } struct Bar { Foo f; int k; @dynamicCompileEmit int get(int val) { return f.i + f.j * 10 + k * 100 + val * 1000; } } @dynamicCompile int baz1(Bar b) { return b.f.i + b.f.j * 10 + b.k * 100; } @dynamicCompile int baz2(Bar* b) { return b.f.i + b.f.j * 10 + b.k * 100; } @dynamicCompile int zzz1(int function() f) { return f(); } @dynamicCompile int zzz2(int delegate() f) { return f(); } int get6() { return 6; } @dynamicCompile int yyy(int i, int delegate() j) { return i + j(); } @dynamicCompile int ccc(int i, const int j, immutable int k) { return i + j + k; } void main(string[] args) { foreach (i; 0..4) { CompilerSettings settings; settings.optLevel = i; auto f1 = ldc.dynamic_compile.bind(&foo, placeholder, placeholder, placeholder); auto f2 = ldc.dynamic_compile.bind(&foo, 1, placeholder, 3); auto f3 = ldc.dynamic_compile.bind(&foo, 1, 2, 3); auto f4 = f3; assert(!f1.isNull()); assert(!f2.isNull()); assert(!f3.isNull()); assert(!f4.isNull()); int delegate(int,int,int) fd1 = f1.toDelegate(); int delegate(int) fd2 = f2.toDelegate(); int delegate() fd3 = f3.toDelegate(); int delegate() fd4 = f4.toDelegate(); auto b1 = ldc.dynamic_compile.bind(&bar, placeholder, placeholder, placeholder); auto b2 = ldc.dynamic_compile.bind(&bar, 1, placeholder, 3); auto b3 = ldc.dynamic_compile.bind(&bar, 1, 2, 3); auto b4 = b3; auto bz1 = ldc.dynamic_compile.bind(&baz1, Bar(Foo(1,2),3)); auto b = Bar(Foo(1,2),3); auto bz2 = ldc.dynamic_compile.bind(&baz2, &b); int delegate() bzd1 = bz1.toDelegate(); int delegate() bzd2 = bz2.toDelegate(); auto zz1 = ldc.dynamic_compile.bind(&zzz1, &get6); import std.functional; auto zz2 = ldc.dynamic_compile.bind(&zzz2, toDelegate(&get6)); int delegate() zzd1 = zz1.toDelegate(); int delegate() zzd2 = zz2.toDelegate(); auto elem = Bar(Foo(1,3),5); auto yy = ldc.dynamic_compile.bind(&elem.get, 7); auto yyd = yy.toDelegate(); int dget6() { return 6; } auto p = ldc.dynamic_compile.bind(&yyy, placeholder, &dget6); auto c = ldc.dynamic_compile.bind(&ccc, 1, 10, 100); compileDynamicCode(settings); assert(f1.isCallable()); assert(f2.isCallable()); assert(f3.isCallable()); assert(f4.isCallable()); assert(321 == f1(1,2,3)); assert(321 == f2(2)); assert(321 == f3()); assert(321 == f4()); assert(321 == fd1(1,2,3)); assert(321 == fd2(2)); assert(321 == fd3()); assert(321 == fd4()); f3 = null; assert(f3.isNull()); assert(!f4.isNull()); assert(!f3.isCallable()); assert(f4.isCallable()); assert(b1.isCallable()); assert(b2.isCallable()); assert(b3.isCallable()); assert(b4.isCallable()); assert(321 == b1(1,2,3)); assert(321 == b2(2)); assert(321 == b3()); assert(321 == b4()); assert(321 == bz1()); assert(321 == bz2()); assert(321 == bzd1()); assert(321 == bzd2()); assert(6 == zz1()); assert(6 == zz2()); assert(6 == zzd1()); assert(6 == zzd2()); assert(yy.isCallable()); assert(7531 == yy()); assert(7531 == yyd()); assert(10 == p(4)); assert(111 == c()); } } ./ldc-1.42.0-src/tests/dynamiccompile/global_opt.d0000644000175000017500000000146315205374122020637 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.array; import std.string; import ldc.attributes; import ldc.dynamic_compile; @dynamicCompileConst __gshared int value = 0; @dynamicCompile int foo() { return (value + 5) / 2; } void main(string[] args) { auto dump = appender!(char[])(); CompilerSettings settings; settings.optLevel = 2; settings.dumpHandler = (DumpStage stage, in char[] str) { if (DumpStage.FinalAsm == stage) { dump.put(str); } }; value = 7; compileDynamicCode(settings); // Function return value will be reduced to constant // search for this value in asm assert(indexOf(dump.data, "6") != -1); assert(foo() == 6); dump.clear(); value = 3; compileDynamicCode(settings); assert(indexOf(dump.data, "4") != -1); assert(foo() == 4); } ./ldc-1.42.0-src/tests/dynamiccompile/bind_bool.d0000644000175000017500000000216715205374122020446 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.array; import std.string; import std.stdio; import ldc.attributes; import ldc.dynamic_compile; @dynamicCompileEmit int foo(int a, int b, bool flag) { if (flag) { return a + b; } else { return a - b; } } void main(string[] args) { foreach (val; [false, true]) { auto dump = appender!(char[])(); CompilerSettings settings; settings.optLevel = 3; settings.dumpHandler = (DumpStage stage, in char[] str) { if (DumpStage.FinalAsm == stage || DumpStage.OptimizedModule == stage) { dump.put(str); write(str); } }; auto f = ldc.dynamic_compile.bind(&foo, 123110, 3, val); auto d = f.toDelegate(); compileDynamicCode(settings); if (val) { assert(indexOf(dump.data, "123113") != -1); assert(indexOf(dump.data, "123107") == -1); assert(f() == 123113); assert(d() == 123113); } else { assert(indexOf(dump.data, "123113") == -1); assert(indexOf(dump.data, "123107") != -1); assert(f() == 123107); assert(d() == 123107); } } } ./ldc-1.42.0-src/tests/dynamiccompile/throw.d0000644000175000017500000000136315205374122017657 0ustar fabiofabio // exceptions is broken on windows // win64 issue https://bugs.llvm.org//show_bug.cgi?id=24233 // XFAIL: Windows // // Also, some issue on macOS Arm64 // XFAIL: host_Darwin_AArch64 // RUN: %ldc -enable-dynamic-compile -run %s import std.exception; import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile void foo() { throw new Exception("foo"); } @dynamicCompile int bar() { try { throw new Exception("foo"); } catch(Exception e) { return 42; } return 0; } @dynamicCompile int baz() { try { foo(); } catch(Exception e) { return 42; } return 0; } void main(string[] args) { compileDynamicCode(); assert(collectExceptionMsg(foo()) == "foo"); assert(42 == bar()); assert(42 == baz()); } ./ldc-1.42.0-src/tests/dynamiccompile/bind_nested_opt.d0000644000175000017500000000265415205374122021660 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.array; import std.stdio; import std.string; import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile { int foo(int delegate() a, int delegate() b) { return a() + b(); } int bar(int delegate() a, int delegate() b) { return a() + b(); } int getVal(int val) { return val; } } void main(string[] args) { auto dump = appender!string(); CompilerSettings settings; settings.optLevel = 3; settings.dumpHandler = (DumpStage stage, in char[] str) { if (DumpStage.FinalAsm == stage || DumpStage.MergedModule == stage || DumpStage.OptimizedModule == stage) { write(str); dump.put(str); } }; writeln("==========================================="); compileDynamicCode(settings); writeln(); writeln("==========================================="); stdout.flush(); auto v1 = ldc.dynamic_compile.bind(&getVal, 1001); auto v2 = ldc.dynamic_compile.bind(&getVal, 1002); auto v3 = ldc.dynamic_compile.bind(&getVal, 1003); auto d1 = v1.toDelegate(); auto d2 = v2.toDelegate(); auto d3 = v3.toDelegate(); auto f1 = ldc.dynamic_compile.bind(&foo, d1, d2); auto d4 = f1.toDelegate(); auto f2 = ldc.dynamic_compile.bind(&bar, d3, d4); compileDynamicCode(settings); assert(2003 == f1()); assert(3006 == f2()); assert(indexOf(dump.data, "2003") != -1); assert(indexOf(dump.data, "3006") != -1); } ./ldc-1.42.0-src/tests/dynamiccompile/classes.d0000644000175000017500000000066315205374122020153 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import ldc.attributes; import ldc.dynamic_compile; interface IFoo { int foo(); } class Foo : IFoo { int val = 0; @dynamicCompile int foo() { return val; } } void main(string[] args) { auto f1 = new Foo; auto f2 = cast(IFoo)f1; auto fun = &f1.foo; f1.val = 42; compileDynamicCode(); assert(42 == f1.foo()); assert(42 == f2.foo()); assert(42 == fun()); } ./ldc-1.42.0-src/tests/dynamiccompile/options.d0000644000175000017500000000202315205374122020201 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.stdio; import std.array; import std.string; import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile int foo() { int* i = new int; *i = 42; return *i; } void main(string[] args) { foreach (bool add_opt; [false, true]) { auto dump = appender!string(); CompilerSettings settings; settings.optLevel = 3; settings.dumpHandler = (DumpStage stage, in char[] str) { if (DumpStage.OptimizedModule == stage) { write(str); dump.put(str); } }; writeln("==========================================="); if (add_opt) { auto res = setDynamicCompilerOptions(["-disable-gc2stack"]); assert(res); } compileDynamicCode(settings); writeln(); writeln("==========================================="); stdout.flush(); if (add_opt) { assert(count(dump.data, "_d_allocmemoryT") > 0); } else { assert(count(dump.data, "_d_allocmemoryT") == 0); } } } ./ldc-1.42.0-src/tests/dynamiccompile/bind_opt.d0000644000175000017500000000367515205374122020322 0ustar fabiofabio// RUN: %ldc -enable-dynamic-compile -run %s import std.array; import std.stdio; import std.string; import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile int foo(int a, int b, int c) { return a + b * 10 + c * 100; } struct Foo { int i; int j; } struct Bar { Foo f; int k; @dynamicCompile int get(int val) { return f.i + f.j * 10 + k * 100 + val * 1000; } } @dynamicCompile int bar(Bar b) { return b.f.i + b.f.j * 10 + b.k * 100; } @dynamicCompileEmit int zzz(int a, int b, int c) { return a + b * 10 + c * 100; } @dynamicCompileEmit int baz(int[4] a) { return a[0] + a[1] * 10 + a[2] * 100 + a[3] * 1000; } void main(string[] args) { auto dump = appender!string(); CompilerSettings settings; settings.optLevel = 3; settings.dumpHandler = (DumpStage stage, in char[] str) { if (DumpStage.FinalAsm == stage) { write(str); dump.put(str); } }; writeln("==========================================="); compileDynamicCode(settings); writeln(); writeln("==========================================="); stdout.flush(); auto elem = Bar(Foo(1,3),5); int[4] arr = [2,6,8,9]; auto f = ldc.dynamic_compile.bind(&foo, 1, 2, 3); auto b = ldc.dynamic_compile.bind(&bar, Bar(Foo(4,5),6)); auto z = ldc.dynamic_compile.bind(&foo, 7, 8, 9); auto e = ldc.dynamic_compile.bind(&elem.get, 7); auto a = ldc.dynamic_compile.bind(&baz, arr); compileDynamicCode(settings); assert(321 == f()); assert(654 == b()); assert(987 == z()); assert(7531 == e()); version (Win64) { // TODO: fix https://github.com/ldc-developers/ldc/issues/3695 } else { assert(9862 == a()); } assert(indexOf(dump.data, "321") != -1); assert(indexOf(dump.data, "654") != -1); assert(indexOf(dump.data, "987") != -1); //assert(indexOf(dump.data, "7531") != -1); // TODO: doesn't properly optimized yet version (Win64) { /* ditto */ } else assert(indexOf(dump.data, "9862") != -1); } ./ldc-1.42.0-src/tests/dynamiccompile/multiple_modules.d0000644000175000017500000000122515205374122022074 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -I%S %s %S/inputs/module1.d %S/inputs/module2.d %S/inputs/module3.d -run // RUN: %ldc -enable-dynamic-compile -singleobj -I%S %s %S/inputs/module1.d %S/inputs/module2.d %S/inputs/module3.d -run import ldc.attributes; import ldc.dynamic_compile; import inputs.module1; import inputs.module2; @dynamicCompile int foo() { return inputs.module1.get() + inputs.module2.get(); } int bar() { return inputs.module1.get() + inputs.module2.get(); } void main(string[] args) { compileDynamicCode(); assert(10 == inputs.module1.get()); assert(11 == inputs.module2.get()); assert(21 == foo()); assert(21 == bar()); } ./ldc-1.42.0-src/tests/dynamiccompile/recursive_call.d0000644000175000017500000000042115205374122021510 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile int foo(int i) { if (i > 0) { return foo(i - 1) + 1; } return 0; } void main(string[] args) { compileDynamicCode(); assert(15 == foo(15)); } ./ldc-1.42.0-src/tests/dynamiccompile/compiler_context_parallel.d0000644000175000017500000000133615205374122023746 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.parallelism; import std.range; import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile { int foo(int a, int b, int c) { return a + b + c; } int bar(int a, int b, int c) { return a + b + c; } } void main(string[] args) { foreach (i; parallel(iota(16))) { auto context = createCompilerContext(); assert(context !is null); scope(exit) destroyCompilerContext(context); auto f = ldc.dynamic_compile.bind(context, &foo, 1,2,3); auto b = ldc.dynamic_compile.bind(context, &bar, 4,5,6); CompilerSettings settings; settings.optLevel = 3; compileDynamicCode(context, settings); assert(6 == f()); assert(15 == b()); } } ./ldc-1.42.0-src/tests/dynamiccompile/simple.d0000644000175000017500000000171115205374122020002 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.stdio; import ldc.attributes; import ldc.dynamic_compile; version(LDC_DynamicCompilation) { } else { static assert(false, "LDC_DynamicCompilation is not defined"); } @dynamicCompile int foo() { return 5; } @dynamicCompile int bar() { return foo() + 7; } @dynamicCompile void baz() { // has regressed with Phobos v2.108, dragging in unsupported inline asm //writeln("baz"); } @dynamicCompile int bzz(int a, int b) { return a + b; } void main(string[] args) { void run(CompilerSettings settings) { compileDynamicCode(settings); assert(5 == foo()); assert(12 == bar()); baz(); int function() fptr = &bar; assert(12 == fptr()); assert(15 == bzz(7, 8)); } foreach(i;0..4) { CompilerSettings settings; settings.optLevel = i; run(settings); } foreach(i;0..3) { CompilerSettings settings; settings.sizeLevel = i; run(settings); } } ./ldc-1.42.0-src/tests/dynamiccompile/thread_local.d0000644000175000017500000000140315205374122021130 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import core.thread; import ldc.attributes; import ldc.dynamic_compile; ThreadID threadId; //thread local @dynamicCompile void set_val() { threadId = Thread.getThis().id(); } @dynamicCompile ThreadID get_val() { return threadId; } @dynamicCompile ThreadID* get_ptr() { auto ptr = &threadId; return ptr; } void bar() { set_val(); auto id = Thread.getThis().id(); assert(id == threadId); assert(id == get_val()); assert(&threadId is get_ptr()); assert(id == *get_ptr()); } void main(string[] args) { compileDynamicCode(); bar(); Thread[] threads = [new Thread(&bar),new Thread(&bar),new Thread(&bar)]; foreach(t;threads[]) { t.start(); } foreach(t;threads[]) { t.join(); } } ./ldc-1.42.0-src/tests/dynamiccompile/globals.d0000644000175000017500000000102415205374122020131 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import ldc.attributes; import ldc.dynamic_compile; @dynamicCompileConst __gshared int foovar = 0; @dynamicCompile int foo() { return foovar; } @dynamicCompileConst __gshared int barvar = 5; @dynamicCompile int bar() { return barvar; } void main(string[] args) { compileDynamicCode(); assert(0 == foo()); assert(5 == bar()); foovar = 42; barvar = 43; assert(0 == foo()); assert(5 == bar()); compileDynamicCode(); assert(42 == foo()); assert(43 == bar()); } ./ldc-1.42.0-src/tests/dynamiccompile/multiple_modules_rtconst.d0000644000175000017500000000073515205374122023655 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -I%S %s %S/inputs/rtconst_owner.d %S/inputs/rtconst_user.d -run // RUN: %ldc -enable-dynamic-compile -singleobj -I%S %s %S/inputs/rtconst_owner.d %S/inputs/rtconst_user.d -run import ldc.dynamic_compile; import inputs.rtconst_owner; import inputs.rtconst_user; void main(string[] args) { compileDynamicCode(); assert(11 == getValue()); value = 2; assert(11 == getValue()); compileDynamicCode(); assert(12 == getValue()); } ./ldc-1.42.0-src/tests/dynamiccompile/struct_init.d0000644000175000017500000000212015205374122021053 0ustar fabiofabio // llvm generates overlapped simd reads and writes to init these // structs but fails on win32 for some reason // XFAIL: Windows_x86 // RUN: %ldc -enable-dynamic-compile -run %s import ldc.dynamic_compile; import ldc.attributes; import std.stdio; struct Foo1 { int[4 + 2] arr = [ 0 , 1, 2, 3, 4, 5]; } struct Foo2 { int[8 + 4] arr = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11]; } struct Foo3 { int[16 + 8] arr = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11, 12,13,14,15,16,17,18,19,20,21,22,23]; } Foo1 foo1() { auto f = Foo1(); return f; } Foo2 foo2() { auto f = Foo2(); return f; } Foo3 foo3() { auto f = Foo3(); return f; } @dynamicCompile Foo1 bar1() { auto f = Foo1(); return f; } @dynamicCompile Foo2 bar2() { auto f = Foo2(); return f; } @dynamicCompile Foo3 bar3() { auto f = Foo3(); return f; } void main(string[] args) { compileDynamicCode(); stdout.flush(); auto f1 = foo1(); auto f2 = foo2(); auto f3 = foo3(); auto b1 = bar1(); auto b2 = bar2(); auto b3 = bar3(); assert(f1 == b1); assert(f2 == b2); assert(f3 == b3); } ./ldc-1.42.0-src/tests/dynamiccompile/globals_types.d0000644000175000017500000000370015205374122021360 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import ldc.attributes; import ldc.dynamic_compile; struct Foo { int i; float f; void* p; int[3] a; int[] da; } struct Bar { Foo f; Foo* pf; Bar* pb; } @dynamicCompileConst { __gshared byte i8 = 42 + 1; __gshared short i16 = 42 + 2; __gshared int i32 = 42 + 3; __gshared long i64 = 42 + 4; __gshared ubyte u8 = 42 + 5; __gshared ushort u16 = 42 + 6; __gshared uint u32 = 42 + 7; __gshared ulong u64 = 42 + 8; __gshared float f32 = 42 + 9; __gshared double f64 = 42 + 10; __gshared void* ptr = cast(void*)(42 + 11); __gshared int[3] arr = [42 + 12,42 + 13,42 + 14]; __gshared int[] darr = [42 + 15,42 + 16,42 + 17,42 + 18]; __gshared Foo foo = Foo(42 + 19,42 + 20,cast(void*)(42 + 21),[42 + 22,42 + 23,42 + 24],[42 + 25,42 + 26,42 + 27,42 + 28]); __gshared Bar bar = Bar(Foo(42 + 19,42 + 20,cast(void*)(42 + 21),[42 + 22,42 + 23,42 + 24],[42 + 25,42 + 26,42 + 27,42 + 28]), cast(Foo*)(42 + 29), cast(Bar*)(42 + 30)); } @dynamicCompile { byte foo_i8() { return i8; } short foo_i16() { return i16; } int foo_i32() { return i32; } long foo_i64() { return i64; } ubyte foo_u8() { return u8; } ushort foo_u16() { return u16; } uint foo_u32() { return u32; } ulong foo_u64() { return u64; } float foo_f32() { return f32; } double foo_f64() { return f64; } void* foo_ptr() { return ptr; } int[3] foo_arr() { return arr; } int[] foo_darr() { return darr; } Foo foo_foo() { return foo; } Bar foo_bar() { return bar; } } void test(T,F)(ref T val, F fun) { assert(val == fun()); } void main(string[] args) { compileDynamicCode(); test(i8, &foo_i8); test(i16, &foo_i16); test(i32, &foo_i32); test(i64, &foo_i64); test(u8, &foo_u8); test(u16, &foo_u16); test(u32, &foo_u32); test(u64, &foo_u64); test(f32, &foo_f32); test(f64, &foo_f64); assert(ptr is foo_ptr()); test(arr, &foo_arr); test(darr, &foo_darr); test(foo, &foo_foo); test(bar, &foo_bar); } ./ldc-1.42.0-src/tests/dynamiccompile/bind_func_opt.d0000644000175000017500000000265315205374122021330 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.array; import std.stdio; import std.string; import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile { int foo(int function() a, int function() b, int function() c) { return a() + b() + c(); } int bar(int delegate() a, int delegate() b, int delegate() c) { return a() + b() + c(); } int get1001() { return 1001; } int get1002() { return 1002; } int get1003() { return 1003; } } void main(string[] args) { auto dump = appender!string(); CompilerSettings settings; settings.optLevel = 3; settings.dumpHandler = (DumpStage stage, in char[] str) { if (DumpStage.FinalAsm == stage || DumpStage.OptimizedModule == stage) { write(str); dump.put(str); } }; writeln("==========================================="); compileDynamicCode(settings); writeln(); writeln("==========================================="); stdout.flush(); @dynamicCompile int get1001d() { return 1001; } @dynamicCompile int get1002d() { return 1002; } @dynamicCompile int get1004d() { return 1004; } auto f = ldc.dynamic_compile.bind(&foo, &get1001, &get1002, &get1003); auto b = ldc.dynamic_compile.bind(&bar, &get1001d, &get1002d, &get1004d); compileDynamicCode(settings); assert(3006 == f()); assert(3007 == b()); assert(indexOf(dump.data, "3006") != -1); assert(indexOf(dump.data, "3007") != -1); } ./ldc-1.42.0-src/tests/dynamiccompile/lambdas.d0000644000175000017500000000056215205374122020117 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import ldc.attributes; import ldc.dynamic_compile; void main(string[] args) { @dynamicCompile int foo() { return 42; } int val1 = 5; int val2 = 3; @dynamicCompile int bar() { val2 += 5; return val1; } compileDynamicCode(); assert(42 == foo()); assert(5 == bar()); assert(8 == val2); } ./ldc-1.42.0-src/tests/dynamiccompile/array.d0000644000175000017500000000106715205374122017633 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.exception; import ldc.attributes; import ldc.dynamic_compile; __gshared int[555] arr1 = 42; __gshared int[555] arr2 = 42; @dynamicCompile int foo() { int[555] a = arr1; return a[3]; } @dynamicCompile int bar() { arr2 = 0; return arr2[3]; } @dynamicCompile int baz() { // Large stack array to force compiler to emit __chkstk call int[4 * 1024] a; return a[3 * 1024]; } void main(string[] args) { compileDynamicCode(); assert(42 == foo()); assert(0 == bar()); assert(0 == baz()); } ./ldc-1.42.0-src/tests/dynamiccompile/jit_module_stripping.d0000644000175000017500000000261215205374122022744 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.stdio; import std.array; import std.string; import ldc.attributes; import ldc.dynamic_compile; __gshared int value = 32; @dynamicCompile int foo() { return 42; } @dynamicCompile int bar() { return foo(); } void fun(int function()) { } @dynamicCompile void baz() { fun(&foo); } @dynamicCompile int bzz() { return value; } class Foo() { @dynamicCompile int foo() { return 43; } } struct UnusedStruct1 { int i; int j; }; struct UnusedStruct2 { UnusedStruct1 f; int k; } void unusedfunc1(UnusedStruct2) { } void unusedfunc2(int function()) { } __gshared int unusedvalue = 32; void main(string[] args) { auto dump = appender!string(); CompilerSettings settings; settings.dumpHandler = (DumpStage stage, in char[] str) { if (DumpStage.OriginalModule == stage) { write(str); dump.put(str); } }; writeln("==========================================="); compileDynamicCode(settings); writeln("==========================================="); assert(0 == count(dump.data, "thunk")); assert(0 == count(dump.data, "unusedvalue")); assert(0 == count(dump.data, "unusedfunc1")); assert(0 == count(dump.data, "unusedfunc2")); // TODO: these symbols is pulled by llvm.ldc.typeinfo //assert(0 == count(dump.data, "UnusedStruct1")); //assert(0 == count(dump.data, "UnusedStruct2")); } ./ldc-1.42.0-src/tests/dynamiccompile/options_invalid.d0000644000175000017500000000061315205374122021712 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.array; import std.string; import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile int foo() { return 42; } void main(string[] args) { auto dump = appender!string(); auto res = setDynamicCompilerOptions(["-invalid_option"], (in char[] str) { dump.put(str); }); assert(!res); assert(dump.data.length > 0); } ./ldc-1.42.0-src/tests/dynamiccompile/tls_workaround_opt.d0000644000175000017500000000061015205374122022445 0ustar fabiofabio // tls without workaround broken on all platforms // just test ldc accept this option // RUN: %ldc -enable-dynamic-compile -dynamic-compile-tls-workaround=0 -run %s // RUN: %ldc -enable-dynamic-compile -dynamic-compile-tls-workaround=1 -run %s import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile void foo() { } void main(string[] args) { compileDynamicCode(); foo(); } ./ldc-1.42.0-src/tests/dynamiccompile/library.d0000644000175000017500000000164615205374122020164 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -lib -I%S %S/inputs/module1.d %S/inputs/module2.d %S/inputs/module3.d -of=%t1%lib // RUN: %ldc -enable-dynamic-compile -O1 -lib -I%S %S/inputs/module1.d -of=%t2%lib // RUN: %ldc -enable-dynamic-compile -O2 -lib -I%S %S/inputs/module2.d -of=%t3%lib // RUN: %ldc -enable-dynamic-compile -O3 -lib -I%S %S/inputs/module3.d -of=%t4%lib // RUN: %ldc -enable-dynamic-compile -I%S %s %t1%lib -run // RUN: %ldc -enable-dynamic-compile -Os -I%S %s %t2%lib %t3%lib %t4%lib -run import ldc.attributes; import ldc.dynamic_compile; import inputs.module1; import inputs.module2; @dynamicCompile int foo() { return inputs.module1.get() + inputs.module2.get(); } int bar() { return inputs.module1.get() + inputs.module2.get(); } void main(string[] args) { compileDynamicCode(); assert(10 == inputs.module1.get()); assert(11 == inputs.module2.get()); assert(21 == foo()); assert(21 == bar()); } ./ldc-1.42.0-src/tests/dynamiccompile/dump_handler.d0000644000175000017500000000200515205374122021150 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile int foo() { return 5; } @dynamicCompile int bar(int i = 5) { if(i > 0) { return bar(i - 1) + 1; } return 1; } @dynamicCompile int baz() { int i = 0; foreach(j;1..4) { i += j * j; } return i; } void main(string[] args) { bool[4] dumpHandlerCalled = false; bool progressHandlerCalled = false; CompilerSettings settings; settings.dumpHandler = (DumpStage stage, in char[] str) { dumpHandlerCalled[stage] = true; }; settings.progressHandler = (in char[] desc, in char[] object) { progressHandlerCalled = true; }; compileDynamicCode(settings); assert(5 == foo()); assert(6 == bar()); assert(14 == baz()); assert(dumpHandlerCalled[DumpStage.OriginalModule]); assert(dumpHandlerCalled[DumpStage.MergedModule]); assert(dumpHandlerCalled[DumpStage.OptimizedModule]); assert(dumpHandlerCalled[DumpStage.FinalAsm]); assert(progressHandlerCalled); } ./ldc-1.42.0-src/tests/dynamiccompile/simd_simple_opt.d0000644000175000017500000000353615205374122021707 0ustar fabiofabio// RUN: %ldc -enable-dynamic-compile -run %s import std.stdio; import std.array; import std.string; import ldc.simd; import ldc.attributes; import ldc.dynamic_compile; import core.simd; @dynamicCompile ubyte[32] hex_encode_16b(ubyte[16] binary) { const ubyte ascii_a = 'a' - 9 - 1; ubyte16 invec = loadUnaligned!ubyte16(binary.ptr); ubyte[32] hex; ubyte16 masked1 = invec & 0xF; ubyte16 masked2 = (invec >> 4) & 0xF; ubyte16 cmpmask1 = masked1 > 9; ubyte16 cmpmask2 = masked2 > 9; ubyte16 masked1_r = ((cmpmask1 & ascii_a) | (~cmpmask1 & '0')) + masked1; ubyte16 masked2_r = ((cmpmask2 & ascii_a) | (~cmpmask2 & '0')) + masked2; ubyte16 res1 = shufflevector!(ubyte16, 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23)( masked2_r, masked1_r); ubyte16 res2 = shufflevector!(ubyte16, 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31)( masked2_r, masked1_r); storeUnaligned!ubyte16(res1, hex.ptr); storeUnaligned!ubyte16(res2, hex.ptr + 16); return hex; } void main(string[] args) { const ubyte[16] binary = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 0xff, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf ]; const ubyte[32] expected = [ '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', 'f', 'f', '0', 'a', '0', 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f' ]; CompilerSettings settings; auto dump = appender!string(); settings.dumpHandler = (DumpStage stage, in char[] str) { if (DumpStage.FinalAsm == stage) { write(str); dump.put(str); } }; settings.optLevel = 3; auto f = ldc.dynamic_compile.bind(&hex_encode_16b, binary); compileDynamicCode(settings); ubyte[32] hex = hex_encode_16b(binary); assert(hex == expected); assert(f() == expected); } ./ldc-1.42.0-src/tests/dynamiccompile/asm_output.d0000644000175000017500000000245115205374122020713 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import std.stdio; import std.array; import std.string; import ldc.attributes; import ldc.dynamic_compile; __gshared int value = 32; @dynamicCompile int foo() { return value; } @dynamicCompile int bar() { return 7; } @dynamicCompile int baz() { return 8; } void main(string[] args) { auto dump = appender!string(); CompilerSettings settings; settings.dumpHandler = (DumpStage stage, in char[] str) { if (DumpStage.FinalAsm == stage) { write(str); dump.put(str); } }; writeln("==========================================="); compileDynamicCode(settings); writeln(); writeln("==========================================="); stdout.flush(); // Check function and variables names in asm assert(1 == count(dump.data, foo.mangleof)); assert(1 == count(dump.data, bar.mangleof)); assert(1 == count(dump.data, baz.mangleof)); assert(count(dump.data, value.mangleof) > 0); version (ARM) enum literalPrefix = "#"; version (AArch64) enum literalPrefix = "#"; version (X86) enum literalPrefix = "$"; version (X86_64) enum literalPrefix = "$"; static if (is(typeof(literalPrefix))) { assert(1 == count(dump.data, literalPrefix ~ "7")); assert(1 == count(dump.data, literalPrefix ~ "8")); } } ./ldc-1.42.0-src/tests/dynamiccompile/compiler_context.d0000644000175000017500000000163715205374122022076 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import ldc.attributes; import ldc.dynamic_compile; @dynamicCompile { int foo(int a, int b, int c) { return a + b + c; } int bar(int a, int b, int c) { return a + b + c; } } void main(string[] args) { auto context1 = createCompilerContext(); assert(context1 !is null); scope(exit) destroyCompilerContext(context1); auto context2 = createCompilerContext(); assert(context2 !is null); scope(exit) destroyCompilerContext(context2); auto f = ldc.dynamic_compile.bind(context1, &foo, 1,2,3); auto b = ldc.dynamic_compile.bind(context2, &bar, 4,5,6); CompilerSettings settings; settings.optLevel = 3; compileDynamicCode(context1, settings); assert(f.isCallable()); assert(!b.isCallable()); assert(6 == f()); compileDynamicCode(context2, settings); assert(f.isCallable()); assert(b.isCallable()); assert(6 == f()); assert(15 == b()); } ./ldc-1.42.0-src/tests/dynamiccompile/empty_jit_modules.d0000644000175000017500000000020115205374122022236 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import ldc.dynamic_compile; void main(string[] args) { compileDynamicCode(); } ./ldc-1.42.0-src/tests/dynamiccompile/params_ctors.d0000644000175000017500000000131515205374122021206 0ustar fabiofabio // RUN: %ldc -enable-dynamic-compile -run %s import ldc.attributes; import ldc.dynamic_compile; __gshared int ctorsCalled = 0; __gshared int dtorsCalled = 0; __gshared int fooCalled = 0; struct Foo { this(this) { ++ctorsCalled; } ~this() { ++dtorsCalled; } void foo() { ++fooCalled; } } void func1(Foo f) { f.foo(); } @dynamicCompile void func2(Foo f) { f.foo(); } void main(string[] args) { compileDynamicCode(); Foo f; func1(f); assert(1 == ctorsCalled); assert(1 == dtorsCalled); assert(1 == fooCalled); ctorsCalled = 0; dtorsCalled = 0; fooCalled = 0; func2(f); assert(1 == ctorsCalled); assert(1 == dtorsCalled); assert(1 == fooCalled); } ./ldc-1.42.0-src/tests/sanitizers/0000755000175000017500000000000015205374122015542 5ustar fabiofabio./ldc-1.42.0-src/tests/sanitizers/inputs/0000755000175000017500000000000015205374122017064 5ustar fabiofabio./ldc-1.42.0-src/tests/sanitizers/inputs/fsanitize_blacklist.txt0000644000175000017500000000070015205374122023646 0ustar fabiofabio# Blacklist for the sanitizers. Turns off instrumentation of particular # functions or sources. Use with care. You may set location of blacklist # at compile-time using -fsanitize-blacklist= flag. # Example usage: # fun:*bad_function_name* # src:file_with_tricky_code.cc # global:*global_with_bad_access_or_initialization* # global:*global_with_initialization_issues*=init # type:*Namespace::ClassName*=init fun:blacklisted fun:*black_set* ./ldc-1.42.0-src/tests/sanitizers/inputs/fsanitize_blacklist_file.txt0000644000175000017500000000004115205374122024643 0ustar fabiofabiosrc:*fsanitize_blacklist_file2.d ./ldc-1.42.0-src/tests/sanitizers/inputs/fsanitize_blacklist2.txt0000644000175000017500000000003715205374122023733 0ustar fabiofabiofun:_D*__T6ABCDEFTiZQk6method* ./ldc-1.42.0-src/tests/sanitizers/asan_fakestack_GC.d0000644000175000017500000000664215205374122021226 0ustar fabiofabio// AddressSanitizer: Test that the GC properly scans ASan's fakestack when enabled. Requires runtime support. // FIXME: broke with v2.100.0 // REQUIRES: ASan, RTSupportsSanitizers, DISABLE_HACK // Test without and with fake stack enabled. // Note on debug lineinfo: on macOS the executable contains a link back to the // object files for debug info. Therefore the order of text execution is important, // i.e. we should finish all testing on one compiled executable before recompiling // with different conditional compilation settings (because it will overwrite the // object files from the previous compilation). // RUN: %ldc %s -of=%t1%exe && %t1%exe -O // RUN: %ldc -g -fsanitize=address %s -of=%t_asan%exe -O // RUN: %t_asan%exe // RUN: %env_asan_opts=detect_stack_use_after_return=true %t_asan%exe 2>&1 | FileCheck %s import core.memory; import core.thread; import std.stdio; import ldc.attributes; @weak pragma(inline, false) void doNotOptimizeParameter(T)(ref T) { } void test_nulling_triggers_collection() { void*[100] a; // Large enough so it will be on fakestack heap (not inlined in local stack frame) GC.collect(); auto initialSize = GC.stats.usedSize; //writeln(__LINE__, " ", GC.stats.usedSize); a[50] = GC.malloc(100); //writeln(__LINE__, " ", GC.stats.usedSize); auto allocatedSize = GC.stats.usedSize - initialSize; assert(allocatedSize >= 100); a[50] = null; doNotOptimizeParameter(a); //writeln(__LINE__, " ", GC.stats.usedSize); GC.collect(); //writeln(__LINE__, " ", GC.stats.usedSize); assert(GC.stats.usedSize == initialSize); doNotOptimizeParameter(a); } void test_non_null_does_not_trigger_collection(uint index) { void*[100] a; // Large enough so it will be on fakestack heap (not inlined in local stack frame) //writefln("Address range a, line %u: 0x%x - 0x%x", __LINE__, cast(size_t)&a[0], cast(size_t)&a[$-1]); GC.collect(); auto initialSize = GC.stats.usedSize; //writeln("GC.stats.usedSize, line ", __LINE__, ": ", GC.stats.usedSize); a[index] = GC.malloc(100); //writeln("GC.stats.usedSize, line ", __LINE__, ": ", GC.stats.usedSize); //writefln("Address a[index], line %u: 0x%x", __LINE__, cast(size_t) a[index]); auto allocatedSize = GC.stats.usedSize - initialSize; assert(allocatedSize >= 100); doNotOptimizeParameter(a); //writeln("GC.stats.usedSize, line ", __LINE__, ": ", GC.stats.usedSize); GC.collect(); writeln("GC.stats.usedSize, line ", __LINE__, ": ", GC.stats.usedSize); assert(GC.stats.usedSize == initialSize + allocatedSize); // This fails if GC scanning does not support ASan's fakestack. GC.collect(); doNotOptimizeParameter(a); } void main() { test_nulling_triggers_collection(); test_non_null_does_not_trigger_collection(0); test_non_null_does_not_trigger_collection(50); test_non_null_does_not_trigger_collection(99); // Also test threading auto t = new Thread({ test_non_null_does_not_trigger_collection(0); test_non_null_does_not_trigger_collection(50); test_non_null_does_not_trigger_collection(99); }); t.start(); t.join(); } // Make sure that the function calls did indeed happen. // CHECK: GC.stats.usedSize // CHECK: GC.stats.usedSize // CHECK: GC.stats.usedSize // CHECK: GC.stats.usedSize // CHECK: GC.stats.usedSize // CHECK: GC.stats.usedSize ./ldc-1.42.0-src/tests/sanitizers/tsan_noerror.d0000644000175000017500000000024415205374122020422 0ustar fabiofabio// Test that a simple program passes ThreadSanitizer without error // REQUIRES: TSan // RUN: %ldc -fsanitize=thread %s -of=%t%exe // RUN: %t%exe void main() { } ./ldc-1.42.0-src/tests/sanitizers/asan_stackoverflow.d0000644000175000017500000000127215205374122021604 0ustar fabiofabio// Test stack overflow detection with AddressSanitizer // REQUIRES: ASan // RUN: %ldc -g -fsanitize=address %s -of=%t%exe // RUN: not %t%exe 2>&1 | FileCheck %s void foo(int* arr) { // CHECK: stack-buffer-overflow // CHECK: WRITE of size 4 // CHECK-NEXT: #0 {{.*}} in {{.*foo.*}} {{.*}}asan_stackoverflow.d:[[@LINE+1]] arr[10] = 1; } // CHECK: Address {{.*}} is located in stack of // CHECK-NEXT: #0 {{.*}} in {{.*main.*}} {{.*}}asan_stackoverflow.d:[[@LINE+1]] void main() { // Test for the name of the variable that is overflown. // CHECK: 'aiaiaiaiaiaiai'{{.*}} <== {{.*}} overflows this variable int[10] aiaiaiaiaiaiai; int b; foo(&aiaiaiaiaiaiai[0]); } ./ldc-1.42.0-src/tests/sanitizers/asan_noerror.d0000644000175000017500000000025015205374122020374 0ustar fabiofabio// Test that a simple progam passes AddressSanitizer without error // REQUIRES: ASan // RUN: %ldc -g -fsanitize=address %s -of=%t%exe // RUN: %t%exe void main() { } ./ldc-1.42.0-src/tests/sanitizers/fsanitize_blacklist_file2.d0000644000175000017500000000061615205374122023017 0ustar fabiofabio// Test sanitizer blacklist file functionality // This file is blacklisted (file1 is not) // RUN: %ldc -c -output-ll -fsanitize=address \ // RUN: -fsanitize-blacklist=%S/inputs/fsanitize_blacklist_file.txt \ // RUN: -of=%t.ll %s && FileCheck %s < %t.ll // CHECK-NOT: ; Function Attrs:{{.*}} sanitize_address // CHECK: define{{.*}} void {{.*}}9foofoofoo void foofoofoo(int* i) { *i = 1; } ./ldc-1.42.0-src/tests/sanitizers/msan_uninitialized.d0000644000175000017500000000111215205374122021570 0ustar fabiofabio// Test unitialized data access with MemorySanitizer // REQUIRES: MSan // RUN: %ldc -g -fsanitize=memory -run %s // RUN: %ldc -g -fsanitize=memory -fsanitize-memory-track-origins=2 -d-version=BUG %s -of=%t%exe // RUN: not %t%exe 2>&1 | FileCheck %s // CHECK: MemorySanitizer: use-of-uninitialized-value // CHECK: Uninitialized value was created by an allocation of {{.*}} in the stack frame // CHECK-NEXT: #0 {{.* in (_Dmain|D main) .*}}msan_uninitialized.d:[[@LINE+1]] int main() { version (BUG) int x = void; else int x; int* p = &x; return *p; } ./ldc-1.42.0-src/tests/sanitizers/asan_recover_stackoverflow.d0000644000175000017500000000214315205374122023327 0ustar fabiofabio// Test recovery with AddressSanitizer // REQUIRES: ASan // RUN: %ldc -g -fsanitize=address -fsanitize-recover=address %s -of=%t%exe // RUN: not %t%exe 2>&1 | FileCheck %s // RUN: %env_asan_opts=halt_on_error=true not %t%exe 2>&1 | FileCheck %s // RUN: %env_asan_opts=halt_on_error=false %t%exe 2>&1 | FileCheck %s // RUN: %ldc -g -fsanitize=address -fsanitize-recover=all %s -of=%t%exe // RUN: not %t%exe 2>&1 | FileCheck %s // RUN: %env_asan_opts=halt_on_error=true not %t%exe 2>&1 | FileCheck %s // RUN: %env_asan_opts=halt_on_error=false %t%exe 2>&1 | FileCheck %s void foo(int* arr) { // CHECK: stack-buffer-overflow // CHECK: WRITE of size 4 // CHECK-NEXT: #0 {{.*}} in {{.*foo.*}} {{.*}}asan_recover_stackoverflow.d:[[@LINE+1]] arr[10] = 1; } // CHECK: Address {{.*}} is located in stack of // CHECK-NEXT: #0 {{.*}} in {{.*main.*}} {{.*}}asan_recover_stackoverflow.d:[[@LINE+1]] void main() { // Test for the name of the variable that is overflown. // CHECK: 'aiaiaiaiaiaiai'{{.*}} <== {{.*}} overflows this variable int[10] aiaiaiaiaiaiai; int b; foo(&aiaiaiaiaiaiai[0]); } ./ldc-1.42.0-src/tests/sanitizers/link_fuzzer.d0000644000175000017500000000100715205374122020247 0ustar fabiofabio// Test linking C++ stdlib (or not) with -fsanitize=fuzzer // REQUIRES: Fuzzer // UNSUPPORTED: Windows // RUN: %ldc -v -fsanitize=fuzzer %s | FileCheck %s // "lib(ldc|clang)_rt.fuzzer.*.a" since LLVM 6.0 // CHECK: {{_rt\.fuzzer.*\.a}} // CHECK-SAME: -l{{(std)?}}c++ // RUN: %ldc -v -fsanitize=fuzzer -link-no-cpp %s > %t_nocpp.log || true // RUN: FileCheck %s --check-prefix=NOCPP < %t_nocpp.log // NOCPP-NOT: -l{{(std)?}}c++ extern (C) int LLVMFuzzerTestOneInput(const(ubyte*) data, size_t size) { return 0; } ./ldc-1.42.0-src/tests/sanitizers/asan_use_after_scope.d0000644000175000017500000000116415205374122022061 0ustar fabiofabio// REQUIRES: ASan // RUN: %ldc -femit-local-var-lifetime -g -fsanitize=address %s -of=%t%exe // RUN: not %t%exe 2>&1 | FileCheck %s // CHECK: ERROR: AddressSanitizer: stack-use-after-scope // CHECK-NEXT: WRITE of size 4 void useAfterScope() { int* p; { int x = 0; p = &x; // cannot statically disallow this because *p = 1; // this is a valid use of things } // CHECK-NEXT: #0 {{.*}} in {{.*}}asan_use_after_scope.d:[[@LINE+1]] *p = 5; // but then this can happen... stack use after scope bug! } void main() { // CHECK-NEXT: #1 {{.*}} in {{.*}}asan_use_after_scope.d:[[@LINE+1]] useAfterScope(); } ./ldc-1.42.0-src/tests/sanitizers/fsanitize_coverage.d0000644000175000017500000000241315205374122021556 0ustar fabiofabio// Test basic coverage sanitizer functionality // RUN: %ldc -c -output-ll -fsanitize-coverage=trace-pc-guard -of=%t.ll %s && FileCheck %s --check-prefix=PCGUARD < %t.ll // RUN: %ldc -c -output-ll -fsanitize-coverage=trace-pc-guard,trace-cmp -of=%t.cmp.ll %s && FileCheck %s --check-prefix=PCCMP < %t.cmp.ll // RUN: %ldc -c -output-ll -fsanitize-coverage=trace-pc-guard,func -of=%t.func.ll %s && FileCheck %s --check-prefix=PCFUNC < %t.func.ll // PCGUARD-LABEL: define{{.*}} @{{.*}}FuzzMe // PCCMP-LABEL: define{{.*}} @{{.*}}FuzzMe // PCFUNC-LABEL: define{{.*}} @{{.*}}FuzzMe bool FuzzMe(const ubyte* data, size_t dataSize) { // PCGUARD: call {{.*}}_sanitizer_cov_trace_pc_guard // PCGUARD-NOT: call {{.*}}_sanitizer_cov_trace_{{(const_)?}}cmp // PCGUARD: call {{.*}}_sanitizer_cov_trace_pc_guard // PCGUARD-NOT: call {{.*}}_sanitizer_cov_trace_{{(const_)?}}cmp // PCCMP: call {{.*}}_sanitizer_cov_trace_pc_guard // PCCMP: call {{.*}}_sanitizer_cov_trace_{{(const_)?}}cmp // PCFUNC: call {{.*}}_sanitizer_cov_trace_pc_guard // PCFUNC-NOT: call {{.*}}_sanitizer_cov_trace_pc_guard return dataSize >= 3 && data[0] == 'F' && data[1] == 'U' && data[2] == 'Z' && data[3] == 'Z'; // :‑< // PCFUNC: ret i1 } ./ldc-1.42.0-src/tests/sanitizers/fsanitize_error_diagnostic.d0000644000175000017500000000040215205374122023314 0ustar fabiofabio// Test sanitizer errors on unrecognized values // RUN: not %ldc -c -fsanitize=poiuyt -fsanitize-coverage=aqswdefr %s 2>&1 | FileCheck %s // CHECK-DAG: Unrecognized -fsanitize value 'poiuyt' // CHECK-DAG: Unrecognized -fsanitize-coverage option 'aqswdefr' ./ldc-1.42.0-src/tests/sanitizers/fsanitize_blacklist.d0000644000175000017500000000306715205374122021741 0ustar fabiofabio// Test sanitizer blacklist functionality // RUN: %ldc -c -output-ll -fsanitize=address \ // RUN: -fsanitize-blacklist=%S/inputs/fsanitize_blacklist.txt \ // RUN: -fsanitize-blacklist=%S/inputs/fsanitize_blacklist2.txt \ // RUN: -of=%t.ll %s && FileCheck %s < %t.ll // Don't attempt to load the blacklist when no sanitizer is active // RUN: %ldc -o- -fsanitize-blacklist=%S/thisfilecertainlydoesnotexist %s // CHECK-LABEL: define {{.*}}9foofoofoo // CHECK-SAME: #[[ATTR_WITHASAN:[0-9]+]] void foofoofoo(int* i) { // CHECK: call {{.*}}_asan *i = 1; } // CHECK-LABEL: define {{.*}}blacklisted // CHECK-SAME: #[[ATTR_NOASAN:[0-9]+]] extern (C) void blacklisted(int* i) { // CHECK-NOT: call {{.*}}_asan *i = 1; } // Test blacklisted wildcard // CHECK-LABEL: define {{.*}}10black_set1 // CHECK-SAME: #[[ATTR_NOASAN:[0-9]+]] void black_set1(int* i) { // CHECK-NOT: call {{.*}}_asan *i = 1; } // CHECK-LABEL: define {{.*}}10black_set2 // CHECK-SAME: #[[ATTR_NOASAN:[0-9]+]] void black_set2(int* i) { // CHECK-NOT: call {{.*}}_asan *i = 1; } // Test blacklisting of template class methods class ABCDEF(T) { void method(int* i) { *i = 1; } } // CHECK-LABEL: define {{.*}}__T6ABCDEFTiZQk6method // CHECK-SAME: #[[ATTR_NOASAN:[0-9]+]] ABCDEF!int ofBlacklistedType; // CHECK-LABEL: define {{.*}}__T6ABCDEFTAyaZQm6method // CHECK-SAME: #[[ATTR_WITHASAN:[0-9]+]] ABCDEF!string ofInstrumentedType; //CHECK: attributes #[[ATTR_WITHASAN]] ={{.*}}sanitize_address //CHECK: attributes #[[ATTR_NOASAN]] //CHECK-NOT: sanitize_address //CHECK-SAME: } ./ldc-1.42.0-src/tests/sanitizers/fuzz_asan.d0000644000175000017500000000244415205374122017713 0ustar fabiofabio// Test Fuzz+ASan functionality // REQUIRES: Fuzzer, ASan // See https://github.com/ldc-developers/ldc/pull/4328 for -fsanitize-address-use-after-return=never // RUN: %ldc -g -fsanitize=address,fuzzer -fsanitize-address-use-after-return=never %s -of=%t%exe // RUN: not %t%exe 2>&1 | FileCheck %s bool FuzzMe(ubyte* data, size_t dataSize) { return dataSize >= 3 && data[0] == 'F' && data[1] == 'U' && data[2] == 'Z' && // CHECK: ERROR: AddressSanitizer: stack-buffer-overflow // CHECK-NEXT: READ of size 1 // CHECK-NEXT: #0 {{.*}} in {{.*fuzz_asan6FuzzMe.*}} {{.*}}fuzz_asan.d: // FIXME, debug line info is wrong (Github issue #2090). Once fixed, add [[@LINE+1]] data[dataSize] == 'Z'; // :‑< } extern (C) int LLVMFuzzerTestOneInput(const(ubyte*) data, size_t size) { // D runtime must be initialized, but only once. static bool init = false; if (!init) { import core.runtime : rt_init; rt_init(); init = true; } ubyte[3] stackdata; if (data) { for (auto i = 0; (i < size) && (i < stackdata.length); ++i) stackdata[i] = data[i]; } // CHECK-NEXT: #1 {{.*}} in LLVMFuzzerTestOneInput {{.*}}fuzz_asan.d:[[@LINE+1]] FuzzMe(&stackdata[0], size); return 0; } ./ldc-1.42.0-src/tests/sanitizers/asan_fiber_main.d0000644000175000017500000000402415205374122021004 0ustar fabiofabio// AddressSanitizer: Test stack overflow detection inside a fiber of an array on main's stack. // REQUIRES: ASan, RTSupportsSanitizers // Test without and with fake stack enabled. // Note on debug lineinfo: on macOS the executable contains a link back to the // object files for debug info. Therefore the order of text execution is important, // i.e. we should finish all testing on one compiled executable before recompiling // with different conditional compilation settings (because it will overwrite the // object files from the previous compilation). // RUN: %ldc -g -fsanitize=address %s -of=%t1%exe && not %t1%exe 2>&1 | FileCheck %s // RUN: %env_asan_opts=detect_stack_use_after_return=true not %t1%exe 2>&1 | FileCheck %s --check-prefix=FAKESTACK // RUN: %ldc -g -fsanitize=address %s -of=%t22%exe -d-version=BAD_AFTER_YIELD && not %t22%exe 2>&1 | FileCheck %s // RUN: %env_asan_opts=detect_stack_use_after_return=true not %t22%exe 2>&1 | FileCheck %s --check-prefix=FAKESTACK import core.thread; void foo(int* arr) { version (BAD_AFTER_YIELD) Fiber.yield(); // CHECK: stack-buffer-overflow // CHECK: WRITE of size 4 // CHECK-NEXT: #0 {{.*}} in {{.*foo.*}} {{.*}}asan_fiber_main.d:[[@LINE+1]] arr[10] = 1; // out-of-bounds write } // Without fake stack, ASan only keeps track of the current stack and thus reports // the bad memory location as a "wild pointer". // But with fake stack enabled we get something much better: // FAKESTACK: Address {{.*}} is located in stack of // FAKESTACK: #0 {{.*}} in {{.*main.*}} {{.*}}asan_fiber_main.d:[[@LINE+1]] void main() { // FAKESTACK: 'abcdabcdabcd'{{.*}} <== {{.*}} overflows this variable int[10] abcdabcdabcd; int b; // Use an extra variable instead of passing `&a[0]` directly to `foo`. // This is to keep `a` on the stack: `ptr` may be heap allocated because // it is used in the lambda (delegate). int* ptr = &abcdabcdabcd[0]; auto fib = new Fiber(() => foo(ptr)); fib.call(); version (BAD_AFTER_YIELD) fib.call(); } ./ldc-1.42.0-src/tests/sanitizers/fuzz_mixin.d0000644000175000017500000000114115205374122020106 0ustar fabiofabio// Test the basic fuzz target mixin for a D-signature fuzz target. // REQUIRES: Fuzzer // UNSUPPORTED: Windows // RUN: %ldc -g -fsanitize=fuzzer %s -of=%t%exe // RUN: not %t%exe 2>&1 | FileCheck %s int FuzzMe(in ubyte[] data) { if ((data.length >= 3) && data[0] == 'F' && data[1] == 'U' && data[2] == 'Z') { // Testing this assertion also tests that druntime is initialized. // CHECK: fuzz_mixin.d([[@LINE+1]]): Assertion failure assert(false); // CHECK: ERROR: libFuzzer: deadly signal } return 0; } import ldc.libfuzzer; mixin DefineTestOneInput!FuzzMe; ./ldc-1.42.0-src/tests/sanitizers/tsan_tiny_race_TLS.d0000644000175000017500000000331215205374122021432 0ustar fabiofabio// Test that ThreadSanitizer+LDC works on a very basic testcase. // REQUIRES: TSan // RUN: %ldc -g -fsanitize=thread %s -of=%t%exe // RUN: %deflake 20 %t%exe | FileCheck %s // CHECK: WARNING: ThreadSanitizer: data race import core.thread; void thread1(ref int x) nothrow { barrier_wait(&barrier); // CHECK-DAG: 7thread1{{.*}}[[@LINE+1]] x = 42; } int main() { int tls_variable; barrier_init(&barrier, 2); auto tid = createLowLevelThread(() { thread1(tls_variable); }); // CHECK-DAG: {{(_Dmain|D main).*}}[[@LINE+1]] tls_variable = 43; barrier_wait(&barrier); joinLowLevelThread(tid); return 0; } //---------------------------------------------------------------------------- // Code to facilitate thread synchronization to make this test deterministic. // See LLVM: compiler-rt/test/tsan/test.h // TSan-invisible barrier. // Tests use it to establish necessary execution order in a way that does not // interfere with tsan (does not establish synchronization between threads). alias invisible_barrier_t = __c_ulonglong; import core.stdc.config; alias __c_unsigned = uint; // Default instance of the barrier, but a test can declare more manually. __gshared invisible_barrier_t barrier; nothrow: extern (C) { // These functions reside inside the tsan library. void __tsan_testonly_barrier_init(invisible_barrier_t *barrier, __c_unsigned count); void __tsan_testonly_barrier_wait(invisible_barrier_t *barrier); } void barrier_init(invisible_barrier_t *barrier, __c_unsigned count) { __tsan_testonly_barrier_init(barrier, count); } void barrier_wait(invisible_barrier_t *barrier) { __tsan_testonly_barrier_wait(barrier); } //---------------------------------------------------------------------------- ./ldc-1.42.0-src/tests/sanitizers/lit.local.cfg0000644000175000017500000000367615205374122020120 0ustar fabiofabioimport os import platform sys = platform.system() # Add "LSan" feature if 'lsan' in config.enabled_rt_libs: config.available_features.add('LSan') # FreeBSD TSan doesn't seem to work, # Linux TSan currently only works with static druntime, # and there's no Windows TSan (yet?). if (sys != 'FreeBSD') and (sys != 'Windows') and not (sys == 'Linux' and config.shared_rt_libs_only): if 'tsan' in config.enabled_rt_libs: config.available_features.add('TSan') # FreeBSD ASan and MSan don't cope well with ASLR (might do with FreeBSD 14 according to https://github.com/llvm/llvm-project/pull/73439) if sys != 'FreeBSD': if 'asan' in config.enabled_rt_libs: config.available_features.add('ASan') # MSan is supported on Linux, FreeBSD (modulo ASLR issue), and OpenBSD: https://clang.llvm.org/docs/MemorySanitizer.html#supported-platforms if (sys == 'Linux') or (sys == 'OpenBSD'): if 'msan' in config.enabled_rt_libs: config.available_features.add('MSan') # Add "Fuzzer" feature if 'fuzzer' in config.enabled_rt_libs: config.available_features.add('Fuzzer') if 'ASan' in config.available_features: # On Darwin, ASan defaults to `abort_on_error=1`, which would make tests run # much slower. Let's override this and run lit tests with 'abort_on_error=0'. # Also, make sure we do not overwhelm the syslog while testing. default_asan_options = 'abort_on_error=0:log_to_syslog=0' config.environment['ASAN_OPTIONS'] = default_asan_options # And add a convenience substitution so we can append to the default ASAN_OPTIONS config.substitutions.append(('%env_asan_opts=', 'env ASAN_OPTIONS=' + default_asan_options + ':')) # Add the %deflake substitution, to help with flaky tests. # Usage: "%deflake ", runs a maximum of times until a failure occurs. config.substitutions.append( ("%deflake", os.path.join(os.path.dirname(__file__), "deflake.bash"))) ./ldc-1.42.0-src/tests/sanitizers/asan_fiber.d0000644000175000017500000000230415205374122017777 0ustar fabiofabio// AddressSanitizer: Test stack overflow detection of an array on a fiber's local stack. // REQUIRES: ASan, RTSupportsSanitizers // RUN: %ldc -g -fsanitize=address %s -of=%t%exe && not %t%exe 2>&1 | FileCheck %s // RUN: %ldc -g -fsanitize=address %s -of=%t%exe -d-version=BAD_AFTER_YIELD && not %t%exe 2>&1 | FileCheck %s import core.thread; // Note: the ordering of `foo` and `prefoo` is intentional to ease FileCheck checking line numbers, // because of the order in which ASan reports the stack buffer overflow. void foo(int* ptr) { version (BAD_AFTER_YIELD) Fiber.yield(); // CHECK: stack-buffer-overflow // CHECK: WRITE of size 4 // CHECK-NEXT: #0 {{.*}} in {{.*foo.*}} {{.*}}asan_fiber.d:[[@LINE+1]] ptr[10] = 1; } // CHECK-NOT: wild pointer // CHECK: Address {{.*}} is located in stack of // CHECK-NEXT: #0 {{.*}} in {{.*prefoo.*}} {{.*}}asan_fiber.d:[[@LINE+1]] void prefoo() { // CHECK: 'aiaiaiaiaiaiaiaiaiai'{{.*}} <== {{.*}} overflows this variable int[10] aiaiaiaiaiaiaiaiaiai; foo(&aiaiaiaiaiaiaiaiaiai[0]); } void main() { auto fib = new Fiber(&prefoo); fib.call(); version (BAD_AFTER_YIELD) fib.call(); } ./ldc-1.42.0-src/tests/sanitizers/attr_nosanitize.d0000644000175000017500000000257215205374122021132 0ustar fabiofabio// Test ldc.attributes.noSanitize UDA // RUN: %ldc -c -w -de -output-ll -fsanitize=address,thread -of=%t.normal.ll %s -d-version=NORMAL && FileCheck %s --check-prefix=NORMAL < %t.normal.ll // RUN: %ldc -c -w -de -output-ll -fsanitize=address,thread -of=%t.nosanitize.ll %s -d-version=NOSANITIZE && FileCheck %s --check-prefix=NOSANITIZE < %t.nosanitize.ll // RUN: %ldc -wi -c -fsanitize=address -d-version=WARNING %s 2>&1 | FileCheck %s --check-prefix=WARNING import ldc.attributes; extern (C): // For easier name mangling version (NORMAL) { // NORMAL: ; Function Attrs:{{.*}} sanitize_address sanitize_thread // NORMAL-NEXT: define{{.*}} void {{.*}}foo void foo() { } } else version (NOSANITIZE) { // NOSANITIZE-NOT: sanitize_address // NOSANITIZE: sanitize_thread // NOSANITIZE-NOT: sanitize_address // NOSANITIZE: define{{.*}} void {{.*}}foo_noaddress @noSanitize("address") void foo_noaddress() { } // NOSANITIZE-NOT: ; Function Attrs:{{.*}} sanitize_ // NOSANITIZE: define{{.*}} void {{.*}}foo_nothread_noaddress @noSanitize("thread") @noSanitize("address") void foo_nothread_noaddress() { } } else version (WARNING) { // WARNING: attr_nosanitize.d([[@LINE+1]]){{.*}} unrecognized sanitizer name 'invalid_name' @noSanitize("invalid_name") void foo_error() { } } ./ldc-1.42.0-src/tests/sanitizers/lsan_memleak.d0000644000175000017500000000110515205374122020334 0ustar fabiofabio// Test leak detection with LSan // REQUIRES: LSan // UNSUPPORTED: Windows, FreeBSD // RUN: %ldc -g -fsanitize=address %s -of=%t_asan%exe // RUN: not %env_asan_opts=detect_leaks=true %t_asan%exe 2>&1 | FileCheck %s // RUN: %ldc -g -fsanitize=leak %s -of=%t%exe // RUN: not %t%exe 2>&1 | FileCheck %s import core.stdc.stdlib; // CHECK: ERROR: LeakSanitizer: detected memory leaks void* foo() { // CHECK: Direct leak of 17 byte(s) in 1 object(s) allocated from: // CHECK: #{{.*}} in {{.*}}lsan_memleak.d:[[@LINE+1]] return malloc(17); } void main() { foo(); } ./ldc-1.42.0-src/tests/sanitizers/fsanitize_blacklist_file1.d0000644000175000017500000000066115205374122023016 0ustar fabiofabio// Test sanitizer blacklist file functionality // This file is _not_ blacklisted (file2 is) // RUN: %ldc -c -output-ll -fsanitize=address \ // RUN: -fsanitize-blacklist=%S/inputs/fsanitize_blacklist_file.txt \ // RUN: -of=%t.ll %s && FileCheck %s < %t.ll // CHECK: ; Function Attrs:{{.*}} sanitize_address // CHECK-NEXT: define{{.*}} void {{.*}}9foofoofoo void foofoofoo(int* i) { // CHECK: call {{.*}}_asan *i = 1; } ./ldc-1.42.0-src/tests/sanitizers/msan_noerror.d0000644000175000017500000000024615205374122020415 0ustar fabiofabio// Test that a simple progam passes MemorySanitizer without error // REQUIRES: MSan // RUN: %ldc -g -fsanitize=memory %s -of=%t%exe // RUN: %t%exe void main() { } ./ldc-1.42.0-src/tests/sanitizers/asan_use_after_scope_if.d0000644000175000017500000000121215205374122022531 0ustar fabiofabio// REQUIRES: ASan // RUN: %ldc -femit-local-var-lifetime -g -fsanitize=address %s -of=%t%exe // RUN: not %t%exe 2>&1 | FileCheck %s // CHECK: ERROR: AddressSanitizer: stack-use-after-scope // CHECK-NEXT: WRITE of size 4 void useAfterScope(int xparam) { int* p; if (int x = xparam) { p = &x; // cannot statically disallow this because *p = 1; // this is a valid use of things } // CHECK-NEXT: #0 {{.*}} in {{.*}}asan_use_after_scope_if.d:[[@LINE+1]] *p = 5; // but then this can happen... stack use after scope bug! } void main() { // CHECK-NEXT: #1 {{.*}} in {{.*}}asan_use_after_scope_if.d:[[@LINE+1]] useAfterScope(1); } ./ldc-1.42.0-src/tests/sanitizers/fuzz_basic.d0000644000175000017500000000142615205374122020051 0ustar fabiofabio// Test basic fuzz test crash // REQUIRES: Fuzzer // UNSUPPORTED: Windows // RUN: %ldc -g -fsanitize=fuzzer %s -of=%t%exe // RUN: not %t%exe 2> %t.out // RUN: FileCheck %s < %t.out void FuzzMe(const(ubyte*) data, size_t size) { if ((size >= 3) && data[0] == 'F' && data[1] == 'U' && data[2] == 'Z') { // CHECK: fuzz_basic.d([[@LINE+1]]): Assertion failure assert(false); // CHECK: ERROR: libFuzzer: deadly signal } } extern (C) int LLVMFuzzerTestOneInput(const(ubyte*) data, size_t size) { // D runtime must be initialized, but only once. static bool init = false; if (!init) { import core.runtime : rt_init; rt_init(); init = true; } auto a = new int; // Test that GC works FuzzMe(data, size); return 0; } ./ldc-1.42.0-src/tests/sanitizers/fsanitize_address.d0000644000175000017500000000126015205374122021407 0ustar fabiofabio// Test basic AddressSanitizer functionality // RUN: %ldc -c -output-ll -g -fsanitize=address -of=%t.ll %s && FileCheck %s < %t.ll // RUN: %ldc -c -output-ll -g -fsanitize=address,thread -of=%t.tsan.ll %s && FileCheck %s --check-prefix=wTSAN < %t.tsan.ll // RUN: %ldc -c -output-ll -g -fsanitize=address -fsanitize=thread -of=%t.tsan.ll %s && FileCheck %s --check-prefix=wTSAN < %t.tsan.ll void foo(size_t a) { // wTSAN: call {{.*}}_tsan_func_entry // CHECK: call {{.*}}_asan_stack_malloc // wTSAN: {{(call|invoke)}} {{.*}}_asan_stack_malloc int[10] i; // CHECK: call {{.*}}_asan_report_store // wTSAN: {{(call|invoke)}} {{.*}}_asan_report_store i[a] = 1; } ./ldc-1.42.0-src/tests/sanitizers/fsanitize_thread.d0000644000175000017500000000061515205374122021234 0ustar fabiofabio// Test basic ThreadSanitizer functionality // RUN: %ldc -c -output-ll -g -fsanitize=thread -of=%t.ll %s && FileCheck %s < %t.ll // LLVM 14+: no more __tsan_func_{entry,exit} calls // XFAIL: * // CHECK: ; Function Attrs:{{.*}} sanitize_thread // CHECK-NEXT: define {{.*}}D16fsanitize_thread3foo int foo(int i) { // CHECK: call {{.*}}_tsan_func_entry return i + 1; // CHECK: ret i } ./ldc-1.42.0-src/tests/sanitizers/asan_use_after_return.d0000644000175000017500000000224715205374122022272 0ustar fabiofabio// REQUIRES: ASan, RTSupportsSanitizers // Note on debug lineinfo: on macOS the executable contains a link back to the // object files for debug info. Therefore the order of text execution is important, // i.e. we should finish all testing on one compiled executable before recompiling // with different conditional compilation settings (because it will overwrite the // object files from the previous compilation). // RUN: %ldc -g -fsanitize=address %s -of=%t%exe // RUN: not %env_asan_opts=detect_stack_use_after_return=true %t%exe 2>&1 | FileCheck %s import core.memory; import std.stdio; // CHECK: ERROR: AddressSanitizer: stack-use-after-return // CHECK-NEXT: READ of size 4 struct S(Dlg) { Dlg dlg; } auto invoker(Dlg)(scope Dlg dlg) { return S!Dlg(dlg); } @nogc auto f(int x) { scope dlg = delegate() { // CHECK-NEXT: #0 {{.*}} in {{.*}}asan_use_after_return.d:[[@LINE+1]] x++; }; return invoker(dlg); } void main() { auto inv = f(2); // CHECK-NEXT: #1 {{.*}} in {{.*}}asan_use_after_return.d inv.dlg(); } // CHECK: Address {{.*}} is located in stack of // CHECK-NEXT: #0 {{.*}} in {{.*}}asan_use_after_return.d:[[@LINE-16]] ./ldc-1.42.0-src/tests/sanitizers/tsan_tiny_race.d0000644000175000017500000000322015205374122020706 0ustar fabiofabio// Test that ThreadSanitizer+LDC works on a very basic testcase. // REQUIRES: TSan // RUN: %ldc -g -fsanitize=thread %s -of=%t%exe // RUN: %deflake 20 %t%exe | FileCheck %s // CHECK: WARNING: ThreadSanitizer: data race import core.thread; shared int global; void thread1() { barrier_wait(&barrier); // CHECK-DAG: 7thread1{{.*}}[[@LINE+1]] global = 42; } int main() { barrier_init(&barrier, 2); auto t = new Thread(&thread1); t.start(); // CHECK-DAG: {{(_Dmain|D main).*}}[[@LINE+1]] global = 43; barrier_wait(&barrier); t.join(); return global; } //---------------------------------------------------------------------------- // Code to facilitate thread synchronization to make this test deterministic. // See LLVM: compiler-rt/test/tsan/test.h // TSan-invisible barrier. // Tests use it to establish necessary execution order in a way that does not // interfere with tsan (does not establish synchronization between threads). alias invisible_barrier_t = __c_ulonglong; import core.stdc.config; alias __c_unsigned = uint; // Default instance of the barrier, but a test can declare more manually. __gshared invisible_barrier_t barrier; extern (C) { // These functions reside inside the tsan library. void __tsan_testonly_barrier_init(invisible_barrier_t *barrier, __c_unsigned count); void __tsan_testonly_barrier_wait(invisible_barrier_t *barrier); } void barrier_init(invisible_barrier_t *barrier, __c_unsigned count) { __tsan_testonly_barrier_init(barrier, count); } void barrier_wait(invisible_barrier_t *barrier) { __tsan_testonly_barrier_wait(barrier); } //---------------------------------------------------------------------------- ./ldc-1.42.0-src/tests/sanitizers/asan_dynalloc.d0000644000175000017500000000172415205374122020522 0ustar fabiofabio// Test dynamic allocated memory read overflow detection with AddressSanitizer // REQUIRES: ASan // RUN: %ldc -g -fsanitize=address -boundscheck=off %s -of=%t%exe // RUN: %ldc -g -fsanitize=address -boundscheck=off %s -of=%t.malloc%exe -d-version=MALLOC // FIXME, GC allocations are not ASan ready yet. R UN: not %t%exe 2>&1 | FileCheck %s // RUN: not %t.malloc%exe 2>&1 | FileCheck %s --check-prefix=MALLOC import core.stdc.stdlib; import ldc.asan; int getX() { version (MALLOC) { byte* x = cast(byte*) malloc(5 * (byte).sizeof); // MALLOC: heap-buffer-overflow // MALLOC: READ of size 1 // MALLOC-NEXT: #0 {{.*}} in {{.*getX.*}} {{.*}}asan_dynalloc.d:[[@LINE+1]] return x[5]; } else { byte[] x = new byte[5]; // CHECK: READ of size 1 // CHECK-NEXT: #0 {{.*}} in {{.*getX.*}} {{.*}}asan_dynalloc.d:[[@LINE+1]] return x[5]; } } int main() { auto x = getX(); return 0; } ./ldc-1.42.0-src/tests/sanitizers/asan_interface.d0000644000175000017500000000142515205374122020653 0ustar fabiofabio// Test the AddressSanitizer (un)poison interface // REQUIRES: ASan // RUN: %ldc -g -fsanitize=address -boundscheck=off %s -of=%t%exe // RUN: not %t%exe 2>&1 | FileCheck %s import ldc.asan; int getX() { int[] x = new int[5]; assert(__asan_address_is_poisoned(&x[1]) == 0); __asan_poison_memory_region(x.ptr, 5*int.sizeof); assert(__asan_address_is_poisoned(&x[1]) == 1); __asan_unpoison_memory_region(x.ptr, 5*int.sizeof); assert(__asan_address_is_poisoned(&x[1]) == 0); int a = x[1]; __asan_poison_memory_region(x.ptr, 5*int.sizeof); // CHECK: use-after-poison // CHECK: READ of size 4 // CHECK-NEXT: #0 {{.*}} in {{.*getX.*}} {{.*}}asan_interface.d:[[@LINE+1]] return a + x[1]; } int main() { auto x = getX(); return 0; } ./ldc-1.42.0-src/tests/sanitizers/fsanitize_fuzzer.d0000644000175000017500000000154315205374122021313 0ustar fabiofabio// Test basic Fuzz sanitizer functionality // RUN: %ldc -c -output-ll -O3 -fsanitize=fuzzer -of=%t.ll %s && FileCheck %s < %t.ll // RUN: %ldc -c -output-ll -fsanitize=fuzzer,address -of=%t.asan.ll %s && FileCheck %s --check-prefix=CHECK --check-prefix=wASAN < %t.asan.ll // CHECK-LABEL: define{{.*}} @{{.*}}FuzzMe bool FuzzMe(const ubyte* data, size_t dataSize) { // CHECK: call {{.*}}_sanitizer_cov_trace_{{(const_)?}}cmp return dataSize >= 3 && data[0] == 'F' && data[1] == 'U' && data[2] == 'Z' && data[3] == 'Z'; // :‑< } // CHECK-LABEL: define{{.*}} @{{.*}}allocInt void allocInt(size_t i) { // wASAN: call {{.*}}_asan_stack_malloc int[10] a; a[i] = 1; } // CHECK-LABEL: define{{.*}} @{{.*}}foo void foo(int function() a) { // CHECK: call void @__sanitizer_cov_trace_pc_indir a(); } ./ldc-1.42.0-src/tests/sanitizers/deflake.bash0000755000175000017500000000152115205374122017776 0ustar fabiofabio#!/usr/bin/env bash # Copied from LLVM's testsuite: compiler-rt/test/tsan # This script is used to deflake inherently flaky tsan tests. # It is invoked from lit tests as: # %deflake $THRESHOLD mybinary # which is then substituted by lit to: # $(dirname %s)/deflake.bash $THRESHOLD mybinary # - When TSAN_TEST_DEFLAKE_THRESHOLD is defined to a positive integer value, # THRESHOLD will be the defined value. # - When TSAN_TEST_DEFLAKE_THRESHOLD is not defined, THRESHOLD will be 10. # The script runs the target program up to $THRESHOLD times, # until it fails (i.e. produces a race report). THRESHOLD="${1}" shift # Early exit if $THRESHOLD is not a non-negative integer [[ "${THRESHOLD}" =~ ^[0-9]+$ ]] || exit 1 while (( THRESHOLD-- )); do OUT=`$@ 2>&1` if [[ $? != 0 ]]; then echo "$OUT" exit 0 fi done exit 1 ./ldc-1.42.0-src/tests/sanitizers/asan_gh4816.d0000644000175000017500000000046115205374122017633 0ustar fabiofabio// Test extern(C) structs (zero sized structs) and zero-sized arrays. Github #4816 // REQUIRES: ASan // RUN: %ldc -g -fsanitize=address %s -of=%t%exe // RUN: %t%exe auto foo(void[0] bar) { } extern(C) struct S {} auto foo(S s) { } void main() { void[0] bar; foo(bar); S s; foo(s); } ./ldc-1.42.0-src/tests/tools/0000755000175000017500000000000015205374122014507 5ustar fabiofabio./ldc-1.42.0-src/tests/tools/timetrace2txt_tsv.d0000644000175000017500000000062215205374122020347 0ustar fabiofabio// Test timetrace2txt tool basic TSV functionality // RUN: %ldc -c -o- --ftime-trace --ftime-trace-file=%t.timetrace --ftime-trace-granularity=1 %s // RUN: %timetrace2txt %t.timetrace -o %t.txt --tsv %t.tsv && FileCheck %s < %t.tsv // RUN: %timetrace2txt %t.timetrace -o %t.txt --tsv - | FileCheck %s // CHECK: Duration Text Line Number Name Location Detail void foo(); void main() { foo(); } ./ldc-1.42.0-src/tests/tools/timetrace2txt_1.d0000644000175000017500000000053615205374122017677 0ustar fabiofabio// Test timetrace2txt tool basic functionality // RUN: %ldc -c -o- --ftime-trace --ftime-trace-file=%t.timetrace --ftime-trace-granularity=1 %s // RUN: %timetrace2txt %t.timetrace -o %t.txt && FileCheck %s < %t.txt // RUN: %timetrace2txt %t.timetrace -o - | FileCheck %s // CHECK: Timetrace // CHECK: main void foo(); void main() { foo(); } ./ldc-1.42.0-src/tests/tools/ldc_prune_cache_1.d0000644000175000017500000000340015205374122020167 0ustar fabiofabio// Test ldc-cache-prune tool // This test assumes that the `void main(){}` object file size is below 200_000 bytes and above 200_000/2, // such that rebuilding with version(NEW_OBJ_FILE) will clear the cache of all but the latest object file. // RUN: %ldc %s -cache=%t-dir // RUN: %ldc %s -cache=%t-dir -d-version=SLEEP // RUN: %prunecache -f %t-dir // RUN: %ldc %s -cache=%t-dir -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc %s -cache=%t-dir -vv -d-version=NEW_OBJ_FILE | FileCheck --check-prefix=NO_HIT %s // RUN: %prunecache %t-dir -f // RUN: %ldc %s -cache=%t-dir -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc -d-version=SLEEP -run %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %prunecache --force --max-bytes=200000 %t-dir // RUN: %ldc %t%obj // RUN: %ldc %s -cache=%t-dir -d-version=SLEEP -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc -d-version=SLEEP -run %s // RUN: %ldc %s -cache=%t-dir -d-version=NEW_OBJ_FILE // RUN: %prunecache --interval=0 %t-dir --max-bytes=200000 // RUN: %ldc %s -cache=%t-dir -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc -d-version=SLEEP -run %s // RUN: %ldc -d-version=SLEEP -run %s // RUN: %prunecache %t-dir -f --expiry=2 // RUN: %ldc %s -cache=%t-dir -vv | FileCheck --check-prefix=NO_HIT %s // MUST_HIT: Cache object found! // NO_HIT-NOT: Cache object found! void main() { // Add non-zero static data to guarantee a binary size larger than 200_000/2. static byte[120_000] dummy = 1; version (NEW_OBJ_FILE) { auto a = __TIME__; } version (SLEEP) { // Sleep for 2 seconds, so we are sure that the cache object file timestamps are "aging". import core.thread; Thread.sleep( dur!"seconds"(2) ); } } ./ldc-1.42.0-src/tests/instrument/0000755000175000017500000000000015205374122015557 5ustar fabiofabio./ldc-1.42.0-src/tests/instrument/inputs/0000755000175000017500000000000015205374122017101 5ustar fabiofabio./ldc-1.42.0-src/tests/instrument/inputs/coverage_cycle_input.d0000644000175000017500000000010315205374122023431 0ustar fabiofabiomodule inputs.coverage_cycle_input; import coverage_cycle_gh2177; ./ldc-1.42.0-src/tests/instrument/coverage_cycle_gh2177.d0000644000175000017500000000046715205374122021704 0ustar fabiofabio// Test that `-cov` does not lead to harmless import cycle errors. // Github issue 2177 // RUN: %ldc -cov=100 -Iinputs %s %S/inputs/coverage_cycle_input.d -of=%t%exe // RUN: %t%exe module coverage_cycle_gh2177; import inputs.coverage_cycle_input; static this() { int i; } int main () { return 0; } ./ldc-1.42.0-src/tests/instrument/coverage_main_gh2163.d0000644000175000017500000000003315205374122021511 0ustar fabiofabio// RUN: %ldc -main -cov %s ./ldc-1.42.0-src/tests/instrument/xray_check_pipeline.d0000644000175000017500000000053715205374122021736 0ustar fabiofabio// Check that the LLVM pipeline is set up correctly to generate XRay sleds. // If we have the XRay runtime lib for this platform, then we can also do machinecodegen: // REQUIRES: XRay_RT // RUN: %ldc -c -output-s -betterC -fxray-instrument -fxray-instruction-threshold=1 -of=%t.s %s && FileCheck %s < %t.s // CHECK: xray_sled void instrument() { } ./ldc-1.42.0-src/tests/instrument/finstrument_functions.d0000644000175000017500000000163215205374122022374 0ustar fabiofabio// RUN: %ldc -c -output-ll -finstrument-functions -of=%t.ll %s && FileCheck %s < %t.ll void fun0 () { // CHECK-LABEL: define{{.*}} @{{.*}}4fun0FZv // CHECK: [[RET1:%[0-9]]] = call ptr @llvm.returnaddress(i32 0) // CHECK: call void @__cyg_profile_func_enter{{.*}}4fun0FZv{{.*}}[[RET1]] // CHECK: [[RET2:%[0-9]]] = call ptr @llvm.returnaddress(i32 0) // CHECK: call void @__cyg_profile_func_exit{{.*}}4fun0FZv{{.*}}[[RET2]] // CHECK-NEXT: ret return; } pragma(LDC_profile_instr, false) int fun1 (int x) { // CHECK-LABEL: define{{.*}} @{{.*}}4fun1FiZi // CHECK-NOT: __cyg_profile_func_enter // CHECK-NOT: __cyg_profile_func_exit return 42; } bool fun2 (int x) { // CHECK-LABEL: define{{.*}} @{{.*}}4fun2FiZb if (x < 10) // CHECK: call void @__cyg_profile_func_exit // CHECK-NEXT: ret return true; // CHECK: call void @__cyg_profile_func_exit // CHECK-NEXT: ret return false; } ./ldc-1.42.0-src/tests/instrument/xray_instrument_threshold.d0000644000175000017500000000045415205374122023256 0ustar fabiofabio// RUN: %ldc -c -output-ll -fxray-instrument -fxray-instruction-threshold=543 -of=%t.ll %s && FileCheck %s < %t.ll // CHECK-LABEL: define{{.*}} @{{.*}}10instrument // CHECK-SAME: #[[INSTR:[0-9]+]] void instrument() { } // CHECK-DAG: attributes #[[INSTR]] ={{.*}} "xray-instruction-threshold"="543" ./ldc-1.42.0-src/tests/instrument/lit.local.cfg0000644000175000017500000000026615205374122020125 0ustar fabiofabioimport platform # Add "XRay_RT" feature on non-Windows if (platform.system() != 'Windows'): if 'xray' in config.enabled_rt_libs: config.available_features.add('XRay_RT') ./ldc-1.42.0-src/tests/instrument/xray_instrument.d0000644000175000017500000000102015205374122021170 0ustar fabiofabio// RUN: %ldc -c -output-ll -fxray-instrument -of=%t.ll %s && FileCheck %s < %t.ll import ldc.attributes; // CHECK-LABEL: define{{.*}} @{{.*}}10instrument // CHECK-SAME: #[[INSTR:[0-9]+]] void instrument() { } // CHECK-LABEL: define{{.*}} @{{.*}}15dont_instrument // CHECK-SAME: #[[DONT_INSTR:[0-9]+]] void dont_instrument() { pragma(LDC_profile_instr, false); } // CHECK-DAG: attributes #[[INSTR]] ={{.*}} "xray-instruction-threshold"= // CHECK-DAG: attributes #[[DONT_INSTR]] ={{.*}} "function-instrument"="xray-never" ./ldc-1.42.0-src/tests/instrument/xray_simple_execution.d0000644000175000017500000000076315205374122022351 0ustar fabiofabio// Check basic execution of XRay to verify the basic system is working. // REQUIRES: Linux // REQUIRES: XRay_RT // RUN: %ldc -fxray-instrument -fxray-instruction-threshold=1 %s -of=%t%exe // RUN: env XRAY_OPTIONS="patch_premain=true xray_mode=xray-basic verbosity=1" %t%exe 2>&1 | FileCheck %s // This last command should give some output on stderr, one line of which containing: // CHECK: XRay: Log file // If stderr is empty, things are not working. void foo() { } void main() { foo(); } ./ldc-1.42.0-src/tests/instrument/xray_link.d0000644000175000017500000000064715205374122017733 0ustar fabiofabio// REQUIRES: XRay_RT // fails on macOS with LLVM 11-16 due to a linker error, see // https://github.com/llvm/llvm-test-suite/commit/2c3c4a6286d453f763c0245c6536ddd368f0db99 // XFAIL: Darwin && atmost_llvm1609 // RUN: %ldc -fxray-instrument -fxray-instruction-threshold=1 -of=%t%exe %s -vv 2>&1 | FileCheck %s void foo() { } void main() { foo(); } // CHECK-NOT: error // CHECK: Linking with: // CHECK-NEXT: rt.xray ./ldc-1.42.0-src/tests/PGO/0000755000175000017500000000000015205374122013774 5ustar fabiofabio./ldc-1.42.0-src/tests/PGO/inputs/0000755000175000017500000000000015205374122015316 5ustar fabiofabio./ldc-1.42.0-src/tests/PGO/inputs/singleobj_input.d0000644000175000017500000000005515205374122020656 0ustar fabiofabioextern(C) int return_seven() { return 7; } ./ldc-1.42.0-src/tests/PGO/allstatementtypes.d0000644000175000017500000003767215205374122017742 0ustar fabiofabio// Test instrumentation of all 'simple' AST statement types. // REQUIRES: PGO_RT // Disable autogenerated boundschecking to declutter the generated code. // See boundscheck.d for boundschecking instrumenation tests. // RUN: %ldc -boundscheck=off -c -output-ll -fprofile-instr-generate="hoihoihoi" -of=%t.ll %s \ // RUN: && FileCheck -allow-deprecated-dag-overlap %s --check-prefix=PROFGEN < %t.ll // PROFGEN-DAG: @[[FILENAME:.+]] ={{.*}} constant{{.*}} c"hoihoihoi\00" // RUN: %ldc -boundscheck=off -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -boundscheck=off -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %s \ // RUN: && FileCheck -allow-deprecated-dag-overlap %s -check-prefix=PROFUSE < %t2.ll extern(C): // simplify name mangling for simpler string matching // PROFGEN-DAG: @[[FL:__(llvm_profile_counters|profc)_for_loop]] ={{.*}} global [7 x i64] zeroinitializer // PROFGEN-DAG: @[[FEL:__(llvm_profile_counters|profc)_foreach_loop]] ={{.*}} global [5 x i64] zeroinitializer // PROFGEN-DAG: @[[FERL:__(llvm_profile_counters|profc)_foreachrange_loop]] ={{.*}} global [6 x i64] zeroinitializer // PROFGEN-DAG: @[[LG:__(llvm_profile_counters|profc)_label_goto]] ={{.*}} global [7 x i64] zeroinitializer // PROFGEN-DAG: @[[SWC:__(llvm_profile_counters|profc)_c_switches]] ={{.*}} global [24 x i64] zeroinitializer // PROFGEN-DAG: @[[DSW:__(llvm_profile_counters|profc)_d_switches]] ={{.*}} global [15 x i64] zeroinitializer // PROFGEN-DAG: @[[BOOL:__(llvm_profile_counters|profc)_booleanlogic]] ={{.*}} global [9 x i64] zeroinitializer // PROFGEN-DAG: @[[DW:__(llvm_profile_counters|profc)_do_while]] ={{.*}} global [6 x i64] zeroinitializer // PROFGEN-LABEL: @for_loop() // PROFUSE-LABEL: @for_loop() // PROFGEN: store {{.*}} @[[FL]] // PROFUSE-SAME: !prof ![[FL0:[0-9]+]] void for_loop() { uint i; // PROFGEN: store {{.*}} @[[FL]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[FL1:[0-9]+]] for (i = 0; i < 400; ++i) { // PROFGEN: store {{.*}} @[[FL]], i{{32|64}} 0, i{{32|64}} 2 // PROFUSE: br {{.*}} !prof ![[FL2:[0-9]+]] if (i > 389) { break; } else { // PROFGEN: store {{.*}} @[[FL]], i{{32|64}} 0, i{{32|64}} 3 // PROFUSE: br {{.*}} !prof ![[FL3:[0-9]+]] if (i) {} } // PROFGEN: store {{.*}} @[[FL]], i{{32|64}} 0, i{{32|64}} 4 // PROFUSE: br {{.*}} !prof ![[FL4:[0-9]+]] if (i > 2) { continue; } } // PROFGEN: store {{.*}} @[[FL]], i{{32|64}} 0, i{{32|64}} 5 // PROFUSE: br {{.*}} !prof ![[FL5:[0-9]+]] // PROFGEN: store {{.*}} @[[FL]], i{{32|64}} 0, i{{32|64}} 6 // PROFUSE: br {{.*}} !prof ![[FL6:[0-9]+]] for (uint a = i ? 2 : 1; /+ empty condition +/; ) { break; } } // PROFGEN-LABEL: @foreach_loop() // PROFUSE-LABEL: @foreach_loop() // PROFGEN: store {{.*}} @[[FEL]] // PROFUSE-SAME: !prof ![[FEL0:[0-9]+]] void foreach_loop() { // PROFGEN: store {{.*}} @[[FEL]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[FEL1:[0-9]+]] foreach (i; 0..400) { // PROFGEN: store {{.*}} @[[FEL]], i{{32|64}} 0, i{{32|64}} 2 // PROFUSE: br {{.*}} !prof ![[FEL2:[0-9]+]] if (i > 389) { break; } else { // PROFGEN: store {{.*}} @[[FEL]], i{{32|64}} 0, i{{32|64}} 3 // PROFUSE: br {{.*}} !prof ![[FEL3:[0-9]+]] if (i) {} } // PROFGEN: store {{.*}} @[[FEL]], i{{32|64}} 0, i{{32|64}} 4 // PROFUSE: br {{.*}} !prof ![[FEL4:[0-9]+]] if (i > 2) { continue; } } } // PROFGEN-LABEL: @foreachrange_loop() // PROFUSE-LABEL: @foreachrange_loop() // PROFGEN: store {{.*}} @[[FERL]] // PROFUSE-SAME: !prof ![[FERL0:[0-9]+]] void foreachrange_loop() { import std.range : iota; auto f = false; // PROFGEN: store {{.*}} @[[FERL]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[FERL1:[0-9]+]] // PROFGEN: store {{.*}} @[[FERL]], i{{32|64}} 0, i{{32|64}} 2 // PROFUSE: br {{.*}} !prof ![[FERL2:[0-9]+]] foreach (i; f ? iota(0,200) : iota(0,400)) { // PROFGEN: store {{.*}} @[[FERL]], i{{32|64}} 0, i{{32|64}} 3 // PROFUSE: br {{.*}} !prof ![[FERL3:[0-9]+]] if (i > 389) { break; } else { // PROFGEN: store {{.*}} @[[FERL]], i{{32|64}} 0, i{{32|64}} 4 // PROFUSE: br {{.*}} !prof ![[FERL4:[0-9]+]] if (i) {} } // PROFGEN: store {{.*}} @[[FERL]], i{{32|64}} 0, i{{32|64}} 5 // PROFUSE: br {{.*}} !prof ![[FERL5:[0-9]+]] if (i > 2) { continue; } } } // PROFGEN-LABEL: @label_goto() // PROFUSE-LABEL: @label_goto() // PROFGEN: store {{.*}} @[[LG]] // PROFUSE-SAME: !prof ![[LG0:[0-9]+]] void label_goto() { int i = 0; // 1x // PROFGEN: store {{.*}} @[[LG]], i{{32|64}} 0, i{{32|64}} 1 start: ++i; // 10x // PROFGEN: store {{.*}} @[[LG]], i{{32|64}} 0, i{{32|64}} 2 // PROFUSE: br {{.*}} !prof ![[LG2:[0-9]+]] if (i >= 10) // 10x { goto end; // 1x } goto start; // 9x // PROFGEN: store {{.*}} @[[LG]], i{{32|64}} 0, i{{32|64}} 3 // PROFUSE-NOT: br {{.*}} !prof // PROFUSE: br if (i >= 567) {} // 0x (never reached -> no weights) // PROFGEN: store {{.*}} @[[LG]], i{{32|64}} 0, i{{32|64}} 4 doublelabel: // 0x // PROFGEN: store {{.*}} @[[LG]], i{{32|64}} 0, i{{32|64}} 5 end: // 1x ++i; // 1x // Also emit counter for label at end of function: // PROFGEN: store {{.*}} @[[LG]], i{{32|64}} 0, i{{32|64}} 6 emptylabel: // 1x } // PROFGEN-LABEL: @c_switches() // PROFUSE-LABEL: @c_switches() // PROFGEN: store {{.*}} @[[SWC]] // PROFUSE-SAME: !prof ![[SW0:[0-9]+]] void c_switches() { static int[] weights = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]; // The switch counter blocks are generated in the following order: // - default block // - cases // - switch end // No cases -> no weights switch (weights[0]) { // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 2 default: break; } // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 1 // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 3 // PROFUSE: br {{.*}} !prof ![[SW1:[0-9]+]] for (int i = 0; i < weights.length; ++i) { // PROFUSE: switch {{.*}} [ // PROFUSE: ], !prof ![[SW2:[0-9]+]] switch (weights[i]) { // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 5 case 1: // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 6 // PROFUSE: br {{.*}} !prof ![[SW3:[0-9]+]] if (i) {} goto case; // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 7 case 2: // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 8 // PROFUSE: br {{.*}} !prof ![[SW4:[0-9]+]] if (i) {} break; // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 9 case 3: // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 10 // PROFUSE: br {{.*}} !prof ![[SW5:[0-9]+]] if (i) {} continue; // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 11 case 4: // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 12 // PROFUSE: br {{.*}} !prof ![[SW6:[0-9]+]] if (i) {} // PROFUSE: switch {{.*}} [ // PROFUSE: ], !prof ![[SW7:[0-9]+]] switch (i) { // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 14 // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 15 // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 16 // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 17 case 6: .. case 9: // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 18 // PROFUSE: br {{.*}} !prof ![[SW8:[0-9]+]] if (i) {} continue; // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 19 default: } // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 13 goto default; // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 20 default: // PROFUSE: br {{.*}} !prof ![[SW9:[0-9]+]] // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 21 if (i == weights.length - 1) return; } // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 4 } // PROFGEN: store {{.*}} @[[SWC]], i{{32|64}} 0, i{{32|64}} 23 // Never reached -> no weights if (weights[0]) {} // PROFGEN-NOT: store {{.*}} @[[SWC]], // PROFUSE-NOT: br {{.*}} !prof ![0-9]+ } // test the particulars of switches using D features // PROFGEN-LABEL: @d_switches() // PROFUSE-LABEL: @d_switches() // PROFGEN: store {{.*}} @[[DSW]] // PROFUSE-SAME: !prof ![[DSW0:[0-9]+]] void d_switches() { uint i; // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[DSW1:[0-9]+]] for (i = 1; i < 4; ++i) { // PROFUSE: switch {{.*}} [ // PROFUSE: ], !prof ![[DSW2:[0-9]+]] switch (i) { // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 3 case 1: // 1 + 1*gototarget // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 4 // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 5 // PROFUSE: br {{.*}} !prof ![[DSW5:[0-9]+]] if (i != 1) {} goto default; // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 6 case 11: // 0x // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 7 // never reached, no branch weights if (i != 11) {} goto case; // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 8 case 2: // 1x // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 9 // PROFUSE: br {{.*}} !prof ![[DSW9:[0-9]+]] if (i != 2) {} goto case 1; // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 10 default: // 1 + 2*gototarget // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 11 goto case; // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 12 case 5: // 0 + 3*fallthrough // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 13 // PROFUSE: br {{.*}} !prof ![[DSW13:[0-9]+]] if (i != 5) {} break; } // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 2 } // PROFGEN: store {{.*}} @[[DSW]], i{{32|64}} 0, i{{32|64}} 14 // PROFUSE: br {{.*}} !prof ![[DSW14:[0-9]+]] if (i) {} // PROFGEN-NOT: store {{.*}} @[[DSW]], // PROFUSE-NOT: br {{.*}} !prof ![0-9]+ } // PROFGEN-LABEL: @booleanlogic() // PROFUSE-LABEL: @booleanlogic() // PROFGEN: store {{.*}} @[[BOOL]] // PROFUSE-SAME: !prof ![[BOOL0:[0-9]+]] void booleanlogic() { bool t = true, f = false; bool x; // PROFGEN: store {{.*}} @[[BOOL]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[BOOL1:[0-9]+]] x = f && t; // PROFGEN: store {{.*}} @[[BOOL]], i{{32|64}} 0, i{{32|64}} 2 // PROFGEN: store {{.*}} @[[BOOL]], i{{32|64}} 0, i{{32|64}} 3 // PROFUSE: br {{.*}} !prof ![[BOOL2:[0-9]+]] // 2nd is never reached -> no weights x = f && (f && t); // PROFGEN: store {{.*}} @[[BOOL]], i{{32|64}} 0, i{{32|64}} 4 // PROFUSE: br {{.*}} !prof ![[BOOL4:[0-9]+]] x = t || f; // PROFGEN: store {{.*}} @[[BOOL]], i{{32|64}} 0, i{{32|64}} 6 // PROFGEN: store {{.*}} @[[BOOL]], i{{32|64}} 0, i{{32|64}} 5 // PROFUSE: br {{.*}} !prof ![[BOOL6:[0-9]+]] // PROFUSE: br {{.*}} !prof ![[BOOL5:[0-9]+]] x = (f || f) || t; // PROFGEN: store {{.*}} @[[BOOL]], i{{32|64}} 0, i{{32|64}} 7 // PROFGEN: store {{.*}} @[[BOOL]], i{{32|64}} 0, i{{32|64}} 8 // PROFUSE: br {{.*}} !prof ![[BOOL7:[0-9]+]] // PROFUSE: br {{.*}} !prof ![[BOOL8:[0-9]+]] x = f ? t : (f && t); // PROFGEN-NOT: store {{.*}} @[[BOOL]], // PROFUSE-NOT: br {{.*}} !prof ![0-9]+ } // PROFGEN-LABEL: @do_while() // PROFUSE-LABEL: @do_while() // PROFGEN: store {{.*}} @[[DW]] // PROFUSE-SAME: !prof ![[DW0:[0-9]+]] void do_while() { int i; // PROFGEN: store {{.*}} @[[DW]], i{{32|64}} 0, i{{32|64}} 1 do { ++i; // PROFGEN: store {{.*}} @[[DW]], i{{32|64}} 0, i{{32|64}} 2 // PROFUSE: br {{.*}} !prof ![[DW2:[0-9]+]] if (i < 10) { continue; } // PROFGEN: store {{.*}} @[[DW]], i{{32|64}} 0, i{{32|64}} 3 // PROFUSE: br {{.*}} !prof ![[DW3:[0-9]+]] if (i >= 33) { break; } } while (i < 6633); // PROFUSE: br {{.*}} !prof ![[DW1:[0-9]+]] // (while is lowered to a for statement) // PROFGEN: store {{.*}} @[[DW]], i{{32|64}} 0, i{{32|64}} 4 // PROFUSE: br {{.*}} !prof ![[DW4:[0-9]+]] while (i > 2) { --i; // PROFGEN: store {{.*}} @[[DW]], i{{32|64}} 0, i{{32|64}} 5 // PROFUSE: br {{.*}} !prof ![[DW5:[0-9]+]] if (i < 321) {} } } // PROFGEN-LABEL: @_Dmain( // PROFUSE-LABEL: @_Dmain( extern(D): void main() { // Simply tests that all conditional branches have branch weights: // PROFUSE-NOT: {{br i1 %[0-9]+, label %[A-Za-z0-9\.]+, label %[A-Za-z0-9\.]+$}} for_loop(); foreach_loop(); foreachrange_loop(); label_goto(); c_switches(); d_switches(); booleanlogic(); do_while(); // Detect function end: // PROFUSE: ret i32 0 // PROFUSE-NEXT: } } // PROFUSE-DAG: ![[FL0]] = !{!"function_entry_count", i64 1} // PROFUSE-DAG: ![[FL1]] = !{!"branch_weights", i32 392, i32 1} // PROFUSE-DAG: ![[FL2]] = !{!"branch_weights", i32 2, i32 391} // PROFUSE-DAG: ![[FL3]] = !{!"branch_weights", i32 390, i32 2} // PROFUSE-DAG: ![[FL4]] = !{!"branch_weights", i32 388, i32 4} // PROFUSE-DAG: ![[FL5]] = !{!"branch_weights", i32 2, i32 1} // PROFUSE-DAG: ![[FL6]] = !{!"branch_weights", i32 2, i32 1} // PROFUSE-DAG: ![[FEL0]] = !{!"function_entry_count", i64 1} // PROFUSE-DAG: ![[FEL1]] = !{!"branch_weights", i32 392, i32 1} // PROFUSE-DAG: ![[FEL2]] = !{!"branch_weights", i32 2, i32 391} // PROFUSE-DAG: ![[FEL3]] = !{!"branch_weights", i32 390, i32 2} // PROFUSE-DAG: ![[FEL4]] = !{!"branch_weights", i32 388, i32 4} // PROFUSE-DAG: ![[FERL0]] = !{!"function_entry_count", i64 1} // PROFUSE-DAG: ![[FERL1]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[FERL2]] = !{!"branch_weights", i32 392, i32 1} // PROFUSE-DAG: ![[FERL3]] = !{!"branch_weights", i32 2, i32 391} // PROFUSE-DAG: ![[FERL4]] = !{!"branch_weights", i32 390, i32 2} // PROFUSE-DAG: ![[FERL5]] = !{!"branch_weights", i32 388, i32 4} // PROFUSE-DAG: ![[LG0]] = !{!"function_entry_count", i64 1} // PROFUSE-DAG: ![[LG2]] = !{!"branch_weights", i32 2, i32 10} // PROFUSE-DAG: ![[SW0]] = !{!"function_entry_count", i64 1} // PROFUSE-DAG: ![[SW1]] = !{!"branch_weights", i32 16, i32 1} // PROFUSE-DAG: ![[SW2]] = !{!"branch_weights", i32 6, i32 2, i32 3, i32 4, i32 5} // PROFUSE-DAG: ![[SW3]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[SW4]] = !{!"branch_weights", i32 3, i32 1} // PROFUSE-DAG: ![[SW5]] = !{!"branch_weights", i32 4, i32 1} // PROFUSE-DAG: ![[SW6]] = !{!"branch_weights", i32 5, i32 1} // PROFUSE-DAG: ![[SW7]] = !{!"branch_weights", i32 1, i32 2, i32 2, i32 2, i32 2} // PROFUSE-DAG: ![[SW8]] = !{!"branch_weights", i32 5, i32 1} // PROFUSE-DAG: ![[SW9]] = !{!"branch_weights", i32 2, i32 5} // PROFUSE-DAG: ![[DSW0]] = !{!"function_entry_count", i64 1} // PROFUSE-DAG: ![[DSW1]] = !{!"branch_weights", i32 4, i32 2} // PROFUSE-DAG: ![[DSW2]] = !{!"branch_weights", i32 2, i32 2, i32 1, i32 2, i32 1} // PROFUSE-DAG: ![[DSW5]] = !{!"branch_weights", i32 2, i32 2} // PROFUSE-DAG: ![[DSW9]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[DSW13]] = !{!"branch_weights", i32 1, i32 -1} // PROFUSE-DAG: ![[BOOL0]] = !{!"function_entry_count", i64 1} // PROFUSE-DAG: ![[BOOL1]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[BOOL2]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[BOOL4]] = !{!"branch_weights", i32 2, i32 1} // PROFUSE-DAG: ![[BOOL5]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[BOOL6]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[BOOL7]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[BOOL8]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[DW0]] = !{!"function_entry_count", i64 1} // PROFUSE-DAG: ![[DW1]] = !{!"branch_weights", i32 33, i32 1} // PROFUSE-DAG: ![[DW2]] = !{!"branch_weights", i32 10, i32 25} // PROFUSE-DAG: ![[DW3]] = !{!"branch_weights", i32 2, i32 24} // PROFUSE-DAG: ![[DW4]] = !{!"branch_weights", i32 32, i32 2} // PROFUSE-DAG: ![[DW5]] = !{!"branch_weights", i32 32, i32 1} ./ldc-1.42.0-src/tests/PGO/switch_disable.d0000644000175000017500000000271615205374122017133 0ustar fabiofabio// Test function-level enabling/disabling of instrumentation of switch statements. // RUN: %ldc -boundscheck=off -c -output-ll -fprofile-instr-generate -of=%t.ll %s && FileCheck %s --check-prefix=PROFGEN < %t.ll extern (C): // simplify name mangling for simpler string matching // PROFGEN-LABEL: @enabled( int enabled(int i) { pragma(LDC_profile_instr, true); switch (i) { // PROFGEN: casecntr case 1: return 1; // PROFGEN: casecntr case 2: return 2; // PROFGEN: defaultcntr default: return 3; } } // PROFGEN-LABEL: @disabled( // PROFGEN-NOT: casecntr // PROFGEN-NOT: defaultcntr int disabled(int i) { pragma(LDC_profile_instr, false); switch (i) { case 1: return 1; case 2: return 2; default: return 3; } } // PROFGEN-LABEL: @bunch_of_branches_enabled( int bunch_of_branches_enabled(int i, const int two) { pragma(LDC_profile_instr, true); switch (i) { // PROFGEN: casecntr case 1: return 1; // PROFGEN: casecntr case two: return 2; // PROFGEN: defaultcntr default: return 3; } } // PROFGEN-LABEL: @bunch_of_branches_disabled( // PROFGEN-NOT: casecntr // PROFGEN-NOT: defaultcntr int bunch_of_branches_disabled(int i, const int two) { pragma(LDC_profile_instr, false); switch (i) { case 1: return 1; case two: return 2; default: return 3; } } ./ldc-1.42.0-src/tests/PGO/uninstrumented_main.d0000644000175000017500000000047215205374122020234 0ustar fabiofabio// Test that autogenerated C main() is never instrumented. // RUN: %ldc -c -output-ll -fprofile-instr-generate -of=%t.ll %s && FileCheck %s < %t.ll // CHECK-DAG: @__{{(llvm_profile_counters|profc)}}__Dmain ={{.*}} [1 x i64] zeroinitializer // CHECK-NOT: @__{{(llvm_profile_counters|profc)}}_main void main() {} ./ldc-1.42.0-src/tests/PGO/withO.d0000644000175000017500000000024315205374122015232 0ustar fabiofabio// Test instrumentation codegen with -O // (tests correct setup of LLVM optimizer passes) // RUN: %ldc -c -O -fprofile-instr-generate -of=%t.o %s void main() {} ./ldc-1.42.0-src/tests/PGO/irbased_indirect_calls.d0000644000175000017500000000231315205374122020610 0ustar fabiofabio// Test instrumentation of indirect calls // REQUIRES: PGO_RT // FIXME: fails with LLVM 13+ for Windows, call remains indirect // XFAIL: Windows // RUN: %ldc -O3 -fprofile-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -O3 -c -output-ll -of=%t.use.ll -fprofile-use=%t.profdata %s \ // RUN: && FileCheck %s -check-prefix=PROFUSE < %t.use.ll import ldc.attributes; extern (C) { // simplify name mangling for simpler string matching @optStrategy("none") void hot() { } void luke() { } void cold() { } void function() foo; @weak // disable reasoning about this function void select_func(int i) { if (i < 1700) foo = &hot; else if (i < 1990) foo = &luke; else foo = &cold; } } // extern C // PROFUSE-LABEL: @_Dmain( int main() { for (int i; i < 2000; ++i) { select_func(i); // PROFUSE: [[REG1:%[0-9]+]] = load ptr, ptr @foo // PROFUSE: [[REG2:%[0-9]+]] = icmp eq ptr [[REG1]], @hot // PROFUSE: call void @hot() // PROFUSE: call void [[REG1]]() foo(); } return 0; } ./ldc-1.42.0-src/tests/PGO/indirect_calls.d0000644000175000017500000000326715205374122017130 0ustar fabiofabio// Test instrumentation of indirect calls // REQUIRES: PGO_RT // FIXME: fails with LLVM 13+, call remains indirect // XFAIL: * // RUN: %ldc -c -output-ll -fprofile-instr-generate -of=%t.ll %s && FileCheck %s --check-prefix=PROFGEN < %t.ll // RUN: %ldc -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -O3 -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %s \ // RUN: && FileCheck %s -check-prefix=PROFUSE < %t2.ll import ldc.attributes; extern (C) { // simplify name mangling for simpler string matching @optStrategy("none") // don't inline / elide call void hot() { } void luke() { } void cold() { } void function() foo; @weak // disable reasoning about this function void select_func(int i) { if (i < 1700) foo = &hot; else if (i < 1990) foo = &luke; else foo = &cold; } } // extern C // PROFGEN-LABEL: @_Dmain( // PROFUSE-LABEL: @_Dmain( int main() { for (int i; i < 2000; ++i) { select_func(i); // PROFGEN: [[REG1:%[0-9]+]] = load void ()*, void ()** @foo // PROFGEN-NEXT: [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64 // PROFGEN-NEXT: call void @__llvm_profile_instrument_target(i64 [[REG2]], i8* bitcast ({{.*}}_Dmain to i8*), i32 0) // PROFGEN-NEXT: call void [[REG1]]() // PROFUSE: [[REG1:%[0-9]+]] = load void ()*, void ()** @foo // PROFUSE: [[REG2:%[0-9]+]] = icmp eq void ()* [[REG1]], @hot // PROFUSE: call void @hot() // PROFUSE: call void [[REG1]]() foo(); } return 0; } ./ldc-1.42.0-src/tests/PGO/pragma.d0000644000175000017500000000360115205374122015410 0ustar fabiofabio// Test pragma to turn on/off PGO instrumentation // RUN: %ldc -w -c -o- %s // RUN: %ldc -w -c -output-ll -fprofile-instr-generate -of=%t.ll %s && FileCheck %s < %t.ll // disable name mangling extern(C): // CHECK-NOT: @__llvm_profile{{.*}}not_instrumented // CHECK-NOT: @__prof{{.*}}not_instrumented // CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_instrumented ={{.*}} global [1 x i64] zeroinitializer void instrumented() {} void not_instrumented() { pragma(LDC_profile_instr, false); } pragma(LDC_profile_instr, false) { void not_instrumented_2() {} // CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_instrumented2_override ={{.*}} global [1 x i64] zeroinitializer void instrumented2_override() { pragma(LDC_profile_instr, true); } // CHECK-DAG: @__{{(llvm_profile_counters|profc).*}}_{{.*}}instrumented_template{{.*}} global [1 x i64] zeroinitializer void instrumented_template(T)(T i) { pragma(LDC_profile_instr, true); } void not_instrumented_template(T)(T i) {} pragma(LDC_profile_instr, true): // CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_{{.*}}instantiate_templates{{.*}} global [1 x i64] zeroinitializer void instantiate_templates() { not_instrumented_template(1); instrumented_template(1); } } // pragma(LDC_profile_instr, false) // CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_instrumented_two ={{.*}} global [1 x i64] zeroinitializer void instrumented_two() {} pragma(LDC_profile_instr, false) struct Strukt { void not_instrumented() {} // CHECK-DAG: @__{{(llvm_profile_counters|profc).*}}_{{.*}}Strukt{{.*}}instrumented_method{{.*}} global [1 x i64] zeroinitializer void instrumented_method() { pragma(LDC_profile_instr, true); } } // CHECK-DAG: @__{{(llvm_profile_counters|profc)}}_instrumented_three ={{.*}} global [1 x i64] zeroinitializer void instrumented_three() {} ./ldc-1.42.0-src/tests/PGO/final_switch_release.d0000644000175000017500000000204415205374122020313 0ustar fabiofabio// See GH issue 3375 // REQUIRES: PGO_RT // Test instrumentation for final switches without default case. // The frontend creates hidden default case to catch runtime errors. We disable // that using `-release`. // RUN: %ldc -release -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -release -c -output-ll -of=%t.ll -fprofile-instr-use=%t.profdata %s \ // RUN: && FileCheck %s < %t.ll extern (C): // Simplify matching by disabling function name mangling enum A { Start, End } // CHECK-LABEL: @final_switch( // CHECK-SAME: !prof ![[SW0:[0-9]+]] void final_switch(A state) { // CHECK: switch {{.*}} [ // CHECK: ], !prof ![[SW1:[0-9]+]] final switch (state) { case A.Start: break; case A.End: break; } } void main() { final_switch(A.Start); final_switch(A.End); final_switch(A.Start); } // CHECK-DAG: ![[SW0]] = !{!"function_entry_count", i64 3} // CHECK-DAG: ![[SW1]] = !{!"branch_weights", i32 1, i32 3, i32 2} ./ldc-1.42.0-src/tests/PGO/eh_gh1943.d0000644000175000017500000000020015205374122015524 0ustar fabiofabio// RUN: %ldc -c -fprofile-instr-generate=%t.profraw %s void foo(); void bar() { try { foo(); } catch (Throwable) {} } ./ldc-1.42.0-src/tests/PGO/summary.d0000644000175000017500000000077015205374122015642 0ustar fabiofabio// Test that maximum function counts are set correctly // REQUIRES: PGO_RT // RUN: %ldc -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %s \ // RUN: && FileCheck %s < %t2.ll // CHECK: !{{[0-9]+}} = !{i32 1, !"ProfileSummary", !{{[0-9]+}}} // CHECK: !{{[0-9]+}} = !{!"MaxFunctionCount", i64 2} void foo() {} void bar() {} void main() { foo(); bar(); bar(); } ./ldc-1.42.0-src/tests/PGO/boundscheck.d0000644000175000017500000000221415205374122016430 0ustar fabiofabio// Test instrumentation of autogenerated boundschecking calls // Boundschecks are inserted for (a) array indexing and (b) array slicing. // Boundschecks should not be instrumented. // The fail branch of a boundscheck goes to a basicblock that terminates in // 'unreachable'. This means that LLVM will already assign minimum probability // to the fail branch and maximum probability to the pass branch. See the // documentation of UR_TAKEN_WEIGHT and UR_NONTAKEN_WEIGHT in file // "llvm/Analysis/BranchProbabilityInfo.cpp". // Adding instrumentation to boundschecks would only add runtime overhead at // zero benefit. // The tests here check for the absence of the instrumentation of boundschecks. // RUN: %ldc -c -output-ll -fprofile-instr-generate -of=%t.ll %s && FileCheck %s --check-prefix=PROFGEN < %t.ll // PROFGEN: @[[MAIN:__(llvm_profile_counters|profc)__Dmain]] ={{.*}} global [1 x i64] zeroinitializer // PROFGEN-LABEL: @_Dmain( // PROFGEN: store {{.*}} @[[MAIN]] @safe: void main() { int[] array = [1,2,3]; // PROFGEN-NOT: store {{.*}} @[[MAIN]] auto one = array[2]; // (a) array indexing auto two = array[1..2]; // (b) array slicing } ./ldc-1.42.0-src/tests/PGO/lit.local.cfg0000644000175000017500000000015315205374122016335 0ustar fabiofabio# Add "PGO_RT" feature if 'profile' in config.enabled_rt_libs: config.available_features.add('PGO_RT') ./ldc-1.42.0-src/tests/PGO/branching_switch.d0000644000175000017500000000665615205374122017472 0ustar fabiofabio// Test instrumentation of switch with non-constant case expression. // REQUIRES: PGO_RT // RUN: %ldc -c -output-ll -fprofile-instr-generate -of=%t.ll %s \ // RUN: && FileCheck -allow-deprecated-dag-overlap %s --check-prefix=PROFGEN < %t.ll // RUN: %ldc -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -boundscheck=off -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %s \ // RUN: && FileCheck -allow-deprecated-dag-overlap %s -check-prefix=PROFUSE < %t2.ll extern(C): // simplify name mangling for simpler string matching // PROFGEN-DAG: @[[BoB:__(llvm_profile_counters|profc)_bunch_of_branches]] ={{.*}} global [15 x i64] zeroinitializer // PROFGEN-LABEL: @bunch_of_branches(i32 // PROFUSE-LABEL: @bunch_of_branches(i32 // PROFGEN: store {{.*}} @[[BoB]] // PROFUSE-SAME: !prof ![[BoB0:[0-9]+]] void bunch_of_branches(const uint two) { uint i; // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[BoB1:[0-9]+]] for (i = 1; i < 4; ++i) { switch (i) { // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 3 case 1: // 1 + 1*gototarget // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 4 // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 5 // PROFUSE: br {{.*}} !prof ![[BoB5:[0-9]+]] if (i != 1) {} goto default; // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 6 case 11: // 0x // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 7 // never reached, no branch weights if (i != 11) {} goto case; // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 8 case two: // 1x // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 9 // PROFUSE: br {{.*}} !prof ![[BoB9:[0-9]+]] if (i != 2) {} goto case 1; // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 10 default: // 1 + 2*gototarget // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 11 goto case; // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 12 case 5: // 0 + 3*fallthrough // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 13 // PROFUSE: br {{.*}} !prof ![[BoB13:[0-9]+]] if (i != 5) {} break; } // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 2 // Bunch of compares and branches is put at the end in IR // PROFUSE: br {{.*}} !prof ![[BoB3:[0-9]+]] // PROFUSE: br {{.*}} !prof ![[BoB6:[0-9]+]] // PROFUSE: br {{.*}} !prof ![[BoB8:[0-9]+]] // PROFUSE: br {{.*}} !prof ![[BoB12:[0-9]+]] } // PROFGEN: store {{.*}} @[[BoB]], i{{32|64}} 0, i{{32|64}} 14 // PROFUSE: br {{.*}} !prof ![[BoB14:[0-9]+]] if (i) {} } // PROFGEN-LABEL: @_Dmain( // PROFUSE-LABEL: @_Dmain( extern(D): void main() { bunch_of_branches(2); } // PROFUSE-DAG: ![[BoB0]] = !{!"function_entry_count", i64 1} // PROFUSE-DAG: ![[BoB1]] = !{!"branch_weights", i32 4, i32 2} // PROFUSE-DAG: ![[BoB3]] = !{!"branch_weights", i32 2, i32 3} // PROFUSE-DAG: ![[BoB6]] = !{!"branch_weights", i32 1, i32 3} // PROFUSE-DAG: ![[BoB8]] = !{!"branch_weights", i32 2, i32 2} // PROFUSE-DAG: ![[BoB12]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[BoB5]] = !{!"branch_weights", i32 2, i32 2} // PROFUSE-DAG: ![[BoB9]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[BoB13]] = !{!"branch_weights", i32 1, i32 -1} ./ldc-1.42.0-src/tests/PGO/hash.d0000644000175000017500000000532615205374122015072 0ustar fabiofabio// A non-exhaustive test to check that old profile information is only partially // applied when code has changed. // The code changes are simulated by version(.) blocks. // REQUIRES: PGO_RT // RUN: %ldc -d-version=ProfData -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -d-version=ProfData -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %s \ // RUN: && FileCheck -allow-deprecated-dag-overlap %s -check-prefix=PROFDATA < %t2.ll \ // RUN: && %ldc -wi -c -output-ll -of=%t3.ll -fprofile-instr-use=%t.profdata %s \ // RUN: && FileCheck -allow-deprecated-dag-overlap %s -check-prefix=NODATA < %t3.ll extern(C): // PROFDATA-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}same{{[A-Za-z0-9]*}}( // PROFDATA-SAME: !prof ![[SAME0:[0-9]+]] // NODATA-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}same{{[A-Za-z0-9]*}}( // NODATA-SAME: !prof ![[SAME0:[0-9]+]] void same(int i) { // PROFDATA: br {{.*}} !prof ![[SAME1:[0-9]+]] // NODATA: br {{.*}} !prof ![[SAME1:[0-9]+]] if (i % 3) {} } // PROFDATA-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}undetectedchange{{[A-Za-z0-9]*}}( // PROFDATA-SAME: !prof ![[UNDTCTD0:[0-9]+]] // NODATA-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}undetectedchange{{[A-Za-z0-9]*}}( // NODATA-SAME: !prof ![[UNDTCTD0:[0-9]+]] void undetectedchange(int i, int i2) { // PROFDATA: br {{.*}} !prof ![[UNDTCTD1:[0-9]+]] // NODATA: br {{.*}} !prof ![[UNDTCTD1:[0-9]+]] version(ProfData) { if (i % 3) {} } else { if (i2 % 2) {} } } // PROFDATA-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}changedhash{{[A-Za-z0-9]*}}( // PROFDATA-SAME: !prof ![[DIFF0:[0-9]+]] // NODATA-LABEL: define {{.*}} @{{[A-Za-z0-9_]*}}changedhash{{[A-Za-z0-9]*}}( // NODATA-NOT: !prof void changedhash(int i, int i2) { // PROFDATA: br {{.*}} !prof ![[DIFF1:[0-9]+]] version(ProfData) { if (i % 3) {} } else { while (i++ < i2) { } } } // PROFDATA-LABEL: define {{.*}} @_Dmain( // NODATA-LABEL: define {{.*}} @_Dmain( extern(D) void main() { foreach (int i; 0..10) { same(i); undetectedchange(i, i+2); changedhash(i, i+2); } } // PROFDATA-DAG: ![[SAME0]] = !{!"function_entry_count", i64 10} // PROFDATA-DAG: ![[SAME1]] = !{!"branch_weights", i32 7, i32 5} // NODATA-DAG: ![[SAME0]] = !{!"function_entry_count", i64 10} // NODATA-DAG: ![[SAME1]] = !{!"branch_weights", i32 7, i32 5} // PROFDATA-DAG: ![[UNDTCTD0]] = !{!"function_entry_count", i64 10} // PROFDATA-DAG: ![[UNDTCTD1]] = !{!"branch_weights", i32 7, i32 5} // NODATA-DAG: ![[UNDTCTD0]] = !{!"function_entry_count", i64 10} // NODATA-DAG: ![[UNDTCTD1]] = !{!"branch_weights", i32 7, i32 5} // PROFDATA-DAG: ![[DIFF0]] = !{!"function_entry_count", i64 10} // PROFDATA-DAG: ![[DIFF1]] = !{!"branch_weights", i32 7, i32 5} ./ldc-1.42.0-src/tests/PGO/hash_smallchange.d0000644000175000017500000000204615205374122017424 0ustar fabiofabio// Test that a small code change changes the function hash. // See: https://github.com/ldc-developers/ldc/pull/3511 and https://reviews.llvm.org/D79961 // REQUIRES: PGO_RT // RUN: %ldc -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -d-version=WithChange -c -wi -fprofile-instr-use=%t.profdata %s 2>&1 | FileCheck %s // CHECK: Warning: Ignoring profile data for function {{.*}}.foo{{.*}} control-flow hash mismatch // CHECK: Warning: Ignoring profile data for function {{.*}}.longerfunction{{.*}} control-flow hash mismatch bool bar; void foo() { if (bar) {} version(WithChange) if (bar) {} } // Function with more controlflow to trigger MD5 hashing void longerfunction() { version(WithChange) if (bar) {} if (bar) {} if (bar) {} if (bar) {} if (bar) {} if (bar) {} if (bar) {} if (bar) {} if (bar) {} if (bar) {} if (bar) {} if (bar) {} if (bar) {} if (bar) {} if (bar) {} if (bar) {} } void main() { foo(); longerfunction(); } ./ldc-1.42.0-src/tests/PGO/profile_rt_calls.d0000644000175000017500000000261015205374122017463 0ustar fabiofabio// Tests runtime profile-rt access. // REQUIRES: PGO_RT // RUN: %ldc -fprofile-instr-generate=%t.profraw -run %s import ldc.profile; bool foo(bool a, bool b) { return a ? a : b; } bool bar(bool a, bool b) { return a ? a : b; } extern(C) bool fooC(bool a, bool b) { return a; } extern(C++) bool fooCpp(bool a, bool b) { return a; } bool notinstrumented(bool a, bool b) { pragma(LDC_profile_instr, false) return a ? a : b; } extern(C) void getdataprofile() { assert( getData!foo != null ); assert( getData!fooC != null ); assert( getData!fooCpp != null ); assert( getData!notinstrumented == null ); } void check_counters() { resetAll(); foo(true, true); foo(false, true); assert( getCount!(foo)(0) == 2 ); assert( getCount!(foo)(1) == 1 ); assert( getCount!(foo)(2) == ulong.max ); assert( getCount!notinstrumented(0) == ulong.max ); bar(true, true); bar(true, true); bar(true, true); assert( getCallCount!bar == 3 ); assert( getCallCount!notinstrumented == ulong.max ); setCount!bar(0, 123); assert( getCount!(bar)(0) == 123 ); setCount!bar(3, 123); resetCounts!foo; assert( getCount!(foo)(0) == 0 ); assert( getCount!(foo)(1) == 0 ); assert( getCount!(bar)(0) == 123 ); } void main() { getdataprofile(); check_counters(); // prevent linker stripping fooC(true, false); fooCpp(true, false); } ./ldc-1.42.0-src/tests/PGO/sample_based.d0000644000175000017500000000113715205374122016562 0ustar fabiofabio// Test basic use of sample-based PGO profile // RUN: split-file %s %t // RUN: %ldc -O2 -c -gline-tables-only -output-ll -of=%t.ll -fprofile-sample-use=%t/pgo-sample.prof %t/testcase.d && FileCheck %s < %t.ll //--- pgo-sample.prof foo:100:100 1: 100 //--- testcase.d // CHECK: define{{.*}} @foo{{.*}} #[[ATTRID:[0-9]+]]{{.*}} !prof ![[PROFID:[0-9]+]] // CHECK: attributes #[[ATTRID]] = {{.*}} "use-sample-profile" // CHECK-DAG: "ProfileFormat", !"SampleProfile" // CHECK-DAG: "TotalCount", i64 100 // CHECK-DAG: ![[PROFID]] = !{!"function_entry_count", i64 101} extern (C) int foo () { return 1; } ./ldc-1.42.0-src/tests/PGO/max_function_count.d0000644000175000017500000000070515205374122020045 0ustar fabiofabio// Test that maximum function counts are set correctly // REQUIRES: PGO_RT // RUN: %ldc -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %s \ // RUN: && FileCheck %s < %t2.ll // CHECK: !{{[0-9]+}} = {{.*}}!"MaxFunctionCount", i{{(32|64)}} 2} void foo() {} void bar() {} void main() { foo(); bar(); bar(); } ./ldc-1.42.0-src/tests/PGO/reset_counters.d0000644000175000017500000000123415205374122017205 0ustar fabiofabio// Tests (the availability of) the runtime lib function to reset all profile counters. // REQUIRES: PGO_RT // RUN: %ldc -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %s \ // RUN: && FileCheck %s < %t2.ll extern(C) void foo(int N) { // CHECK-LABEL: define void @foo( // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[FOO:[0-9]+]] if (N) {} } // CHECK-LABEL: define i32 @_Dmain( void main() { import ldc.profile; foo(0); resetAll(); foo(1); } // CHECK: ![[FOO]] = !{!"branch_weights", i32 2, i32 1} ./ldc-1.42.0-src/tests/PGO/break.d0000644000175000017500000001000715205374122015223 0ustar fabiofabio// Test calculation of execution counts with loops with break-to-label and continue-to-label. // REQUIRES: PGO_RT // RUN: %ldc -c -output-ll -fprofile-instr-generate -of=%t.ll %s \ // RUN: && FileCheck -allow-deprecated-dag-overlap %s --check-prefix=PROFGEN < %t.ll // RUN: %ldc -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -boundscheck=off -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %s \ // RUN: && FileCheck -allow-deprecated-dag-overlap %s -check-prefix=PROFUSE < %t2.ll extern(C): // simplify name mangling for simpler string matching // PROFGEN-DAG: @[[BREAK:__(llvm_profile_counters|profc)_testbreak]] ={{.*}} global [8 x i64] zeroinitializer // PROFGEN-DAG: @[[CONT:__(llvm_profile_counters|profc)_testcontinue]] ={{.*}} global [8 x i64] zeroinitializer // PROFGEN-LABEL: @testbreak({{.*}}) // PROFUSE-LABEL: @testbreak({{.*}}) // PROFGEN: store {{.*}} @[[BREAK]] // PROFUSE-SAME: !prof ![[BREAK0:[0-9]+]] void testbreak(bool a) { // PROFGEN: store {{.*}} @[[BREAK]], i{{32|64}} 0, i{{32|64}} 1 outer: // PROFGEN: store {{.*}} @[[BREAK]], i{{32|64}} 0, i{{32|64}} 2 // PROFUSE: br {{.*}} !prof ![[BREAK2:[0-9]+]] foreach (i; 0..4) { // PROFGEN: store {{.*}} @[[BREAK]], i{{32|64}} 0, i{{32|64}} 3 // PROFUSE: br {{.*}} !prof ![[BREAK3:[0-9]+]] foreach (j; 0..4) { // PROFGEN: store {{.*}} @[[BREAK]], i{{32|64}} 0, i{{32|64}} 4 // PROFUSE: br {{.*}} !prof ![[BREAK4:[0-9]+]] if (i>0) break outer; // PROFGEN: store {{.*}} @[[BREAK]], i{{32|64}} 0, i{{32|64}} 5 // PROFUSE: br {{.*}} !prof ![[BREAK5:[0-9]+]] if (a) {} } // PROFGEN: store {{.*}} @[[BREAK]], i{{32|64}} 0, i{{32|64}} 6 // PROFUSE: br {{.*}} !prof ![[BREAK6:[0-9]+]] if (a) {} } // PROFGEN: store {{.*}} @[[BREAK]], i{{32|64}} 0, i{{32|64}} 7 // PROFUSE: br {{.*}} !prof ![[BREAK7:[0-9]+]] if (a) {} } // PROFGEN-LABEL: @testcontinue({{.*}}) // PROFUSE-LABEL: @testcontinue({{.*}}) // PROFGEN: store {{.*}} @[[CONT]] // PROFUSE-SAME: !prof ![[CONT0:[0-9]+]] void testcontinue(bool a) { // PROFGEN: store {{.*}} @[[CONT]], i{{32|64}} 0, i{{32|64}} 1 outer: // PROFGEN: store {{.*}} @[[CONT]], i{{32|64}} 0, i{{32|64}} 2 // PROFUSE: br {{.*}} !prof ![[CONT2:[0-9]+]] foreach (i; 0..4) { // PROFGEN: store {{.*}} @[[CONT]], i{{32|64}} 0, i{{32|64}} 3 // PROFUSE: br {{.*}} !prof ![[CONT3:[0-9]+]] foreach (j; 0..4) { // PROFGEN: store {{.*}} @[[CONT]], i{{32|64}} 0, i{{32|64}} 4 // PROFUSE: br {{.*}} !prof ![[CONT4:[0-9]+]] if (i>0) continue outer; // PROFGEN: store {{.*}} @[[CONT]], i{{32|64}} 0, i{{32|64}} 5 // PROFUSE: br {{.*}} !prof ![[CONT5:[0-9]+]] if (a) {} } // PROFGEN: store {{.*}} @[[CONT]], i{{32|64}} 0, i{{32|64}} 6 // PROFUSE: br {{.*}} !prof ![[CONT6:[0-9]+]] if (a) {} } // PROFGEN: store {{.*}} @[[CONT]], i{{32|64}} 0, i{{32|64}} 7 // PROFUSE: br {{.*}} !prof ![[CONT7:[0-9]+]] if (a) {} } // PROFGEN-LABEL: @_Dmain( // PROFUSE-LABEL: @_Dmain( extern(D): void main() { testbreak(false); testcontinue(false); } // PROFUSE-DAG: ![[BREAK0]] = !{!"function_entry_count", i64 1} // PROFUSE-DAG: ![[BREAK2]] = !{!"branch_weights", i32 3, i32 1} // PROFUSE-DAG: ![[BREAK3]] = !{!"branch_weights", i32 6, i32 2} // PROFUSE-DAG: ![[BREAK4]] = !{!"branch_weights", i32 2, i32 5} // PROFUSE-DAG: ![[BREAK5]] = !{!"branch_weights", i32 1, i32 5} // PROFUSE-DAG: ![[BREAK6]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[BREAK7]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[CONT0]] = !{!"function_entry_count", i64 1} // PROFUSE-DAG: ![[CONT2]] = !{!"branch_weights", i32 5, i32 2} // PROFUSE-DAG: ![[CONT3]] = !{!"branch_weights", i32 8, i32 2} // PROFUSE-DAG: ![[CONT4]] = !{!"branch_weights", i32 4, i32 5} // PROFUSE-DAG: ![[CONT5]] = !{!"branch_weights", i32 1, i32 5} // PROFUSE-DAG: ![[CONT6]] = !{!"branch_weights", i32 1, i32 2} // PROFUSE-DAG: ![[CONT7]] = !{!"branch_weights", i32 1, i32 2} ./ldc-1.42.0-src/tests/PGO/functions.d0000644000175000017500000002343015205374122016153 0ustar fabiofabio// Test PGO for different kinds of functions // // The tests should not test function name mangling, therefore the functionname // matching strings contain regexp wildcards. // REQUIRES: PGO_RT // RUN: %ldc -c -output-ll -fprofile-instr-generate -of=%t.ll %s \ // RUN: && FileCheck -allow-deprecated-dag-overlap %s --check-prefix=PROFGEN < %t.ll // RUN: %ldc -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %s \ // RUN: && FileCheck -allow-deprecated-dag-overlap %s -check-prefix=PROFUSE < %t2.ll // PROFGEN-DAG: @[[SMPL:__(llvm_profile_counters|profc).*simplefunction[A-Za-z0-9]*]] ={{.*}} [2 x i64] zeroinitializer // PROFGEN-DAG: @[[TMPL:__(llvm_profile_counters|profc).*templatefunc[A-Za-z0-9]*]] ={{.*}} [2 x i64] zeroinitializer // PROFGEN-DAG: @[[OUTR:__(llvm_profile_counters|profc).*outerfunc[A-Za-z0-9]*]] ={{.*}} [2 x i64] zeroinitializer // PROFGEN-DAG: @[[NEST:__(llvm_profile_counters|profc).*nestedfunc[A-Za-z0-9]*]] ={{.*}} [2 x i64] zeroinitializer // PROFGEN-DAG: @[[LMBD:__(llvm_profile_counters|profc).*testanonymous.*lambda.*]] ={{.*}} [2 x i64] zeroinitializer // PROFGEN-DAG: @[[KCTR:__(llvm_profile_counters|profc).*Klass.*__ctor.*]] ={{.*}} [2 x i64] zeroinitializer // PROFGEN-DAG: @[[KMTH:__(llvm_profile_counters|profc).*Klass.*stdmethod.*]] ={{.*}} [2 x i64] zeroinitializer // PROFGEN-DAG: @[[KDTR:__(llvm_profile_counters|profc).*Klass.*__dtor.*]] ={{.*}} [2 x i64] zeroinitializer // PROFGEN-DAG: @[[KSTC:__(llvm_profile_counters|profc).*Klass.*staticmethod.*]] ={{.*}} [2 x i64] zeroinitializer // PROFGEN-DAG: @[[SCTR:__(llvm_profile_counters|profc).*Strukt.*__ctor.*]] ={{.*}} [2 x i64] zeroinitializer // PROFGEN-DAG: @[[SMTH:__(llvm_profile_counters|profc).*Strukt.*stdmethod.*]] ={{.*}} [2 x i64] zeroinitializer // PROFGEN-DAG: @[[SDTR:__(llvm_profile_counters|profc).*Strukt.*__dtor.*]] ={{.*}} [2 x i64] zeroinitializer // PROFGEN-DAG: @[[CNTR:__(llvm_profile_counters|profc).*contractprog.*]] ={{.*}} [5 x i64] zeroinitializer // PROFGEN-NOT: @{{__llvm_profile_counters_.*fwddecl.*}} // PROFGEN-NOT: @{{__profc.*fwddecl.*}} // PROFGEN-LABEL: define {{.*}} @{{.*}}simplefunction{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}simplefunction{{.*}}( // PROFGEN: store {{.*}} @[[SMPL]] // PROFUSE-SAME: !prof ![[SMPL0:[0-9]+]] void simplefunction(int i) { // PROFGEN: store {{.*}} @[[SMPL]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[SMPL1:[0-9]+]] if (i % 3) {} } // PROFGEN-LABEL: define {{.*}} @{{.*}}templatefunc{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}templatefunc{{.*}}( // PROFGEN: store {{.*}} @[[TMPL]] // PROFUSE-SAME: !prof ![[TMPL0:[0-9]+]] void templatefunc(T)(T i) { // PROFGEN: store {{.*}} @[[TMPL]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[TMPL1:[0-9]+]] if (i % 3) {} } // The purpose of this function is to pin the location of the instantiation of // templatefunc at a defined location in IR. void call_templatefunc(int i) { templatefunc!uint(i); } // PROFGEN-LABEL: define {{.*}} @{{.*}}outerfunc{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}outerfunc{{.*}}( // PROFGEN: store {{.*}} @[[OUTR]] // PROFUSE-SAME: !prof ![[OUTR0:[0-9]+]] // PROFGEN: store {{.*}} @[[OUTR]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[OUTR1:[0-9]+]] // PROFGEN-LABEL: define {{.*}} @{{.*}}nestedfunc{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}nestedfunc{{.*}}( // PROFGEN: store {{.*}} @[[NEST]] // PROFUSE-SAME: !prof ![[NEST0:[0-9]+]] // PROFGEN: store {{.*}} @[[NEST]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[NEST1:[0-9]+]] void outerfunc(int i) { void nestedfunc(int i) { if (!(i % 3)) {} } nestedfunc(i); if (i % 3) {} } void takedelegate(int i, int delegate(int) fd) { if (fd(i) % 3) {} } // PROFGEN-LABEL: define {{.*}} @{{.*}}testanonymous{{.*}}lambda{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}testanonymous{{.*}}lambda{{.*}}( // PROFGEN: store {{.*}} @[[LMBD]] // PROFUSE-SAME: !prof ![[LMBD0:[0-9]+]] // PROFGEN: store {{.*}} @[[LMBD]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[LMBD1:[0-9]+]] void testanonymous(int i) { takedelegate(i, (i) { if (i % 5) {} return i+1;} ); } class Klass { int a; // PROFGEN-LABEL: define {{.*}} @{{.*}}Klass{{.*}}__ctor{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}Klass{{.*}}__ctor{{.*}}( // PROFGEN: store {{.*}} @[[KCTR]] // PROFUSE-SAME: !prof ![[KCTR0:[0-9]+]] // PROFGEN: store {{.*}} @[[KCTR]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[KCTR1:[0-9]+]] this(int i) { a = i; if (a % 3) {} } // PROFGEN-LABEL: define {{.*}} @{{.*}}Klass{{.*}}__dtor{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}Klass{{.*}}__dtor{{.*}}( // PROFGEN: store {{.*}} @[[KDTR]] // PROFUSE-SAME: !prof ![[KDTR0:[0-9]+]] // PROFGEN: store {{.*}} @[[KDTR]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[KDTR1:[0-9]+]] ~this() { if (!(a % 3)) {} } // PROFGEN-LABEL: define {{.*}} @{{.*}}Klass{{.*}}stdmethod{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}Klass{{.*}}stdmethod{{.*}}( // PROFGEN: store {{.*}} @[[KMTH]] // PROFUSE-SAME: !prof ![[KMTH0:[0-9]+]] // PROFGEN: store {{.*}} @[[KMTH]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[KMTH1:[0-9]+]] void stdmethod() { if (a % 4) {} } // PROFGEN-LABEL: define {{.*}} @{{.*}}Klass{{.*}}staticmethod{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}Klass{{.*}}staticmethod{{.*}}( // PROFGEN: store {{.*}} @[[KSTC]] // PROFUSE-SAME: !prof ![[KSTC0:[0-9]+]] // PROFGEN: store {{.*}} @[[KSTC]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[KSTC1:[0-9]+]] static void staticmethod(int i) { if (i % 2) {} } } struct Strukt { int a; // PROFGEN-LABEL: define {{.*}} @{{.*}}Strukt{{.*}}__ctor{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}Strukt{{.*}}__ctor{{.*}}( // PROFGEN: store {{.*}} @[[SCTR]] // PROFUSE-SAME: !prof ![[SCTR0:[0-9]+]] // PROFGEN: store {{.*}} @[[SCTR]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[SCTR1:[0-9]+]] this(int i) { a = i; if (a % 3) {} } // PROFGEN-LABEL: define {{.*}} @{{.*}}Strukt{{.*}}stdmethod{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}Strukt{{.*}}stdmethod{{.*}}( // PROFGEN: store {{.*}} @[[SMTH]] // PROFUSE-SAME: !prof ![[SMTH0:[0-9]+]] // PROFGEN: store {{.*}} @[[SMTH]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[SMTH1:[0-9]+]] void stdmethod() { if (a % 4) {} } // PROFGEN-LABEL: define {{.*}} @{{.*}}Strukt{{.*}}__dtor{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}Strukt{{.*}}__dtor{{.*}}( // PROFGEN: store {{.*}} @[[SDTR]] // PROFUSE-SAME: !prof ![[SDTR0:[0-9]+]] // PROFGEN: store {{.*}} @[[SDTR]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[SDTR1:[0-9]+]] ~this() { if (!(a % 3)) {} } } // PROFGEN-LABEL: define {{.*}} @{{.*}}contractprog{{.*}}( // PROFUSE-LABEL: define {{.*}} @{{.*}}contractprog{{.*}}( // PROFGEN: store {{.*}} @[[CNTR]] // PROFUSE-SAME: !prof ![[CNTR0:[0-9]+]] void contractprog(int i) in { // PROFGEN: store {{.*}} @[[CNTR]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[CNTR1:[0-9]+]] if (i < 3) {} } out { if (i < 6) {} } body { // PROFGEN: store {{.*}} @[[CNTR]], i{{32|64}} 0, i{{32|64}} 2 // PROFUSE: br {{.*}} !prof ![[CNTR2:[0-9]+]] if (i % 2) {} } // Out label+body: // PROFGEN: store {{.*}} @[[CNTR]], i{{32|64}} 0, i{{32|64}} 3 // PROFGEN: store {{.*}} @[[CNTR]], i{{32|64}} 0, i{{32|64}} 4 // PROFUSE: br {{.*}} !prof ![[CNTR4:[0-9]+]] // Check that no code is generated for function declarations without definition. // PROFGEN-NOT: define {{.*}} @fwddecl( // PROFUSE-NOT: define {{.*}} @fwddecl( extern (C) void fwddecl(int); void main() { foreach (int i; 0..10) { simplefunction(i); call_templatefunc(i); outerfunc(i); testanonymous(i); scope k = new Klass(i); // `scope` for deterministic finalization k.stdmethod(); Klass.staticmethod(i); auto s = Strukt(i); s.stdmethod(); contractprog(i); } } // PROFUSE-DAG: ![[SMPL0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[SMPL1]] = !{!"branch_weights", i32 7, i32 5} // PROFUSE-DAG: ![[TMPL0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[TMPL1]] = !{!"branch_weights", i32 7, i32 5} // PROFUSE-DAG: ![[OUTR0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[OUTR1]] = !{!"branch_weights", i32 7, i32 5} // PROFUSE-DAG: ![[NEST0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[NEST1]] = !{!"branch_weights", i32 5, i32 7} // PROFUSE-DAG: ![[LMBD0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[LMBD1]] = !{!"branch_weights", i32 9, i32 3} // PROFUSE-DAG: ![[KCTR0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[KCTR1]] = !{!"branch_weights", i32 7, i32 5} // PROFUSE-DAG: ![[KMTH0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[KMTH1]] = !{!"branch_weights", i32 8, i32 4} // PROFUSE-DAG: ![[KDTR0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[KDTR1]] = !{!"branch_weights", i32 5, i32 7} // PROFUSE-DAG: ![[KSTC0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[KSTC1]] = !{!"branch_weights", i32 6, i32 6} // PROFUSE-DAG: ![[SCTR0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[SCTR1]] = !{!"branch_weights", i32 7, i32 5} // PROFUSE-DAG: ![[SMTH0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[SMTH1]] = !{!"branch_weights", i32 8, i32 4} // PROFUSE-DAG: ![[SDTR0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[SDTR1]] = !{!"branch_weights", i32 5, i32 7} // PROFUSE-DAG: ![[CNTR0]] = !{!"function_entry_count", i64 10} // PROFUSE-DAG: ![[CNTR1]] = !{!"branch_weights", i32 4, i32 8} // PROFUSE-DAG: ![[CNTR2]] = !{!"branch_weights", i32 6, i32 6} // PROFUSE-DAG: ![[CNTR4]] = !{!"branch_weights", i32 7, i32 5} ./ldc-1.42.0-src/tests/PGO/exceptions.d0000644000175000017500000001244515205374122016330 0ustar fabiofabio// Test instrumentation of statement types involving exceptions. // REQUIRES: PGO_RT // XFAIL: Windows // RUN: %ldc -c -output-ll -fprofile-instr-generate -of=%t.ll %s && FileCheck %s --check-prefix=PROFGEN < %t.ll // RUN: %ldc -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -boundscheck=off -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %s \ // RUN: && FileCheck %s -check-prefix=PROFUSE < %t2.ll extern(C): // simplify name mangling for simpler string matching // PROFGEN-DAG: @[[TC:__(llvm_profile_counters|profc)_try_catch]] ={{.*}} global [9 x i64] zeroinitializer // FIXME: fix the nr of counter entries: // PROFGEN-DAG: @[[TF:__(llvm_profile_counters|profc)_try_finally]] ={{.*}} global [{{[0-9]+}} x i64] zeroinitializer // PROFGEN-DAG: @[[SCP:__(llvm_profile_counters|profc)_scope_stmts]] ={{.*}} global [{{[0-9]+}} x i64] zeroinitializer // Simple classes to disambiguate different throw statements class ExceptionTwo : Exception { this(string s) { super(s); } } class ExceptionThree : Exception { this(string s) { super(s); } } // PROFGEN-LABEL: @scope_stmts( // PROFUSE-LABEL: @scope_stmts( // PROFGEN: store {{.*}} @[[SCP]] // PROFUSE-SAME: !prof ![[SCP0:[0-9]+]] void scope_stmts(bool fail) { int i; scope(failure) i += 890; scope(exit) i += 234; scope(success) i += 456; if (fail) throw new Exception(i ? "true string" : "fail scope_stmts"); // OnScope statements are lowered into TryCatch statements. // Simplify the tests to only make sure that all conditional branches have // branch weights, // PROFUSE-NOT: {{br i1 %[0-9]+, label %[A-Za-z0-9\.]+, label %[A-Za-z0-9\.]+$}} // and test that switches have profiling information too // P ROFUSE-NOT: {{^[ ]+\]$}} // Detect function end: // PROFUSE: ret void } // PROFGEN-LABEL: @try_catch() // PROFUSE-LABEL: @try_catch() // PROFGEN: store {{.*}} @[[TC]] // PROFUSE-SAME: !prof ![[TC0:[0-9]+]] void try_catch() { // PROFGEN: store {{.*}} @[[TC]], i{{32|64}} 0, i{{32|64}} 1 // PROFUSE: br {{.*}} !prof ![[TC1:[0-9]+]] for (int i = 0; i < 6; ++i) { // 6 : 0 (branch taken) // The IR for TryStatements has a very unintuitive ordering. // The IR block ordering needs to be improved, but for now we have to // carefully read the generated IR and put the checks here in the according // order. // The try statement and exception catches receive their counter numbers // before recursing into the try body and exception handlers. try { if (i < 2) { // 2 : 4 (branch taken) throw new ExceptionThree("first"); // 2x } else if (i < 5) { // 3 : 1 (branch taken) throw new ExceptionTwo("two"); // 3x } throw new Exception("Uncaught exception"); } catch (ExceptionTwo e) { // 3 : 3 (match : pass) if (i) {} // 3 : 0 (branch taken) } catch (ExceptionThree e) { // 2 : 1 (match : pass) if (i) {} // 1 : 1 (branch taken) } // Try body: if(i < 2) // PROFGEN: store {{.*}} @[[TC]], i{{32|64}} 0, i{{32|64}} 5 // More try body: if(i < 5) // PROFGEN: store {{.*}} @[[TC]], i{{32|64}} 0, i{{32|64}} 6 // ExceptionTwo body: // PROFGEN: store {{.*}} @[[TC]], i{{32|64}} 0, i{{32|64}} 3 // More ExceptionTwo body: if(i) // PROFGEN: store {{.*}} @[[TC]], i{{32|64}} 0, i{{32|64}} 7 // ExceptionThree body: // PROFGEN: store {{.*}} @[[TC]], i{{32|64}} 0, i{{32|64}} 4 // More ExceptionThree body: if(i) // PROFGEN: store {{.*}} @[[TC]], i{{32|64}} 0, i{{32|64}} 8 // Try end: // PROFGEN: store {{.*}} @[[TC]], i{{32|64}} 0, i{{32|64}} 2 // Try body: if(i < 2) // PROFUSE: br {{.*}} !prof ![[TC5:[0-9]+]] // More try body: if(i < 5) // PROFUSE: br {{.*}} !prof ![[TC6:[0-9]+]] // Catch bodies: if(i) // PROFUSE: br {{.*}} !prof ![[TC7:[0-9]+]] // PROFUSE: br {{.*}} !prof ![[TC8:[0-9]+]] // Landing pad - match ExceptionTwo: // PROFUSE: br {{.*}} !prof ![[TC3:[0-9]+]] // Landing pad - match ExceptionThree: // PROFUSE: br {{.*}} !prof ![[TC4:[0-9]+]] } } // PROFGEN-LABEL: @try_finally() // PROFUSE-LABEL: @try_finally() // PROFGEN: store {{.*}} @[[TF]] // PROFUSE-SAME: !prof ![[TF0:[0-9]+]] void try_finally() { int i; try { i+=512; if (!i) throw new Exception("first"); } finally { i+=765; //throw new Exception("second"); } // } catch (Exception e) { // i+=91;//if (true) {} //} } // PROFGEN-LABEL: @_Dmain( // PROFUSE-LABEL: @_Dmain( extern(D): void main() { try { // for testing an escaping Exception try_catch(); } catch (Exception e) {} try_finally(); scope_stmts(false); try { scope_stmts(true); } catch (Exception e) {} // Detect function end: // PROFUSE: ret i32 0 } // PROFUSE-DAG: ![[TC0]] = !{!"function_entry_count", i64 1} // PROFUSE-DAG: ![[TC1]] = !{!"branch_weights", i32 7, i32 1} // PROFUSE-DAG: ![[TC5]] = !{!"branch_weights", i32 3, i32 5} // PROFUSE-DAG: ![[TC6]] = !{!"branch_weights", i32 4, i32 2} // PROFUSE-DAG: ![[TC7]] = !{!"branch_weights", i32 4, i32 1} // PROFUSE-DAG: ![[TC3]] = !{!"branch_weights", i32 4, i32 4} // PROFUSE-DAG: ![[TC4]] = !{!"branch_weights", i32 3, i32 2} // PROFUSE-DAG: ![[TC8]] = !{!"branch_weights", i32 2, i32 2} // PROFUSE-DAG: ![[SCP0]] = !{!"function_entry_count", i64 2} ./ldc-1.42.0-src/tests/PGO/singleobj.d0000644000175000017500000000074415205374122016122 0ustar fabiofabio// Tests simulaneous compilation into singleobj // REQUIRES: PGO_RT // RUN: %ldc -fprofile-instr-generate=%t.profraw %S/inputs/singleobj_input.d -c -of=%t%obj \ // RUN: && %ldc -fprofile-instr-generate=%t.profraw %t%obj -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -singleobj -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %S/inputs/singleobj_input.d %s void foo() {} void bar() {} void main() { foo(); bar(); bar(); } ./ldc-1.42.0-src/tests/PGO/const_cond.d0000644000175000017500000000226715205374122016301 0ustar fabiofabio// Test that generation of PGO counters is the same as with // the no-elision version. // RUN: %ldc -c -output-ll -fprofile-instr-generate -of=%t.ll %s && FileCheck %s < %t.ll extern(C): // Test that we have exactly 2 counters for `foo` (one for the function, one for the `if`) // and only one counter for `bar` (bar has always false if, should be elided). // CHECK: @__{{(llvm_profile_counters|profc)}}_foo ={{.*}} [2 x i64] zeroinitializer // We want 2 counters here too, no matter that the second one (for the `if`) is not referenced. // It may be queried by the user. // CHECK: @__{{(llvm_profile_counters|profc)}}_bar ={{.*}} [2 x i64] zeroinitializer // CHECK-LABEL: @foo() // - Counters appear in triads: // 1) load counter // 2) increment it // 3) store back // The first 2 contain a `pgocount*` named register. void foo() { // CHECK-NOT: pgocount // CHECK: pgocount // CHECK: pgocount // CHECK: pgocount // CHECK: pgocount // CHECK-NOT: pgocount if (true) { int a; } } // CHECK-LABEL: @bar void bar() { // CHECK-NOT: pgocount // CHECK: pgocount // CHECK: pgocount // CHECK-NOT: pgocount if (false) { int a; } } ./ldc-1.42.0-src/tests/PGO/thinlto_pgo.d0000644000175000017500000000110615205374122016465 0ustar fabiofabio// Test execution path for ThinLTO when PGO data is available. // I manually verified that PGO data is added to the ThinLTO module summary, but do not know how to automatically test this reliably. // REQUIRES: LTO // REQUIRES: PGO_RT // RUN: %ldc -fprofile-instr-generate=%t.profraw -run %s \ // RUN: && %profdata merge %t.profraw -o %t.profdata \ // RUN: && %ldc -c -flto=thin -of=%t2%obj -fprofile-instr-use=%t.profdata %s void coldfunction() { } void hotfunction() { } void main() { coldfunction(); foreach (i; 0 .. 1000) { hotfunction(); } } ./ldc-1.42.0-src/tests/PGO/unrolledloopstatement_gh3375.d0000644000175000017500000000474515205374122021616 0ustar fabiofabio// Test PGO instrumentation and profile use for front-end-unrolled loops. // REQUIRES: PGO_RT // RUN: %ldc -fprofile-instr-generate=%t.profraw -run %s // RUN: %profdata merge %t.profraw -o %t.profdata // RUN: %ldc -c -output-ll -of=%t2.ll -fprofile-instr-use=%t.profdata %s // RUN: FileCheck -allow-deprecated-dag-overlap %s -check-prefix=PROFUSE < %t2.ll alias AliasSeq(TList...) = TList; void main() { foreach (i; 0..400) foofoofoo(i); } // PROFUSE-LABEL: define void @foofoofoo( // PROFUSE-SAME: !prof ![[FUNCENTRY:[0-9]+]] extern(C) void foofoofoo(int i) { alias R = AliasSeq!(char, int); foreach (j, r; R) { if (i + 125*j > 200) continue; if (i + 125*j > 150) break; if (i-j == 0) goto function_exit; } /* The loop will be unrolled to: { // Here: i in [0..399] = 400 counts // PROFUSE: br {{.*}} !prof ![[IF1_1:[0-9]+]] if (i + 0 > 200) continue; // [201..399] = 199 counts // [0..200] = 201 counts // PROFUSE: br {{.*}} !prof ![[IF1_2:[0-9]+]] if (i + 0 > 150) break; // [151..200] = 50 counts // [0..150] = 151 counts // PROFUSE: br {{.*}} !prof ![[IF1_3:[0-9]+]] if (i-0 == 0) goto function_exit; } { // [1..150] U [201..399] = 150+199 = 349 counts // PROFUSE: br {{.*}} !prof ![[IF2_1:[0-9]+]] if (i + 125 > 200) continue; // [76..150] U [201..399] = 75+199 = 274 counts // [1..75] = 75 counts // PROFUSE: br {{.*}} !prof ![[IF2_2:[0-9]+]] if (i + 125 > 150) break; // [26..75] = 50 counts // [1..25] = 25 counts // PROFUSE: br {{.*}} !prof ![[IF2_3:[0-9]+]] if (i-1 == 0) goto function_exit; } */ // [2..400] = 398 counts // PROFUSE: br {{.*}} !prof ![[IFEXIT:[0-9]+]] if (i) {} // always true // 400 counts function_exit: } // PROFUSE-DAG: ![[FUNCENTRY]] = !{!"function_entry_count", i64 400} // PROFUSE-DAG: ![[IF1_1]] = !{!"branch_weights", i32 200, i32 202} // PROFUSE-DAG: ![[IF1_2]] = !{!"branch_weights", i32 51, i32 152} // PROFUSE-DAG: ![[IF1_3]] = !{!"branch_weights", i32 2, i32 151} // PROFUSE-DAG: ![[IF2_1]] = !{!"branch_weights", i32 275, i32 76} // PROFUSE-DAG: ![[IF2_2]] = !{!"branch_weights", i32 51, i32 26} // PROFUSE-DAG: ![[IF2_3]] = !{!"branch_weights", i32 2, i32 25} // PROFUSE-DAG: ![[IFEXIT]] = !{!"branch_weights", i32 399, i32 1} ./ldc-1.42.0-src/tests/fail_compilation/0000755000175000017500000000000015205374122016660 5ustar fabiofabio./ldc-1.42.0-src/tests/fail_compilation/inputs/0000755000175000017500000000000015205374122020202 5ustar fabiofabio./ldc-1.42.0-src/tests/fail_compilation/inputs/asm_diagnostics2.d0000644000175000017500000000021115205374122023572 0ustar fabiofabiomodule asm_diagnostics2; void barTemplate()() { import ldc.llvmasm; __asm( `hello movq 123, %elx`, "~{eax}"); } ./ldc-1.42.0-src/tests/fail_compilation/asm_error_gh4293.d0000644000175000017500000000031215205374122022012 0ustar fabiofabio// Make sure an invalid asm instruction causes a non-zero exit code. // RUN: not %ldc -c %s 2> %t.stderr // RUN: FileCheck %s < %t.stderr void main() { asm { "some_garbage"; } } // CHECK: error: ./ldc-1.42.0-src/tests/fail_compilation/no_address_for_intrinsics.d0000644000175000017500000000074615205374122024270 0ustar fabiofabio// RUN: not %ldc -c %s 2>&1 | FileCheck %s import ldc.intrinsics; alias exp = llvm_exp!real; alias exp = llvm_exp!double; alias exp = llvm_exp!float; void foo() { import core.math; // CHECK: no_address_for_intrinsics.d(12): Error: cannot take the address of intrinsic function `llvm_sin` real function(real) psin = &sin; // CHECK: no_address_for_intrinsics.d(15): Error: cannot take the address of intrinsic function `llvm_exp` real function(real) pexp = &exp; } ./ldc-1.42.0-src/tests/fail_compilation/asm_gcc_indirect.d0000644000175000017500000000054615205374122022307 0ustar fabiofabio// REQUIRES: target_X86 // RUN: not %ldc -mtriple=x86_64-linux-gnu %s 2> %t.stderr // RUN: FileCheck %s < %t.stderr void indirectInput(int x) { asm { "movl %%eax, %0" : : "m" (&x) : "eax"; } } // CHECK: {{.}}asm_gcc_indirect.d(12): Error: indirect `"m"` input operands require an lvalue, but `& x` is an rvalue ./ldc-1.42.0-src/tests/fail_compilation/asm_diagnostics.d0000644000175000017500000000140315205374122022172 0ustar fabiofabio// Try to compile a single object file and check inline asm errors from // 2 source files. // REQUIRES: target_X86 // RUN: not %ldc -mtriple=x86_64-linux-gnu %s %S/inputs/asm_diagnostics2.d 2> %t.stderr // RUN: FileCheck %s < %t.stderr void foo() { import asm_diagnostics2; barTemplate(); asm { "nope\nnoper\nmovq %0, %%eax" : : "b" (123L); } } // CHECK: inputs{{.}}asm_diagnostics2.d(6):1:2: error: invalid instruction mnemonic 'hello' // CHECK: inputs{{.}}asm_diagnostics2.d(6):2:19: error: invalid register name // CHECK: asm_diagnostics.d(14):1:2: error: invalid instruction mnemonic 'nope' // CHECK: asm_diagnostics.d(14):2:1: error: invalid instruction mnemonic 'noper' // CHECK: asm_diagnostics.d(14):3:12: error: invalid operand for instruction ./ldc-1.42.0-src/tests/fail_compilation/betterC_typeinfo_diag.d0000644000175000017500000000046215205374122023320 0ustar fabiofabio// https://github.com/ldc-developers/ldc/issues/3631 // RUN: not %ldc -betterC %s 2> %t.stderr // RUN: FileCheck %s < %t.stderr extern(C) void main() { // CHECK: betterC_typeinfo_diag.d([[@LINE+1]]): Error: this array literal requires the GC and cannot be used with `-betterC` int[] foo = [1]; } ./ldc-1.42.0-src/tests/fail_compilation/global_var_collision.d0000644000175000017500000000125115205374122023207 0ustar fabiofabio// It should compile fine when not referencing the colliding external global: // RUN: %ldc -c %s -d-version=DontReference // But fail if referenced: // RUN: not %ldc -c %s -verrors-context=false 2>&1 | FileCheck %s extern(C) extern int myGlobal; version (DontReference) {} else { int dummyRef() { return myGlobal; } } // CHECK: global_var_collision.d([[@LINE+4]]): Error: Global variable type does not match previous declaration with same mangled name: `myGlobal` // CHECK-NEXT: Previous IR type: i32, mutable, thread-local // CHECK-NEXT: New IR type: i64, const, non-thread-local pragma(mangle, myGlobal.mangleof) extern(C) __gshared const long myGlobal2 = 123; ./ldc-1.42.0-src/tests/fail_compilation/gh4938.d0000644000175000017500000000023415205374122017752 0ustar fabiofabio// RUN: not %ldc -c %s 2>&1 | FileCheck %s // CHECK: gh4938.d(4): Error: expression `&"whoops"w[0]` is not a constant immutable(wchar)* x = &"whoops"w[0]; ./ldc-1.42.0-src/tests/fail_compilation/dmd_style_asm_in_inline_d_function.d0000644000175000017500000000102215205374122026100 0ustar fabiofabio// The presence of DMD-style inline assembly inhibits inlining, // so if `pragma(inline, true)` is also present, some kind of error should occur. // REQUIRES: target_X86 // RUN: not %ldc -mtriple=i686-pc-windows-msvc -c %s 2>&1 | FileCheck %s module dmd_style_asm_in_inline_d_function; // CHECK: `dmd_style_asm_in_inline_d_function.hasDMDStyleAsm` cannot be `pragma(inline, true)` as it contains DMD-style inline assembly pragma(inline, true) uint hasDMDStyleAsm(uint a) { asm { mov EAX, dword ptr [a]; } } ./ldc-1.42.0-src/tests/linking/0000755000175000017500000000000015205374122015002 5ustar fabiofabio./ldc-1.42.0-src/tests/linking/inputs/0000755000175000017500000000000015205374122016324 5ustar fabiofabio./ldc-1.42.0-src/tests/linking/inputs/link_bitcode_libs_input.d0000644000175000017500000000014115205374122023343 0ustar fabiofabiomodule inputs.link_bitcode_libs_input; pragma(lib, "imported_one"); pragma(lib, "imported_two");./ldc-1.42.0-src/tests/linking/inputs/asm_x86.d0000644000175000017500000000014715205374122017760 0ustar fabiofabiovoid foo() { asm { naked; ret; } } int simplefunction() { return 1; } ./ldc-1.42.0-src/tests/linking/inputs/link_bitcode_import.d0000644000175000017500000000017315205374122022512 0ustar fabiofabiomodule inputs.link_bitcode_import; extern(C) struct SomeStrukt { int i; } extern(C) void takeStrukt(SomeStrukt*) {}; ./ldc-1.42.0-src/tests/linking/inputs/link_bitcode_input3.d0000644000175000017500000000020315205374122022414 0ustar fabiofabiomodule inputs.link_bitcode_input3; import inputs.link_bitcode_import; void foo() { SomeStrukt r = {0}; takeStrukt(&r); } ./ldc-1.42.0-src/tests/linking/inputs/link_bitcode_input.d0000644000175000017500000000025715205374122022342 0ustar fabiofabiomodule inputs.link_bitcode_input; extern(C) int return_seven() { return 7; } import inputs.link_bitcode_import; void bar() { SomeStrukt r = {1}; takeStrukt(&r); } ./ldc-1.42.0-src/tests/linking/inputs/thinlto_ctor.d0000644000175000017500000000007715205374122021205 0ustar fabiofabioimport core.stdc.stdio; static this() { puts("ctor\n"); } ./ldc-1.42.0-src/tests/linking/link_bitcode_libs.d0000644000175000017500000000137515205374122020614 0ustar fabiofabio// Test passing of LLVM bitcode file with Linker Options set // Linker Options are currently only set on Windows platform, so we must (cross-)compile to Windows // REQUIRES: target_X86 // RUN: %ldc -mtriple=x86_64-windows -c -output-bc %S/inputs/link_bitcode_libs_input.d -of=%t.bc \ // RUN: && %ldc -mtriple=x86_64-windows -c -singleobj -output-ll %t.bc %s -of=%t.ll \ // RUN: && FileCheck %s < %t.ll pragma(lib, "library_one"); pragma(lib, "library_two"); // CHECK: !llvm.linker.options = !{![[ATTR_LIB1:[0-9]+]], ![[ATTR_LIB2:[0-9]+]], ![[ATTR_LIB3:[0-9]+]], ![[ATTR_LIB4:[0-9]+]]} // CHECK: ![[ATTR_LIB1]]{{.*}}library_one // CHECK: ![[ATTR_LIB2]]{{.*}}library_two // CHECK: ![[ATTR_LIB3]]{{.*}}imported_one // CHECK: ![[ATTR_LIB4]]{{.*}}imported_two ./ldc-1.42.0-src/tests/linking/ir2obj_caching.d0000644000175000017500000000072715205374122020020 0ustar fabiofabio// Test recognition of -cache commandline flag // RUN: %ldc -cache=%t-dir %s -vv | FileCheck --check-prefix=FIRST %s // RUN: %ldc -cache=%t-dir %s -vv | FileCheck --check-prefix=SECOND %s // FIRST: Use IR-to-Object cache in {{.*}}-dir // Don't check whether the object is in the cache on the first run, because if this test is ran twice the cache will already be there. // SECOND: Use IR-to-Object cache in {{.*}}-dir // SECOND: Cache object found! void main() { } ./ldc-1.42.0-src/tests/linking/rt_options.d0000644000175000017500000000024715205374122017352 0ustar fabiofabio// RUN: %ldc -run %s extern(C) __gshared string[] rt_options = [ "key=value" ]; void main() { import rt.config; assert(rt_configOption("key") == "value"); } ./ldc-1.42.0-src/tests/linking/thinlto_modulecdtors.d0000644000175000017500000000051515205374122021415 0ustar fabiofabio// ThinLTO: Test that module ctors/dtors are called // REQUIRES: LTO // UNSUPPORTED: FreeBSD // RUN: %ldc -flto=thin -O3 -run %s | FileCheck %s // CHECK: ctor // CHECK: main // CHECK: dtor import core.stdc.stdio; static this() { puts("ctor\n"); } static ~this() { puts("dtor\n"); } void main() { puts("main\n"); } ./ldc-1.42.0-src/tests/linking/link_bitcode.d0000644000175000017500000000136615205374122017603 0ustar fabiofabio// Test linking with an LLVM bitcode file // RUN: %ldc -c -output-bc -I%S %S/inputs/link_bitcode_input.d -of=%t.bc // RUN: %ldc -c -output-bc -I%S %S/inputs/link_bitcode_import.d -of=%t2.bc // RUN: %ldc -c -output-bc -I%S %S/inputs/link_bitcode_input3.d -of=%t3.bc // RUN: %ldc -c -singleobj -output-bc %t.bc %t3.bc %s // RUN: %ldc -c -singleobj -I%S %t.bc %s %S/inputs/link_bitcode_input3.d // RUN: %ldc -c -singleobj -I%S %t.bc %S/inputs/link_bitcode_input3.d %s // RUN: %ldc -c -I%S %t.bc %S/inputs/link_bitcode_input3.d %s // RUN: %ldc %t.bc %t2.bc %t3.bc -run %s // RUN: %ldc %t.bc %S/inputs/link_bitcode_import.d %t3.bc -run %s // Defined in input/link_bitcode_input.d extern(C) int return_seven(); void main() { assert( return_seven() == 7 ); } ./ldc-1.42.0-src/tests/linking/fulllto_1.d0000644000175000017500000000035015205374122017046 0ustar fabiofabio// Test full LTO commandline flag // REQUIRES: LTO // RUN: %ldc %s -of=%t%obj -c -flto=full -vv | FileCheck %s // RUN: %ldc -flto=full -run %s // CHECK: Writing LLVM bitcode // CHECK-NOT: Creating module summary void main() { } ./ldc-1.42.0-src/tests/linking/betterc.d0000644000175000017500000000050415205374122016576 0ustar fabiofabio// RUN: %ldc -betterC -c -output-ll -of=%t.ll %s && FileCheck %s < %t.ll // RUN: %ldc -betterC -run %s // CHECK-NOT: ModuleInfoZ // CHECK-NOT: ModuleRefZ // CHECK-NOT: call void @ldc.register_dso extern (C) int main(int argc, char** argv) { assert(argc == 1); // make sure we can link against C assert return 0; } ./ldc-1.42.0-src/tests/linking/ir2obj_cache_pruning2.d0000644000175000017500000000327415205374122021313 0ustar fabiofabio// Test cache pruning for size // This test assumes that the `void main(){}` object file size is below 200_000 bytes and above 200_000/2, // such that rebuilding with version(NEW_OBJ_FILE) will clear the cache of all but the latest object file. // RUN: %ldc %s -cache=%t-dir // RUN: %ldc %s -cache=%t-dir -cache-prune -cache-prune-interval=0 -d-version=SLEEP // RUN: %ldc %s -cache=%t-dir -cache-prune -cache-prune-interval=0 -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc %s -cache=%t-dir -cache-prune -cache-prune-interval=0 -vv -d-version=NEW_OBJ_FILE | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -cache=%t-dir -cache-prune -cache-prune-interval=0 -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc -d-version=SLEEP -run %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -cache-prune-interval=0 -cache-prune-maxbytes=200000 -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc %t%obj // RUN: %ldc %s -cache=%t-dir -d-version=SLEEP -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc -d-version=SLEEP -run %s // RUN: %ldc %s -cache=%t-dir -cache-prune-interval=1 -cache-prune-maxbytes=200000 -d-version=NEW_OBJ_FILE // RUN: %ldc %s -cache=%t-dir -cache-prune -cache-prune-interval=0 -vv | FileCheck --check-prefix=NO_HIT %s // MUST_HIT: Cache object found! // NO_HIT-NOT: Cache object found! void main() { // Add non-zero static data to guarantee a binary size larger than 200_000/2. static byte[120_000] dummy = 1; version (NEW_OBJ_FILE) { auto a = __TIME__; } version (SLEEP) { // Sleep for 4 seconds, so we are sure that the cache object file timestamps are "aging". import core.thread; Thread.sleep( dur!"seconds"(4) ); } } ./ldc-1.42.0-src/tests/linking/thinlto_modulecdtors_2.d0000644000175000017500000000044715205374122021642 0ustar fabiofabio// REQUIRES: LTO // UNSUPPORTED: FreeBSD // RUN: %ldc -flto=thin -O3 %S/inputs/thinlto_ctor.d -run %s | FileCheck --check-prefix=EXECUTE %s // EXECUTE: ctor // EXECUTE: main // EXECUTE: dtor import core.stdc.stdio; static ~this() { puts("dtor\n"); } void main() { puts("main\n"); } ./ldc-1.42.0-src/tests/linking/ir2obj_caching_flags2.d0000644000175000017500000000261115205374122021250 0ustar fabiofabio// Test that certain cmdline flags result in different cache objects, even though the LLVM IR may be the same. // Test a few fsanitize-coverage options. // Note that the NO_HIT tests should change the default setting of the tested flag. // Create and then empty the cache for correct testing when running the test multiple times. // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir // RUN: %prunecache -f %t-dir --max-bytes=1 // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -g -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -fsanitize-coverage=trace-pc-guard -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -fsanitize-coverage=8bit-counters -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -fsanitize-coverage=trace-cmp -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -g -vv | FileCheck --check-prefix=MUST_HIT %s // The last test is a MUST_HIT test (hits with the first compile invocation), to make sure that the cache wasn't pruned somehow which could effectively disable some NO_HIT tests. // MUST_HIT: Cache object found! // NO_HIT: Cache object not found. // Could hit is used for cases where we could have a cache hit, but currently we don't: a "TODO" item. // COULD_HIT: Cache object void main() {} ./ldc-1.42.0-src/tests/linking/linker_switches.d0000644000175000017500000000054415205374122020347 0ustar fabiofabio// Test if global order of flags passed with -Xcc, -L and pragma(lib) is preserved // UNSUPPORTED: Windows // RUN: %ldc %s --gcc=echo -Xcc=-Wl,-DOPT1,-DOPT2 -L-L/usr/lib -L--defsym -Lfoo=5 -Xcc -DOPT3 | FileCheck %s // CHECK: -Wl,-DOPT1,-DOPT2 -L/usr/lib -Xlinker --defsym -Xlinker foo=5 -DOPT3 {{.*}}-lpthread pragma(lib, "pthread"); void main() { } ./ldc-1.42.0-src/tests/linking/link_internally.d0000644000175000017500000000023115205374122020341 0ustar fabiofabio// REQUIRES: Windows // REQUIRES: internal_lld // RUN: %ldc -link-internally -run %s void main() { import std.stdio; writeln("Hello world"); } ./ldc-1.42.0-src/tests/linking/fullystatic.d0000644000175000017500000000062215205374122017512 0ustar fabiofabio/* Make sure -static overrides -link-defaultlib-shared. * We only care about the default libs in the linker command line; * make sure linking fails in all cases (no main()) as linking would * fail if there are no static default libs (BUILD_SHARED_LIBS=ON). */ // RUN: not %ldc -v -static -link-defaultlib-shared %s | FileCheck %s // CHECK-NOT: druntime-ldc-shared // CHECK-NOT: phobos2-ldc-shared ./ldc-1.42.0-src/tests/linking/thinlto_asm_x86.d0000644000175000017500000000042315205374122020174 0ustar fabiofabio// ThinLTO: Test inline assembly functions with thinlto // REQUIRES: LTO // REQUIRES: host_X86 // RUN: %ldc -flto=thin %S/inputs/asm_x86.d -c -of=%t_input%obj // RUN: %ldc -flto=thin -I%S %s %t_input%obj import inputs.asm_x86; int main() { return simplefunction(); } ./ldc-1.42.0-src/tests/linking/platformlib.d0000644000175000017500000000134215205374122017462 0ustar fabiofabio// Make sure -platformlib overrides the default platform libraries list. // RUN: %ldc %s -platformlib= -gcc=echo -linker=echo | FileCheck --check-prefix=EMPTY %s // EMPTY-NOT: -lrt // EMPTY-NOT: -ldl // EMPTY-NOT: -lpthread // EMPTY-NOT: -lm // EMPTY-NOT: kernel32 // EMPTY-NOT: user32 // EMPTY-NOT: gdi32 // EMPTY-NOT: winspool // EMPTY-NOT: shell32 // EMPTY-NOT: ole32 // EMPTY-NOT: oleaut32 // EMPTY-NOT: uuid // EMPTY-NOT: comdlg32 // EMPTY-NOT: advapi32 // EMPTY-NOT: oldnames // EMPTY-NOT: legacy_stdio_definitions // RUN: %ldc %s -platformlib=myPlatformLib1,myPlatformLib2 -gcc=echo -linker=echo | FileCheck --check-prefix=CUSTOM %s // CUSTOM: {{(-lmyPlatformLib1 -lmyPlatformLib2)|(myPlatformLib1.lib myPlatformLib2.lib)}} ./ldc-1.42.0-src/tests/linking/thinlto_1.d0000644000175000017500000000036315205374122017052 0ustar fabiofabio// Test ThinLTO commandline flag // REQUIRES: LTO // RUN: %ldc %s -of=%t%obj -c -flto=thin -vv | FileCheck %s // RUN: %ldc -flto=thin -O3 -run %s // CHECK: Writing LLVM bitcode // CHECK: Creating module summary for ThinLTO void main() { } ./ldc-1.42.0-src/tests/linking/ir2obj_caching_retrieval.d0000644000175000017500000000146115205374122022071 0ustar fabiofabio// Test recognition of -cache-retrieval commandline flag // RUN: %ldc -c -of=%t%obj -cache=%t-dir %s -vv | FileCheck --check-prefix=FIRST %s // RUN: %ldc -c -of=%t%obj -cache=%t-dir %s -cache-retrieval=copy -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc %t%obj // RUN: %ldc -c -of=%t%obj -cache=%t-dir %s -cache-retrieval=link -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc %t%obj // RUN: %ldc -c -of=%t%obj -cache=%t-dir %s -cache-retrieval=hardlink -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc %t%obj // FIRST: Use IR-to-Object cache in {{.*}}-dir // Don't check whether the object is in the cache on the first run, because if this test is ran twice the cache will already be there. // MUST_HIT: Use IR-to-Object cache in {{.*}}-dir // MUST_HIT: Cache object found! void main() { } ./ldc-1.42.0-src/tests/linking/linker_empty.d0000644000175000017500000000035715205374122017656 0ustar fabiofabio// Check that the user can override LDC passing `-fuse-ld` to `cc`. // REQUIRES: target_X86 // RUN: %ldc --gcc=echo --mtriple=x86_64-linux --linker= %s | FileCheck %s // CHECK-NOT: -fuse-ld // CHECK: linker_empty // CHECK-NOT: -fuse-ld ./ldc-1.42.0-src/tests/linking/ir2obj_cache_pruning.d0000644000175000017500000000104115205374122021217 0ustar fabiofabio// Test recognition of -cache-prune-* commandline flags // RUN: %ldc %s -cache=%t-dir -cache-prune // RUN: %ldc %s -cache=%t-dir -cache-prune-interval=10 -cache-prune-maxbytes=10000 // RUN: %ldc %s -cache=%t-dir -cache-prune -cache-prune-interval=0 // RUN: %ldc %s -cache=%t-dir -cache-prune -cache-prune-maxbytes=10000 // RUN: %ldc %s -cache=%t-dir -cache-prune -cache-prune-expiration=10000 // RUN: %ldc %s -cache=%t-dir -cache-prune-maxpercentage=50 // RUN: %ldc %s -cache=%t-dir -cache-prune -cache-prune-maxpercentage=150 void main() { } ./ldc-1.42.0-src/tests/linking/betterc_cleanups.d0000644000175000017500000000110215205374122020463 0ustar fabiofabio// RUN: %ldc -betterC -run %s > %t.stdout // RUN: FileCheck %s < %t.stdout import core.stdc.stdio; void notNothrow() { printf("notNothrow\n"); } struct WithDtor { ~this() { printf("destructing\n"); } } void foo(WithDtor a, bool skip) { if (skip) return; notNothrow(); } extern(C) int main() { WithDtor a; scope(exit) printf("exiting\n"); foo(a, true); // CHECK: destructing foo(a, false); // CHECK-NEXT: notNothrow // CHECK-NEXT: destructing return 0; // CHECK-NEXT: exiting // CHECK-NEXT: destructing } ./ldc-1.42.0-src/tests/linking/ir2obj_caching_flags1.d0000644000175000017500000000761215205374122021255 0ustar fabiofabio// Test that certain cmdline flags result in different cache objects, even though the LLVM IR may be the same. // Note that the NO_HIT tests should change the default setting of the tested flag. // Create and then empty the cache for correct testing when running the test multiple times. // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir // RUN: %prunecache -f %t-dir --max-bytes=1 // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -g -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -O -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -O3 -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -O2 -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -O4 -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc -O5 %s -c -of=%t%obj -cache=%t-dir -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -Os -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -Oz -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -disable-d-passes -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -disable-simplify-drtcalls -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -disable-simplify-libcalls -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -disable-gc2stack -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -enable-inlining -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -strip-debug -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -disable-loop-unrolling -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -disable-loop-vectorization -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -disable-slp-vectorization -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -vectorize-loops -vv | FileCheck --check-prefix=NO_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -v -wi -d -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -D -H -I. -J. -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -d-version=Irrelevant -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -unittest -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc %s -cache=%t-dir -lib -vv | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc -cache=%t-dir -vv -run %s | FileCheck --check-prefix=COULD_HIT %s // RUN: %ldc -cache=%t-dir -vv -run %s a b | FileCheck --check-prefix=MUST_HIT %s // RUN: %ldc %s -c -of=%t%obj -cache=%t-dir -g -vv | FileCheck --check-prefix=MUST_HIT %s // The last test is a MUST_HIT test (hits with the first compile invocation), to make sure that the cache wasn't pruned somehow which could effectively disable some NO_HIT tests. // MUST_HIT: Cache object found! // NO_HIT: Cache object not found. // Could hit is used for cases where we could have a cache hit, but currently we don't: a "TODO" item. // COULD_HIT: Cache object void main() {} ./ldc-1.42.0-src/tests/semantic/0000755000175000017500000000000015205374122015152 5ustar fabiofabio./ldc-1.42.0-src/tests/semantic/inputs/0000755000175000017500000000000015205374122016474 5ustar fabiofabio./ldc-1.42.0-src/tests/semantic/inputs/notatcompute.d0000644000175000017500000000007715205374122021367 0ustar fabiofabiomodule tests.semantic.inputs.notatcompute; void somefunc() {} ./ldc-1.42.0-src/tests/semantic/dcompute.d0000644000175000017500000000534315205374122017144 0ustar fabiofabio// RUN: not %ldc -o- -verrors=0 -I%S %s 2>&1 | FileCheck %s @compute(CompileFor.deviceOnly) module tests.semaintic.dcompute; import ldc.dcompute; import inputs.notatcompute : somefunc; extern(C) bool perhaps(); //CHECK: dcompute.d([[@LINE+1]]): Error: interfaces and classes not allowed in `@compute` code interface I {} //CHECK: dcompute.d([[@LINE+1]]): Error: interfaces and classes not allowed in `@compute` code class C : Throwable { this() { super(""); } } //CHECK: dcompute.d([[@LINE+1]]): Error: global variables not allowed in `@compute` code C c; void func() { //CHECK: dcompute.d([[@LINE+1]]): Error: associative arrays not allowed in `@compute` code int[int] foo; //CHECK: dcompute.d([[@LINE+1]]): Error: array literal in `@compute` code not allowed auto bar = [0, 1, 2]; //CHECK: dcompute.d([[@LINE+1]]): Error: cannot use `new` in `@compute` code auto baz = new int; //CHECK: dcompute.d([[@LINE+1]]): Error: interfaces and classes not allowed in `@compute` code I i; //CHECK: dcompute.d([[@LINE+1]]): Error: interfaces and classes not allowed in `@compute` code C cc; int[] quux; //CHECK: dcompute.d([[@LINE+1]]): Error: setting `length` in `@compute` code not allowed quux.length = 1; //CHECK: dcompute.d([[@LINE+1]]): Error: cannot use operator `~=` in `@compute` code quux ~= 42; //CHECK: dcompute.d([[@LINE+1]]): Error: cannot use operator `~` in `@compute` code cast(void) (quux ~ 1); //CHECK: dcompute.d([[@LINE+1]]): Error: typeinfo not available in `@compute` code cast(void) typeid(int); //CHECK: dcompute.d([[@LINE+1]]): Error: cannot use `synchronized` in `@compute` code synchronized {} //CHECK: dcompute.d([[@LINE+1]]): Error: string literals not allowed in `@compute` code auto s = "geaxsese"; //CHECK: dcompute.d([[@LINE+1]]): Error: cannot `switch` on strings in `@compute` code switch(s) { default: break; } //CHECK: dcompute.d([[@LINE+1]]): Error: can only call functions from other `@compute` modules in `@compute` code somefunc(); if (__dcompute_reflect(ReflectTarget.Host,0)) //CHECK-NOT: Error: somefunc(); //CHECK: dcompute.d([[@LINE+1]]): Error: no exceptions in `@compute` code try { func1(); } catch(C c) { } if (perhaps()) //CHECK: dcompute.d([[@LINE+1]]): Error: no exceptions in `@compute` code throw c; //CHECK-NOT: Error: try { func1(); } finally { func2(); } //CHECK-NOT: Error: scope(exit) func2(); } void func1() {} void func2() {} //CHECK: dcompute.d([[@LINE+1]]): Error: linking additional libraries not supported in `@compute` code pragma(lib, "bar"); ./ldc-1.42.0-src/tests/semantic/target_traits_diag.d0000644000175000017500000000154315205374122021162 0ustar fabiofabio// Tests diagnostics of __traits(targetCPU) and __traits(targetHasFeature, ...) // RUN: not %ldc -c -w %s 2>&1 | FileCheck %s void main() { // CHECK: Warning: ignoring arguments for __traits targetCPU enum a = __traits(targetCPU, 1); // CHECK: Error: __traits targetHasFeature expects one argument, not 0 enum b = __traits(targetHasFeature); // CHECK: Error: __traits targetHasFeature expects one argument, not 2 enum c = __traits(targetHasFeature, "fma", 1); // CHECK: Error: expression expected as argument of __traits targetHasFeature enum d = __traits(targetHasFeature, main); // CHECK: Error: string expected as argument of __traits targetHasFeature instead of 1 enum e = __traits(targetHasFeature, 1); // CHECK: 夜畔' is not a recognized feature for this target (ignoring feature) enum f = __traits(targetHasFeature, "夜畔"); } ./ldc-1.42.0-src/tests/semantic/traits_initSymbol.d0000644000175000017500000000202415205374122021034 0ustar fabiofabio// RUN: %ldc -run %s struct Zero { int x; } struct NonZero { long x = 1; } class C { short x = 123; } void main() { auto zeroInit = __traits(initSymbol, Zero); static assert(is(typeof(zeroInit) == const(void[]))); assert(zeroInit.ptr is null && zeroInit.length == Zero.sizeof); auto nonZeroInit = __traits(initSymbol, NonZero); static assert(is(typeof(nonZeroInit) == const(void[]))); assert(nonZeroInit.ptr !is null && nonZeroInit.length == NonZero.sizeof); assert(cast(const(long[])) nonZeroInit == [1L]); auto cInit = __traits(initSymbol, C); static assert(is(typeof(cInit) == const(void[]))); assert(cInit.ptr !is null && cInit.length == __traits(classInstanceSize, C)); scope c = new C; import core.stdc.string; assert(memcmp(cast(void*) c, cInit.ptr, cInit.length) == 0); static assert(!__traits(compiles, __traits(initSymbol, int))); static assert(!__traits(compiles, __traits(initSymbol, Zero[1]))); static assert(!__traits(compiles, __traits(initSymbol, 123))); } ./ldc-1.42.0-src/tests/semantic/dcompute_asm.d0000644000175000017500000000067715205374122020011 0ustar fabiofabio// Test that the "asm" statement is not allowed for DCompute code. // "asm" is only allowed for X86, so we must explicitly target X86 in this test. // REQUIRES: target_X86 // RUN: not %ldc -mtriple=x86_64-linux-gnu -o- %s 2>&1 | FileCheck %s @compute(CompileFor.deviceOnly) module tests.semaintic.dcompute; import ldc.dcompute; void func() { //CHECK: dcompute_asm.d([[@LINE+1]]): Error: asm not allowed in `@compute` code asm {ret;} } ./ldc-1.42.0-src/tests/semantic/target_traits_dcompute.d0000644000175000017500000000045215205374122022074 0ustar fabiofabio// Tests LDC-specific target __traits // RUN: %ldc -c %s -mdcompute-targets=cuda-350 -mdcompute-file-prefix=testing // REQUIRES: target_NVPTX static assert([ __traits(getTargetInfo, "dcomputeTargets") ] == ["cuda-350"]); static assert(__traits(getTargetInfo, "dcomputeFilePrefix") == "testing"); ./ldc-1.42.0-src/tests/semantic/target_traits.d0000644000175000017500000000467315205374122020205 0ustar fabiofabio// Tests LDC-specific target __traits // REQUIRES: target_X86 // RUN: %ldc -mtriple=x86_64-apple-darwin -mcpu=nehalem -d-version=CPU_NEHALEM -c %s // RUN: %ldc -mtriple=i686-pc-linux -mcpu=pentium -mattr=+fma -d-version=ATTR_FMA -c %s // RUN: %ldc -mtriple=i686-pc-linux -mcpu=pentium -mattr=+fma,-sse -d-version=ATTR_FMA_MINUS_SSE -c %s // RUN: %ldc -mtriple=x86_64-apple-darwin -mcpu=haswell -d-version=CPU_HASWELL -c %s // Important: LLVM's default CPU selection already enables some features (like sse3) void main() { version (CPU_NEHALEM) { static assert(__traits(targetCPU) == "nehalem"); static assert(__traits(targetHasFeature, "sse3")); static assert(__traits(targetHasFeature, "sse4.1")); static assert(!__traits(targetHasFeature, "avx")); static assert(!__traits(targetHasFeature, "sse4")); static assert(!__traits(targetHasFeature, "sse4a")); static assert(!__traits(targetHasFeature, "unrecognized feature")); version(D_AVX) static assert(false); version(D_AVX2) static assert(false); } version (ATTR_FMA) { static assert(__traits(targetHasFeature, "sse")); static assert(__traits(targetHasFeature, "sse2")); static assert(__traits(targetHasFeature, "sse3")); static assert(__traits(targetHasFeature, "sse4.1")); static assert(__traits(targetHasFeature, "fma")); static assert(__traits(targetHasFeature, "avx")); static assert(!__traits(targetHasFeature, "avx2")); static assert(!__traits(targetHasFeature, "unrecognized feature")); version(D_AVX) {} else static assert(false); version(D_AVX2) static assert(false); } version (ATTR_FMA_MINUS_SSE) { // All implied features must be enabled for targetHasFeature to return true static assert(!__traits(targetHasFeature, "fma")); version(D_AVX) static assert(false); version(D_AVX2) static assert(false); } version (CPU_HASWELL) { static assert(__traits(targetHasFeature, "sse")); static assert(__traits(targetHasFeature, "sse2")); static assert(__traits(targetHasFeature, "sse3")); static assert(__traits(targetHasFeature, "sse4.1")); static assert(__traits(targetHasFeature, "avx")); static assert(__traits(targetHasFeature, "avx2")); version(D_AVX) {} else static assert(false); version(D_AVX2) {} else static assert(false); } } ./ldc-1.42.0-src/tests/compilable/0000755000175000017500000000000015205374122015456 5ustar fabiofabio./ldc-1.42.0-src/tests/compilable/inputs/0000755000175000017500000000000015205374122017000 5ustar fabiofabio./ldc-1.42.0-src/tests/compilable/inputs/foo/0000755000175000017500000000000015205374122017563 5ustar fabiofabio./ldc-1.42.0-src/tests/compilable/inputs/foo/bla.di0000644000175000017500000000001415205374122020632 0ustar fabiofabiomodule foo; ./ldc-1.42.0-src/tests/compilable/inputs/bar/0000755000175000017500000000000015205374122017544 5ustar fabiofabio./ldc-1.42.0-src/tests/compilable/inputs/bar/bla.di0000644000175000017500000000001415205374122020613 0ustar fabiofabiomodule bar; ./ldc-1.42.0-src/tests/compilable/inputs/gh2782b.d0000644000175000017500000000004315205374122020225 0ustar fabiofabiostruct S {} extern(C) void foo(S); ./ldc-1.42.0-src/tests/compilable/inputs/gh2422a.d0000644000175000017500000000002015205374122020206 0ustar fabiofabioclass Empty { } ./ldc-1.42.0-src/tests/compilable/inputs/gh1906b.d0000644000175000017500000000010715205374122020223 0ustar fabiofabioclass Base { auto foo() { return this; } abstract int bar(); } ./ldc-1.42.0-src/tests/compilable/inputs/gh2777b.d0000644000175000017500000000004615205374122020234 0ustar fabiofabioint main(string[] args) { return 0; } ./ldc-1.42.0-src/tests/compilable/inputs/gh1741b.d0000644000175000017500000000002515205374122020217 0ustar fabiofabioimport gh1741; S s; ./ldc-1.42.0-src/tests/compilable/gh2458.d0000644000175000017500000000045015205374122016543 0ustar fabiofabio// Make sure llvm_expect() is supported during CTFE. // RUN: %ldc -c %s import ldc.intrinsics : llvm_expect; int notZero(int x) { if (llvm_expect(x == 0, false)) return 666; return x; } void main() { static assert(notZero(0) == 666); static assert(notZero(1) == 1); } ./ldc-1.42.0-src/tests/compilable/gh4489.d0000644000175000017500000000022515205374122016551 0ustar fabiofabio// REQUIRES: target_AArch64 // RUN: %ldc -mtriple=arm64-apple-macos11.0 -c %s void foo(inout float[3]); void bar() { float[3] x; foo(x); } ./ldc-1.42.0-src/tests/compilable/gh2033.d0000644000175000017500000000057215205374122016535 0ustar fabiofabio// RUN: %ldc -c %s void foo(const(uint)[4] arg) { // The front-end coerces the explicit and following implicit cast // (implicit: int[4] -> const(int[4])) into a single CastExp with // differing types CastExp::to and CastExp::type. // Make sure the repainting code performing the implicit cast // handles static arrays. const copy = cast(int[4]) arg; } ./ldc-1.42.0-src/tests/compilable/c_masm.c0000644000175000017500000000064215205374122017063 0ustar fabiofabio// DMD supports case-insensitive register operands for x86 assembly in C files, when targeting Windows. // Additionally, a new-line can be used to terminate an instruction. // REQUIRES: Windows && target_X86 // RUN: %ldc -mtriple=i686-pc-windows-msvc -c %s unsigned int subtract(unsigned int a, unsigned int b) { __asm { mov eax, dword ptr [a] mov eDX, dword ptr [b] sub Eax, edx } } ./ldc-1.42.0-src/tests/compilable/gh3324.d0000644000175000017500000000015715205374122016540 0ustar fabiofabio// RUN: %ldc -c %s extern (C++) interface I { extern (System) void func(); } void foo(I i) { i.func(); } ./ldc-1.42.0-src/tests/compilable/gh4646.d0000644000175000017500000000102215205374122016540 0ustar fabiofabio// RUN: %ldc -c -preview=bitfields %s struct BitField { uint _0 : 1; uint _1 : 1; uint _2 : 1; uint _3 : 1; uint _4 : 1; uint _5 : 1; uint _6 : 1; uint _7 : 1; uint _8 : 1; uint _9 : 1; uint _10 : 1; uint _11 : 1; uint _12 : 1; uint _13 : 1; uint _14 : 1; uint _15 : 1; uint _16 : 1; } static assert(BitField.sizeof == 4); static assert(BitField.alignof == 4); struct Foo { BitField bf; } static assert(Foo.sizeof == 4); static assert(Foo.alignof == 4); ./ldc-1.42.0-src/tests/compilable/gh2932.d0000644000175000017500000000062615205374122016545 0ustar fabiofabio// RUN: %ldc -c -allinst %s import std.algorithm; extern __gshared int[] array; void funcWithNoFrame() { int local; // lambda is codegen'd pragma(msg, typeof(array.map!(e => local))); } void funcWithFrame() { int capturedVar, local; int nestedFunc() { return capturedVar; } // lambda is codegen'd with `-allinst` static assert(__traits(compiles, array.map!(e => local))); } ./ldc-1.42.0-src/tests/compilable/dcompute.d0000644000175000017500000000216515205374122017447 0ustar fabiofabio// Tests that // - we don't try to link with one file on the commandline that is @compute // - turning on debugging doesn't ICE // - don't analyse uninstantiated templates // - typeid generated for hashing of struct (typeid(const(T))) is ignored and does not error // - if (__ctfe) and if (!__ctfe) don't cause errors // REQUIRES: target_NVPTX // RUN: %ldc -mdcompute-targets=cuda-350 -g %s @compute(CompileFor.deviceOnly) module dcompute; import ldc.dcompute; @kernel void foo() { if (__ctfe) { auto a = new int; } if (__ctfe) { auto a = new int; } else {} if (!__ctfe) { } else { auto a = new int; } } struct AutoIndexed(T) { T p = void; alias U = typeof(*T); @property U index() { return p[0]; } @property void index(U t) { p[0] = t; } @disable this(); void opAssign(U u) { index = u; } alias index this; } alias aagf = AutoIndexed!(GlobalPointer!(float)); @kernel void auto_index_test(aagf a, aagf b, aagf c) { a = b + c; } ./ldc-1.42.0-src/tests/compilable/gh2777.d0000644000175000017500000000015215205374122016546 0ustar fabiofabio// RUN: %ldc -c -singleobj %s %S/inputs/gh2777b.d int main(string[] args); void reset() { main(null); } ./ldc-1.42.0-src/tests/compilable/gh2988.d0000644000175000017500000000027315205374122016556 0ustar fabiofabio// RUN: %ldc -c %s import core.simd; float4 getVector() { return float4(1.0f); } void foo() { // front-end implicitly casts from float4 to float[4] float x = getVector()[0]; } ./ldc-1.42.0-src/tests/compilable/gh2422.d0000644000175000017500000000013415205374122016531 0ustar fabiofabio// RUN: %ldc -c -I%S/inputs %s import gh2422a; void main() { auto aa = ["": new Empty]; } ./ldc-1.42.0-src/tests/compilable/gh1906.d0000644000175000017500000000010315205374122016533 0ustar fabiofabio// RUN: %ldc -c -I%S/inputs %s import gh1906b; class C : Base {} ./ldc-1.42.0-src/tests/compilable/arch64bit_abi32bit_gh3802.d0000644000175000017500000000153215205374122022064 0ustar fabiofabio// Tests compilation for 64-bit architecture with 32-bit word size ABI. // Triple examples: mips64el-linux-gnuabin32, x86_64-linux-gnux32 // Targeting x86 because that's the most widely available target in our CI/developer systems. // REQUIRES: target_X86 // RUN: %ldc -mtriple=x86_64-linux-gnux32 -O -c %s static assert((void*).sizeof == 4); static assert(size_t.sizeof == 4); static assert(ptrdiff_t.sizeof == 4); version (D_LP64) static assert(0); version (D_X32) { /* expected */ } else static assert(0); bool equals(string lhs, string rhs) { foreach (const i; 0 .. lhs.length) {} return false; } // test _d_array_slice_copy optimization IR pass (requires -O) auto test_ArraySliceCopyOpt() { static void copy(int[] a, int[] b) { a[] = b[]; } int[2] a = [1, 2]; int[2] b = [3, 4]; copy(a, b); return a; } ./ldc-1.42.0-src/tests/compilable/gh2859.d0000644000175000017500000000014715205374122016553 0ustar fabiofabio// RUN: %ldc -c %s void foo() { static struct S { int a; } S s; const aa = [1 : &s.a]; } ./ldc-1.42.0-src/tests/compilable/gh4927.d0000644000175000017500000000205515205374122016551 0ustar fabiofabio// RUN: %ldc -c %s alias T = int; T[] arrayAlloc(size_t size); T[] Σ(size_t length) { size_t elemSize = T.sizeof; size_t arraySize; if (length == 0 || elemSize == 0) return null; version (D_InlineAsm_X86) { asm pure nothrow @nogc { mov EAX, elemSize ; mul EAX, length ; mov arraySize, EAX ; jnc Lcontinue ; } } else version (D_InlineAsm_X86_64) { asm pure nothrow @nogc { mov RAX, elemSize ; mul RAX, length ; mov arraySize, RAX ; jnc Lcontinue ; } } else { import core.checkedint : mulu; bool overflow = false; arraySize = mulu(elemSize, length, overflow); if (!overflow) goto Lcontinue; } Loverflow: assert(0); Lcontinue: auto arr = arrayAlloc(arraySize); if (!arr.ptr) goto Loverflow; return arr; } ./ldc-1.42.0-src/tests/compilable/gh4734.d0000644000175000017500000000027215205374122016544 0ustar fabiofabio// RUN: %ldc -c %s align(1) struct Item { KV v; uint i; } struct KV { align(1) S* s; uint k; } struct S { Table table; } struct Table { char a; Item v; } ./ldc-1.42.0-src/tests/compilable/gh3194.d0000644000175000017500000000017215205374122016542 0ustar fabiofabio// REQUIRES: target_X86 // RUN: %ldc -c %s import ldc.gccbuiltins_x86; // should be importable by non-installed compiler ./ldc-1.42.0-src/tests/compilable/gh1933.d0000644000175000017500000000212115205374122016535 0ustar fabiofabio// See Github issue 1933. // RUN: %ldc -c -release -g -O0 %s // RUN: %ldc -c -release -g -O3 %s ptrdiff_t countUntil(T, N)(T haystack, N needle) { ptrdiff_t result; foreach (elem; haystack) { if (elem == needle) return result; result++; } return -1; } bool foo(alias pred, N)(N haystack) { foreach (elem; haystack) { if (pred(elem)) return true; } return false; } struct MatchTree { struct Tag { } struct Terminal { string[] varNames; } Tag[] m_terminalTags; Terminal term; void rebuildGraph() { MatchGraphBuilder builder; uint process() { auto aaa = m_terminalTags.length; foreach (t; builder.m_nodes) { auto bbb = term.varNames.countUntil(t.var); assert(m_terminalTags.foo!(u => t.index)); } return 0; } } } struct MatchGraphBuilder { struct TerminalTag { size_t index; string var; } TerminalTag[] m_nodes; } ./ldc-1.42.0-src/tests/compilable/ctfe_math.d0000644000175000017500000000453215205374122017561 0ustar fabiofabio// Tests CTFE-ability of some common std.math functions. // RUN: %ldc -c %s import std.math; mixin template Func1(string name) { enum r = mixin(name ~ "(0.5L)"); pragma(msg, name ~ "(0.5L) = " ~ r.stringof); enum d = mixin(name ~ "(0.5)"); pragma(msg, name ~ "(0.5) = " ~ d.stringof); enum f = mixin(name ~ "(0.5f)"); pragma(msg, name ~ "(0.5f) = " ~ f.stringof); } mixin template Func2(string name) { enum r = mixin(name ~ "(0.5L, -2.5L)"); pragma(msg, name ~ "(0.5L, -2.5L) = " ~ r.stringof); enum d = mixin(name ~ "(0.5, -2.5)"); pragma(msg, name ~ "(0.5, -2.5) = " ~ d.stringof); enum f = mixin(name ~ "(0.5f, -2.5f)"); pragma(msg, name ~ "(0.5f, -2.5f) = " ~ f.stringof); } mixin template Func2_int(string name) { enum r = mixin(name ~ "(0.5L, 2)"); pragma(msg, name ~ "(0.5L, 2) = " ~ r.stringof); enum d = mixin(name ~ "(0.5, 2)"); pragma(msg, name ~ "(0.5, 2) = " ~ d.stringof); enum f = mixin(name ~ "(0.5f, 2)"); pragma(msg, name ~ "(0.5f, 2) = " ~ f.stringof); } mixin template Func3(string name) { enum r = mixin(name ~ "(0.5L, -2.5L, 6.25L)"); pragma(msg, name ~ "(0.5L, -2.5L, 6.25L) = " ~ r.stringof); enum d = mixin(name ~ "(0.5, -2.5, 6.25)"); pragma(msg, name ~ "(0.5, -2.5, 6.25) = " ~ d.stringof); enum f = mixin(name ~ "(0.5f, -2.5f, 6.25f)"); pragma(msg, name ~ "(0.5f, -2.5f, 6.25f) = " ~ f.stringof); } void main() { { mixin Func1!"isNaN"; } { mixin Func1!"isInfinity"; } { mixin Func1!"isFinite"; } { mixin Func1!"abs"; } { mixin Func1!"fabs"; } { mixin Func1!"sqrt"; } { mixin Func1!"sin"; } { mixin Func1!"cos"; } { mixin Func1!"tan"; } { mixin Func1!"cosh"; } { mixin Func1!"asinh"; } { mixin Func1!"acosh"; } { mixin Func1!"atanh"; } { mixin Func1!"ceil"; } { mixin Func1!"floor"; } { mixin Func1!"round"; } { mixin Func1!"trunc"; } { mixin Func1!"rint"; } { mixin Func1!"nearbyint"; } { mixin Func1!"exp"; } { mixin Func1!"exp2"; } { mixin Func2_int!"ldexp"; } { mixin Func1!"log"; } { mixin Func1!"log2"; } { mixin Func1!"log10"; } { mixin Func2!"pow"; } { mixin Func2_int!"pow"; } { mixin Func2!"fmin"; } { mixin Func2!"fmax"; } { mixin Func2!"copysign"; } { mixin Func3!"fma"; } static assert(2.0 ^^ 8 == 256.0); } ./ldc-1.42.0-src/tests/compilable/gh1741.d0000644000175000017500000000030515205374122016534 0ustar fabiofabio// Explicitly target Linux x86_64. // REQUIRES: target_X86 // RUN: %ldc -mtriple=x86_64-pc-linux-gnu -c %s %S/inputs/gh1741b.d struct S { C c; } class C { @property s() { return S(); } } ./ldc-1.42.0-src/tests/compilable/gh3243.d0000644000175000017500000000011715205374122016534 0ustar fabiofabio// RUN: %ldc -c %s %S/inputs/foo/bla.di %S/inputs/bar/bla.di import foo, bar; ./ldc-1.42.0-src/tests/compilable/union_voidinit.d0000644000175000017500000000064515205374122020665 0ustar fabiofabio// slightly modified chunk of dmd-testsuite's compilable/interpret3.d // RUN: %ldc -c %s struct Vector13831() { } struct Coord13831 { union // reversed field order { Vector13831!() vector; struct { short x; } } } struct Chunk13831 { this(Coord13831) { coord = coord; } Coord13831 coord; static const Chunk13831* unknownChunk = new Chunk13831(Coord13831()); } ./ldc-1.42.0-src/tests/compilable/gh2782.d0000644000175000017500000000012615205374122016543 0ustar fabiofabio// RUN: %ldc -c -singleobj %s %S/inputs/gh2782b.d struct S {} extern(C) void foo(S); ./ldc-1.42.0-src/tests/compilable/gh3496.d0000644000175000017500000000023715205374122016551 0ustar fabiofabio// RUN: %ldc -c %s interface I { static void staticFoo(); final void finalFoo(); } void foo() { I.staticFoo(); (new class I{}).finalFoo(); } ./ldc-1.42.0-src/tests/compilable/gh2808.d0000644000175000017500000000057115205374122016546 0ustar fabiofabio// RUN: %ldc -c %s void gh2808() { extern(C) void DoubleArrayToAnyArray(void* arg0) { auto dg = () => { auto r = arg0; }; } auto local = 123; auto arg = () { return local; }(); DoubleArrayToAnyArray(null); } void gh3234() { int i; void nested() { ++i; } extern (C++) class Visitor { void visit() { nested(); } } } ./ldc-1.42.0-src/tests/compilable/gh4266.d0000644000175000017500000000036415205374122016546 0ustar fabiofabio// REQUIRES: target_NVPTX // RUN: %ldc -c -mdcompute-targets=cuda-350 %s @compute(CompileFor.deviceOnly) module gh4266; import ldc.dcompute; pragma(LDC_intrinsic, "llvm.nvvm.barrier0") void barrier0(); void callbarrier() { barrier0(); } ./ldc-1.42.0-src/tests/compilable/gh2415.d0000644000175000017500000000034715205374122016541 0ustar fabiofabio// RUN: %ldc -c %s struct Row { float val; ref float opIndex(int i) { return val; } } struct Matrix { Row row; ref Row opIndex(int i) { return row; } } void main() { Matrix matrix; matrix[1][2] += 0.0; } ./ldc-1.42.0-src/tests/compilable/objc_gh2388.d0000644000175000017500000000031415205374122017541 0ustar fabiofabio// REQUIRES: Darwin // RUN: %ldc -c -singleobj %s %S/objc_gh2387.d void alloc() { NSObject o; o.alloc(); } extern (Objective-C): interface NSObject { NSObject alloc() @selector("alloc"); } ./ldc-1.42.0-src/tests/compilable/captured_nonpassed_params.d0000644000175000017500000000107315205374122023050 0ustar fabiofabio// Some ABIs don't pass empty static arrays or empty PODs as arguments. // This can get hairy, e.g., if such a parameter is captured. // RUN: %ldc -c -g %s struct EmptyPOD {} EmptyPOD emptyPOD(EmptyPOD e) { EmptyPOD nested() { return e; } nested(); return e; } int[0] emptySArray(int[0] a) { int[0] nested() { return a; } nested(); return a; } void tuple() { auto test(T...)(T params) { auto nested() { return params[0]; } nested(); return params[0]; } test(EmptyPOD()); int[0] a; test(a); } ./ldc-1.42.0-src/tests/compilable/gh2471.d0000644000175000017500000000126615205374122016544 0ustar fabiofabio// RUN: %ldc -c %s struct Iterator(T : T[]) { alias ThisType = Iterator!(T[]); alias ItemType = T; this(T[] container, size_t index = 0) { container_ = container; index_ = index; } U opCast(U)() const if (is(U == ItemType)) { return this ? container_[index_] : ItemType.init; } ref ThisType opUnary(string op)() if (op == "++" || op == "--") { mixin(op ~ "index_;"); return this; } @property ItemType value() const { return container_[index_]; } alias value this; private T[] container_ = null; private size_t index_ = 0; } void main() { string test = "abcde"; auto it = Iterator!string(test); char ch = it++; } ./ldc-1.42.0-src/tests/compilable/gh4993.d0000644000175000017500000000014515205374122016552 0ustar fabiofabio// RUN: %ldc -c %s struct Foo {} void main() { Foo f; auto x = cast(ubyte[Foo.sizeof])f; } ./ldc-1.42.0-src/tests/compilable/intrinsics_imports.d0000644000175000017500000000177715205374122021601 0ustar fabiofabio// Very basic test to check that instrinsics include file is made correctly. // Related to https://github.com/ldc-developers/ldc/issues/4347 // Just do SemA, no codegen, such that it works on all CI systems. // RUN: %ldc -o- %s import core.simd; static import ldc.gccbuiltins_aarch64; static import ldc.gccbuiltins_arm; static import ldc.gccbuiltins_mips; static import ldc.gccbuiltins_nvvm; static import ldc.gccbuiltins_ppc; static import ldc.gccbuiltins_x86; short2 s2; short8 s8; double2 d2; void* ptr; void main() { ldc.gccbuiltins_aarch64.__builtin_arm_isb(1); ldc.gccbuiltins_arm.__builtin_arm_dmb(2); short2 mips = ldc.gccbuiltins_mips.__builtin_mips_addq_s_ph(s2, s2); double nvvm = ldc.gccbuiltins_nvvm.__nvvm_fma_rz_d(1.0, 2.0, 3.0); short8 ppc8 = ldc.gccbuiltins_ppc.__builtin_altivec_crypto_vpmsumh(s8, s8); ldc.gccbuiltins_x86.__builtin_ia32_lfence(); ldc.gccbuiltins_x86.__builtin_ia32_umonitor(ptr); double2 x86 = ldc.gccbuiltins_x86.__builtin_ia32_maxpd(d2, d2); } ./ldc-1.42.0-src/tests/compilable/gh3250.d0000644000175000017500000000015615205374122016535 0ustar fabiofabio// RUN: %ldc -c %s struct Q { auto func(uint[3] a, uint[3] b, uint c) { return this; } } ./ldc-1.42.0-src/tests/compilable/gh2849.d0000644000175000017500000000020315205374122016543 0ustar fabiofabio// RUN: %ldc -c %s extern(C++): __gshared const int dblreg = 1; pragma(mangle, dblreg.mangleof) extern __gshared const int bla; ./ldc-1.42.0-src/tests/compilable/no-integrated-as.d0000644000175000017500000000066315205374122020771 0ustar fabiofabio// RUN: %ldc -no-integrated-as %s // We currently rely on gcc/clang; no MSVC toolchain support yet. // UNSUPPORTED: Windows /* on Linux, need clang-13 with LLVM 13: * LLVM 12: .section __minfo,"aw",@progbits * LLVM 13: .section __minfo,"awR",@progbits,unique,1 */ // UNSUPPORTED: Linux module noIntegratedAs; void main() { import std.stdio; writeln("This object is assembled externally and linked to an executable."); } ./ldc-1.42.0-src/tests/compilable/gh4719.d0000644000175000017500000000116015205374122016544 0ustar fabiofabio// RUN: %ldc -c %s // RUN: %ldc -c %s -O struct TraceBuf { align(1) uint args; } // Test correct compilation (no error) of the context pointer type for the delegate of `foo`. void foo() { byte[2] fixDescs; TraceBuf fixLog; auto dlg = delegate() { fixDescs[0] = 1; fixLog.args = 1; }; } class TraceClass { align(1) uint args; } // Test correct compilation (no error) of the context pointer type for the delegate of `foo2`. void foo2() { byte[2] fixDescs; scope TraceClass fixLog; auto dlg = delegate() { fixDescs[0] = 1; fixLog.args = 1; }; } ./ldc-1.42.0-src/tests/compilable/gh2996.d0000644000175000017500000000047115205374122016555 0ustar fabiofabio// RUN: %ldc -c %s struct Table { RCArray _elems; void update(int x) { auto e = _elems[0 .. x][x == 0 ? x : $]; } } struct RCArray { int[] _arr; inout opSlice(size_t, size_t) { return _arr; } const length() { return _arr.length; } const opDollar() { return length; } } ./ldc-1.42.0-src/tests/compilable/gh3990.d0000644000175000017500000000040215205374122016542 0ustar fabiofabio// RUN: %ldc -c %s struct Vector { float x, y, z; } struct QAngle { float x, y, z; QAngle opOpAssign(string op)(const(QAngle)) { return this; } } void OnUserCmdPre() { Vector ss; QAngle dd; dd -= cast(QAngle)ss; } ./ldc-1.42.0-src/tests/compilable/gh4309.d0000644000175000017500000000007415205374122016542 0ustar fabiofabio// RUN: %ldc -c %s void foo(void* p) { auto q = p++; } ./ldc-1.42.0-src/tests/compilable/objc_gh2387.d0000644000175000017500000000030115205374122017534 0ustar fabiofabio// REQUIRES: Darwin // RUN: %ldc -c %s extern (Objective-C) interface NSView { void setWantsLayer(bool value) @selector("setWantsLayer:"); } void foo(NSView v) { v.setWantsLayer(true); } ./ldc-1.42.0-src/tests/dmd/0000755000175000017500000000000015205374130014112 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/tools/0000755000175000017500000000000015205374122015253 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/tools/dshell_prebuilt/0000755000175000017500000000000015205374122020434 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/tools/dshell_prebuilt/dshell_prebuilt.d0000644000175000017500000002207315205374122023766 0ustar fabiofabio/** A small library to help write D shell-like test scripts. */ module dshell_prebuilt; public import core.stdc.stdlib : exit; public import core.time; public import core.thread; public import std.meta; public import std.exception; public import std.array; public import std.string; public import std.format; public import std.path; public import std.file; public import std.regex; public import std.stdio; public import std.process; /** Emulates bash environment variables. Variables set here will be availble for BASH-like expansion. */ struct Vars { private static __gshared string[string] map; static void set(string name, string value) in { assert(value !is null); } do { const expanded = shellExpand(value); assert(expanded !is null, "codebug"); map[name] = expanded; } static string get(const(char)[] name) { auto result = map.get(cast(string)name, null); if (result is null) assert(0, "Unknown variable '" ~ name ~ "'"); return result; } static string opDispatch(string name)() { return get(name); } static void opDispatch(string name)(string value) { set(name, value); } } private alias requiredEnvVars = AliasSeq!( "MODEL", "RESULTS_DIR", "EXE", "OBJ", "DMD", "DFLAGS", "OS", "SEP", "DSEP", "BUILD", "BUILD_SHARED_LIBS" // LDC - passed through from CMake ); private alias optionalEnvVars = AliasSeq!( "CC", "CXX", "PIC_FLAG" ); private alias allVars = AliasSeq!( requiredEnvVars, optionalEnvVars, "TEST_DIR", "TEST_NAME", "RESULTS_TEST_DIR", "OUTPUT_BASE", "EXTRA_FILES", "LIBEXT", "SOEXT" ); static foreach (var; allVars) { mixin(`string ` ~ var ~ `() { return Vars.` ~ var ~ `; }`); } /// called from the dshell module to initialize environment void dshellPrebuiltInit(string testDir, string testName) { foreach (var; requiredEnvVars) { Vars.set(var, requireEnv(var)); } foreach (var; optionalEnvVars) { Vars.set(var, environment.get(var, "")); } Vars.set("TEST_DIR", testDir); Vars.set("TEST_NAME", testName); // reference to the resulting test_dir folder, e.g .test_results/runnable Vars.set("RESULTS_TEST_DIR", buildPath(RESULTS_DIR, TEST_DIR)); // reference to the resulting files without a suffix, e.g. test_results/runnable/test123import test); Vars.set("OUTPUT_BASE", buildPath(RESULTS_TEST_DIR, TEST_NAME)); // reference to the extra files directory Vars.set("EXTRA_FILES", buildPath(TEST_DIR, "extra-files")); // reference to the imports directory Vars.set("IMPORT_FILES", buildPath(TEST_DIR, "imports")); version (Windows) { Vars.set("LIBEXT", ".lib"); Vars.set("SOEXT", ".dll"); } else version (OSX) { Vars.set("LIBEXT", ".a"); Vars.set(`SOEXT`, `.dylib`); } else { Vars.set("LIBEXT", ".a"); Vars.set("SOEXT", ".so"); } } private string requireEnv(string name) { const result = environment.get(name, null); if (result is null) { writefln("Error: missing required environment variable '%s'", name); exit(1); } return result; } /// Exit code to return if the test is disabled for the current platform enum DISABLED = 125; /// Remove one or more files void rm(scope const(char[])[] args...) { foreach (arg; args) { auto expanded = shellExpand(arg); if (exists(expanded)) { writeln("rm '", expanded, "'"); // Use loop to workaround issue in windows with removing // executables after running then for (int sleepMsecs = 10; ; sleepMsecs *= 2) { try { std.file.remove(expanded); break; } catch (Exception e) { if (sleepMsecs >= 3000) throw e; Thread.sleep(dur!"msecs"(sleepMsecs)); } } } } } /// Make all parent directories needed to create the given `filename` void mkdirFor(string filename) { auto dir = dirName(filename); if (!exists(dir)) { writefln("[INFO] mkdir -p '%s'", dir); mkdirRecurse(dir); } } /** Run the given command. The `tryRun` variants return the exit code, whereas the `run` variants will assert on a non-zero exit code. */ int tryRun(scope const(char[])[] args, File stdout = std.stdio.stdout, File stderr = std.stdio.stderr, string[string] env = null) { std.stdio.stdout.write("[RUN]"); if (env) { foreach (pair; env.byKeyValue) { std.stdio.stdout.write(" ", pair.key, "=", pair.value); } } std.stdio.write(" ", escapeShellCommand(args)); if (stdout != std.stdio.stdout) { std.stdio.stdout.write(" > ", stdout.name); } // "Commit" all output from the tester std.stdio.stdout.writeln(); std.stdio.stdout.flush(); std.stdio.stderr.writeln(); std.stdio.stderr.flush(); auto proc = spawnProcess(args, stdin, stdout, stderr, env); return wait(proc); } /// ditto int tryRun(string cmd, File stdout = std.stdio.stdout, File stderr = std.stdio.stderr, string[string] env = null) { return tryRun(parseCommand(cmd), stdout, stderr, env); } /// ditto void run(scope const(char[])[] args, File stdout = std.stdio.stdout, File stderr = std.stdio.stderr, string[string] env = null) { const exitCode = tryRun(args, stdout, stderr, env); if (exitCode != 0) { writefln("Error: last command exited with code %s", exitCode); assert(0, "last command failed"); } } /// ditto void run(string cmd, File stdout = std.stdio.stdout, File stderr = std.stdio.stderr, string[string] env = null) { // TODO: option to disable this? if (SEP != "/") cmd = cmd.replace("/", SEP); run(parseCommand(cmd), stdout, stderr, env); } /** Parse the given string `s` as a command. Performs BASH-like variable expansion. */ string[] parseCommand(string s) { auto rawArgs = s.split(); auto args = appender!(string[])(); foreach (rawArg; rawArgs) { const exp = shellExpand(rawArg); if (exp.length) args.put(exp); } return args.data; } /// Expand the given string using BASH-like variable expansion. string shellExpand(const(char)[] s) { auto expanded = appender!(char[])(); for (size_t i = 0; i < s.length;) { if (s[i] != '$') { expanded.put(s[i]); i++; } else { i++; assert(i < s.length, "lone '$' at end of string"); auto start = i; if (s[i] == '{') { start++; for (;;) { i++; assert(i < s.length, "unterminated ${..."); if (s[i] == '}') break; } expanded.put(Vars.get(s[start .. i])); i++; } else { assert(validVarChar(s[i]), "invalid sequence $'" ~ s[i]); for (;;) { i++; if (i >= s.length || !validVarChar(s[i])) break; } expanded.put(Vars.get(s[start .. i])); } } } auto result = expanded.data; return (result is null) ? "" : result.assumeUnique; } // [a-zA-Z0-9_] private bool validVarChar(const char c) { import std.ascii : isAlphaNum; return c.isAlphaNum || c == '_'; } struct GrepResult { string[] matches; void enforceMatches(string message) { if (matches.length == 0) { assert(0, message); } } } /** grep the given `file` for the given `pattern`. */ GrepResult grep(string file, string pattern) { const patternExpanded = shellExpand(pattern); const fileExpanded = shellExpand(file); writefln("[GREP] file='%s' pattern='%s'", fileExpanded, patternExpanded); return grepLines(File(fileExpanded, "r").byLine, patternExpanded); } /// ditto GrepResult grep(GrepResult lastResult, string pattern) { auto patternExpanded = shellExpand(pattern); writefln("[GREP] (%s lines from last grep) pattern='%s'", lastResult.matches.length, patternExpanded); return grepLines(lastResult.matches, patternExpanded); } private GrepResult grepLines(T)(T lineRange, string finalPattern) { auto matches = appender!(string[])(); foreach(line; lineRange) { if (matchFirst(line, finalPattern)) { static if (is(typeof(lineRange.front()) == string)) matches.put(line); else matches.put(line.idup); } } writefln("[GREP] matched %s lines", matches.data.length); return GrepResult(matches.data); } /** remove \r and the compiler debug header from the given string. */ string filterCompilerOutput(string output) { output = std.string.replace(output, "\r", ""); output = std.regex.replaceAll(output, regex(`^DMD v2\.[0-9]+.*\n? DEBUG\n`, "m"), ""); return output; } ./ldc-1.42.0-src/tests/dmd/tools/sh_do_test.sh0000755000175000017500000000306115205374122017745 0ustar fabiofabio#!/usr/bin/env bash set -euo pipefail DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" ################################################################################ # Exported variables ################################################################################ source "$DIR/exported_vars.sh" source "$DIR/common_funcs.sh" ################################################################################ # Generated variables _script_name="${TEST_DIR}/${TEST_NAME}.sh" _output_file="${RESULTS_DIR}/${_script_name}.out" echo " ... ${_script_name}" rm -f "${_output_file}" mkdir -p ${RESULTS_TEST_DIR} function finish { # reset output stream set +x exec 1>&40 exec 2>&41 if [ "$1" -ne 0 ]; then echo "==============================" echo "Test ${_script_name} failed. The logged output:" cat "${_output_file}" echo "==============================" echo "Test ${_script_name} failed. The xtrace output:" cat "${_output_file}.log" rm -rf "${_output_file}" exit $1 fi } trap 'finish $?' INT TERM EXIT # redirect stdout + stderr to the output file + keep a reference to the std{out,err} streams for later exec 40>&1 exec 41>&2 exec 1> "${_output_file}" exec 2>&1 # log all a verbose xtrace to a temporary file which is only displayed when an error occurs exec 42> "${_output_file}.log" export BASH_XTRACEFD=42 # fail on errors and undefined variables set -euo pipefail # activate xtrace logging for the to-be-called shell script set -x source "${_script_name}" ./ldc-1.42.0-src/tests/dmd/tools/sanitize_json.d0000644000175000017500000001450315205374122020302 0ustar fabiofabioimport std.exception : assumeUnique; import std.conv : text; import std.range : take, chain, drop; import std.string : startsWith, replace; import std.format : formattedWrite, format; import std.uni : asCapitalized; import std.json; import std.getopt; import std.file : readText; import std.path : dirName; import std.stdio; bool keepDeco = false; enum rootDir = __FILE_FULL_PATH__.dirName.dirName; // JSONType has been introduced in 2.082 static if (__VERSION__ <= 2081) { alias JSONType = JSON_TYPE; alias JSON_TYPE_NULL = JSON_TYPE.NULL; alias JSON_TYPE_OBJECT = JSON_TYPE.OBJECT; alias JSON_TYPE_STRING = JSON_TYPE.STRING; alias JSON_TYPE_ARRAY = JSON_TYPE.ARRAY; alias JSON_TYPE_INTEGER = JSON_TYPE.INTEGER; alias JSON_TYPE_UINTEGER = JSON_TYPE.UINTEGER; } else { alias JSON_TYPE_NULL = JSONType.null_; alias JSON_TYPE_OBJECT = JSONType.object; alias JSON_TYPE_STRING = JSONType.string; alias JSON_TYPE_ARRAY = JSONType.array; alias JSON_TYPE_INTEGER = JSONType.integer; alias JSON_TYPE_UINTEGER = JSONType.uinteger; } void usage() { writeln("Usage: santize_json [--keep-deco] []"); } // This module may be imported from d_do_test version (NoMain) {} else int main(string[] args) { getopt(args, "keep-deco", &keepDeco); args = args[1 .. $]; if (args.length == 0) { usage(); return 1; } string inFilename = args[0]; File outFile; if(args.length == 1) { outFile = stdout; } else if(args.length == 2) { outFile = File(args[1], "w"); } else { writeln("Error: too many command line arguments"); return 1; } auto json = readText(inFilename); sanitize(json); outFile.writeln(json); return 0; } string capitalize(string s) { return text(s.take(1).asCapitalized.chain(s.drop(1))); } void sanitize(ref string text) { auto json = parseJSON(text); sanitize(json); text = json.toJSON(true, JSONOptions.doNotEscapeSlashes); } void sanitize(JSONValue root) { if (root.type == JSON_TYPE_ARRAY) { sanitizeSyntaxNode(root); } else { assert(root.type == JSON_TYPE_OBJECT); auto rootObject = root.object; static foreach (name; ["compilerInfo", "buildInfo", "semantics"]) {{ auto node = rootObject.get(name, JSONValue.init); if (node.type != JSON_TYPE_NULL) { mixin("sanitize" ~ name.capitalize ~ "(node.object);"); } }} { auto modules = rootObject.get("modules", JSONValue.init); if (modules.type != JSON_TYPE_NULL) { sanitizeSyntaxNode(modules); } } } } void removeString(JSONValue* value) { assert(value.type == JSON_TYPE_STRING|| value.type == JSON_TYPE_NULL); *value = JSONValue("VALUE_REMOVED_FOR_TEST"); } void removeNumber(JSONValue* value) { assert(value.type == JSON_TYPE_INTEGER || value.type == JSON_TYPE_UINTEGER); *value = JSONValue(0); } void removeStringIfExists(JSONValue* value) { if (value !is null) removeString(value); } void removeArray(JSONValue* value) { assert(value.type == JSON_TYPE_ARRAY); *value = JSONValue([JSONValue("VALUES_REMOVED_FOR_TEST")]); } void sanitizeCompilerInfo(ref JSONValue[string] buildInfo) { removeString(&buildInfo["version"]); removeNumber(&buildInfo["__VERSION__"]); removeString(&buildInfo["vendor"]); removeNumber(&buildInfo["size_t"]); removeArray(&buildInfo["platforms"]); removeArray(&buildInfo["architectures"]); removeArray(&buildInfo["predefinedVersions"]); version (LDC) buildInfo["interface"] = JSONValue("dmd"); // not "ldc" } void sanitizeBuildInfo(ref JSONValue[string] buildInfo) { removeString(&buildInfo["cwd"]); removeString(&buildInfo["argv0"]); removeString(&buildInfo["config"]); removeString(&buildInfo["libName"]); version (LDC) { removeArray(&buildInfo["importPaths"]); } else { auto importPaths = buildInfo["importPaths"].array; foreach(ref path; importPaths) { path = JSONValue(normalizeFile(path.str)); } } removeArray(&buildInfo["objectFiles"]); removeArray(&buildInfo["libraryFiles"]); removeString(&buildInfo["mapFile"]); } void sanitizeSyntaxNode(ref JSONValue value) { if (value.type == JSON_TYPE_ARRAY) { foreach (ref element; value.array) { sanitizeSyntaxNode(element); } } else if(value.type == JSON_TYPE_OBJECT) { foreach (name; value.object.byKey) { if (name == "file") removeString(&value.object[name]); else if (name == "offset") removeNumber(&value.object[name]); else if (!keepDeco && name == "deco") removeString(&value.object[name]); else sanitizeSyntaxNode(value.object[name]); } } } string getOptionalString(ref JSONValue[string] obj, string name) { auto node = obj.get(name, JSONValue.init); if (node.type == JSON_TYPE_NULL) return null; assert(node.type == JSON_TYPE_STRING, format("got %s where STRING was expected", node.type)); return node.str; } void sanitizeSemantics(ref JSONValue[string] semantics) { import std.array : appender; auto modulesArrayPtr = &semantics["modules"].array(); auto newModules = appender!(JSONValue[])(); foreach (ref semanticModuleNode; *modulesArrayPtr) { auto semanticModule = semanticModuleNode.object(); auto moduleName = semanticModule.getOptionalString("name"); if(moduleName.startsWith("std.", "core.", "etc.", "rt.", /*LDC*/ "ldc.") || moduleName == "object") { // remove druntime/phobos modules since they can change for each // platform continue; } auto fileNode = &semanticModule["file"]; *fileNode = JSONValue(normalizeFile(fileNode.str)); newModules.put(JSONValue(semanticModule)); } *modulesArrayPtr = newModules.data; } auto normalizeFile(string file) { import std.path : buildNormalizedPath, relativePath; file = file.buildNormalizedPath.relativePath(rootDir); version(Windows) return file.replace("\\", "/"); return file; } ./ldc-1.42.0-src/tests/dmd/tools/d_do_test.d0000755000175000017500000025542215205374122017401 0ustar fabiofabio#!/usr/bin/env rdmd /** * D testing tool. * * This module implements the test runner for all tests except `unit`. * * The general procedure is: * * 1. Parse the environment variables (`processEnvironment`) * 2. Extract test parameters from the source file (`gatherTestParameters`) * [3. Compile non-D sources (` collectExtraSources`)] * 4. Compile the test file (`tryMain`) * 5. Verify the compiler output (`compareOutput`) * [6. Run the generated executable (`tryMain`) ] * [5. Verify the executable's output (`compareOutput`) ] * [7. Run post-test steps (`tryMain`) ] * 8. Remove intermediate files (`tryMain`) * * Optional steps are marked with [...] */ module d_do_test; version (LDC) version (CRuntime_Microsoft) version = LDC_MSVC; import std.algorithm; import std.array; import std.conv; import std.datetime.stopwatch; import std.datetime.systime; import std.exception; import std.file; import std.format; import std.meta : AliasSeq; import std.process; import std.random; import std.range : chain, choose, roundRobin, takeOne; import std.regex; import std.path; import std.stdio; import std.string; import core.sys.posix.sys.wait; /// Absolute path to the test directory const dmdTestDir = __FILE_FULL_PATH__.dirName.dirName; version(Win32) { extern(C) int putenv(const char*); } /// Prints the `--help` information void usage() { write("d_do_test \n" ~ "\n" ~ " Note: this program is normally called through the Makefile, it" ~ " is not meant to be called directly by the user.\n" ~ "\n" ~ " example: d_do_test runnable/pi.d\n" ~ "\n" ~ " relevant environment variables:\n" ~ " ARGS: set to execute all combinations of\n" ~ " REQUIRED_ARGS: arguments always passed to the compiler\n" ~ " DMD: compiler to use, ex: ../src/dmd (required)\n" ~ " CC: C compiler to use, ex: cl, cc\n" ~ " CXX: C++ compiler to use, ex: cl, g++\n" ~ " OS: windows, linux, freebsd, osx, openbsd, netbsd, dragonflybsd\n" ~ " RESULTS_DIR: base directory for test results\n" ~ " MODEL: 32 or 64 (required)\n" ~ " AUTO_UPDATE: set to 1 to auto-update mismatching test output\n" ~ " PRINT_RUNTIME: set to 1 to print test runtime\n" ~ "\n" ~ " windows vs non-windows portability env vars:\n" ~ " DSEP: \\\\ or /\n" ~ " SEP: \\ or / (required)\n" ~ " OBJ: .obj or .o (required)\n" ~ " EXE: .exe or (required)\n"); } /// Type of test to execute (mapped to the subdirectories) enum TestMode { COMPILE, /// compilable FAIL_COMPILE, /// fail_compilation RUN, /// runnable, runnable_cxx DSHELL, /// dshell } /// Test parameters specified in the source file /// (conditionally expanded depending on the environment) struct TestArgs { TestMode mode; /// Test type based on the directory bool compileSeparately; /// `COMPILE_SEPARATELY`: compile each source file separately bool link; /// `LINK`: force linking for `fail_compilation` & `compilable` tests bool clearDflags; /// `DFLAGS`: whether DFLAGS should be cleared before invoking dmd string executeArgs; /// `EXECUTE_ARGS`: arguments passed to the compiled executable (for `runnable[_cxx]`) string cxxflags; /// `CXXFLAGS`: arguments passed to $CXX when compiling `EXTRA_CPP_SOURCES` string[] sources; /// `EXTRA_SOURCES`: additional D sources (+ main source file) string[] compiledImports; /// `COMPILED_IMPORTS`: files compiled alongside the main source string[] cppSources; /// `EXTRA_CPP_SOURCES`: additional C++ sources string[] objcSources; /// `EXTRA_OBJC_SOURCES`: additional Objective-C sources string permuteArgs; /// `PERMUTE_ARGS`: set of dmd arguments to permute for multiple test runs string[] argSets; /// `ARG_SETS`: selection of dmd arguments to use in different test runs string compileOutput; /// `TEST_OUTPUT`: expected output of dmd string compileOutputFile; /// `TEST_OUTPUT_FILE`: file containing the expected `TEST_OUTPUT` string runOutput; /// `RUN_OUTPUT`: expected output of the compiled executable ubyte runReturn; /// `RUN_RETURN` expected exit code of the executable when run string gdbScript; /// `GDB_SCRIPT`: script executed when running the compiled executable in GDB string gdbMatch; /// `GDB_MATCH`: regex describing the expected output from executing `GDB_SSCRIPT` string postScript; /// `POSTSCRIPT`: bash script executed after a successful test string[] outputFiles; /// generated files appended to the compilation output string transformOutput; /// Transformations for the compiler output string requiredArgs; /// `REQUIRED_ARGS`: dmd arguments passed when compiling D sources string requiredArgsForLink; /// `COMPILE_SEPARATELY`: dmd arguments passed when linking separately compiled objects string disabledReason; /// `DISABLED`: reason to skip this test or empty, if the test is not disabled /// Returns: whether this disabled due to some reason bool isDisabled() const { return disabledReason.length != 0; } } /// Test parameters specified in the environment (e.g. target model) /// which are shared between all tests struct EnvData { string all_args; /// `ARGS`: arguments to test in permutations string dmd; /// `DMD`: compiler under test string results_dir; /// `RESULTS_DIR`: directory for temporary files string sep; /// `SEP`: directory separator (`/` or `\`) string dsep; /// `DSEP`: double directory separator ( `/` or `\\`) string obj; /// `OBJ`: object file extension (`.o` or `.obj`) string exe; /// `EXE`: executable file extension (none or `.exe`) string os; /// `OS`: host operating system (`linux`, `windows`, ...) string compiler; /// `HOST_DMD`: host D compiler string ccompiler; /// `CC`: host C compiler string cxxcompiler; /// `CXX`: host C++ compiler string model; /// `MODEL`: target model (`32` or `64`) string required_args; /// `REQUIRED_ARGS`: flags added to the tests `REQUIRED_ARGS` parameter string cxxCompatFlags; /// Additional flags passed to $(compiler) when `EXTRA_CPP_SOURCES` is present string[] picFlag; /// Compiler flag for PIC (if requested from environment) bool dobjc; /// `D_OBJC`: run Objective-C tests bool coverage_build; /// `COVERAGE`: coverage build, skip linking & executing to save time bool autoUpdate; /// `AUTO_UPDATE`: update `(TEST|RUN)_OUTPUT` on missmatch bool printRuntime; /// `PRINT_RUNTIME`: Print time spent on a single test bool tryDisabled; /// `TRY_DISABLED`:Silently try disabled tests (ignore failure and report success) version (LDC) bool noArchVariant; } /++ Creates a new EnvData instance based on the current environment. Other code should not read from the environment. Returns: an initialized EnvData instance ++/ immutable(EnvData) processEnvironment() { static string envGetRequired(in char[] name) { if (auto value = environment.get(name)) return value; writefln("Error: Missing environment variable '%s', was this called through the Makefile?", name); throw new SilentQuit(); } EnvData envData; envData.all_args = environment.get("ARGS"); envData.results_dir = envGetRequired("RESULTS_DIR"); envData.sep = envGetRequired ("SEP"); envData.dsep = environment.get("DSEP"); envData.obj = envGetRequired ("OBJ"); envData.exe = envGetRequired ("EXE"); envData.os = environment.get("OS"); envData.dmd = replace(envGetRequired("DMD"), "/", envData.sep); envData.compiler = "ldc"; //should be replaced for other compilers envData.ccompiler = environment.get("CC"); envData.cxxcompiler = environment.get("CXX"); envData.model = envGetRequired("MODEL"); envData.required_args = environment.get("REQUIRED_ARGS"); envData.dobjc = environment.get("D_OBJC") == "1"; envData.coverage_build = environment.get("DMD_TEST_COVERAGE") == "1"; envData.autoUpdate = environment.get("AUTO_UPDATE", "") == "1"; envData.printRuntime = environment.get("PRINT_RUNTIME", "") == "1"; envData.tryDisabled = environment.get("TRY_DISABLED") == "1"; version (LDC) envData.noArchVariant = environment.get("NO_ARCH_VARIANT") == "1"; enforce(envData.sep.length == 1, "Path separator must be a single character, not: `"~envData.sep~"`"); if (envData.ccompiler.empty) { if (envData.os == "windows") envData.ccompiler = "cl"; else envData.ccompiler = "cc"; } if (envData.cxxcompiler.empty) { if (envData.os == "windows") envData.cxxcompiler = "cl"; else envData.cxxcompiler = "c++"; } version (Windows) {} else { version(X86_64) envData.picFlag = ["-fPIC"]; if (environment.get("PIC", null) == "1") envData.picFlag = ["-fPIC"]; } switch (envData.compiler) { case "dmd": case "ldc": version (CppRuntime_GNU) envData.cxxCompatFlags = " -L-lstdc++ -L--no-demangle"; else version (CppRuntime_LLVM) envData.cxxCompatFlags = " -L-lc++ -L--no-demangle"; else version (CppRuntime_Gcc) envData.cxxCompatFlags = " -L-lstdc++ -L--no-demangle"; else version (CppRuntime_Clang) envData.cxxCompatFlags = " -L-lc++ -L--no-demangle"; break; case "gdc": envData.cxxCompatFlags = "-Xlinker -lstdc++ -Xlinker --no-demangle"; break; default: writeln("Unknown compiler: ", envData.compiler); throw new SilentQuit(); } return cast(immutable) envData; } /** * Read the single-line test parameter `token` from the source code which * might be defined multiple times. All definitions found will be joined * into a single string using `multilineDelimiter` as a separator. * * This will skip conditional parameters declared as `()` * if the specified environment doesn't match the passed `envData`, e.g. * * --- * REQURIRED_ARGS(linux): -ignore * PERMUTE_ARGS(windows64): -ignore * --- * * Params: * envData = environment data * file = source code * token = test parameter * result = variable to store the parameter * multilineDelimiter = separator for multiple declarations * * Returns: whether the parameter was found in the source code */ bool findTestParameter(const ref EnvData envData, string file, string token, ref string result, string multiLineDelimiter = " ") { if (!consumeNextToken(file, token, envData)) return false; auto lineEndR = std.string.indexOf(file, "\r"); auto lineEndN = std.string.indexOf(file, "\n"); auto lineEnd = lineEndR == -1 ? (lineEndN == -1 ? file.length : lineEndN) : (lineEndN == -1 ? lineEndR : min(lineEndR, lineEndN)); result = file[0 .. lineEnd]; const commentStart = std.string.indexOf(result, "//"); if (commentStart != -1) result = result[0 .. commentStart]; result = strip(result); string result2; if (findTestParameter(envData, file[lineEnd .. $], token, result2, multiLineDelimiter)) { if (result2.length > 0) { if (result.length == 0) result = result2; else result ~= multiLineDelimiter ~ result2; } } // fix-up separators result = result.unifyDirSep(envData.sep); return true; } unittest { immutable file = ` /* Here's a link FOO: a b FOO: c */ void main() {} // BAR(windows): all_win // BAR(windows64): 64_win int i; /* REQUIRED_ARGS: -O * PERMUTE_ARGS: */ // COMPILE_SEPARATELY: import foo.bar; `; immutable EnvData win32 = { os: "windows", model: "32", }; immutable EnvData win64 = { os: "windows", model: "64", }; immutable EnvData linux = { os: "linux", model: "64", }; string found; assert(!findTestParameter(linux, file, "OTHER", found)); assert(found is null); assert(findTestParameter(win64, file, "FOO", found)); assert(found == "a b c"); found = null; assert(findTestParameter(win64, file, "FOO", found, ";")); assert(found == "a b;c"); found = null; assert(findTestParameter(win64, file, "BAR", found)); assert(found == "all_win 64_win"); found = null; assert(findTestParameter(win32, file, "BAR", found)); assert(found == "all_win"); found = null; assert(!findTestParameter(linux, file, "BAR", found)); assert(found is null); assert(findTestParameter(linux, file, "PERMUTE_ARGS", found)); assert(found == ""); found = null; assert(findTestParameter(linux, file, "REQUIRED_ARGS", found)); assert(found == "-O"); found = null; assert(findTestParameter(linux, file, "COMPILE_SEPARATELY", found)); assert(found == ""); } /** * Read the multi-line test parameter `token` from the source code and joins * multiple definitions into a single string. * * ``` * TEST_OUTPUT: * --- * Hello, World! * --- * ``` * * Params: * file = source code * token = test parameter * result = variable to store the parameter * envData = environment data * * Returns: whether the parameter was found in the source code */ bool findOutputParameter(string file, string token, out string result, ref const EnvData envData) { bool found = false; while (consumeNextToken(file, token, envData)) { found = true; enum embed_sep = "---"; auto n = std.string.indexOf(file, embed_sep); enforce(n != -1, "invalid "~token~" format"); n += embed_sep.length; while (file[n] == '-') ++n; if (file[n] == '\r') ++n; if (file[n] == '\n') ++n; file = file[n .. $]; auto iend = std.string.indexOf(file, embed_sep); enforce(iend != -1, "invalid TEST_OUTPUT format"); result ~= file[0 .. iend]; while (file[iend] == '-') ++iend; file = file[iend .. $]; } if (found) { result = std.string.strip(result); result = result.unifyNewLine().unifyDirSep(envData.sep); result = result ? result : ""; // keep non-null } return found; } unittest { immutable EnvData linux = { os: "linux", model: "64", sep: "/ " }; immutable file = ` /* Here's a link TEST_OUTPUT: --- Hello, World --- */ void main() {} /* TEST_OUTPUT(linux): --- Have a nice day --- */ /* TEST_OUTPUT(linux32): --- Ignored --- */ void foo() {} /* MISSING: */ /* INCOMPLETE: --- */ `; string found; assert(!findOutputParameter(file, "UNKNOWN", found, linux)); assert(found is null); assert(findOutputParameter(file, "TEST_OUTPUT", found, linux)); assert(found == "Hello, World\nHave a nice day"); found = null; auto ex = collectException(findOutputParameter(file, "MISSING", found, linux)); assert(ex); assert(ex.msg == "invalid TEST_OUTPUT format"); assert(found is null); ex = collectException(findOutputParameter(file, "INCOMPLETE", found, linux)); assert(ex); assert(ex.msg == "invalid TEST_OUTPUT format"); } /++ + Reads the file content to find the next parameter specified by `token`. + Ignores conditional parameters that don't apply to the current environment. + + Params: + file = file content, will be advanced to the first non-whitespace character + of the parameter value - if `token` was found + token = requested parameter + envData = environment data + + Returns: true if `token` was found +/ private bool consumeNextToken(ref string file, const string token, ref const EnvData envData) { import std.ascii : isWhite; while (true) { const istart = std.string.indexOf(file, token); if (istart == -1) return false; // Examine the preceeding character to avoid false matches const ch = istart ? file[istart - 1] : ' '; file = file[istart + token.length .. $]; file = file.stripLeft!(ch => ch == ' '); // Don't read line breaks // Assume that real test token are preceeded by spaces or comment-related tokens if (!isWhite(ch) && !among(ch, '/', '*', '+')) { debug writeln("Ignoring partial match for token: ", token); continue; } // filter by OS specific setting (os1 os2 ...) if (file.startsWith("(")) { auto close = std.string.indexOf(file, ")"); if (close >= 0) { // Remove the () list from the front of `file`` const oss = split(file[1 .. close], " "); file = file[close + 1 .. $]; file = file.stripLeft!(ch => ch == ' '); // Don't read line breaks // Check if the current environment matches an entry in oss, which can either // be an OS (e.g. "linux") or a combination of OS + MODEL (e.g. "windows32"). if (!oss.canFind!(o => o.skipOver(envData.os) && (o.empty || o == envData.model))) continue; // Parameter was skipped } } // Skip a trailing colon if (file.skipOver(":")) { file = file.stripLeft!(ch => ch == ' '); // Don't read line breaks return true; } writeln("Test directive `", token,"` must be followed by a `:`"); throw new SilentQuit(); } } unittest { immutable EnvData linux = { os: "linux", model: "64", sep: "/ " }; immutable file = q{ GOOD: foo WITH_SPACE : bar /* BAD --- --- */ //BAD foo //OPTLINK // $(TINK foo.bar) IgnoreSTUFF IgnoreSTUFF: x STUFF: someVal */ void main() {} }; string found = file; assert(!consumeNextToken(found, "UNKNOWN", linux)); assert(found is file); assert(consumeNextToken(found, "GOOD", linux)); assert(found.startsWith("foo"), found); found = file; assert(consumeNextToken(found, "WITH_SPACE", linux)); assert(found.startsWith("bar"), found); found = file; assertThrown(consumeNextToken(found, "BAD", linux)); found = file; assert(!consumeNextToken(found, "LINK", linux)); found = file; assert(!consumeNextToken(found, "TINK", linux)); found = file; assert(consumeNextToken(found, "STUFF", linux)); assert(found.startsWith("someVal"), found); } /// Replaces the placeholer `${RESULTS_DIR}` with the actual path /// to `test_results` stored in `envData`. void replaceResultsDir(ref string arguments, const ref EnvData envData) { // Bash would expand this automatically on Posix, but we need to manually // perform the replacement for Windows compatibility. arguments = replace(arguments, "${RESULTS_DIR}", envData.results_dir); } /// Returns: the reason why this test is disabled or null if it isn't skipped. string getDisabledReason(string[] disabledPlatforms, const ref EnvData envData) { if (disabledPlatforms.length == 0) return null; const target = ((envData.os == "windows") ? "win" : envData.os) ~ envData.model; // allow partial matching, e.g. `win` to disable both win32 and win64 const i = disabledPlatforms.countUntil!(p => target.canFind(p)); if (i != -1) return "on " ~ disabledPlatforms[i]; version (LDC) { version (X86) enum isX86 = true; else version (X86_64) enum isX86 = true; else enum isX86 = false; // additionally support `DISABLED: LDC` if (disabledPlatforms.canFind("LDC")) return "for LDC"; // additionally support `DISABLED: LDC_not_x86` (e.g., for tests with DMD-style inline asm) if (!isX86 && disabledPlatforms.canFind("LDC_not_x86")) return "for LDC_not_x86"; // additionally support `DISABLED: LDC_[]` const j = disabledPlatforms.countUntil!(p => p.startsWith("LDC_") && target.canFind(p[4 .. $])); if (j != -1) return "for LDC on " ~ disabledPlatforms[j]; } return null; } unittest { immutable EnvData win32 = { os: "windows", model: "32" }; immutable EnvData win64 = { os: "windows", model: "64" }; assert(getDisabledReason(null, win64) is null); assert(getDisabledReason([ "linux" ], win64) is null); assert(getDisabledReason([ "linux", "win" ], win64) == "on win"); assert(getDisabledReason([ "linux", "win64" ], win64) == "on win64"); assert(getDisabledReason([ "linux", "win32" ], win64) is null); assert(getDisabledReason([ "win32" ], win32) == "on win32"); assert(getDisabledReason([ "win32" ], win64) is null); } /** * Reads the test configuration from the source code (using `findTestParameter` and * `findOutputParameter`) and initializes `testArgs` accordingly. Also merges * configurations/additional parameters specified in the environment, e.g. * `REQUIRED_ARGS`. * * Params: * testArgs = test configuration object * input_dir = test directory (e.g. `runnable`) * input_file = path to the source file * envData = environment configurations * * Returns: whether this test should be executed (true) or skipped (false) * Throws: Exception if the test configuration is invalid */ bool gatherTestParameters(ref TestArgs testArgs, string input_dir, string input_file, const ref EnvData envData) { string file = cast(string)std.file.read(input_file); string dflagsStr; testArgs.clearDflags = findTestParameter(envData, file, "DFLAGS", dflagsStr); enforce(dflagsStr.empty, "The DFLAGS test argument must be empty: It is '" ~ dflagsStr ~ "'"); findTestParameter(envData, file, "REQUIRED_ARGS", testArgs.requiredArgs); if (envData.required_args.length) { if (testArgs.requiredArgs.length) testArgs.requiredArgs ~= " " ~ envData.required_args; else testArgs.requiredArgs = envData.required_args; } replaceResultsDir(testArgs.requiredArgs, envData); if (! findTestParameter(envData, file, "PERMUTE_ARGS", testArgs.permuteArgs)) { if (testArgs.mode == TestMode.RUN) testArgs.permuteArgs = envData.all_args; } replaceResultsDir(testArgs.permuteArgs, envData); // remove permute args enforced as required anyway if (testArgs.requiredArgs.length && testArgs.permuteArgs.length) { version (LDC) { /* * Additionally exclude some permute args which are uninteresting * for LDC due to the split in * * * dmd-testsuite, requiring `-O`, which basically implies `-inline` * too (except for a here irrelevant header generation detail), and * * dmd-testsuite-debug, requiring `-g -link-defaultlib-debug`. * * In case the original permute args specify both `-O` and `-g`, only * 2 of 4 combinations will be tested (`-O` and `-g`), excluding the * rather uninteresting `-O -g` (which would otherwise be tested twice) * and `` (which is untestable anyway). * Similarly, a `-inline` alone without `-O` isn't interesting for * additional test coverage, as it just controls an LLVM optimization * pass. * Ditto for `-fPIC`, which is enabled by default for most targets. */ static immutable permuteArgsExcludedByLDC = ["-O", "-inline", "-g", "-fPIC"]; const required = split(testArgs.requiredArgs) ~ permuteArgsExcludedByLDC; } else { const required = split(testArgs.requiredArgs); } const newPermuteArgs = split(testArgs.permuteArgs) .filter!(a => !required.canFind(a)) .join(" "); testArgs.permuteArgs = newPermuteArgs; } // tests can override -verrors by using REQUIRED_ARGS if (testArgs.mode == TestMode.FAIL_COMPILE) testArgs.requiredArgs = "-verrors=simple -verrors=0 " ~ testArgs.requiredArgs; version (LDC) { // *.{c,i} tests: make sure not to pull in ldc_rt.dso.o for BUILD_SHARED_LIBS=ON builds // (with implicit -link-defaultlib-shared) if (input_file.extension() == ".c" || input_file.extension() == ".i") { if (testArgs.requiredArgs.length) testArgs.requiredArgs ~= " -defaultlib="; else testArgs.requiredArgs = "-defaultlib="; } } { string argSetsStr; findTestParameter(envData, file, "ARG_SETS", argSetsStr, ";"); foreach(s; split(argSetsStr, ";")) { replaceResultsDir(s, envData); testArgs.argSets ~= s; } } // win(32|64) doesn't support pic // -target/-os may compile for non-PIC targets, let the test take care of -fPIC if (envData.os == "windows" || testArgs.requiredArgs.canFind("-target", "-os")) { auto index = std.string.indexOf(testArgs.permuteArgs, "-fPIC"); if (index != -1) testArgs.permuteArgs = testArgs.permuteArgs[0 .. index] ~ testArgs.permuteArgs[index+5 .. $]; // Remove the first -fPIC when added via the REQUIRED_ARGS environment variable // This allows test to explicitly set `-fPIC` if necessary if (envData.required_args.canFind("-fPIC")) testArgs.requiredArgs = testArgs.requiredArgs.replaceFirst("-fPIC", "").strip(); } // clean up extra spaces testArgs.permuteArgs = strip(replace(testArgs.permuteArgs, " ", " ")); if (findTestParameter(envData, file, "EXECUTE_ARGS", testArgs.executeArgs)) replaceResultsDir(testArgs.executeArgs, envData); // Always run main even if compiled with '-unittest' but let // tests switch to another behaviour if necessary if (!testArgs.executeArgs.canFind("--DRT-testmode")) testArgs.executeArgs ~= " --DRT-testmode=run-main"; string extraSourcesStr; findTestParameter(envData, file, "EXTRA_SOURCES", extraSourcesStr); testArgs.sources = [input_file]; // prepend input_dir to each extra source file foreach(s; split(extraSourcesStr)) testArgs.sources ~= input_dir ~ "/" ~ s; { string compiledImports; findTestParameter(envData, file, "COMPILED_IMPORTS", compiledImports); foreach(s; split(compiledImports)) testArgs.compiledImports ~= input_dir ~ "/" ~ s; } findTestParameter(envData, file, "CXXFLAGS", testArgs.cxxflags); version (OSX) { if (envData.compiler == "dmd") testArgs.cxxflags ~= " -arch x86_64"; } string extraCppSourcesStr; findTestParameter(envData, file, "EXTRA_CPP_SOURCES", extraCppSourcesStr); testArgs.cppSources = split(extraCppSourcesStr); if (testArgs.cppSources.length) testArgs.requiredArgs ~= envData.cxxCompatFlags; string extraObjcSourcesStr; auto objc = findTestParameter(envData, file, "EXTRA_OBJC_SOURCES", extraObjcSourcesStr); if (objc && !envData.dobjc) return false; testArgs.objcSources = split(extraObjcSourcesStr); // Using the ld64 linker may result in linker warnings being generated // which are irrelevant to the parts of Objective-C ABI which D implements. // As such we supress linker warnings for Objective-C tests to avoid // linker errors when linking against Objective-C compiler output. version(LDC) if (objc) testArgs.requiredArgs ~= " -L-w"; // swap / with $SEP if (envData.sep && envData.sep != "/") foreach (ref s; testArgs.sources) s = replace(s, "/", to!string(envData.sep)); //writeln ("sources: ", testArgs.sources); { string throwAway; testArgs.link = findTestParameter(envData, file, "LINK", throwAway); } // COMPILE_SEPARATELY can take optional compiler switches when link .o files testArgs.compileSeparately = findTestParameter(envData, file, "COMPILE_SEPARATELY", testArgs.requiredArgsForLink); string disabledPlatformsStr; findTestParameter(envData, file, "DISABLED", disabledPlatformsStr); version (DragonFlyBSD) { // DragonFlyBSD is x86_64 only, instead of adding DISABLED to a lot of tests, just exclude them from running if (testArgs.requiredArgs.canFind("-m32")) testArgs.disabledReason = "on DragonFlyBSD (no -m32)"; } version (ARM) enum supportsM64 = false; else version (MIPS32) enum supportsM64 = false; else version (PPC) enum supportsM64 = false; else enum supportsM64 = true; static if (!supportsM64) { if (testArgs.requiredArgs.canFind("-m64")) testArgs.disabledReason = "because target doesn't support -m64"; } if (!testArgs.isDisabled) testArgs.disabledReason = getDisabledReason(split(disabledPlatformsStr), envData); findTestParameter(envData, file, "TEST_OUTPUT_FILE", testArgs.compileOutputFile); // Only check for TEST_OUTPUT is no file was given because it would // partially match TEST_OUTPUT_FILE if (testArgs.compileOutputFile) { // Don't require tests to specify the test directory testArgs.compileOutputFile = input_dir.buildPath(testArgs.compileOutputFile); testArgs.compileOutput = readText(testArgs.compileOutputFile) .unifyNewLine() // Avoid CRLF issues .strip(); // Only sanitize directory separators from file types that support standalone \ if (!testArgs.compileOutputFile.endsWith(".json")) testArgs.compileOutput = testArgs.compileOutput.unifyDirSep(envData.sep); } else findOutputParameter(file, "TEST_OUTPUT", testArgs.compileOutput, envData); string outFilesStr; findTestParameter(envData, file, "OUTPUT_FILES", outFilesStr); testArgs.outputFiles = outFilesStr.split(';'); findTestParameter(envData, file, "TRANSFORM_OUTPUT", testArgs.transformOutput); findOutputParameter(file, "RUN_OUTPUT", testArgs.runOutput, envData); string dummy; if (findTestParameter(envData, file, "RUN_RETURN", dummy)) { import std.conv : to; scope(failure) { writeln("Something went wrong when parsing RUN_RETURN from " ~ dummy); } testArgs.runReturn = dummy.to!(typeof(testArgs.runReturn)); } findOutputParameter(file, "GDB_SCRIPT", testArgs.gdbScript, envData); findTestParameter(envData, file, "GDB_MATCH", testArgs.gdbMatch); findTestParameter(envData, file, "POST_SCRIPT", testArgs.postScript); return true; } unittest { immutable EnvData linux32 = { os: "linux", model: "32", required_args: "-fPIC" }; immutable EnvData linux64 = { os: "linux", model: "64", required_args: "-fPIC" }; immutable EnvData win64 = { os: "windows", model: "64", }; immutable dir = "runnable"; immutable file = ".d_do_test_unittest_target_example.d"; immutable content = q{ /+ https://foo.bar. REQUIRED_ARGS: -target=x86-unknown-windows-msvc REQUIRED_ARGS(linux32): -fPIC +/ }; std.file.write(file, content); scope (exit) std.file.remove(file); TestArgs args; assert(gatherTestParameters(args, dir, file, win64)); assert(args.requiredArgs == "-target=x86-unknown-windows-msvc", args.requiredArgs); args = TestArgs.init; assert(gatherTestParameters(args, dir, file, linux64)); assert(args.requiredArgs == "-target=x86-unknown-windows-msvc", args.requiredArgs); args = TestArgs.init; assert(gatherTestParameters(args, dir, file, linux32)); assert(args.requiredArgs == "-target=x86-unknown-windows-msvc -fPIC", args.requiredArgs); std.file.write(file, "REQUIRED_ARGS: -os=windows"); args = TestArgs.init; assert(gatherTestParameters(args, dir, file, linux64)); assert(args.requiredArgs == "-os=windows", args.requiredArgs); } string[] splitQuoted(string text) { import std.utf, std.uni; enum quote = '\''; string[] args; size_t pos = 0; while (pos < text.length) { size_t startpos = pos; dchar ch = decode(text, pos); if (isWhite(ch)) continue; size_t quoted = 0; size_t endpos = pos; while (pos < text.length) { if (ch == quote) { while (pos < text.length) { dchar ch2 = decode(text, pos); if (ch2 == quote) // no escaping { quoted++; break; } } ch = 0; } else { ch = decode(text, pos); } if (isWhite(ch)) break; endpos = pos; } if (quoted == 1 && text[startpos] == quote && text[endpos-1] == quote) startpos++, endpos--; auto arg = text[startpos .. endpos].strip; if (!arg.empty) args ~= arg; } return args; } /// Generates all permutations of the space-separated word contained in `argstr` string[] combinations(string argstr) { string[] results; string[] args = splitQuoted(argstr); long combinations = 1 << args.length; for (size_t i = 0; i < combinations; i++) { string r; bool printed = false; for (size_t j = 0; j < args.length; j++) { if (i & 1 << j) { if (printed) r ~= " "; r ~= args[j]; printed = true; } } results ~= r; } return results; } /// Tries to remove the file identified by `filename` and prints warning on failure void tryRemove(in char[] filename) { if (auto ex = std.file.remove(filename).collectException()) debug writeln("WARNING: Failed to remove ", filename); } /** * Executes `command` while logging the invocation and any output produced into f. * * Params: * f = the logfile * command = the command to execute * expectPass = whether the command should succeed * * Returns: the output produced by `command` * Throws: * Exception if `command` returns another exit code than 0/1 (depending on expectPass) */ string execute(ref File f, string command, const ubyte expectedRc) { f.writeln(command); const result = std.process.executeShell(command); f.write(result.output); if (result.status < 0) { enforce(false, "caught signal: " ~ to!string(result.status)); } else { enforce(result.status == expectedRc, format("Expected rc == %d, but exited with rc == %d", expectedRc, result.status)); } return result.output; } /// add quotes around the whole string if it contains spaces that are not in quotes string quoteSpaces(string str) { if (str.indexOf(' ') < 0) return str; bool inquote = false; foreach(dchar c; str) if (c == '"') inquote = !inquote; else if (c == ' ' && !inquote) return "\"" ~ str ~ "\""; return str; } /// Replaces non-Unix line endings in `str` with `\n` string unifyNewLine(string str) { // On Windows, Outbuffer.writenl() puts `\r\n` into the buffer, // then fprintf() adds another `\r` when formatting the message. // This is why there's a match for `\r\r\n` in this regex. static re = regex(`\r\r\n|\r\n|\r|\n`, "g"); return std.regex.replace(str, re, "\n"); } /** Unifies a text `str` with words that could be DMD path references to a common separator `sep`. This normalizes the text and allows comparing path output results between different operating systems. Params: str = text to be unified sep = unification separator to use Returns: Text with path separator standardized to `sep`. */ string unifyDirSep(string str, string sep) { static void unifyWordFromBack(char[] r, char sep) { foreach_reverse(ref ch; r) { // stop at common word boundaries if (ch == '\n' || ch == '\r' || ch == ' ') break; // normalize path characters if (ch == '\\' || ch == '/') ch = sep; } } auto mStr = str.dup; auto remaining = mStr; alias needles = AliasSeq!(".d", ".di", ".mixin", ".c", ".i", ".h"); enum needlesArray = [needles]; // simple multi-delimiter word identification while (!remaining.empty) { auto res = remaining.find(needles); if (res[0].empty) break; auto currentWord = remaining[0 .. res[0].ptr-remaining.ptr]; // skip over current word and matched delimiter const needleLength = res[1] > 0 ? needlesArray[res[1] - 1].length : 0; remaining = remaining[currentWord.length + needleLength .. $]; if (remaining.empty || remaining.startsWith(" ", "\n", "\r", "-mixin", "(", ":", "'", "`", "\"", ".", ",")) unifyWordFromBack(currentWord, sep[0]); } return mStr.assumeUnique; } unittest { assert(`fail_compilation/test.d(1) Error: dummy error message for 'test'`.unifyDirSep(`\`) == `fail_compilation\test.d(1) Error: dummy error message for 'test'`); assert(`fail_compilation/test.d(1) Error: at fail_compilation/test.d(2)`.unifyDirSep(`\`) == `fail_compilation\test.d(1) Error: at fail_compilation\test.d(2)`); assert(`fail_compilation/test.d(1) Error: at fail_compilation/imports/test.d(2)`.unifyDirSep(`\`) == `fail_compilation\test.d(1) Error: at fail_compilation\imports\test.d(2)`); assert(`fail_compilation/diag.d(2): Error: fail_compilation/imports/fail.d must be imported`.unifyDirSep(`\`) == `fail_compilation\diag.d(2): Error: fail_compilation\imports\fail.d must be imported`); assert(`{{RESULTS_DIR}}/fail_compilation/mixin_test.mixin(7): Error:`.unifyDirSep(`\`) == `{{RESULTS_DIR}}\fail_compilation\mixin_test.mixin(7): Error:`); assert(`{{RESULTS_DIR}}/fail_compilation/mixin_test.d-mixin-50(7): Error:`.unifyDirSep(`\`) == `{{RESULTS_DIR}}\fail_compilation\mixin_test.d-mixin-50(7): Error:`); assert("runnable\\xtest46_gc.d-mixin-37(187): Error".unifyDirSep("/") == "runnable/xtest46_gc.d-mixin-37(187): Error"); // optional columns assert(`{{RESULTS_DIR}}/fail_compilation/cols.d(12,7): Error:`.unifyDirSep(`\`) == `{{RESULTS_DIR}}\fail_compilation\cols.d(12,7): Error:`); // gnu style assert(`fail_compilation/test.d:1: Error: dummy error message for 'test'`.unifyDirSep(`\`) == `fail_compilation\test.d:1: Error: dummy error message for 'test'`); // in quotes as well assert("'imports\\foo.d'".unifyDirSep("/") == "'imports/foo.d'"); assert("`imports\\foo.d`".unifyDirSep("/") == "`imports/foo.d`"); assert("\"imports\\foo.d\"".unifyDirSep("/") == "\"imports/foo.d\""); assert("fail_compilation\\foo.d: Error:".unifyDirSep("/") == "fail_compilation/foo.d: Error:"); // at the end of a sentence assert("fail_compilation\\foo.d. A".unifyDirSep("/") == "fail_compilation/foo.d. A"); assert("fail_compilation\\foo.d(2). A".unifyDirSep("/") == "fail_compilation/foo.d(2). A"); assert("fail_compilation\\foo.d, A".unifyDirSep("/") == "fail_compilation/foo.d, A"); assert("fail_compilation\\foo.d(2), A".unifyDirSep("/") == "fail_compilation/foo.d(2), A"); assert("fail_compilation\\foo.d".unifyDirSep("/") == "fail_compilation/foo.d"); assert("fail_compilation\\foo.d\n".unifyDirSep("/") == "fail_compilation/foo.d\n"); assert("fail_compilation\\foo.d\r\n".unifyDirSep("/") == "fail_compilation/foo.d\r\n"); assert("\nfail_compilation\\foo.d".unifyDirSep("/") == "\nfail_compilation/foo.d"); assert("\r\nfail_compilation\\foo.d".unifyDirSep("/") == "\r\nfail_compilation/foo.d"); assert("fail_compilation\\imports\\cfoo.c. A".unifyDirSep("/") == "fail_compilation/imports/cfoo.c. A"); assert(("runnable\\xtest46_gc.d-mixin-37(220): Deprecation: `opDot` is deprecated. Use `alias this`\n"~ "runnable\\xtest46_gc.d-mixin-37(222): Deprecation: `opDot` is deprecated. Use `alias this`").unifyDirSep("/") == "runnable/xtest46_gc.d-mixin-37(220): Deprecation: `opDot` is deprecated. Use `alias this`\n"~ "runnable/xtest46_gc.d-mixin-37(222): Deprecation: `opDot` is deprecated. Use `alias this`"); assert("".unifyDirSep("/") == ""); assert(" \n ".unifyDirSep("/") == " \n "); assert("runnable/xtest46_gc.d-mixin-$n$(222): ".unifyDirSep("\\") == "runnable\\xtest46_gc.d-mixin-$n$(222): "); assert(`S('\xff').this(1)`.unifyDirSep("/") == `S('\xff').this(1)`); assert(`invalid UTF character \U80000000`.unifyDirSep("/") == `invalid UTF character \U80000000`); assert("https://code.dlang.org".unifyDirSep("\\") == "https://code.dlang.org"); } /** * Compiles all non-D sources using their respective compiler and flags * and appends the generated objects to `sources`. * * Params: * input_dir = test directory (e.g. `runnable`) * output_dir = directory for intermediate files * extraSources = sources to compile * sources = list of D sources to extend with object files * envData = environment configuration * compiler = external compiler (E.g. clang) * cxxflags = external compiler flags * logfile = the logfile * * Returns: false if a compilation error occurred */ bool collectExtraSources (in string input_dir, in string output_dir, in string[] extraSources, ref string[] sources, in EnvData envData, in string ccompiler, in string cxxcompiler, const(char)[] cxxflags, ref File logfile, /*LDC*/ in bool objC = false) { foreach (cur; extraSources) { auto curSrc = input_dir ~ envData.sep ~"extra-files" ~ envData.sep ~ cur; auto curObj = output_dir ~ envData.sep ~ cur ~ envData.obj; bool is_cpp_file = cur.extension() == ".cpp"; string command = quoteSpaces(is_cpp_file ? cxxcompiler : ccompiler); if (envData.os == "windows") // cl.exe { command ~= ` /c /nologo `~curSrc~` /Fo`~curObj; } else { command ~= (/*LDC*/ envData.noArchVariant ? null : " -m"~envData.model) ~ " -c "~curSrc~" -o "~curObj; } if (cxxflags) command ~= " " ~ cxxflags; logfile.writeln(command); logfile.flush(); // Avoid reordering due to buffering auto pid = spawnShell(command, stdin, logfile, logfile, null, Config.retainStdout | Config.retainStderr); if(wait(pid)) { return false; } sources ~= curObj; } return true; } /++ Applies custom transformations defined in transformOutput to testOutput. Currently the following actions are supported: * "sanitize_json" = replace compiler/plattform specific data from generated JSON * "sanitize_timetrace" = parse -ftime-trace profiler output, and only extract event names * "remove_lines()" = remove all lines matching a regex Params: testOutput = the existing output to be modified transformOutput = list of transformation identifiers ++/ void applyOutputTransformations(ref string testOutput, string transformOutput) { while (transformOutput.length) { string step, arg; const idx = transformOutput.countUntil(' ', '('); if (idx == -1) { step = transformOutput; transformOutput = null; } else { step = transformOutput[0 .. idx]; const hasArgs = transformOutput[idx] == '('; transformOutput = transformOutput[idx + 1 .. $]; if (hasArgs) { // "..." quotes are optional but necessary if the arg contains ')' const isQuoted = transformOutput[0] == '"'; const end = isQuoted ? `"` : `)`; auto parts = transformOutput[isQuoted .. $].findSplit(end); enforce(parts, "Missing closing `" ~ end ~ "`!"); arg = parts[0]; transformOutput = parts[2][isQuoted .. $]; } // Skip space between steps import std.ascii : isWhite; transformOutput.skipOver!isWhite(); } switch (step) { case "sanitize_json": { import sanitize_json : sanitize; sanitize(testOutput); break; } case "remove_lines": { auto re = regex(arg); testOutput = testOutput .splitter('\n') .filter!(line => !line.matchFirst(re)) .join('\n'); break; } case "sanitize_timetrace": import sanitize_timetrace; sanitizeTimeTrace(testOutput); break; default: throw new Exception(format(`Unknown transformation: "%s"!`, step)); } } } unittest { static void test(string input, const string transformations, const string expected) { applyOutputTransformations(input, transformations); assert(input == expected); } static void testJson(const string transformations, const string expectedJson) { test(`{ "modules": [ { "file": "/path/to/the/file", "kind": "module", "members": [] } ] }`, transformations, expectedJson); } testJson("sanitize_json", `{ "modules": [ { "file": "VALUE_REMOVED_FOR_TEST", "kind": "module", "members": [] } ] }`); testJson(`sanitize_json remove_lines("kind")`, `{ "modules": [ { "file": "VALUE_REMOVED_FOR_TEST", "members": [] } ] }`); testJson(`sanitize_json remove_lines("kind") remove_lines("file")`, `{ "modules": [ { "members": [] } ] }`); test(`This is a text containing some words which is a text sample nevertheless`, `remove_lines(text sample)`, `This is a text containing nevertheless`); test(`This is a text with a random ) which should still work`, `remove_lines("random \)")`, `This is a text with still work`); test(`Tom bought 12 apples and 6 berries from the store`, `remove_lines("(\d+)")`, `Tom bought from the store`); assertThrown(test("", "unknown", "")); } /// List of supported special sequences used in compareOutput alias specialSequences = AliasSeq!("$n$", "$p:", "$r:", "$?:"); /++ Compares the output string to the reference string by character except parts marked with one of the following special sequences: $n$ = numbers (e.g. compiler generated unique identifiers) $p:$ = real paths ending with $?:$ = environment dependent content supplied as a list choices (either = or ), separated by a '|'. Currently supported conditions are OS and model as supplied from the environment $r:$ = text matching (using $ inside of regex is not supported, use multiple regexes instead) Params: output = the real output refoutput = the expected output envData = test environment Returns: whether output matches the expected refoutput ++/ bool compareOutput(string output, string refoutput, const ref EnvData envData) { // If no output is expected, only check that nothing was captured. if (refoutput.length == 0) return (output.length == 0) ? true : false; version (LDC) refoutput = refoutput.replace("// Automatically generated by Digital Mars D Compiler", "// Automatically generated by LDC Compiler"); for ( ; ; ) { auto special = refoutput.find(specialSequences).rename!("remainder", "id"); // Simple equality check if no special tokens remain if (special.id == 0) return refoutput == output; const expected = refoutput[0 .. $ - special.remainder.length]; // Check until the special token if (!output.skipOver(expected)) return false; // Discard the special token and progress output appropriately refoutput = special.remainder[3 .. $]; if (special.id == 1) // $n$ { import std.ascii : isDigit; output.skipOver!isDigit(); continue; } // $:$ /// ( special content, "$", remaining expected output ) auto refparts = refoutput.findSplit("$"); enforce(refparts, "Malformed special sequence!"); refoutput = refparts[2]; if (special.id == 2) // $p:$ { // special content is the expected path tail // Substitute / with the appropriate directory separator const pathTail = refparts[0].replace("/", envData.sep); const newlineIndex = output.indexOf('\n'); const outputLine = newlineIndex == -1 ? output : output[0 .. newlineIndex]; const path = outputLine.findLastSplitAfter(pathTail)[0]; if (path.empty || !exists(path)) return false; output = output[path.length .. $]; continue; } else if (special.id == 3) // $r:$ { // need some context behind this expression to stop the regex match // e.g. "$r:.*$ failed with..." uses " failed" auto context = refoutput[0 .. min(7, $)]; const parts = context.findSplitBefore("$"); // Avoid collisions with other special sequences if (!parts[1].empty) { context = parts[0]; enforce(context.length, "Another sequence following $r:...$ is not supported!"); } // Remove the context from the remaining expected output refoutput = refoutput[context.length .. $]; // Use '^' to match at the beginning of output auto re = regex('^' ~ refparts[0] ~ context, "s"); auto match = output.matchFirst(re); if (!match) return false; output = output[match.front.length .. $]; continue; } // $?:=(;=)*(;)?$ string toSkip = null; foreach (const chunk; refparts[0].splitter('|')) { // ( , "=", ) const searchResult = chunk.findSplit("="); if (searchResult[1].empty) // { toSkip = chunk; break; } // Match against OS or model else if (searchResult[0].splitter('+').all!(c => c.among(envData.os, envData.model))) { toSkip = searchResult[2]; break; } } if (toSkip !is null && !output.skipOver(toSkip)) return false; } } private string[2] findLastSplitAfter(in string haystack, in string needle) { string[2] r = [null, haystack]; foreach_reverse (end; needle.length .. haystack.length + 1) // include haystack.length { const candidateTail = haystack[end - needle.length .. end]; if (candidateTail == needle) { r[0] = haystack[0 .. end]; r[1] = haystack[end .. $]; break; } } return r; } unittest { assert("abc".findLastSplitAfter("abcd") == ["", "abc"]); assert("abc".findLastSplitAfter("abc") == ["abc", ""]); assert("abc".findLastSplitAfter("ab") == ["ab", "c"]); assert("/phobos/bla/phobos/blub".findLastSplitAfter("phobos") == ["/phobos/bla/phobos", "/blub"]); } unittest { EnvData ed; version (Windows) ed.sep = `\`; else ed.sep = `/`; assert( compareOutput(`Grass is green`, `Grass is green`, ed)); assert(!compareOutput(`Grass is green`, `Grass was green`, ed)); assert( compareOutput(`Bob took 12 apples`, `Bob took $n$ apples`, ed)); assert(!compareOutput(`Bob took abc apples`, `Bob took $n$ apples`, ed)); assert(!compareOutput(`Bob took 12 berries`, `Bob took $n$ apples`, ed)); assert( compareOutput(`HINT: ` ~ __FILE_FULL_PATH__ ~ ` is important`, `HINT: $p:d_do_test.d$ is important`, ed)); version (LDC) assert( compareOutput(`HINT: ` ~ __FILE_FULL_PATH__ ~ ` is important`, `HINT: $p:tools/d_do_test.d$ is important`, ed)); else assert( compareOutput(`HINT: ` ~ __FILE_FULL_PATH__ ~ ` is important`, `HINT: $p:test/tools/d_do_test.d$ is important`, ed)); ed.sep = "/"; assert(!compareOutput(`See /path/to/druntime/import/object.d`, `See $p:druntime/import/object.d$`, ed)); assertThrown(compareOutput(`Path /a/b/c.d!`, `Path $p:c.d!`, ed)); // Missing closing $ const fmt = "This $?:windows=A|posix=B|C$ uses $?:64=1|32=2|3$ bytes"; assert( compareOutput("This C uses 3 bytes", fmt, ed)); ed.os = "posix"; ed.model = "64"; assert( compareOutput("This B uses 1 bytes", fmt, ed)); assert(!compareOutput("This C uses 3 bytes", fmt, ed)); const emptyFmt = "On <$?:windows=abc|$> use <$?:posix=$>!"; assert(compareOutput("On <> use <>!", emptyFmt, ed)); ed.model = "32"; assert(compareOutput("size_t is uint!", "size_t is $?:32=uint|64=ulong$!", ed)); assert(compareOutput("no", "$?:posix+64=yes|no$", ed)); ed.model = "64"; assert(compareOutput("yes", "$?:posix+64=yes|no$", ed)); assert(compareOutput("This number 12", `This $r:\w+ \d+$`, ed)); assert(compareOutput("This number 12", `This $r:\w+ (\d)+$`, ed)); assert(compareOutput("This number 12 is nice", `This $r:.*$ 12 is nice`, ed)); assert(compareOutput("This number 12", `This $r:.*$ 12`, ed)); assert(!compareOutput("This number 12 is 24", `This $r:\d*$ 12`, ed)); assert(compareOutput("This number 12 is 24", `This $r:.*$ 12 is $n$`, ed)); string msg = collectExceptionMsg(compareOutput("12345", `$r:\d*$$n$`, ed)); assert(msg == "Another sequence following $r:...$ is not supported!"); } /++ Creates a diff of the expected and actual test output. Params: expected = the expected output expectedFile = file containing expected (if present, null otherwise) actual = the actual output name = the test files name Returns: the comparison created by the `diff` utility ++/ string generateDiff(const string expected, string expectedFile, const string actual, const string name) { string actualFile = tempDir.buildPath("actual_" ~ name); File(actualFile, "w").writeln(actual); // Append \n scope (exit) tryRemove(actualFile); const needTmp = !expectedFile; if (needTmp) // Create a temporary file { expectedFile = tempDir.buildPath("expected_" ~ name); File(expectedFile, "w").writeln(expected); // Append \n } // Remove temporary file scope (exit) if (needTmp) tryRemove(expectedFile); const cmd = ["diff", "-up", "--strip-trailing-cr", expectedFile, actualFile]; try { string diff = std.process.execute(cmd).output; // Skip diff's status lines listing the diffed files and line count foreach (_; 0..3) diff = diff.findSplitAfter("\n")[1]; return diff; } catch (Exception e) return format(`%-(%s, %) failed: %s`, cmd, e.msg); } /** * Exception thrown to abort the test without further error messages * (they were either already printed or suppressed due to the environment) */ class SilentQuit : Exception { this() { super(null); } } /** * Exception thrown when the actual output doesn't match the expected * `TEST_OUTPUT`/`RUN_OUTPUT.` */ class CompareException : Exception { string expected; /// expected output string actual; /// actual output bool fromRun; /// Compared execution instead of compilation output string diff; /// diff between expected and actual output this(string expected, string actual, string diff, bool fromRun = false) { string msg = "\nexpected:\n----\n" ~ expected ~ "\n----\nactual:\n----\n" ~ actual ~ "\n----\ndiff:\n----\n" ~ diff ~ "----\n"; super(msg); this.expected = expected; this.actual = actual; this.fromRun = fromRun; this.diff = diff; } } /// Return code indicating that the test should be restarted. /// Issued when an OUTPUT section was changed due to AUTO_UPDATE=1. enum RERUN_TEST = 2; version(unittest) void main(){} else int main(string[] args) { try { // Test may be run multiple times with AUTO_UPDATE=1 because updates // to output sections may change line numbers. // Set a hard limit to avoid infinite loops in fringe cases foreach (_; 0 .. 10) { const res = tryMain(args); if (res == RERUN_TEST) writeln("==> Restarting test to verify new output section(s)...\n"); else return res; } // Should never happen, but just to be sure writeln("Output sections changed too many times, please update manually."); return RERUN_TEST; } catch(SilentQuit) { return 1; } } int tryMain(string[] args) { if (args.length != 2) { usage(); return 1; } immutable envData = processEnvironment(); const input_file = args[1]; const input_dir = input_file.dirName(); const test_base_name = input_file.baseName(); const test_name = test_base_name.stripExtension(); const test_ext = test_base_name.extension(); // Previously we did not take into account the test file extension, // because of ImportC we now have the ability to have conflicting source file basenames (when ignoring extension). // This can cause a race condition with the concurrent test runner, // in which whilst one test is running another will try to clobber it and fail. // Unfortunately dshell does not take into account our output directory, // at least not in a way that'll allow us to take advantage of the test extension. // However since its not really an issue for clobbering, we'll ignore it. version (LDC_MSVC) { const result_path = (envData.results_dir ~ envData.sep).replace("/", `\`); } else { const result_path = envData.results_dir ~ envData.sep; } const output_dir_base = result_path ~ input_dir; const output_dir = (input_dir == "dshell" ? output_dir_base : (output_dir_base ~ envData.sep ~ test_ext[1 .. $])); const output_file = result_path ~ input_file ~ ".out"; // We are potentially creating a test extension specific directory mkdirRecurse(output_dir); version (LDC) { if (test_base_name.startsWith("gdb") && environment.get("GDB_FLAGS") == "OFF") { writefln(" ... %-30s [DISABLED due to GDB_FLAGS=OFF]", input_file); return 0; } } TestArgs testArgs; switch (input_dir) { case "compilable": testArgs.mode = TestMode.COMPILE; break; case "fail_compilation": testArgs.mode = TestMode.FAIL_COMPILE; break; case "runnable", "runnable_cxx": // running & linking costs time - for coverage builds we can save this testArgs.mode = envData.coverage_build ? TestMode.COMPILE : TestMode.RUN; break; case "dshell": testArgs.mode = TestMode.DSHELL; return runDShellTest(input_dir, test_name, envData, output_dir, output_file); default: writefln("Error: invalid test directory '%s', expected 'compilable', 'fail_compilation', 'runnable', 'runnable_cxx' or 'dshell'", input_dir); return 1; } if (test_ext == ".sh") { string file = cast(string) std.file.read(input_file); string disabledPlatforms; if (findTestParameter(envData, file, "DISABLED", disabledPlatforms)) { const reason = getDisabledReason(split(disabledPlatforms), envData); if (reason.length != 0) { writefln(" ... %-30s [DISABLED %s]", input_file, reason); return 0; } } version (linux) { if (file.canFind("GDB_SCRIPT")) { return runGDBTestWithLock(envData, () { return runBashTest(input_dir, test_name, envData); }); } } return runBashTest(input_dir, test_name, envData); } // envData.sep is required as the results_dir path can be `generated` const absoluteResultDirPath = envData.results_dir.absolutePath ~ envData.sep; const resultsDirReplacement = "{{RESULTS_DIR}}" ~ envData.sep; const test_app_dmd_base = output_dir ~ envData.sep ~ test_name ~ "_"; auto stopWatch = StopWatch(AutoStart.no); if (envData.printRuntime) stopWatch.start(); if (!gatherTestParameters(testArgs, input_dir, input_file, envData)) return 0; // Clear the DFLAGS environment variable if it was specified in the test file if (testArgs.clearDflags) environment["DFLAGS"] = ""; writef(" ... %-30s %s%s(%s)", input_file, testArgs.requiredArgs, (!testArgs.requiredArgs.empty ? " " : ""), testArgs.permuteArgs); if (testArgs.isDisabled) { writef("!!! [DISABLED %s]", testArgs.disabledReason); if (!envData.tryDisabled) { writeln(); return 0; } } auto f = File(output_file, "w"); if ( //prepare cpp extra sources !collectExtraSources(input_dir, output_dir, testArgs.cppSources, testArgs.sources, envData, envData.ccompiler, envData.cxxcompiler, testArgs.cxxflags, f) || //prepare objc extra sources !collectExtraSources(input_dir, output_dir, testArgs.objcSources, testArgs.sources, envData, "clang", "clang++", null, f, /*LDC, objC=*/true) ) { writeln(); // Ignore failed test if (testArgs.isDisabled) return 0; printTestFailure(input_file, f); return 1; } enum Result { continue_, return0, return1, returnRerun } // Runs the test with a specific combination of arguments Result testCombination(bool autoCompileImports, string argSet, size_t permuteIndex, string permutedArgs) { string test_app_dmd = test_app_dmd_base ~ to!string(permuteIndex) ~ envData.exe; string command; // copy of the last executed command so that it can be re-invoked on failures try { string[] toCleanup; auto thisRunName = output_file ~ to!string(permuteIndex); auto fThisRun = File(thisRunName, "w"); scope(exit) { fThisRun.close(); f.write(readText(thisRunName)); f.writeln(); tryRemove(thisRunName); // Never reached unless file is present } string compile_output; if (!testArgs.compileSeparately) { version (LDC) { /** * HACK: Some tests use -lib. For a relative output_dir, it is required to * pass -of= for the static library to end up in * the output_dir specified via -od, as (L)DMD treats relative -of paths * for static libs (and static libs only!) as relative to the -od dir. * * E.g., `ldmd2 -lib -od=../obj -of=../obj/mylib.a` generates * `../obj/../obj/mylib.a` => change to `ldmd2 -lib -od=../obj -of=mylib.a`. */ string fixupOf(string of) { return (" " ~ testArgs.requiredArgs ~ " ").canFind(" -lib ") ? baseName(of) : of; } } string objfile = output_dir ~ envData.sep ~ test_name ~ "_" ~ to!string(permuteIndex) ~ envData.obj; toCleanup ~= objfile; command = format("%s -conf= -m%s -I%s %s %s -od%s -of%s %s %s%s %s", envData.dmd, envData.model, input_dir, testArgs.requiredArgs, permutedArgs, output_dir, fixupOf(testArgs.mode == TestMode.RUN || testArgs.link ? test_app_dmd : objfile), argSet, (testArgs.mode == TestMode.RUN || testArgs.link ? "" : "-c "), join(testArgs.sources, " "), (autoCompileImports ? "-i" : join(testArgs.compiledImports, " "))); try compile_output = execute(fThisRun, command, testArgs.mode == TestMode.FAIL_COMPILE); catch (Exception e) { writeln(""); // We're at "... runnable/xxxx.d (args)" printCppSources(testArgs.sources); throw e; } } else { foreach (filename; testArgs.sources ~ (autoCompileImports ? null : testArgs.compiledImports)) { string newo = output_dir ~ envData.sep ~ filename.baseName().setExtension(envData.obj); toCleanup ~= newo; command = format("%s -conf= -m%s -I%s %s %s -od%s -c %s %s", envData.dmd, envData.model, input_dir, testArgs.requiredArgs, permutedArgs, output_dir, argSet, filename); compile_output ~= execute(fThisRun, command, testArgs.mode == TestMode.FAIL_COMPILE); } if (testArgs.mode == TestMode.RUN || testArgs.link) { // link .o's into an executable command = format("%s -conf= -m%s%s%s %s %s -od%s -of%s %s", envData.dmd, envData.model, autoCompileImports ? " -i" : "", autoCompileImports ? "extraSourceIncludePaths" : "", envData.required_args, testArgs.requiredArgsForLink, output_dir, test_app_dmd, join(toCleanup, " ")); execute(fThisRun, command, testArgs.runReturn); } } void prepare(ref string compile_output) { if (compile_output.empty) return; compile_output = compile_output.unifyNewLine(); compile_output = std.regex.replaceAll(compile_output, regex(`^DMD v2\.[0-9]+.*\n? DEBUG$`, "m"), ""); compile_output = std.string.strip(compile_output); // replace test_result path with fixed ones compile_output = compile_output.replace(result_path, resultsDirReplacement); compile_output = compile_output.replace(absoluteResultDirPath, resultsDirReplacement); compile_output.applyOutputTransformations(testArgs.transformOutput); } prepare(compile_output); auto m = std.regex.match(compile_output, `Internal error: .*$`); enforce(!m, m.hit); m = std.regex.match(compile_output, `core.exception.AssertError@dmd.*`); enforce(!m, m.hit); // Prepare and append the content of each OUTPUT_FILE conforming to // the HAR (https://code.dlang.org/packages/har) format, e.g. // === // // === // // ... foreach (const outfile; testArgs.outputFiles) { string path = outfile; replaceResultsDir(path, envData); // Don't abort if a file is missing, at least verify the remaining output. string content = readText(path).ifThrown("<< File missing >>"); prepare(content); // Make sure file starts on a new line if (!compile_output.empty && !compile_output.endsWith("\n")) compile_output ~= '\n'; // Prepend a header listing the explicit file compile_output.reserve(outfile.length + content.length + 5); compile_output ~= "=== "; compile_output ~= outfile; compile_output ~= '\n'; compile_output ~= content; } if (!compareOutput(compile_output, testArgs.compileOutput, envData)) { const diff = generateDiff(testArgs.compileOutput, testArgs.compileOutputFile, compile_output, test_base_name); throw new CompareException(testArgs.compileOutput, compile_output, diff); } if (testArgs.mode == TestMode.RUN) { toCleanup ~= test_app_dmd; version(Windows) { toCleanup ~= test_app_dmd_base ~ to!string(permuteIndex) ~ ".ilk"; toCleanup ~= test_app_dmd_base ~ to!string(permuteIndex) ~ ".pdb"; } if (testArgs.gdbScript is null) { command = test_app_dmd; if (testArgs.executeArgs) command ~= " " ~ testArgs.executeArgs; string output = execute(fThisRun, command, testArgs.runReturn) .strip() .unifyNewLine(); output.applyOutputTransformations(testArgs.transformOutput); if (testArgs.runOutput && !compareOutput(output, testArgs.runOutput, envData)) { const diff = generateDiff(testArgs.runOutput, null, output, test_base_name); throw new CompareException(testArgs.runOutput, output, diff, true); } } else version (linux) { runGDBTestWithLock(envData, () { auto script = test_app_dmd_base ~ to!string(permuteIndex) ~ ".gdb"; toCleanup ~= script; with (File(script, "w")) { writeln("set disable-randomization off"); write(testArgs.gdbScript); } string gdbCommand = "gdb "~test_app_dmd~" --batch -x "~script; auto gdb_output = execute(fThisRun, gdbCommand, 0); if (testArgs.gdbMatch !is null) { enforce(match(gdb_output, regex(testArgs.gdbMatch)), "\nGDB regex: '"~testArgs.gdbMatch~"' didn't match output:\n----\n"~gdb_output~"\n----\n"); } return 0; }); } } fThisRun.close(); if (testArgs.postScript && !envData.coverage_build) { f.write("Executing post-test script: "); string prefix = ""; version (Windows) prefix = "bash "; execute(f, prefix ~ "tools/postscript.sh " ~ testArgs.postScript ~ " " ~ input_dir ~ " " ~ test_name ~ " " ~ thisRunName, 0); } foreach (file; chain(toCleanup, testArgs.outputFiles)) tryRemove(file); return Result.continue_; } catch(Exception e) { // it failed but it was disabled, exit as if it was successful if (testArgs.isDisabled) { writeln(); return Result.return0; } if (envData.autoUpdate) if (auto ce = cast(CompareException) e) { // remove the output file in test_results as its outdated // (might fail for runnable tests on Windows) if (output_file.remove().collectException()) writef("\nWARNING: Failed to remove `%s`!", output_file); // Don't overwrite TEST_OUTPUT sections which contain special // sequences because they must be manually adapted if (testArgs.compileOutput.canFind(specialSequences)) { writefln("\nWARNING: %s uses special sequences in `TEST_OUTPUT` blocks and can't be auto-updated", input_file); return Result.return0; } if (testArgs.compileOutputFile && !ce.fromRun) { std.file.write(testArgs.compileOutputFile, ce.actual); writefln("\n==> `TEST_OUTPUT_FILE` `%s` has been updated", testArgs.compileOutputFile); return Result.returnRerun; } auto existingText = input_file.readText; auto updatedText = existingText.replace(ce.expected, ce.actual); const type = ce.fromRun ? `RUN`: `TEST`; if (existingText != updatedText) { std.file.write(input_file, updatedText); writefln("\n==> `%s_OUTPUT` of %s has been updated", type, input_file); return Result.returnRerun; } else { try { string diffUpdatedText = replaceFromDiff(existingText, ce.diff); std.file.write(input_file, diffUpdatedText); writefln("\n==> `%s_OUTPUT` of %s has been updated by applying a diff", type, input_file); return Result.returnRerun; } catch (Exception e) { writefln("\nERROR: Couldn't update `%s_OUTPUT` blocks of %s through the diff: \"%s\" Please update the file manually to make the tests pass.", type, input_file, e.msg); } return Result.return0; } } const outputText = printTestFailure(input_file, f, e.msg); // auto-update if a diff is found and can be updated if (envData.autoUpdate && outputText.canFind("diff ") && outputText.canFind("--- ") && outputText.canFind("+++ ")) { import std.range : dropOne; auto newFile = outputText.findSplitAfter("+++ ")[1].until("\t"); auto baseFile = outputText.findSplitAfter("--- ")[1].until("\t"); writefln("===> Updating %s with %s", baseFile, newFile); newFile.copy(baseFile); return Result.return0; } // automatically rerun a segfaulting test and print its stack trace version(linux) if (e.msg.canFind("exited with rc == 139")) { auto gdbCommand = "gdb -q -n -ex 'set backtrace limit 100' -ex run -ex bt -batch -args " ~ command; runGDBTestWithLock(envData, () => spawnShell(gdbCommand).wait); } return Result.return1; } } size_t index = 0; // index over all tests to avoid identical output names in consecutive tests auto argSets = (testArgs.argSets.length == 0) ? [""] : testArgs.argSets; for(auto autoCompileImports = false;; autoCompileImports = true) { foreach(argSet; argSets) { foreach (c; combinations(testArgs.permuteArgs)) { final switch(testCombination(autoCompileImports, argSet, index, c)) { case Result.continue_: break; case Result.return0: return 0; case Result.return1: return 1; case Result.returnRerun: return RERUN_TEST; } index++; } } if(autoCompileImports || testArgs.compiledImports.length == 0) break; } if (envData.printRuntime) { const long ms = stopWatch.peek.total!"msecs"; writefln(" [%.3f secs]", ms / 1000.0); } else writeln(); // it was disabled but it passed! print an informational message if (testArgs.isDisabled) writefln(" !!! %-30s DISABLED but PASSES!", input_file); return 0; } // Replace consecutive ---+++ diff lines with intertwined lines -+-+-+, which helps putting // additions in the right TEST_OUTPUT block. Otherwise, sometimes all but the last TEST_OUTPUT blocks // are emptied and the last TEST_OUTPUT block will be filled will all updated output. string intertwineDiff(string diff) { static if (__VERSION__ < 2097) { // `splitWhen` didn't exist, but the bootstrap compiler test doesn't need AUTO_UPDATE return diff; } else { // First, split diff lines into groups of deletions (-), additions (+), or other (@, ' ') auto editGroups = diff.splitter('\n').chunkBy!((a, b) => a.takeOne.equal(b.takeOne)).map!array; // Then split before every deletion (-) group auto deletionGroups = editGroups.splitWhen!((a, b) => b.front.startsWith("-")).map!array; // Then, if we have a deletion group followed by an addition group, roundRobin the first two editGroups, and append the rest // Otherwise, just join all editGroups to keep the original order return deletionGroups.map!(g => choose( g.length > 1 && g[0].front.startsWith("-") && g[1].front.startsWith("+"), g.length > 1 ? chain(roundRobin(g[0], g[1]), g[2 .. $].join).array : g.join.array, g.join )).join.join("\n"); } } unittest { string input = "@@@ -A0 -B1 +E2 +F3 +H4 -32 +33 +34 35 36 -C5"; string expected = "@@@ -A0 +E2 -B1 +F3 +H4 -32 +33 +34 35 36 -C5"; assert(intertwineDiff("") == ""); static if (__VERSION__ >= 2097) assert(intertwineDiff(input) == expected); } /// Given test file with contents `input` and diff file with the diff of actual TEST_OUTPUT vs expected TEST_OUTPUT, /// return new contents of the test file with updated TEST_OUTPUT blocks. Throws an Exception if the diff couldn't be /// matched against the input. string replaceFromDiff(string input, string diff) { const string[] lines = input.splitLines; string result = ""; size_t i = 0; foreach (diffLine; intertwineDiff(diff).splitLines) { const bool deletion = diffLine.skipOver("-"); const bool seek = deletion || diffLine.skipOver(" "); if (seek) { while (i < lines.length && lines[i] != diffLine) { result ~= lines[i] ~ "\n"; i++; } if (i >= lines.length) throw new Exception("Can't find diff line \"" ~ diffLine ~ "\" in the text to update"); if (!deletion) result ~= lines[i] ~ "\n"; i++; } else if (diffLine.skipOver("+")) { result ~= diffLine ~ "\n"; continue; } else if (diffLine.skipOver("@")) { continue; } else { throw new Exception("Unrecognized first character in diff line: \"" ~ diffLine ~ "\""); } } while (i < lines.length) { result ~= lines[i] ~ "\n"; i++; } return result; } unittest { string input = " TEST_OUTPUT: --- Error: dummy --- TEST_OUTPUT: --- Error: something else Deprecation: dummy --- "; string diff = "-Error: dummy -Error: something else +Error: dummies @@@ ... Deprecation: dummy +Deprecation: another "; string expected = " TEST_OUTPUT: --- Error: dummies --- TEST_OUTPUT: --- Deprecation: dummy Deprecation: another --- "; string result = replaceFromDiff(input, diff); static if (__VERSION__ >= 2097) assert(result == expected); try { replaceFromDiff(input, "-Nonexistend line"); assert(0); } catch (Exception e) { assert(e.msg == `Can't find diff line "Nonexistend line" in the text to update`); } } /** * Executes a bash script (deprecated in favour of `dshell` tests). * * Params: * input_dir = test directory (e.g. `runnable`) * test_name = script filename * envData = environment configuration * * Returns: the script's exit code */ int runBashTest(string input_dir, string test_name, const ref EnvData envData) { enum script = "tools/sh_do_test.sh"; version(Windows) { const cmd = "bash " ~ script ~ ' ' ~ input_dir ~ ' ' ~ test_name; const env = [ // Make sure the path is bash-friendly "DMD": envData.dmd.relativePath(dmdTestDir).replace("\\", "/") ]; auto process = spawnShell(cmd, env, Config.none, dmdTestDir); } else { const scriptPath = dmdTestDir.buildPath(script); auto process = spawnProcess([scriptPath, input_dir, test_name]); } return process.wait(); } /** * Executes `fun` mutually exclusive to other instances of `d_do_test` * using the lockfile `$RESULTS_DIR/gdb.lock`. * * Params: * envData = environment configuration * fun = task to execute * * Returns: the return value of `fun` */ int runGDBTestWithLock(const ref EnvData envData, int delegate() fun) { // Tests failed on SemaphoreCI when multiple GDB tests were run at once scope lockfile = File(envData.results_dir.buildPath("gdb.lock"), "w"); lockfile.lock(); scope (exit) lockfile.unlock(); return fun(); } /** * Executes a `dshell` test. * * Params: * input_dir = test directory (e.g. `runnable`) * test_name = script filename * envData = environment configuration * output_dir = directory for intermediate files (usually `${RESULTS_DIR}/dshell`) * output_file = logfile path * * Returns: the script's exit code (or dmd's exit code upon compilation failure) */ int runDShellTest(string input_dir, string test_name, const ref EnvData envData, string output_dir, string output_file) { const testScriptDir = buildPath(dmdTestDir, input_dir); const testScriptPath = buildPath(testScriptDir, test_name ~ ".d"); const testOutDir = buildPath(output_dir, test_name); const testLogName = format("%s/%s.d", input_dir, test_name); writefln(" ... %s", testLogName); if (exists(testOutDir)) rmdirRecurse(testOutDir); mkdirRecurse(testOutDir); // create the "dshell" module for the tests { auto dshellFile = File(buildPath(testOutDir, "dshell.d"), "w"); dshellFile.writeln(`module dshell; public import dshell_prebuilt; static this() { dshellPrebuiltInit("` ~ input_dir ~ `", "`, test_name , `"); } `); } const testScriptExe = buildPath(testOutDir, "run" ~ envData.exe); auto outfile = File(output_file, "w"); enum keepFilesOpen = Config.retainStdout | Config.retainStderr; // // compile the test // { const compile = [envData.dmd, "-conf=", "-m"~envData.model] ~ envData.picFlag ~ [ "-od" ~ testOutDir, "-of" ~ testScriptExe, "-I=" ~ testScriptDir, "-I=" ~ testOutDir, "-I=" ~ buildPath(dmdTestDir, "tools", "dshell_prebuilt"), "-i", // Causing linker errors for some reason? "-i=-dshell_prebuilt", buildPath(envData.results_dir, "dshell_prebuilt" ~ envData.obj), testScriptPath, ]; outfile.writeln("[COMPILE_TEST] ", escapeShellCommand(compile)); outfile.flush(); // Note that spawnprocess closes the file, so it will need to be re-opened // below when we run the test auto compileProc = std.process.spawnProcess(compile, stdin, outfile, outfile, null, keepFilesOpen); const exitCode = wait(compileProc); if (exitCode != 0) { printTestFailure(testLogName, outfile); return exitCode; } } // // run the test // { const runTest = [testScriptExe]; outfile.writeln("\n[RUN_TEST] ", escapeShellCommand(runTest)); outfile.flush(); // LDC: propagate C(++) compiler from envData as CC/CXX env var (required by cpp_header_gen test) version (LDC) const string[string] runEnv = ["CC": envData.ccompiler, "CXX": envData.cxxcompiler]; else const string[string] runEnv = null; auto runTestProc = std.process.spawnProcess(runTest, stdin, outfile, outfile, runEnv, keepFilesOpen); const exitCode = wait(runTestProc); if (exitCode == 125) // = DISABLED from tools/dshell_prebuilt.d { writefln(" !!! %s is disabled!", testLogName); return 0; } else if (exitCode != 0) { printTestFailure(testLogName, outfile); return exitCode; } } return 0; } /** * Prints the summary of a test failure to stdout and removes the logfile. * * Params: * testLogName = name of the test * outfile = the logfile * extra = supplemental error message * Returns: the content of outfile **/ string printTestFailure(string testLogName, scope ref File outfile, string extra = null) { const output_file_temp = outfile.name; outfile.close(); writeln("=============================="); writefln("Test '%s' failed. The logged output:", testLogName); const output = readText(output_file_temp); write(output); if (!output.endsWith("\n")) writeln(); writeln("=============================="); if (extra) writefln("Test '%s' failed: %s\n", testLogName, extra); tryRemove(output_file_temp); return output; } /** * Print symbols in C++ objects * * If linking failed, we print the symbols present in the C++ object file being * linked it. This is so that C++ `runnable` tests are easier to debug, * as the CI machines can have different environment than the users, * and it is generally painful to work with them when trying to support * newer (C++11, C++14, C++17, etc...) features. */ void printCppSources (in const(char)[][] compiled) { version (Posix) { foreach (file; compiled) { if (!file.endsWith(".cpp.o")) continue; writeln("========== Symbols for C++ object file: ", file, " =========="); std.process.spawnProcess(["nm", file]).wait(); } } } ./ldc-1.42.0-src/tests/dmd/tools/sanitize_timetrace.d0000644000175000017500000000147515205374122021312 0ustar fabiofabio/** The output of -ftime-trace is not deterministic because it contains timer data, and it's also full of implementation details (such as the order of semantic analysis). In order to test the output, this program extracts only 'name' and 'details' strings of events, and sorts them, so the output can be tested. */ module sanitize_timetrace; import std.algorithm; import std.array; import std.conv; import std.json; import std.range; import std.string; void sanitizeTimeTrace(ref string testOutput) { parseJSON(testOutput); auto json = parseJSON(testOutput); string result = json["traceEvents"].array .filter!(x => x["ph"].str == "X") .map!(x => strip(x["name"].str ~ ", " ~ x["args"]["detail"].str)) .array .sort .uniq .joiner("\n").text; testOutput = result; } ./ldc-1.42.0-src/tests/dmd/tools/paths.d0000644000175000017500000000633315205374122016544 0ustar fabiofabiomodule tools.paths; import std.file : exists; import std.path : buildNormalizedPath, buildPath, dirName, setExtension; import std.process : environment; version (LDC) version = IN_LLVM; version (Posix) enum exeExtension = ""; else version (Windows) enum exeExtension = ".exe"; version (Windows) enum os = "windows"; else version (OSX) enum os = "osx"; else version (linux) enum os = "linux"; else version (FreeBSD) enum os = "freebsd"; else version (OpenBSD) enum os = "openbsd"; else version (NetBSD) enum os = "netbsd"; else version (DragonFlyBSD) enum os = "dragonflybsd"; else version (Solaris) enum os = "solaris"; else version (SunOS) enum os = "solaris"; else static assert(0, "Unrecognized or unsupported OS."); version (IN_LLVM) { enum dmdTestsuitePath = __FILE_FULL_PATH__.dirName.dirName; // LDC repo root enum compilerRootDir = dmdTestsuitePath.dirName.dirName; alias testPath = path => dmdTestsuitePath.buildPath(path); } else { enum projectRootDir = __FILE_FULL_PATH__.dirName.buildNormalizedPath("..", "..", ".."); enum generatedDir = projectRootDir.buildPath("generated"); enum dmdFilename = "dmd".setExtension(exeExtension); enum compilerRootDir = __FILE_FULL_PATH__.dirName.buildNormalizedPath("..", ".."); alias testPath = path => compilerRootDir.buildPath("test", path); } string build() { static string build; return build = build ? build : environment.get("BUILD", "release"); } version (IN_LLVM) { string model() { static string model; version (D_LP64) enum def = "64"; else enum def = "32"; return model ? model : (model = environment.get("MODEL", def)); } string dmdPath() { static string dmdPath; return dmdPath ? dmdPath : (dmdPath = environment.get("DMD", "ldmd2")); } } else { string buildOutputPath() { static string buildOutputPath; return buildOutputPath ? buildOutputPath : (buildOutputPath = generatedDir.buildPath(os, build, dmdModel)); } // auto-tester might run the test suite with a different $(MODEL) than DMD // has been compiled with. Hence we manually check which binary exists. string dmdModel() { static string dmdModel; if (dmdModel) return dmdModel; const prefix = generatedDir.buildPath(os, build); return dmdModel = environment.get("DMD_MODEL", prefix.buildPath("64", dmdFilename).exists ? "64" : "32"); } string model() { static string model; return model ? model : (model = environment.get("MODEL", dmdModel)); } string dmdPath() { static string dmdPath; return dmdPath ? dmdPath : (dmdPath = buildOutputPath.buildPath(dmdFilename)); } } // !IN_LLVM string resultsDir() { static string resultsDir; enum def = testPath("test_results"); return resultsDir ? resultsDir : (resultsDir = environment.get("RESULTS_DIR", def)); } /// Returns: a path to 'target' relative to `base` using POSIX file separators version (Windows) string relativePosixPath(const string target, const string base) pure @safe { import std.array : join; import std.path : relativePath, pathSplitter; return target.relativePath(base) .pathSplitter() .join('/'); } ./ldc-1.42.0-src/tests/dmd/tools/README.md0000644000175000017500000000370315205374122016535 0ustar fabiofabio# Tools These files implement tools and utilities used by the test suite. | File | Purpose | |--------------------------------------------|-------------------------------------------------------------------------------------------------| | [`d_do_test.d`](d_do_test.d) | Test runner for all non-`unit` tests | | [`dshell_prebuilt.d`](dshell_prebuilt.d) | Common utilities for `dshell` tests | | [`paths.d`](paths.d) | Definitions for [common environment variables](../README.md#environment-variables) (e.g. `DMD`) | | [`sanitize_json.d`](sanitize_json.d) | Remove platform-specific information from dmd's JSON output (`-X`) | | [`unit_test_runner.d`](unit_test_runner.d) | Test runner for `unit` tests | --- The following files are deprecated and will be removed in the future. | File | Purpose | |--------------------------------------------|-------------------------------------------------------------------------------------------------| | `sh_do_test.sh` | Old test runner, superseded by `d_do_test.d` | | `postscript.sh` | Setup before running bash scripts defined as `POSTSCRIPT` | | `common_funcs.sh` | Common functions for shell scripts | --- Refer to [test/README.md](../README.md) for more general information on the test suite. ./ldc-1.42.0-src/tests/dmd/tools/unit_test_runner.d0000755000175000017500000002412515205374122021036 0ustar fabiofabio#!/usr/bin/env rdmd module unit_test_runner; import std.algorithm : filter, map, joiner, substitute; import std.array : array, join; import std.conv : to; import std.exception : enforce; import std.file : dirEntries, exists, SpanMode, mkdirRecurse, write; import std.format : format; import std.getopt : getopt; import std.path : absolutePath, buildPath, dirSeparator, relativePath, stripExtension, setExtension; import std.process : Config, environment, execute; import std.range : empty, chain; import std.stdio; import std.string : join, outdent; import tools.paths; enum unitTestDir = testPath("unit"); string[] testFiles(Range)(Range givenFiles) { if (!givenFiles.empty) return givenFiles.map!(testPath).array; return unitTestDir .dirEntries("*.d", SpanMode.depth) .map!(e => e.name) .array; } auto moduleNames(const string[] testFiles) { return testFiles .map!(e => e[unitTestDir.length + 1 .. $]) .map!stripExtension .array .map!(e => e.substitute(dirSeparator, ".")); } void writeRunnerFile(Range)(Range moduleNames, string path, string filter) { enum codeTemplate = q{ import core.runtime : Runtime, UnitTestResult; import std.meta : AliasSeq; // modules to unit test starts here: %s alias modules = AliasSeq!( %s ); enum filter = %s; version(unittest) shared static this() { Runtime.extendedModuleUnitTester = &unitTestRunner; } UnitTestResult unitTestRunner() { import std.algorithm : any, canFind, each, map; import std.array : array; import std.conv : text; import std.format : format; import std.meta : Alias; import std.range : chain, empty, enumerate, only, repeat; import std.stdio : writeln, writefln, stderr, stdout; import std.string : join; import std.traits : hasUDA, isCallable; static import support; alias TestCallback = void function(); struct Test { Throwable throwable; string[] descriptions; string toString(size_t i) { const descs = descriptions; const index = text(i + 1) ~ ") "; enum fmt = "%%s%%s\n%%s"; if (descs.length < 2) return format!fmt(index, descriptions.join(""), throwable); auto trailing = descs[1 .. $] .map!(e => ' '.repeat(index.length).array ~ e); const description = descriptions[0] .only .chain(trailing) .join("\n"); return format!fmt(index, description, throwable); } string fileInfo() { with (throwable) return format!"%%s:%%s"(file, line); } } Test[] failedTests; size_t testCount; void printReport() { if (!failedTests.empty) { alias formatTest = t => t.value.toString(t.index); const failedTestsMessage = failedTests .enumerate .map!(formatTest) .join("\n\n"); stderr.writefln!"Failures:\n\n%%s\n"(failedTestsMessage); } auto output = failedTests.empty ? stdout : stderr; output.writefln!"%%s tests, %%s failures"(testCount, failedTests.length); if (failedTests.empty) return; stderr.writefln!"\nFailed tests:\n%%s"( failedTests.map!(t => t.fileInfo).join("\n")); } TestCallback[] getTestCallbacks(alias module_, alias uda)() { enum isMemberAccessible(string memberName) = is(typeof(__traits(getMember, module_, memberName))); TestCallback[] callbacks; static foreach(mem ; __traits(allMembers, module_)) { static if (isMemberAccessible!(mem)) {{ alias member = __traits(getMember, module_, mem); static if (isCallable!member && hasUDA!(member, uda)) callbacks ~= &member; }} } return callbacks; } void executeCallbacks(const TestCallback[] callbacks) { callbacks.each!(c => c()); } static foreach (module_ ; modules) { foreach (unitTest ; __traits(getUnitTests, module_)) { enum attributes = [__traits(getAttributes, unitTest)]; const beforeEachCallbacks = getTestCallbacks!(module_, support.beforeEach); const afterEachCallbacks = getTestCallbacks!(module_, support.afterEach); Test test; try { static if (!attributes.empty) { test.descriptions = attributes; if (attributes.any!(a => a.canFind(filter))) { testCount++; executeCallbacks(beforeEachCallbacks); unitTest(); } } else static if (filter.length == 0) { testCount++; executeCallbacks(beforeEachCallbacks); unitTest(); } } catch (Throwable t) { test.throwable = t; failedTests ~= test; } finally executeCallbacks(afterEachCallbacks); } } printReport(); UnitTestResult result = { runMain: false, executed: testCount, passed: testCount - failedTests.length }; return result; } version (D_Coverage) shared static this() { import core.runtime; static immutable sourcePath = `%s`; dmd_coverSourcePath(sourcePath); dmd_coverDestPath(sourcePath); dmd_coverSetMerge(true); } }.outdent; const imports = moduleNames .map!(e => format!"static import %s;"(e)) .joiner("\n") .to!string; const modules = moduleNames .map!(e => format!"%s"(e)) .joiner(",\n") .to!string; const content = format!codeTemplate(imports, modules, format!`"%s"`(filter), compilerRootDir); write(path, content); } /** Returns the arguments for the compiler invocation. Params: runnerPath = the path of the unit test runner file outputted by `writeRunnerFile` outputPath = the path where to place the compiled binary testFiles = the test files to compile */ string[] buildCmdArgs(string runnerPath, string outputPath, const string[] testFiles) { auto flags = chain([ "-version=NoBackend", "-version=GC", "-version=NoMain", "-version=MARS", "-version=DMDLIB", "-g", "-unittest", // LDC: no `"-J" ~ buildOutputPath,` "-J" ~ compilerRootDir.buildPath("dmd/res"), // LDC: was `"-Jsrc/dmd/res",` "-I" ~ compilerRootDir, // LDC: was `"-Isrc",` "-I" ~ unitTestDir, "-i", "-main", "-of" ~ outputPath, "-m" ~ model ], testFiles.map!(f => relativePath(f, compilerRootDir)), [ runnerPath ] ).array; // Generate coverage reports if requested if (environment.get("DMD_TEST_COVERAGE", "0") == "1") flags ~= "-cov"; return flags; } /** Returns `true` if any of the given files don't exist. Also prints an error message. */ bool missingTestFiles(Range)(Range givenFiles) { const nonExistingTestFiles = givenFiles .filter!(file => !file.exists) .join("\n"); if (!nonExistingTestFiles.empty) { stderr.writefln("The following test files don't exist:\n\n%s", nonExistingTestFiles); return true; } return false; } int main(string[] args) { string unitTestFilter; getopt(args, "filter|f", &unitTestFilter); auto givenFiles = args[1 .. $].map!absolutePath; if (missingTestFiles(givenFiles)) return 1; const absResultsDir = resultsDir.absolutePath(); const runnerPath = absResultsDir.buildPath("runner.d"); const testFiles = givenFiles.testFiles; mkdirRecurse(resultsDir); testFiles .moduleNames .writeRunnerFile(runnerPath, unitTestFilter); const cmdfilePath = absResultsDir.buildPath("cmdfile"); const outputPath = absResultsDir.buildPath("runner" ~ exeExtension); const flags = buildCmdArgs(runnerPath, outputPath, testFiles); write(cmdfilePath, flags.join("\n")); const dmd = execute([ dmdPath, "@" ~ cmdfilePath ], null, Config.none, size_t.max, compilerRootDir); if (dmd.status) { enum msg = "Failed to compile the `unit` test executable! (exit code %d) > %-(%s %) %s"; // Build the string in advance to avoid cluttering writeln(format(msg, dmd.status, dmdPath ~ flags, dmd.output)); return 1; } const test = execute(outputPath); if (test.status) { enum msg = "Failed to execute the `unit` test executable! (exit code %d) > %-(%s %) %s > %s %s"; // Build the string in advance to avoid cluttering writeln(format(msg, test.status, dmdPath ~ flags, dmd.output, outputPath, test.output)); return 1; } return 0; } ./ldc-1.42.0-src/tests/dmd/tools/common_funcs.sh0000644000175000017500000000052515205374122020277 0ustar fabiofabio# rm with retry # Useful to workaround a race condition on windows when removing executables # that were just running. function rm_retry { local attempt=1 for true; do rm -f $@ && break if [ $attempt -ge 4 ]; then return 1 fi let attempt=attempt+=1 sleep 1 done return 0 } ./ldc-1.42.0-src/tests/dmd/tools/exported_vars.sh0000644000175000017500000000247215205374122020501 0ustar fabiofabio# Common bash variables exported to the bash script and bash post script of DMD's testsuite if [ "${RESULTS_DIR+x}" == "" ]; then VARS_FILE="$DIR/../test_results/setup_env.sh" if [ -f "$VARS_FILE" ] then source "$VARS_FILE" else echo Note: this program is normally called through the Makefile, it echo is not meant to be called directly by the user. exit 1 fi fi export TEST_DIR=$1 # TEST_DIR should be one of compilable, fail_compilation or runnable export TEST_NAME=$2 # name of the test, e.g. test12345 export RESULTS_TEST_DIR=${RESULTS_DIR}/${TEST_DIR} # reference to the resulting test_dir folder, e.g .test_results/runnable export OUTPUT_BASE=${RESULTS_TEST_DIR}/${TEST_NAME} # reference to the resulting files without a suffix, e.g. test_results/runnable/test123 export EXTRA_FILES=${TEST_DIR}/extra-files # reference to the extra files directory export LC_ALL=C #otherwise objdump localizes its output if [ "$OS" == "windows" ]; then export LIBEXT=.lib else export LIBEXT=.a fi if [[ "$OS" == "win"* ]]; then export SOEXT=.dll elif [[ "$OS" = "osx" ]]; then export SOEXT=.dylib else export SOEXT=.so fi # Default to Microsoft cl on Windows if [[ "$OS" == "win"* && -z "${CC+set}" ]] ; then CC="cl" fi export CC="${CC:-c++}" # C++ compiler to use ./ldc-1.42.0-src/tests/dmd/tools/postscript.sh0000755000175000017500000000063415205374122020027 0ustar fabiofabio#!/usr/bin/env bash # A wrapper for all postscript files which sets `-euo pipefail` set -euo pipefail script_file="$1" shift DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" # export common variables source "$DIR/exported_vars.sh" # Remove TEST_DIR and TEST_NAME shift shift # called scripts should fail on errors and undefined variables set -euo pipefail set -x source "${script_file}" ./ldc-1.42.0-src/tests/dmd/fail_compilation/0000755000175000017500000000000015205374124017426 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22121/0000755000175000017500000000000015151104326020724 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22121/imports/0000755000175000017500000000000015151104326022421 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22121/imports/test22121/0000755000175000017500000000000015205374122023773 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22121/imports/test22121/package.d0000644000175000017500000000004415205374122025531 0ustar fabiofabiomodule fail22121.imports.test22121; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/0000755000175000017500000000000015205374123021122 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test18938b/0000755000175000017500000000000015205374122022657 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test18938b/file.d0000644000175000017500000000065715205374122023753 0ustar fabiofabiomodule imports.test18938b.file; import std.algorithm; class IniLikeGroup { this(string ) {} @trusted byNode() { map!(node => lineNode); } } class IniLikeFile { struct WriteOptions { static exact() { return WriteOptions(No.lineBetweenGroups); } this(Args)(Args ){} } void saveToFile(WriteOptions = WriteOptions.exact) {} final save() {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test18938a/0000755000175000017500000000000015205374123022657 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test18938a/file.d0000644000175000017500000000025415205374123023744 0ustar fabiofabioimport imports.test18938b.file; class IconThemeGroup : IniLikeGroup { this() { super("Icon Theme"); } ///setter string inherits()() { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test18938a/cache.d0000644000175000017500000000000015205374123024055 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test10327/0000755000175000017500000000000015205374123022476 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test10327/empty.d0000644000175000017500000000001615205374123023776 0ustar fabiofabiomodule empty; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/diag20518a/0000755000175000017500000000000015205374123022567 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/diag20518a/b.d0000644000175000017500000000000015205374123023143 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice21060c/0000755000175000017500000000000015205374123022416 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice21060c/package.d0000644000175000017500000000003215205374123024151 0ustar fabiofabioimport imports.ice21060d; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice21060a/0000755000175000017500000000000015205374123022414 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice21060a/package.d0000644000175000017500000000003215205374123024147 0ustar fabiofabioimport imports.ice21060c; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/pkg313/0000755000175000017500000000000015205374123022132 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/pkg313/package.d0000644000175000017500000000004615205374123023672 0ustar fabiofabiomodule imports.pkg313; void bug() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice21060d/0000755000175000017500000000000015205374123022417 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice21060d/package.d0000644000175000017500000000005515205374123024157 0ustar fabiofabiomodule imports.ice21060d; struct P21060 { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice21060b/0000755000175000017500000000000015205374123022415 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice21060b/package.d0000644000175000017500000000005515205374123024155 0ustar fabiofabiomodule imports.ice21060d; struct P21060 { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice7782algorithm.d0000644000175000017500000000007715205374122024271 0ustar fabiofabiomodule imports.ice7782algorithm; import imports.ice7782range; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a14424.d0000644000175000017500000000004515205374122022104 0ustar fabiofabiomodule imports.a14424; unittest { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/import22857.d0000644000175000017500000000004615205374122023210 0ustar fabiofabiotemplate unaryFun() { static if } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a13131elec.d0000644000175000017500000000036715205374122022736 0ustar fabiofabiomodule imports.a13131elec; import imports.a13131checkpoint; // [2] import void initElec(T)(T L) { immutable cv = econn.velocities; // econn is invalid so generates ErrorExp } alias econn = elecConnOf!gconn; // invalid declaration ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp15925.d0000644000175000017500000000001415205374122022454 0ustar fabiofabioenum X = 1; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice10600b.d0000644000175000017500000000072515205374122022563 0ustar fabiofabiomodule imports.ice10600b; import imports.ice10600a; template to(T) { T to(A...)(A args) { return toImpl!T(args); } } T toImpl(T, S)(S value) if (is(S : T)) { return value; } T toImpl(T, S)(S value) if (!is(S : T) && is(T == string)) { auto w = appender!T(); //Appender!T w; return null; } T toImpl(T, S)(S value) if ( is(S == string) && !is(T == string) && is(typeof(to!string(value[0]))) ) { return T.init; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/dip22e.d0000644000175000017500000000010515205374122022347 0ustar fabiofabiomodule imports.dip22e; public struct Foo {} public void bar(int) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152k.d0000644000175000017500000000156415205374122023022 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/import15525.d0000644000175000017500000000007115205374122023200 0ustar fabiofabiomodule imports.import15525; template Tuple{ static if } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152j.d0000644000175000017500000000156415205374122023021 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a11919.d0000644000175000017500000000047715205374122022123 0ustar fabiofabiovoid doBar(T)(T t) { static if (t.tupleof.length) if (zoo!t.length == 0) {} static if (is(T B == super) && is(B[0] == class) && is(B[]) ) { B[0] b = t; doBar(b); } } template zoo(alias t) { enum zoo = __traits(getAttributes, t.tupleof); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/diag9210stdcomplex.d0000644000175000017500000000061115205374122024607 0ustar fabiofabiomodule imports.diag9210stdcomplex; import imports.diag9210stdtraits; struct Complex(T) if (isFloatingPoint!T) { T re; T im; } // https://issues.dlang.org/show_bug.cgi?id=9210: Complex!real instantiation is incomplete in here, // because its completion is deferred by an "undefined identifier" error in imports.diag9210b. Complex!real expi(real y) { return Complex!real(0, 0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp22329.d0000644000175000017500000000005615205374122022456 0ustar fabiofabiovoid func(T)(T arg) { auto a = arg + 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test21164a.d0000644000175000017500000000012715205374122023004 0ustar fabiofabiostruct D(E) { void G() { import imports.test21164d; I; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152i.d0000644000175000017500000000156415205374122023020 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/spell9644b.d0000644000175000017500000000005615205374122023077 0ustar fabiofabiomodule imports.spell9644b; private int prib; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp15896.d0000644000175000017500000000011215205374122022462 0ustar fabiofabiomodule imports.imp15896; private int thebar=4; package int packagebar=3; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp2.d0000644000175000017500000000007215205374122022134 0ustar fabiofabiomodule imports.imp2; enum X = 2; enum Y = 2; enum Z = 2; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152v.d0000644000175000017500000000156415205374122023035 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test18480a.d0000644000175000017500000000012415205374122023010 0ustar fabiofabiopublic import imports.test18480b : TestTemplate; alias TestTemplate = TestTemplate; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice11513y.d0000644000175000017500000000004415205374122022610 0ustar fabiofabiomodule ice11513b.imports.ice11513y; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/issue21295visitor.d0000644000175000017500000000013115205374122024434 0ustar fabiofabiomodule imports.issue21295visitor; import imports.issue21295astcodegen; class Visitor { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail7372.d0000644000175000017500000000020215205374122022516 0ustar fabiofabiomodule imports.fail7372; import imports.imp1; mixin template Issue7372() { public void f() { int foo = X; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152w.d0000644000175000017500000000156415205374122023036 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test18480b.d0000644000175000017500000000003415205374122023011 0ustar fabiofabiotemplate TestTemplate() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail19609a.d0000644000175000017500000000005415205374122022752 0ustar fabiofabiodeprecated([""]) module imports.fail19609a; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail10277.d0000644000175000017500000000104615205374122022603 0ustar fabiofabiomodule imports.fail10277; class TypeInfo { } class TypeInfo_Class { } class TypeInfo_Interface { } class TypeInfo_Struct { } class TypeInfo_Typedef { } class TypeInfo_Pointer { } class TypeInfo_Array { } class TypeInfo_AssociativeArray { } class TypeInfo_Enum { } class TypeInfo_Function { } class TypeInfo_Delegate { } class TypeInfo_Tuple { } class TypeInfo_Const { } class TypeInfo_Invariant { } class TypeInfo_Shared { } class TypeInfo_Inout { } class TypeInfo_Vector { } class Object { } class Throwable { } class Exception { } class Error { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152y.d0000644000175000017500000000156415205374122023040 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail21275a.d0000644000175000017500000000042415205374122022743 0ustar fabiofabiomodule imports.fail21275a; struct Foo { private int _x; private ref int x() return { return _x; } int x() const { return _x; } } struct Bar { private int _x; private int x(int) { return _x; } int x() const { return _x; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail4479.d0000644000175000017500000000003415205374122022526 0ustar fabiofabiomodule imports.fail4479mod; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a10528.d0000644000175000017500000000023715205374122022110 0ustar fabiofabioprivate enum string a = "asdfgh"; private enum { b = "asdfgh" } struct S { private enum string c = "qwerty"; } class C { private enum string d = "qwerty"; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a17630.d0000644000175000017500000000003715205374122022107 0ustar fabiofabiomodule a17630; import b17630; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test20023b.d0000644000175000017500000000023415205374122022775 0ustar fabiofabiomodule imports.test20023b; auto threw()() @safe { try throw new Exception("Hello"); catch (Exception e) return e; assert(0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a13131checkpoint.d0000644000175000017500000000107115205374122024146 0ustar fabiofabiomodule imports.a13131checkpoint; mixin(createGlobalsMixins); // [3] mixin auto createGlobalsMixins() // [4] semantic3 { pragma(msg, "+A"); enum fullModuleName = "imports.a13131parameters"; // necessary mixin("import "~fullModuleName~";"); foreach (e ; __traits(derivedMembers, mixin(fullModuleName))) { // [5] see imports.parameters (it's listed in command line) static if ( __traits(compiles, mixin(`__traits(getAttributes, `~fullModuleName~`.`~e~`)`))) {} } pragma(msg, "-A"); return ""; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp17602.d0000644000175000017500000000005515205374122022453 0ustar fabiofabiomodule imports.imp17602; enum Status { on } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/dip22c.d0000644000175000017500000000005715205374122022353 0ustar fabiofabiomodule pkg.dip22c; package(pkg) struct Foo {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152n.d0000644000175000017500000000156415205374122023025 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/issue21295ast_node.d0000644000175000017500000000017315205374122024537 0ustar fabiofabiomodule imports.issue21295ast_node; import imports.issue21295visitor : Visitor; class ASTNode { void accept(Visitor); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test15897.d0000644000175000017500000000010415205374122022656 0ustar fabiofabiomodule imports.test15897; import test15897; class Cat : Animal { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152l.d0000644000175000017500000000156415205374122023023 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/b18219.d0000644000175000017500000000023715205374122022116 0ustar fabiofabiomodule b18219; class Foobar { int a; this(int a) { this.a = a; } static int smeth() { return 1; } } void fun() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/stdtraits10727.d0000644000175000017500000000263015205374122023711 0ustar fabiofabiotemplate StaticArrayTypeOf(T) { inout(U[n]) idx(U, size_t n)( inout(U[n]) ); /+static if (is(T == enum)) alias .StaticArrayTypeOf!(OriginalType!T) StaticArrayTypeOf; else +/static if (is(typeof(idx(T.init/+defaultInit!T+/)) X)) alias X StaticArrayTypeOf; else static assert(0, T.stringof~" is not a static array type"); } template DynamicArrayTypeOf(T) { inout(U[]) idx(U)( inout(U[]) ); /+static if (is(T == enum)) alias .DynamicArrayTypeOf!(OriginalType!T) DynamicArrayTypeOf; else +/static if (!is(StaticArrayTypeOf!T) && is(typeof(idx(T.init/+defaultInit!T+/)) X)) { alias typeof(T.init[0]/+defaultInit!T[0]+/) E; E[] idy( E[] ); const(E[]) idy( const(E[]) ); inout(E[]) idy( inout(E[]) ); shared( E[]) idy( shared( E[]) ); shared(const E[]) idy( shared(const E[]) ); shared(inout E[]) idy( shared(inout E[]) ); immutable(E[]) idy( immutable(E[]) ); alias typeof(idy(T.init/+defaultInit!T+/)) DynamicArrayTypeOf; } else static assert(0, T.stringof~" is not a dynamic array"); } template isDynamicArray(T) { enum isDynamicArray = is(DynamicArrayTypeOf!T)/+ && !isAggregateType!T+/; } template isArray(T) { enum bool isArray = /+isStaticArray!T || +/isDynamicArray!T; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/dip22d.d0000644000175000017500000000013215205374122022346 0ustar fabiofabiomodule imports.dip22d; private struct Foo {} private void foo() {} private void bar() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152a.d0000644000175000017500000000156415205374122023010 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/b13465.d0000644000175000017500000000142215205374122022111 0ustar fabiofabiomodule imports.b13465; template isMaskField() { import imports.b13465; } template isMatchingMaskField() { enum isMatchingMaskField = { enum n = isMaskField!(); return n; }(); /* Semantic analysis journey came from isMatchingMaskField!() * * TemplateInstance('isMaskField!T')->semantic() * TemplateInstance('isMaskField!T')->semantic2() <--- * TemplateInstance::semantic() should run its semantic2() in function body. * Import('import imports.ice1365a;')->semantic2() * Module('imports.ice1365a')->semantic2() * VarDeclaration('imports.ice1365a.isMatchingMaskField!().isMatchingMaskField')->semantic2() <--- * Cannot avoid this visiting, so we need to add a fix in VarDeclaration::semantic2(). */ } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/b17630.d0000644000175000017500000000003315205374122022104 0ustar fabiofabiomodule b17630; int Erase; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test21164c.d0000644000175000017500000000006415205374122023006 0ustar fabiofabioenum S = 1; struct O { } struct R(O U, int W) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152b.d0000644000175000017500000000156415205374122023011 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail1900a.d0000644000175000017500000000010015205374122022643 0ustar fabiofabiomodule imports.fail1900a; template Bar(int n) { enum Bar = n; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/diag10089b.d0000644000175000017500000000012515205374122022734 0ustar fabiofabiomodule imports.diag10089b; void chunks(Source)(Source source, size_t chunkSize) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp18127a.c0000644000175000017500000000224515205374123022622 0ustar fabiofabio// https://github.com/dlang/dmd/issues/18127 // union in here, struct in other union struct_or_union { int x; }; // mismatching number of fields struct S_n_fields { int x, y; }; // mismatched types struct S_types { float x; }; // mismatched names struct S_names { float x; }; struct B { int x; }; // Contains a struct that is incompatible struct S_b { struct B b; }; // mismatched anonymous struct struct S_contains_anon_named { struct { int x; } a; }; struct S_contains_anon_unnamed { struct { int x; }; }; // bitfields struct S_bitfields_mismatch1 { unsigned x: 3; unsigned y: 1; }; struct S_bitfields_mismatch2 { unsigned x; unsigned y: 1; }; struct S_bitfields_widths { unsigned x: 3; unsigned y: 1; }; struct S_bitfields_anon { unsigned x: 3; unsigned : 1; }; // mismatched alignment struct S_alignas { _Alignas(8) float x; }; struct S_aligned { float x; }__attribute__((aligned(8))); // mismatched packing struct __attribute__((packed)) S_pack_1 { float x; char c; }; #pragma pack(push) #pragma pack(1) struct S_pack_2 { float x; char c; }; #pragma pack(pop) ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp18979.d0000644000175000017500000000010515205374123022472 0ustar fabiofabiomodule imports.imp18979; struct Foo { private this(A)(A a) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/issue23947a.d0000644000175000017500000000021015205374123023162 0ustar fabiofabiomodule imports.issue23947a; struct X { } struct Y { } class Class { private void handle(X x) { } public void handle(Y y) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a10169.d0000644000175000017500000000007015205374123022105 0ustar fabiofabiomodule imports.a10169; struct B { private int x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152c.d0000644000175000017500000000156415205374123023013 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail1900b.d0000644000175000017500000000010215205374123022647 0ustar fabiofabiomodule imports.fail1900b; template Bar(short n) { enum Bar = n; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a13465.d0000644000175000017500000000133415205374123022113 0ustar fabiofabiomodule imports.a13465; template isMaskField() { import imports.a13465; } template isMatchingMaskField() { enum isMatchingMaskField = isMaskField!(); /* Semantic analysis journey came from isMatchingMaskField!() * * TemplateInstance('isMaskField!T')->semantic() * TemplateInstance('isMaskField!T')->semantic2() <--- * TemplateInstance::semantic() will run its semantic2() always. * Import('import imports.ice1365a;')->semantic2() * Module('imports.ice1365a')->semantic2() * VarDeclaration('imports.ice1365a.isMatchingMaskField!().isMatchingMaskField')->semantic2() <--- * The type field is yet NULL during type inference, then ICE happens. */ } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail5385.d0000644000175000017500000000046415205374123022533 0ustar fabiofabiomodule imports.fail5385; class C { static private int privX; static package int packX; __gshared private int privX2; __gshared package int packX2; } struct S { static private int privX; static package int packX; __gshared private int privX2; __gshared package int packX2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail20164.d0000644000175000017500000000004515205374123022576 0ustar fabiofabiodeprecated module imports.fail20164; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test15785.d0000644000175000017500000000025215205374123022657 0ustar fabiofabiomodule imports.test15785; class Base { private void foo() {} private void bar() {} private alias T = int; } interface IBase2 { private alias T = int; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/constraints.d0000755000175000017500000000442615205374123023647 0ustar fabiofabiomodule imports.constraints; // can be shared between usual and verbose output versions enum P(T) = true; enum N(T) = false; // constraints_func1 void test1(T)(T v) if (N!T); void test2(T)(T v) if (!P!T); void test3(T)(T v) if (P!T && N!T); void test4(T)(T v) if (P!T && N!T && P!T); void test5(T)(T v) if (N!T || N!T); void test6(T)(T v) if (N!T || N!T || !P!T); void test7(T)(T v) if (N!T || P!T && N!T); void test8(T)(T v) if ((N!T || P!T) && N!T); void test9(T)(T v) if (!P!T && !N!T); void test10(T)(T v) if (!N!T && !P!T); void test11(T)(T v) if (!(!N!T && P!T)); void test12(T)(T v) if (!(N!T || P!T)); // constraints_func2 void test13(T)(T v) if (P!T ? N!T : P!T); // P!T && N!T || !P!T && P!T void test14(T)(T v) if (!P!T ? P!T : N!T); void test15(T)(T v) if (!(P!T ? P!T : N!T)); // (!P!T || !P!T) && (P!T || !N!T) void test16(T)(T v) if (N!T && P!T || N!T); void test17(T)(T v) if (N!T && P!T && (P!T || P!T)); void test18(T)(T v) if ((N!T || P!T && N!T) && P!T); void test19(T)(T v) if ((N!T ? P!T : !P!T) ? P!T : N!T); // (N!T && P!T || !N!T && !P!T) && P!T || (!N!T || !P!T) && (N!T || P!T) && N!T void test20(T)(T v) if (N!T && (P!T && N!T || N!T)); void test21(T)(T v) if (P!T && (N!T && P!T || N!T)); void test22(T)(T v) if ((!P!T || !P!T && P!T) && (N!T || !P!T)); void test23(T)(T v) if (!P!T || P!T && N!T || !P!T); void test24(R)(R r) if (__traits(hasMember, R, "stuff")); int test25(T)(T v) if (N!T); float test26(T, U)(U u) if (N!U); // constraints_func3 void overload(T)(T v) if (N!T); void overload(T)(T v) if (!P!T); void overload(T)(T v1, T v2) if (N!T); void overload(T, V)(T v1, V v2) if (N!T || N!V); void variadic(A, T...)(A a, T v) if (N!int); // constraints_tmpl void dummy()() if (false); void message_nice(T, U)() if (P!T && "message 1" && N!U && "message 2"); void message_ugly(T)(T v) if (!N!T && (T.stringof ~ " must be that") && N!T); void args(T, U)() if (N!T || N!U); void lambda(alias pred)() if (N!int); // constraints_defs void def(T, int i = 5, alias R)() if (N!T); void defa(T, U = int)() if (N!T); void defv(T = bool, int i = 5, Ts...)() if (N!T); // constraints_aggr class C { void f(T)(T v) if (P!T && !P!T) {} void g(this T)() if (N!T) {} } template S(T) if (N!T) { alias S = T; } struct BitFlags(E, bool unsafe = false) if (unsafe || N!E) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail2962a.d0000644000175000017500000000010215205374123022657 0ustar fabiofabioimport fail2962; // comment 4 int foo4() { return bar4(0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test23109b.d0000644000175000017500000000024415205374123023007 0ustar fabiofabiomodule imports.test23109b; import imports.test23109a; import imports.test23109c; struct Ensure { Statement ensure; Ensures* arraySyntaxCopy() { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/spell23908a.d0000644000175000017500000000010715205374123023153 0ustar fabiofabiomodule imports.spell23908a; import imports.spell23908b : nonexistent; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a18243.d0000644000175000017500000000013615205374123022111 0ustar fabiofabiomodule imports.a18243; import imports.b18243 : isNaN; public bool isNaN() { return false; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test143.d0000644000175000017500000000005415205374123022475 0ustar fabiofabiomodule imports.test143; package int x = 5; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/diag9210b.d0000644000175000017500000000015415205374123022651 0ustar fabiofabiomodule imports.diag9210b; import imports.diag9210c; import imports.diag9210stdcomplex; interface B : A {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a13131parameters.d0000644000175000017500000000105515205374123024165 0ustar fabiofabiomodule imports.a13131parameters; auto createParameterMixins() // auto is necessary to invoke semantic3 to calculate full signature { pragma(msg, "+B"); enum fullModuleName = "imports.a13131elec"; // necessary mixin("import "~fullModuleName~";"); foreach (e ; __traits(derivedMembers, mixin(fullModuleName))) { // will access yet-not semantic analyzed invalid symbol 'econn' in imports.elec static if ( __traits(compiles, mixin(`__traits(getAttributes, `~fullModuleName~`.`~e~`)`))) {} } pragma(msg, "-B"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/dip22a.d0000644000175000017500000000032415205374123022347 0ustar fabiofabiomodule imports.dip22a; class Klass { private void bar() {} } struct Struct { private void bar() {} } private void bar() {} template Template(T) { private void bar() {} } private void bar(int) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test5412a.d0000644000175000017500000000003215205374123022716 0ustar fabiofabiomodule imports.test5412a; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152z.d0000644000175000017500000000156415205374123023042 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a17625.d0000644000175000017500000000006115205374123022111 0ustar fabiofabiomodule a17625; private int boo() { return 69; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a313.d0000644000175000017500000000030315205374123021732 0ustar fabiofabiomodule imports.a313; private import imports.b313; private static import imports.b313; private static import b313 = imports.b313; private import imports.pkg313; private import core.stdc.stdio; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp19661.d0000644000175000017500000000066615205374123022473 0ustar fabiofabiotemplate isFunction(X...) if (X.length == 1) { static if (is(typeof(&X[0]) U : U*) && is(U == function) || is(typeof(&X[0]) U == delegate)) { // x is a (nested) function symbol. enum isFunction = true; } else static if (is(X[0] T)) { // x is a type. Take the type of it and examine. enum isFunction = is(T == function); } else enum isFunction = false; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/diag9210c.d0000644000175000017500000000010015205374123022641 0ustar fabiofabiomodule imports.diag9210c; import diag9210a; interface C : A {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/i20057.d0000644000175000017500000000053315205374123022116 0ustar fabiofabiotemplate generateEmptyFunction(C, func...) { } template isAbstractFunction(T...) if (T.length == 1) { enum bool isAbstractFunction = __traits(isAbstractFunction, T[0]); } alias BlackHole(Base) = AutoImplement!(Base, generateEmptyFunction, isAbstractFunction); class AutoImplement(Base, alias how, alias what = isAbstractFunction) : Base {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test21246.d0000644000175000017500000000012615205374123022644 0ustar fabiofabiomodule imports.test21246; class Clock {} class B { void set (Clock clock) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail20637b.d0000644000175000017500000000010615205374123022743 0ustar fabiofabiomodule imports.fail20637b; class A { private static void foo() { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice10598b.d0000644000175000017500000000005715205374123022602 0ustar fabiofabiomodule imports.ice10598b; struct LocalType {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test64a.d0000644000175000017500000000005715205374123022563 0ustar fabiofabiomodule imports; const char[] file1 = "File1"; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test19107a.d0000644000175000017500000000006415205374123023011 0ustar fabiofabiomodule imports.test19107a.d; alias I(alias A) = A; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a314.d0000644000175000017500000000015415205374123021737 0ustar fabiofabiomodule imports.a314; static import imports.c314; import renamed = imports.c314; import imports.c314 : bug; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/c19762.d0000644000175000017500000000050715205374123022124 0ustar fabiofabiomodule imports.c19762; struct Foo { import ice19762 : X; X[] x; } Nullable!Foo foo() { Nullable!Foo output; return output; } struct Nullable(T) { bool opEquals(U)(const(U) rhs) const if (is(typeof(this.get == rhs))) { return true; } inout(T) get() inout { return T.init; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail320b.d0000644000175000017500000000005415205374123022570 0ustar fabiofabiovoid foo(T)(string){} void foo(alias a)(){} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/range15788.d0000644000175000017500000000007415205374123023001 0ustar fabiofabiomodule imports.range15788; auto iota(B, E, S)(B, E, S) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp20709.d0000644000175000017500000000002115205374123022447 0ustar fabiofabiomodule imp20709; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152f.d0000644000175000017500000000156415205374123023016 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a11850.d0000644000175000017500000000134515205374123022111 0ustar fabiofabio//import std.array, std.range; module imports.a11850; template filter(alias pred) { auto filter(Range)(Range rs) { return FilterResult!(pred, Range)(rs); } } private struct FilterResult(alias pred, Range) { alias Range R; R _input; this(R r) { _input = r; while (_input.length != 0 && !pred(_input[0])) { _input = _input[1..$]; } } auto opSlice() { return this; } @property bool empty() { return _input.length == 0; } void popFront() { do { _input = _input[1..$]; } while (_input.length != 0 && !pred(_input[0])); } @property auto ref front() { return _input[0]; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/dip22b.d0000644000175000017500000000020415205374123022345 0ustar fabiofabiomodule imports.dip22b; // this public import only exports symbols that are visible within this module public import imports.dip22c; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/b17918a.d0000644000175000017500000000013715205374123022264 0ustar fabiofabiomodule imports.b17918a; class Base { auto byNode() { return _listMap; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test23109a.d0000644000175000017500000000031615205374123023006 0ustar fabiofabiomodule imports.test23109a; import imports.test23109c; import imports.test23109b; struct Array(T) { T[] data; enum SMALLARRAYCAP = 1; T[SMALLARRAYCAP] smallarray; } alias Ensures = Array!Ensure; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/diag20518a.d0000644000175000017500000000000015205374123022722 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152p.d0000644000175000017500000000156415205374123023030 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/b19762.d0000644000175000017500000000011515205374123022116 0ustar fabiofabiomodule imports.b19762; struct Baz {} struct Qux { import imports.c19762; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/deprecatedImportb.d0000644000175000017500000000016415205374123024725 0ustar fabiofabioalias AliasSeq(T...) = T; void foo() {} void bar(T)(T t) {} enum E = 2; struct S {} class C {} interface I {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice9865b.d0000644000175000017500000000005615205374123022526 0ustar fabiofabiopublic import ice9865; class Bar { Foo foo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp18127b.c0000644000175000017500000000211715205374123022621 0ustar fabiofabio// https://github.com/dlang/dmd/issues/18127 // struct in here, union in other struct struct_or_union { int x; }; // mismatching number of fields struct S_n_fields { int x; }; // mismatched types struct S_types { int x; }; // mismatched names struct S_names { float y; }; struct B { float x; }; // Contains a struct that is incompatible struct S_b { struct B b; }; // mismatched anonymous struct struct S_contains_anon_named { struct { float x; } a; }; struct S_contains_anon_unnamed { struct { float x; }; }; // bitfields struct S_bitfields_mismatch1 { unsigned x: 3; unsigned y; }; struct S_bitfields_mismatch2 { unsigned x: 3; unsigned y: 1; }; struct S_bitfields_widths { unsigned x: 3; unsigned y: 2; }; struct S_bitfields_anon { unsigned x: 3; unsigned y: 1; }; // mismatched alignment struct S_alignas { float x; }; struct S_aligned { float x; }__attribute__((aligned(4))); // mismatched packing struct S_pack_1 { float x; char c; }; struct S_pack_2 { float x; char c; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/bar11136.d0000644000175000017500000000003215205374123022422 0ustar fabiofabiomodule ice11136.bar11136; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/diag10089a.d0000644000175000017500000000012015205374123022727 0ustar fabiofabiomodule imports.diag10089a; struct chunks { this(size_t size) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152m.d0000644000175000017500000000156415205374123023025 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp21832.d0000644000175000017500000000040415205374123022452 0ustar fabiofabiomodule imports.imp21832; static if(1) { int fun(int a) { return a; } int tpl()(int a) { return a; } } deprecated { int fun(char a) { return a; } int tpl()(char a) { return a; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a15667.d0000644000175000017500000000044415205374123022122 0ustar fabiofabiomodule imports.a15667; template staticIndexOf(T) { enum staticIndexOf = genericIndexOf!T; } template genericIndexOf(args...) { alias e = args; alias tuple = args; alias tail = tuple; enum next = genericIndexOf!(e, tail); } alias X = ; static if (staticIndexOf!X) ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/issue21295astcodegen.d0000644000175000017500000000014315205374123025055 0ustar fabiofabiomodule imports.issue21295astcodegen; struct ASTCodegen { import imports.issue21295dtemplate; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice10598a.d0000644000175000017500000000031115205374123022572 0ustar fabiofabiomodule imports.ice10598a; template TypeTuple(TL...) { alias TL TypeTuple; } alias TypeTuple!(__traits(getMember, imports.ice10598b, (__traits(allMembers, imports.ice10598b)[1])))[0] notImportedType; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test19107b.d0000644000175000017500000000007315205374123023012 0ustar fabiofabiomodule imports.test19107b; import imports.test19107a : I; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152q.d0000644000175000017500000000156415205374123023031 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail19609b.d0000644000175000017500000000005315205374123022753 0ustar fabiofabiodeprecated([1]) module imports.fail19609b; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/diag10141a.d0000644000175000017500000000056115205374123022725 0ustar fabiofabiomodule imports.diag10141a; import imports.diag10141b; string format() { auto w = Appender!string(); char[] digits = ['0']; put(w, digits); return null; } template Tuple(Specs...) { struct Tuple { Specs expand; enum x = format(); // in injectNameFields() } } private template Identity(alias T) { alias T Identity; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail356.d0000644000175000017500000000004115205374123022433 0ustar fabiofabiomodule imports.fail356; int bar; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a14235.d0000644000175000017500000000010715205374123022104 0ustar fabiofabiomodule imports.a14235; struct SomeThing(T...) { } class SomeClass {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a18219.d0000644000175000017500000000006215205374123022112 0ustar fabiofabiomodule a18219; struct AST { import b18219; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail17646.d0000644000175000017500000000020115205374123022603 0ustar fabiofabiomodule imports.fail17646; struct TestData { } const(TestData)[] allTestData(MOD_STRINGS...)() { foreach (i; MOD_STRINGS) } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test21164b.d0000644000175000017500000000007515205374123023010 0ustar fabiofabioimport imports.test21164c; enum N = O(); alias Q = R!(N, S); ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test5412b.d0000644000175000017500000000003215205374123022717 0ustar fabiofabiomodule imports.test5412b; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/issue21295dtemplate.d0000644000175000017500000000015515205374123024723 0ustar fabiofabiomodule imports.issue21295dtemplate; import imports.issue21295ast_node; class TemplateParameter : ASTNode { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/deprecatedImporta.d0000644000175000017500000000020215205374123024715 0ustar fabiofabiodeprecated("Please import deprecatedImportb directly!") public import imports.deprecatedImportb : AliasSeq, foo, bar, E, S, C, I; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test15117a.d0000644000175000017500000000023215205374123023003 0ustar fabiofabiomodule imports.test15117a; struct AssertResult {} auto test_usr_1() { // 2. generate TyepInfoStructDeclaration auto x = typeid(AssertResult); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a15816.d0000644000175000017500000000004215205374123022110 0ustar fabiofabiomodule imports.a15816; class { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/foofunc.d0000644000175000017500000000004715205374123022727 0ustar fabiofabiomodule imports.foofunc; void foo() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/b314.d0000644000175000017500000000015215205374123021736 0ustar fabiofabiomodule imports.b314; package import renamedpkg = imports.c314; package import imports.c314 : bugpkg=bug; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a14116.d0000644000175000017500000000007215205374123022103 0ustar fabiofabiomodule ice14116.a14116; import ice14116; void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152g.d0000644000175000017500000000156415205374123023017 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/b17625.d0000644000175000017500000000006115205374123022112 0ustar fabiofabiomodule b17625; private int boo() { return 45; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152x.d0000644000175000017500000000156415205374123023040 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test20267.d0000644000175000017500000000005115205374123022643 0ustar fabiofabiomodule imports.test20267; int[1] array; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail20638b.d0000644000175000017500000000006315205374123022746 0ustar fabiofabiomodule imports.fail20638b; private void foo() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152e.d0000644000175000017500000000156415205374123023015 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/foo10727b.d0000644000175000017500000000054415205374123022620 0ustar fabiofabiostruct CirBuff(T) { import imports.stdtraits10727 : isArray; CirBuff!T opAssign(R)(R) if (isArray!R) {} T[] toArray() { T[] ret = new T[this.length]; return ret; } alias toArray this; } class Bar(T = int) { CirBuff!T _bar; } class Once { Bar!Foo _foobar; } class Foo : Frop {} // Frop is not defined ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152d.d0000644000175000017500000000156415205374123023014 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/diag9210stdtraits.d0000644000175000017500000000166415205374123024460 0ustar fabiofabiomodule imports.diag9210stdtraits; template FloatingPointTypeOf(T)// if (!is(T == enum)) { inout( float) idx( inout( float) ); inout(double) idx( inout(double) ); inout( real) idx( inout( real) ); shared(inout float) idx( shared(inout float) ); shared(inout double) idx( shared(inout double) ); shared(inout real) idx( shared(inout real) ); immutable( float) idy( immutable( float) ); immutable(double) idy( immutable(double) ); immutable( real) idy( immutable( real) ); static if (is(typeof(idx(T.init)) X)) { alias X FloatingPointTypeOf; } else static if (is(typeof(idy(T.init)) X)) { alias X FloatingPointTypeOf; } else { static assert(0, T.stringof~" is not a floating point type"); } } template isFloatingPoint(T) { enum bool isFloatingPoint = is(FloatingPointTypeOf!T); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail355.d0000644000175000017500000000003015205374123022430 0ustar fabiofabiomodule imports.fail355; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/diag10141b.d0000644000175000017500000000221315205374123022722 0ustar fabiofabiomodule imports.diag10141b; template isSomeChar(T) { enum isSomeChar = is(immutable T == immutable char) || is(immutable T == immutable wchar) || is(immutable T == immutable dchar); } struct Appender(A : T[], T) { private template canPutItem(U) { enum bool canPutItem = //isImplicitlyConvertible!(U, T) || isSomeChar!T && isSomeChar!U; } private template canPutRange(Range) { enum bool canPutRange = //isInputRange!Range && is(typeof(Appender.init.put("a"d[0]))); } /** * Appends one item to the managed array. */ void put(U)(U item) if (canPutItem!U) { char[T.sizeof == 1 ? 4 : 2] encoded; auto len = 1; put(encoded[0 .. len]); // ! } /** * Appends an entire range to the managed array. */ void put(Range)(Range items) if (canPutRange!Range) { } } void put(R, E)(ref R r, E e) { static if (is(typeof(r.put(e)))) { r.put(e); } else { static assert(false, "Cannot put a "~E.stringof~" into a "~R.stringof); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice10600a.d0000644000175000017500000000023015205374123022552 0ustar fabiofabiomodule imports.ice10600a; struct Appender(A : T[], T) { this(T[]) {} } Appender!(E[]) appender(A : E[], E)() { return Appender!(E[])(null); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152h.d0000644000175000017500000000156415205374123023020 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail21001b.d0000644000175000017500000000013315205374123022725 0ustar fabiofabiomodule imports.fail21001b; private struct S { Alias member; } private alias Alias = int; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/b313.d0000644000175000017500000000004415205374123021735 0ustar fabiofabiomodule imports.b313; void bug() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152r.d0000644000175000017500000000156415205374123023032 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice7782range.d0000644000175000017500000000007715205374123023400 0ustar fabiofabiomodule imports.ice7782range; import imports.ice7782algorithm; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail320a.d0000644000175000017500000000004515205374123022567 0ustar fabiofabiovoid foo(int) { } void foo(bool) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/foo10727a.d0000644000175000017500000000072115205374123022614 0ustar fabiofabiostruct CirBuff(T) { import imports.stdtraits10727 : isArray; CirBuff!T opAssign(R)(R) if (isArray!R) {} struct Range(U, S) { Range!(U, S) save() { return U; } } T[] toArray() { T[] ret = new T[this.length]; return ret; } alias toArray this; Range!(T, T) range() {} } class Bar(T = int) { CirBuff!T _bar; } class Once { Bar!Foo _foobar; } class Foo : Frop {} // Frop is not defined ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/import21508.d0000644000175000017500000000006115205374123023176 0ustar fabiofabiomodule import21508; private class import21508 {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152t.d0000644000175000017500000000156415205374123023034 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp21353.d0000644000175000017500000000015715205374123022455 0ustar fabiofabiomodule imports.imp21353; struct A { int x; } struct B { import imports.imp21353 : A; } private struct P { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152s.d0000644000175000017500000000156415205374123023033 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail347a.d0000644000175000017500000000007215205374123022600 0ustar fabiofabiomodule imports.fail347a; pure size_t strlen(in char* s); ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test23109c.d0000644000175000017500000000011115205374123023001 0ustar fabiofabiomodule imports.test23109c; import imports.test23109b; class Statement {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152o.d0000644000175000017500000000156415205374123023027 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail19609c.d0000644000175000017500000000005615205374123022757 0ustar fabiofabiodeprecated(123.4f) module imports.fail19609c; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test21651b.d0000644000175000017500000000005315205374123023005 0ustar fabiofabiomodule imports.test21651b; alias T = int; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/issue21685.d0000644000175000017500000000011615205374123023023 0ustar fabiofabiomodule issue21685; class E { private this() {} public this(int) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test21164d.d0000644000175000017500000000005115205374123023004 0ustar fabiofabioauto AB() { static if} auto I() { AB; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/test13152u.d0000644000175000017500000000156415205374123023035 0ustar fabiofabiopublic import imports.test13152a; public import imports.test13152b; public import imports.test13152c; public import imports.test13152d; public import imports.test13152e; public import imports.test13152f; public import imports.test13152g; public import imports.test13152h; public import imports.test13152i; public import imports.test13152j; public import imports.test13152k; public import imports.test13152l; public import imports.test13152m; public import imports.test13152n; public import imports.test13152o; public import imports.test13152p; public import imports.test13152q; public import imports.test13152r; public import imports.test13152s; public import imports.test13152t; public import imports.test13152u; public import imports.test13152v; public import imports.test13152w; public import imports.test13152x; public import imports.test13152y; public import imports.test13152z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/a13311.d0000644000175000017500000000015015205374123022074 0ustar fabiofabiomodule imports.a13311; import ice13311; class Z { TextPiece piece; this(PieceTree owner) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp1.d0000644000175000017500000000007215205374123022134 0ustar fabiofabiomodule imports.imp1; enum X = 1; enum Y = 1; enum Z = 1; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/fail19609d.d0000644000175000017500000000012315205374123022753 0ustar fabiofabiodeprecated(msg) module imports.fail19609d; enum msg = "You won't see this either"; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/imp22749.c0000644000175000017500000000004615205374123022463 0ustar fabiofabiostruct S22749 { int field : 1; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/spell9644a.d0000644000175000017500000000014415205374123023075 0ustar fabiofabiomodule imports.spell9644a; public import imports.spell9644b; int cora; int pub; private int priv; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/ice11513x.d0000644000175000017500000000003215205374123022605 0ustar fabiofabiomodule ice11513a.imports; ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/import23873.d0000644000175000017500000000003015205374123023201 0ustar fabiofabiostatic if ; else auto x ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/b18243.d0000644000175000017500000000007515205374123022114 0ustar fabiofabiomodule imports.b18243; bool isNaN(T)(T x) { return false; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/c314.d0000644000175000017500000000005415205374123021740 0ustar fabiofabiomodule imports.c314; void bug(string s) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/imports/spell23908b.d0000644000175000017500000000007115205374123023154 0ustar fabiofabiomodule imports.spell23908b; import imports.spell23908a; ./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/0000755000175000017500000000000015205374123021650 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/test23109/0000755000175000017500000000000015205374123023226 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/test23109/object.d0000644000175000017500000000062015205374123024637 0ustar fabiofabiomodule object; alias size_t = typeof(int.sizeof); class Object {} auto opEquals(Object ) { return true; } class TypeInfo {} class TypeInfo_Const {} bool _xopEquals() { return true; } bool __equals(T1, T2)(T1[] lhs, T2[] rhs) { static at(R)(R[] r, size_t i) { return r.ptr[i]; } foreach (u; 0 .. lhs.length) if (at(lhs, u) != at(rhs, u)) return false; return true; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/minimal/0000755000175000017500000000000015205374123023276 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/minimal/object.d0000644000175000017500000000001715205374123024707 0ustar fabiofabiomodule object; ./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/fail6592.d0000644000175000017500000000003615205374123023255 0ustar fabiofabiomodule test; import std.foo; ./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/a14446.d0000644000175000017500000000007115205374123022636 0ustar fabiofabiomodule a14446; struct CDBMaker { import ice14446; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/fake.a0000644000175000017500000000000115205374123022707 0ustar fabiofabiob./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/fail12485.d0000644000175000017500000000043515205374123023336 0ustar fabiofabiovoid dorecursive() { recursive!"ratherLongSymbolNameToHitTheMaximumSymbolLengthEarlierThanTheTemplateRecursionLimit_"; } void recursive(string name)() { struct S {} // define type to kick off mangler static if (name.length <= (4 << 20)) recursive!(name ~ name); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/bar11453.d0000644000175000017500000000003215205374123023152 0ustar fabiofabiomodule foo11453.bar11453; ./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/fake.lib0000644000175000017500000000000115205374123023235 0ustar fabiofabiob./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/foo11453.d0000644000175000017500000000002115205374123023167 0ustar fabiofabiomodule foo11453; ./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/makedeps-import.txt0000644000175000017500000000001615205374123025507 0ustar fabiofabioImported text ./ldc-1.42.0-src/tests/dmd/fail_compilation/extra-files/makedeps_a.d0000644000175000017500000000004515205374123024105 0ustar fabiofabiomodule makedeps_a; void a_func() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice24188_a/0000755000175000017500000000000015205374123021074 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/ice24188_a/ice24188_c.d0000644000175000017500000000000015205374123022700 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/protection/0000755000175000017500000000000015151104326021607 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/protection/subpkg/0000755000175000017500000000000015205374124023107 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/fail_compilation/protection/subpkg/test1.d0000644000175000017500000000010115205374124024304 0ustar fabiofabiomodule protection.subpkg.test1; package(undefined) void foo1(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/protection/subpkg/test2.d0000644000175000017500000000011215205374124024307 0ustar fabiofabiomodule protection.subpkg.test2; package(protection.subpkg2) void foo2(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/protection/subpkg/test3.d0000644000175000017500000000007315205374124024316 0ustar fabiofabiomodule protection.subpkg.test3; package(123) void foo3(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20515.d0000644000175000017500000000045015205374122021144 0ustar fabiofabio// REQUIRED_ARGS: -verror-style=gnu /* TEST_OUTPUT: --- fail_compilation/test20515.d:16: Deprecation: function `test20515.foo` is deprecated fail_compilation/test20515.d:17: Error: undefined identifier `bar` --- */ module test20515; deprecated void foo() { } void test() { foo; bar; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8101b.d0000644000175000017500000000242715205374122021156 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8101b.d(28): Error: none of the overloads of `foo` are callable using argument types `(double)` fail_compilation/diag8101b.d(19): Candidates are: `diag8101b.S.foo(int __param_0)` fail_compilation/diag8101b.d(20): `diag8101b.S.foo(int __param_0, int __param_1)` fail_compilation/diag8101b.d(30): Error: function `diag8101b.S.bar(int __param_0)` is not callable using argument types `(double)` fail_compilation/diag8101b.d(30): cannot pass argument `1.0` of type `double` to parameter `int __param_0` fail_compilation/diag8101b.d(33): Error: none of the overloads of `foo` are callable using a `const` object with argument types `(int)` fail_compilation/diag8101b.d(19): Candidates are: `diag8101b.S.foo(int __param_0)` fail_compilation/diag8101b.d(20): `diag8101b.S.foo(int __param_0, int __param_1)` fail_compilation/diag8101b.d(35): Error: mutable method `diag8101b.S.bar` is not callable using a `const` object fail_compilation/diag8101b.d(22): Consider adding `const` or `inout` here --- */ struct S { void foo(int) { } void foo(int, int) { } void bar(int) { } } void main() { S s; s.foo(1.0); s.bar(1.0); const(S) cs; cs.foo(1); cs.bar(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/makedeps_doubleparam.d0000644000175000017500000000111315205374122023731 0ustar fabiofabio/* DISABLED: LDC // irrelevant CLI difference PERMUTE_ARGS: REQUIRED_ARGS: -makedeps=${RESULTS_DIR}/compilable/makedeps.dep -makedeps=other-file.dep -Jcompilable/extra-files -Icompilable/extra-files TEST_OUTPUT: --- Error: -makedeps[=file] can only be provided once! run `dmd` to print the compiler manual run `dmd -man` to open browser on manual --- */ module makedeps_doubleparam; // Test import statement import makedeps_a; // Test import expression enum text = import("makedeps-import.txt"); static assert(text == "Imported text\x0a"); void main() { a_func(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail24212.d0000644000175000017500000000101615205374122021075 0ustar fabiofabio/+ REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fail24212.d(29): Error: assigning reference to local variable `n` to non-scope parameter `p` calling `fun` is not allowed in a `@safe` function --- +/ class Base { @safe pure nothrow void fun(int* p) {} } void test() @safe { int* escaped; class Escaper : Base { @safe pure nothrow override void fun(int* p) { escaped = p; } } int n; Base base = new Escaper; base.fun(&n); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13987.d0000644000175000017500000000017615205374122020751 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13987.d(9): Error: cannot use array to initialize `S` --- */ struct S {} S s = [{}]; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22144.d0000644000175000017500000000056515205374122021107 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22144 /* TEST_OUTPUT: --- fail_compilation/fail22144.d(12): Error: cannot cast expression `zarray1` of type `int[0]` to `int[0][]` since sizes don't line up --- */ void main() { int[0] zarray1; int[0][0] zarray2; auto zslice1 = cast(int[0][])zarray1; // ICE -> Error auto zslice2 = cast(int[0][])zarray2; // ICE -> OK } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24353.d0000644000175000017500000000251315205374122021152 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24353 /* REQUIRED_ARGS: -verrors=context TEST_OUTPUT: --- fail_compilation/test24353.d(37): Error: mutable method `test24353.S.opApply` is not callable using a `const(S)` foreach aggregate foreach (e; s) {} // mod error ^ fail_compilation/test24353.d(28): Consider adding a method type qualifier here int opApply(int delegate(int) dg) ^ fail_compilation/test24353.d(40): Error: shared const method `test24353.S2.opApply` is not callable using a `const(S2)` foreach aggregate foreach (i, e; s2) {} // mod error ^ fail_compilation/test24353.d(47): Consider adding a method type qualifier here int opApply(int delegate(int, int) dg) const shared; ^ fail_compilation/test24353.d(42): Error: cannot uniquely infer `foreach` argument types foreach (i, e; const S3()) {} // cannot infer ^ --- */ struct S { int opApply(int delegate(int) dg) { return 0; } } void example() { const S s; foreach (e; s) {} // mod error const S2 s2; foreach (i, e; s2) {} // mod error foreach (i, e; const S3()) {} // cannot infer } struct S2 { int opApply(int delegate(int, int) dg) const shared; } struct S3 { int opApply(int delegate(int) dg); int opApply(int delegate(int, int) dg); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail118.d0000644000175000017500000000334415205374122020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail118.d(45): Error: invalid `foreach` aggregate `Iter` of type `Iter` fail_compilation/fail118.d(45): `foreach` works with input ranges (implementing `front` and `popFront`), aggregates implementing `opApply`, or the result of an aggregate's `.tupleof` property fail_compilation/fail118.d(45): https://dlang.org/phobos/std_range_primitives.html#isInputRange fail_compilation/fail118.d(46): Error: invalid `foreach` aggregate `Iter` of type `Iter` fail_compilation/fail118.d(46): `foreach` works with input ranges (implementing `front` and `popFront`), aggregates implementing `opApply`, or the result of an aggregate's `.tupleof` property fail_compilation/fail118.d(46): https://dlang.org/phobos/std_range_primitives.html#isInputRange fail_compilation/fail118.d(49): Error: invalid `foreach` aggregate `s` of type `S*` fail_compilation/fail118.d(51): Error: undefined identifier `unknown` fail_compilation/fail118.d(39): Error: undefined identifier `doesNotExist` fail_compilation/fail118.d(53): Error: template instance `fail118.error!()` error instantiating fail_compilation/fail118.d(53): Error: invalid `foreach` aggregate `error()` of type `void` --- */ // https://issues.dlang.org/show_bug.cgi?id=441 // Crash on foreach of mixed-in aggregate. template opHackedApply() { struct Iter { } } class Foo { mixin opHackedApply!() oldIterMix; } struct S { int opApply(scope int delegate(const int) dg); } auto error()() { doesNotExist(); } void main() { Foo f = new Foo; foreach (int i; f.oldIterMix.Iter) {} foreach ( i; f.oldIterMix.Iter) {} S* s; foreach (const i; s) {} foreach(const i; unknown) {} foreach (const i; error()) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/dip25.d0000644000175000017500000000166215205374122020521 0ustar fabiofabio/* REQUIRED_ARGS: TEST_OUTPUT: --- fail_compilation/dip25.d(17): Error: escaping a reference to parameter `this` by returning `this.buffer[]` is not allowed in a `@safe` function fail_compilation/dip25.d(15): perhaps annotate the function with `return` fail_compilation/dip25.d(22): Error: returning `identity(x)` escapes a reference to parameter `x` fail_compilation/dip25.d(23): Error: escaping a reference to parameter `x` by returning `identity(x)` is not allowed in a `@safe` function fail_compilation/dip25.d(23): perhaps annotate the parameter with `return` --- */ struct Data { char[256] buffer; @property const(char)[] filename() const pure nothrow @safe { return buffer[]; } } ref int identity(return ref int x) @safe { return x; } ref int fun(return int x) @safe { return identity(x); } ref int fun2(ref int x) @safe { return identity(x); } void main() { Data d; const f = d.filename; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/gag4269g.d0000644000175000017500000000033315205374122021022 0ustar fabiofabio// REQUIRED_ARGS: -c -o- /* TEST_OUTPUT: --- fail_compilation/gag4269g.d(10): Error: undefined identifier `Y13`, did you mean template `X13(Y13 y)`? --- */ static if(is(typeof(X13!(0).init))) {} template X13(Y13 y) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21475.c0000644000175000017500000000056715205374122021116 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail21475.c(12): Error: expression expected, not `)` fail_compilation/fail21475.c(12): Error: found `=>` when expecting `)` fail_compilation/fail21475.c(12): Error: found `0` when expecting `)` fail_compilation/fail21475.c(12): Error: found `)` when expecting `;` following statement --- */ void test21745(void) { __check(() => 0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag12312.d0000644000175000017500000000053415205374122021070 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag12312.d(10): Error: variable `diag12312.main.arr` of type `void[16]` does not have a default initializer fail_compilation/diag12312.d(15): Error: variable `diag12312.bug1176.v` of type `void[1]` does not have a default initializer --- */ void main() { void[16] arr; } void bug1176() { void[1] v; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24157.d0000644000175000017500000000117115205374122021153 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24157 /* TEST_OUTPUT: --- fail_compilation/test24157.d(23): Error: cannot take address of expression `p.self()` because it is not an lvalue fail_compilation/test24157.d(27): Error: cannot take address of expression `p.unshared()` because it is not an lvalue --- */ class Promise { auto ref self() { return this; } auto ref unshared() shared { return cast() this; } } void testThis(Promise p) { auto ptr = &p.self(); // must not return a ref to the Promise class ref } void testCastThis(shared Promise p) { auto ptr = &p.unshared(); // ditto } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test12558.d0000644000175000017500000000411415205374122021155 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test12558.d(32): Deprecation: `catch` statement without an exception specification is deprecated fail_compilation/test12558.d(32): use `catch(Throwable)` for old behavior fail_compilation/test12558.d(36): Deprecation: `catch` statement without an exception specification is deprecated fail_compilation/test12558.d(36): use `catch(Throwable)` for old behavior fail_compilation/test12558.d(43): Deprecation: `catch` statement without an exception specification is deprecated fail_compilation/test12558.d(43): use `catch(Throwable)` for old behavior fail_compilation/test12558.d(47): Deprecation: `catch` statement without an exception specification is deprecated fail_compilation/test12558.d(47): use `catch(Throwable)` for old behavior fail_compilation/test12558.d(56): Deprecation: `catch` statement without an exception specification is deprecated fail_compilation/test12558.d(56): use `catch(Throwable)` for old behavior fail_compilation/test12558.d(31): Error: `catch` statement without an exception specification is deprecated fail_compilation/test12558.d(31): use `catch(Throwable)` for old behavior fail_compilation/test12558.d(36): Error: `catch` statement without an exception specification is deprecated fail_compilation/test12558.d(36): use `catch(Throwable)` for old behavior fail_compilation/test12558.d(42): Error: `catch` statement without an exception specification is deprecated fail_compilation/test12558.d(42): use `catch(Throwable)` for old behavior fail_compilation/test12558.d(47): Error: `catch` statement without an exception specification is deprecated fail_compilation/test12558.d(47): use `catch(Throwable)` for old behavior --- */ void main() { auto handler = () { }; try { assert(0); } catch handler(); try { assert(0); } catch { handler(); } try { assert(0); } catch handler(); try { assert(0); } catch { handler(); } } void foo()() { try {} catch assert(false); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9891.d0000644000175000017500000000116215205374122021037 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9891.d(13): Error: expression `i` of type `immutable(int)` is not implicitly convertible to type `ref int` of parameter `n` fail_compilation/fail9891.d(18): Error: expression `i` of type `immutable(int)` is not implicitly convertible to type `out int` of parameter `n` fail_compilation/fail9891.d(23): Error: cannot create default argument for `ref` / `out` parameter from expression `prop()` because it is not an lvalue --- */ immutable int i; int prop() { return 0; } void f1(ref int n = i) { ++n; } void f2(out int n = i) { ++n; } void f3(ref int n = prop) { ++n; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6451.d0000644000175000017500000000032615205374122021025 0ustar fabiofabio/* DISABLED: win32 win64 linux32 osx32 freebsd32 openbsd32 LDC TEST_OUTPUT: --- fail_compilation/fail6451.d(9): Error: `__va_list_tag` is not defined, perhaps `import core.stdc.stdarg;` ? --- */ void error(...){} ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12827.d0000644000175000017500000000026115205374122020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12827.d(10): Error: circular initialization of variable `ice12827.Test.i` --- */ struct Test { immutable int i = i; } void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/misc1.d0000644000175000017500000000212015205374122020600 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/misc1.d(109): Error: `5` has no effect fail_compilation/misc1.d(110): Error: `1 + 2` has no effect fail_compilation/misc1.d(111): Error: `x` has no effect fail_compilation/misc1.d(117): Deprecation: `1 * 1` has no effect fail_compilation/misc1.d(118): Deprecation: `() { j++; d++; }` has no effect fail_compilation/misc1.d(124): Deprecation: `false` has no effect fail_compilation/misc1.d(127): Deprecation: `*sp++` has no effect fail_compilation/misc1.d(128): Deprecation: `j` has no effect --- */ #line 100 /***************************************************/ //https://issues.dlang.org/show_bug.cgi?id=12490 void hasSideEffect12490(){} void issue12490() { int x; 5, hasSideEffect12490(); 1 + 2, hasSideEffect12490(); x, x++; } void issue23480() { int j; for({} j; 1*1) {} for({j=2; int d = 3;} j+d<7; {j++; d++;}) {} for ( if (true) // (o_O) assert(78); else assert(79); false; false ) {} // unnecessary deref for (ubyte* sp; 0; *sp++) {} for (;; j) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19099.d0000644000175000017500000000054115205374122021120 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19099.d(26): Error: cannot modify struct instance `a` of type `A` because it contains `const` or `immutable` members --- */ struct B { this(this) {} ~this() {} int a; } struct A { B b; immutable int a; this(int b) { a = b;} } void main() { A a = A(2); A b = A(3); a = b; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14965.d0000644000175000017500000000356015205374122021121 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail14965.d(19): Error: forward reference to inferred return type of function `foo1` fail_compilation/fail14965.d(20): Error: forward reference to inferred return type of function `foo2` fail_compilation/fail14965.d(22): Error: forward reference to inferred return type of function `bar1` fail_compilation/fail14965.d(23): Error: forward reference to inferred return type of function `bar2` fail_compilation/fail14965.d(25): Error: forward reference to inferred return type of function `baz1` fail_compilation/fail14965.d(26): Error: forward reference to inferred return type of function `baz2` fail_compilation/fail14965.d(30): Error: forward reference to inferred return type of function `foo1` fail_compilation/fail14965.d(31): Error: forward reference to inferred return type of function `foo2` fail_compilation/fail14965.d(33): Error: forward reference to inferred return type of function `bar1` fail_compilation/fail14965.d(34): Error: forward reference to inferred return type of function `bar2` fail_compilation/fail14965.d(36): Error: forward reference to inferred return type of function `baz1` fail_compilation/fail14965.d(37): Error: forward reference to inferred return type of function `baz2` --- */ auto foo1() { alias F = typeof(foo1); } // TypeTypeof auto foo2() { alias FP = typeof(&foo2); } // TypeTypeof auto bar1() { auto fp = &bar1; } // ExpInitializer auto bar2() { auto fp = cast(void function())&bar2; } // castTo auto baz1() { return &baz1; } // ReturnStatement auto baz2() { (&baz2); } // ExpStatement class C { auto foo1() { alias F = typeof(this.foo1); } auto foo2() { alias FP = typeof(&this.foo2); } auto bar1() { auto fp = &this.bar1; } auto bar2() { auto dg = cast(void delegate())&this.bar2; } auto baz1() { return &baz1; } auto baz2() { (&baz2); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20414.c0000644000175000017500000000100515205374122021136 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test20414.c(1): Error: `size_t` is not defined, perhaps `#include ` ? fail_compilation/test20414.c(2): Error: `ptrdiff_t` is not defined, perhaps `#include ` ? fail_compilation/test20414.c(3): Error: `NULL` is not defined, perhaps `#include ` is needed? fail_compilation/test20414.c(5): Error: undefined identifier `fooo`, did you mean function `foo`? --- */ #line 1 size_t x; ptrdiff_t pd; void *p = NULL; void foo(void); void (*fp)(void) = &fooo; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375r.d0000644000175000017500000000056715205374122021221 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375r.d(16): Error: else is dangling, add { } after condition at fail_compilation/fail4375r.d(10) --- */ void main() { if (true) try assert(103); finally if (true) assert(104); else assert(105); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13942.d0000644000175000017500000000110715205374122021077 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag13942.d(18): Error: template instance `isRawStaticArray!()` does not match template declaration `isRawStaticArray(T, A...)` fail_compilation/diag13942.d(26): Error: template `to` is not callable using argument types `!()()` fail_compilation/diag13942.d(17): Candidate is: `to(A...)(A args)` --- */ template isRawStaticArray(T, A...) { enum isRawStaticArray = false; } template to(T) { T to(A...)(A args) if (!isRawStaticArray!A) { return 0; } } void main(string[] args) { auto t = to!double(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13434_m32.d0000644000175000017500000000036015205374122021563 0ustar fabiofabio// REQUIRED_ARGS: -m32 /* TEST_OUTPUT: --- fail_compilation/fail13434_m32.d(13): Error: cannot implicitly convert expression `()` of type `()` to `uint` --- */ alias tuple(A...) = A; void main() { float[] arr; arr[tuple!()] = 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/foreach2.d0000644000175000017500000000152515205374122021265 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/foreach2.d(15): Error: argument type mismatch, `int` to `ref immutable(int)` fail_compilation/foreach2.d(16): Error: argument type mismatch, `int` to `ref immutable(int)` fail_compilation/foreach2.d(19): Error: argument type mismatch, `int` to `ref double` fail_compilation/foreach2.d(20): Error: argument type mismatch, `int` to `ref const(double)` fail_compilation/foreach2.d(21): Error: argument type mismatch, `int` to `ref immutable(double)` --- */ void test4090 () { // From https://issues.dlang.org/show_bug.cgi?id=4090 int[] arr = [1,2,3]; foreach (immutable ref x; arr) {} foreach (immutable ref int x; arr) {} // convertible type + qualifier + ref foreach ( ref double x; arr) {} foreach ( const ref double x; arr) {} foreach (immutable ref double x; arr) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail335.d0000644000175000017500000000027515205374122020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail335.d(9): Error: cannot overload both property and non-property functions --- */ void foo(); @property void foo(int); void main() { foo(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/staticforeach2.d0000644000175000017500000000030415205374122022467 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/staticforeach2.d(10): Error: must use labeled `continue` within `static foreach` --- */ void main(){ for(;;){ static foreach(i;0..1){ continue; } } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7702.d0000644000175000017500000000030215205374122021017 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7702.d(14): Error: `s.opDispatch!"x"` isn't a template --- */ struct S { template opDispatch (string name) {} } void main() { S s; s.x!int; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20084.d0000644000175000017500000000061415205374122021103 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fail20084.d(109): Error: escaping a reference to parameter `v` by returning `v.front()` is not allowed in a `@safe` function --- */ #line 100 // https://issues.dlang.org/show_bug.cgi?id=20084 struct W() { int value; @safe ref int front() return { return value; } } @safe ref int get(W!() v) { return v.front; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail206.d0000644000175000017500000000024415205374122020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail206.d(9): Error: shift assign by 65 is outside the range `0..63` --- */ void main() { long c; c >>>= 65; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag15411.d0000644000175000017500000000174315205374122021076 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/diag15411.d(17): Error: function `diag15411.test15411.__funcliteral_L17_C15` cannot access variable `i` in frame of function `diag15411.test15411` fail_compilation/diag15411.d(16): `i` declared here fail_compilation/diag15411.d(18): Error: function `diag15411.test15411.__funcliteral_L18_C15` cannot access variable `i` in frame of function `diag15411.test15411` fail_compilation/diag15411.d(16): `i` declared here fail_compilation/diag15411.d(26): Error: `static` function `diag15411.testNestedFunction.myFunc2` cannot access function `myFunc1` in frame of function `diag15411.testNestedFunction` fail_compilation/diag15411.d(25): `myFunc1` declared here --- */ void test15411() { auto i = 0; auto j = (function() { return i; })(); auto f = function() { return i; }; } void testNestedFunction () { int i = 42; void myFunc1() { assert(i == 42); } static void myFunc2 () { myFunc1(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail231.d0000644000175000017500000000064515205374122020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail231.d(15): Error: class `fail231.Derived` cannot implicitly generate a default constructor when base class `fail231.Base` is missing a default constructor --- */ // https://issues.dlang.org/show_bug.cgi?id=951 // Missing line number: no constructor provided for a class derived from a class with no default constructor class Base { this(int x) {} } class Derived : Base { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11503c.d0000644000175000017500000000057015205374122021243 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11503c.d(19): Error: cannot implicitly convert expression `d.filename()` of type `const(char)[]` to `string` --- */ struct Data { char[256] buffer; @property const(char)[] filename() const pure nothrow return { return buffer[]; } } void main() { Data d; string f = d.filename; d.buffer[0] = 'a'; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/code_global_scope.d0000644000175000017500000000175315205374122023222 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/code_global_scope.d(18): Error: `switch` statement must be inside function scope fail_compilation/code_global_scope.d(19): Error: `do` statement must be inside function scope fail_compilation/code_global_scope.d(20): Error: `foreach` statement must be inside function scope fail_compilation/code_global_scope.d(21): Error: `while` statement must be inside function scope fail_compilation/code_global_scope.d(22): Error: `if` statement must be inside function scope fail_compilation/code_global_scope.d(23): Error: `return` statement must be inside function scope fail_compilation/code_global_scope.d(24): Error: `goto` statement must be inside function scope fail_compilation/code_global_scope.d(25): Error: `continue` statement must be inside function scope fail_compilation/code_global_scope.d(26): Error: `break` statement must be inside function scope --- */ switch s; do d; foreach (i; 0 .. 4) {} while (x) {} if (y) {} return 0; goto A; continue B; break; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9273b.d0000644000175000017500000000032115205374122021014 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9273b.d(14): Error: constructor `ice9273b.B.this` no match for implicit `super()` call in constructor --- */ class A { this(T)() {} } class B : A { this() {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22825a.d0000644000175000017500000000044015205374122021246 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22825 /* TEST_OUTPUT: --- fail_compilation/fail22825a.d(10): Error: positive integer argument expected following `#line` fail_compilation/fail22825a.d(11): Error: declaration expected, not `42` --- */ #line /* multi-line comment */ 42 ./ldc-1.42.0-src/tests/dmd/fail_compilation/uda_lambda.d0000644000175000017500000000016215205374122021641 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/uda_lambda.d(7): Error: declaration expected, not `=>` --- +/ @a => 7 int b; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail2350.d0000644000175000017500000000033615205374122021020 0ustar fabiofabio/* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/fail2350.d(8): Error: function `fail2350.test2350` naked assembly functions with contracts are not supported --- */ void test2350() in { } do { asm { naked; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19202.d0000644000175000017500000000033615205374122021104 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail19202.d(11): Deprecation: variable `fail19202.X!().X` is deprecated --- */ void main() { auto b = X!(); } template X() { deprecated enum X = true; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failcstuff2.c0000644000175000017500000001256515205374122022011 0ustar fabiofabio// check semantic analysis of C files /* TEST_OUTPUT: --- fail_compilation/failcstuff2.c(113): Error: cannot modify expression `cast(int)var` because it is not an lvalue fail_compilation/failcstuff2.c(114): Error: `sizeof` is not a member of `int` fail_compilation/failcstuff2.c(115): Error: cannot modify expression `cast(short)3` because it is not an lvalue fail_compilation/failcstuff2.c(116): Error: cannot modify constant `4` fail_compilation/failcstuff2.c(117): Error: cannot modify constant `5` fail_compilation/failcstuff2.c(118): Error: cannot take address of constant `6` fail_compilation/failcstuff2.c(119): Error: cannot modify expression `cast(int)var` because it is not an lvalue fail_compilation/failcstuff2.c(120): Error: cannot modify expression `cast(int)var` because it is not an lvalue fail_compilation/failcstuff2.c(121): Error: cannot modify expression `cast(int)var` because it is not an lvalue fail_compilation/failcstuff2.c(122): Error: cannot modify expression `cast(int)var` because it is not an lvalue fail_compilation/failcstuff2.c(123): Error: cannot take address of expression `cast(int)var` because it is not an lvalue fail_compilation/failcstuff2.c(124): Error: cannot take address of expression `makeS22067().field` because it is not an lvalue fail_compilation/failcstuff2.c(125): Error: cannot modify expression `makeS22067().field` because it is not an lvalue fail_compilation/failcstuff2.c(126): Error: cannot modify expression `makeS22067().field` because it is not an lvalue fail_compilation/failcstuff2.c(127): Error: cannot modify expression `makeS22067().field` because it is not an lvalue fail_compilation/failcstuff2.c(153): Error: cannot modify expression `cast(short)var` because it is not an lvalue fail_compilation/failcstuff2.c(154): Error: cannot modify expression `cast(long)var` because it is not an lvalue fail_compilation/failcstuff2.c(354): Error: variable `arr` cannot be read at compile time fail_compilation/failcstuff2.c(360): Error: variable `str` cannot be read at compile time fail_compilation/failcstuff2.c(352): Error: cannot take address of register variable `reg1` fail_compilation/failcstuff2.c(355): Error: cannot take address of register variable `reg2` fail_compilation/failcstuff2.c(358): Error: cannot take address of register variable `reg3` fail_compilation/failcstuff2.c(359): Error: cannot index through register variable `reg3` fail_compilation/failcstuff2.c(360): Error: cannot take address of register variable `reg3` fail_compilation/failcstuff2.c(361): Error: cannot take address of register variable `reg3` fail_compilation/failcstuff2.c(362): Error: cannot index through register variable `reg3` fail_compilation/failcstuff2.c(373): Error: cannot take address of register variable `reg4` fail_compilation/failcstuff2.c(374): Error: cannot take address of register variable `reg4` fail_compilation/failcstuff2.c(375): Error: cannot take address of register variable `reg4` fail_compilation/failcstuff2.c(376): Error: cannot take address of bitfield `reg4.inner.b` fail_compilation/failcstuff2.c(377): Error: cannot index through register variable `reg4` fail_compilation/failcstuff2.c(378): Error: cannot index through register variable `reg4` fail_compilation/failcstuff2.c(381): Error: cannot take address of register variable `reg5` --- */ /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22069 #line 50 void test22069() { int var; int *ptr; &var; *ptr; +var; -var; ~var; !var; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22067 #line 100 struct S22067 { int field; }; struct S22067 makeS22067() { return (struct S22067) { 42 }; } void test22067() { int var; (int) var = 1; sizeof(var) = 2; ++(short)3; --4; (5)++; (&6); ((int)var)++; ((int)var)--; ++(int)var; --(int)var; &(int)var; &makeS22067().field; makeS22067().field = 1; makeS22067().field++; --makeS22067().field; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22068 #line 150 void test22068() { int var; ++(short) var; --(long long) var; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22405 #line 300 struct S22405 { int * const p; int *q; }; void test22405(struct S22405 *s) { s->p = (const int *)(s->q); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22413 #line 350 void test22413a() { int arr[6] = {1,2,3,4,5,6}; int arr2[] = arr; } void test22413b() { const char *str = "hello"; char msg[] = str; } /***************************************************/ #line 350 void testRegister(register int reg1) { int *ptr1 = ®1; register int reg2; int *ptr2 = ®2; register int reg3[1]; int *ptr3 = (int *)reg3; int idx3a = reg3[0]; int idx3b = *reg3; int idx3c = reg3 + 0; int idx3d = 0[reg3]; register struct { struct { int i; int b : 4; int a[1]; } inner; } reg4; int *ptr4a = &(reg4.inner.i); int *ptr4b = reg4.inner.a; int *ptr4c = (int*)reg4.inner.a; int *ptr4d = &(reg4.inner.b); int idx4a = reg4.inner.a[0]; int idx4b = 0[reg4.inner.a]; register int *reg5; int **ptr5 = ®5; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12534.d0000644000175000017500000000036315205374122020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12534.d(14): Error: static assert: `is(exprs[0 .. 0])` is false --- */ alias TypeTuple(T...) = T; void main() { int x, y; alias exprs = TypeTuple!(x, y); static assert(is(exprs[0..0])); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21408.d0000644000175000017500000000060215205374122021145 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test21408.d(12): Error: can't infer return type in function `opEquals` fail_compilation/test21408.d(19): Error: can't infer return type in function `opEquals` --- */ struct A { A[] as; auto opEquals(A x) { return as == x.as; } } struct B { B[] as; auto opEquals(B x) { return x == this; } } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11125.d0000644000175000017500000000177015205374122021103 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11125.d(26): Error: template instance `fail11125.filter!(function (int a) pure nothrow @nogc @safe => a + 1)` does not match template declaration `filter(alias predfun)` with `predfun = (int a) => a + 1` must satisfy the following constraint: ` is(ReturnType!predfun == bool)` fail_compilation/fail11125.d(27): Error: template instance `fail11125.filter!(function (int a) pure nothrow @nogc @safe => a + 1)` does not match template declaration `filter(alias predfun)` with `predfun = (int a) => a + 1` must satisfy the following constraint: ` is(ReturnType!predfun == bool)` --- */ template ReturnType(alias fun) { alias int ReturnType; } template filter(alias predfun) if (is(ReturnType!predfun == bool)) { static assert(is(ReturnType!predfun == bool)); auto filter(Range)(Range r) { } } void main() { filter!((int a) => a + 1)([1]); // fails in constraint [1].filter!((int a) => a + 1); // fails internally in static assert! } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20809.d0000644000175000017500000000107315205374122021154 0ustar fabiofabio/* REQUIRED_ARGS: TEST_OUTPUT: --- fail_compilation/test20809.d(114): Error: escaping a reference to parameter `this` by returning `this.a` is not allowed in a `@safe` function fail_compilation/test20809.d(112): perhaps annotate the function with `return` --- */ // https://issues.dlang.org/show_bug.cgi?id=20809 #line 100 @safe: struct S { @safe: int a; ~this() { a = 0; } ref int val() { return a; } } S bar() { return S(2); } int foo() { return bar.val; } void test() { assert(foo() == 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20719.d0000644000175000017500000000163115205374122021154 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test20719.d(14): Error: struct `test20719.SumType` no size because of forward reference fail_compilation/test20719.d(17): error on member `test20719.SumType.storage` fail_compilation/test20719.d(33): Error: variable `test20719.isCopyable!(SumType).__lambda_L33_C22.foo` - size of type `SumType` is invalid fail_compilation/test20719.d(19): Error: template instance `test20719.isCopyable!(SumType)` error instantiating --- */ struct SumType { alias Types = AliasSeq!(typeof(this)); union Storage { Types[0] t; } Storage storage; static if (isCopyable!(Types[0])) {} static if (isAssignable!(Types[0])) {} } alias AliasSeq(TList...) = TList; enum isAssignable(Rhs) = __traits(compiles, lvalueOf = rvalueOf!Rhs); struct __InoutWorkaroundStruct {} T rvalueOf(T)(); T lvalueOf()(__InoutWorkaroundStruct); enum isCopyable(S) = { S foo; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16523.d0000644000175000017500000000033315205374122021150 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test16523.d(12): Error: `case` variables have to be `const` or `immutable` --- */ void test(int a, int b) { switch (a) { case b: return; default: assert(0); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test13537.d0000644000175000017500000000233515205374122021156 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test13537.d(31): Error: modifying field `U.y` which overlaps with fields with other storage classes is not allowed in a `@safe` function fail_compilation/test13537.d(32): Error: modifying field `U.y` which overlaps with fields with other storage classes is not allowed in a `@safe` function fail_compilation/test13537.d(33): Error: accessing overlapped field `U.z` with pointers is not allowed in a `@safe` function fail_compilation/test13537.d(34): Error: modifying field `U.y` which overlaps with fields with other storage classes is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=13537 union U { immutable int x; int y; int* z; } union V { immutable int x; const int y; } void fun() @safe { U u; // errors u.y = 1; int* p = &u.y; int** q = &u.z; abc(u.y); // read access is allowed int a = u.x; a = u.y; def(u.y); // Overlapping const/immutable is allowed auto v = V(1); assert(v.y == 1); } void gun() @system { U u; // allowed because system code u.y = 1; int* p = &u.y; int** q = &u.z; abc(u.y); } @safe: void abc(ref int x) { } void def(const ref int x) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/constraints_aggr.d0000755000175000017500000000240715205374122023146 0ustar fabiofabio/* EXTRA_FILES: imports/constraints.d TEST_OUTPUT: --- fail_compilation/constraints_aggr.d(32): Error: template `f` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(60): Candidate is: `f(T)(T v)` with `T = int` must satisfy the following constraint: ` !P!T` fail_compilation/constraints_aggr.d(33): Error: template `g` is not callable using argument types `!()()` fail_compilation/imports/constraints.d(63): Candidate is: `g(this T)()` with `T = imports.constraints.C` must satisfy the following constraint: ` N!T` fail_compilation/constraints_aggr.d(35): Error: template instance `imports.constraints.S!int` does not match template declaration `S(T)` with `T = int` must satisfy the following constraint: ` N!T` fail_compilation/constraints_aggr.d(44): Error: template instance `imports.constraints.BitFlags!(Enum)` does not match template declaration `BitFlags(E, bool unsafe = false)` with `E = Enum` must satisfy one of the following constraints: ` unsafe N!E` --- */ void main() { import imports.constraints; C c = new C; c.f(0); c.g(); S!int; enum Enum { A = 1, B = 2, C = 4, BC = B|C } BitFlags!Enum flags; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail347.d0000644000175000017500000000161015205374122020740 0ustar fabiofabio/* EXTRA_FILES: imports/fail347a.d TEST_OUTPUT: --- fail_compilation/fail347.d(26): Error: undefined identifier `bbr`, did you mean variable `bar`? fail_compilation/fail347.d(27): Error: no property `ofo` for type `S` fail_compilation/fail347.d(20): did you mean `foo`? fail_compilation/fail347.d(29): Error: no property `fool` for type `S*` fail_compilation/fail347.d(20): did you mean `foo`? fail_compilation/fail347.d(30): Error: undefined identifier `strlenx`, did you mean function `strlen`? fail_compilation/fail347.d(31): Error: no property `strlenx` for `"hello"` of type `string` fail_compilation/imports/fail347a.d(3): did you mean function `strlen`? --- */ import imports.fail347a; struct S { int foo; } void main() { S bar; bbr.foo = 3; bar.ofo = 4; auto sp = &bar; sp.fool = 5; auto s = strlenx("hello"); auto q = "hello".strlenx(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13203.d0000644000175000017500000000270515205374122021101 0ustar fabiofabioint v1, v2; /* TEST_OUTPUT: --- fail_compilation/fail13203.d(15): Error: alias `fail13203.FA1!1.T` conflicts with alias `fail13203.FA1!1.T` at fail_compilation/fail13203.d(14) fail_compilation/fail13203.d(22): Error: template instance `fail13203.FA1!1` error instantiating fail_compilation/fail13203.d(20): Error: alias `fail13203.FA2!1.T` conflicts with alias `fail13203.FA2!1.T` at fail_compilation/fail13203.d(19) fail_compilation/fail13203.d(23): Error: template instance `fail13203.FA2!1` error instantiating --- */ template FA1(int b) { alias T = int; static if (b) alias T = uint; } template FA2(int b) { alias T = v1; static if (b) alias T = v2; } alias A1 = FA1!1; // type is not overloadable alias A2 = FA2!1; // variable symbol is not overloadable /* TEST_OUTPUT: --- fail_compilation/fail13203.d(36): Error: alias `fail13203.FB1!1.T` conflicts with alias `fail13203.FB1!1.T` at fail_compilation/fail13203.d(37) fail_compilation/fail13203.d(44): Error: template instance `fail13203.FB1!1` error instantiating fail_compilation/fail13203.d(41): Error: alias `fail13203.FB2!1.T` conflicts with alias `fail13203.FB2!1.T` at fail_compilation/fail13203.d(42) fail_compilation/fail13203.d(45): Error: template instance `fail13203.FB2!1` error instantiating --- */ template FB1(int b) { static if (b) alias T = uint; alias T = int; } template FB2(int b) { static if (b) alias T = v2; alias T = v1; } alias B1 = FB1!1; alias B2 = FB2!1; ./ldc-1.42.0-src/tests/dmd/fail_compilation/dip22e.d0000644000175000017500000000037715205374122020665 0ustar fabiofabio/* EXTRA_FILES: imports/dip22d.d imports/dip22e.d TEST_OUTPUT: --- fail_compilation/dip22e.d(14): Error: undefined identifier `foo`, did you mean struct `Foo`? --- */ import imports.dip22d; import imports.dip22e; void test() { foo(); bar(12); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/staticforeach4.d0000644000175000017500000000104015205374122022467 0ustar fabiofabio/* REQUIRED_ARGS: -verrors=context TEST_OUTPUT: --- fail_compilation/staticforeach4.d(16): Error: index type `byte` cannot cover index range 0..257 static foreach (byte a, int b; data) { } ^ fail_compilation/staticforeach4.d(17): Error: index type `byte` cannot cover index range 0..257 static foreach (byte a, int b; fn()) { } ^ --- */ immutable int[257] data = 1; int[257] fn() { return data; } static foreach (byte a, int b; data) { } static foreach (byte a, int b; fn()) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22538.c0000644000175000017500000000246315205374122021160 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test22538.c(111): Error: function `test22538.sun3` conflicts with function `test22538.sun3` at fail_compilation/test22538.c(110) fail_compilation/test22538.c(114): Error: function `test22538.sun4` conflicts with function `test22538.sun4` at fail_compilation/test22538.c(113) fail_compilation/test22538.c(117): Error: variable `test22538.rock1` conflicts with variable `test22538.rock1` at fail_compilation/test22538.c(116) fail_compilation/test22538.c(120): Error: variable `test22538.rock2` conflicts with variable `test22538.rock2` at fail_compilation/test22538.c(119) fail_compilation/test22538.c(123): Error: variable `test22538.stone1` conflicts with variable `test22538.stone1` at fail_compilation/test22538.c(122) fail_compilation/test22538.c(126): Error: variable `test22538.stone2` conflicts with variable `test22538.stone2` at fail_compilation/test22538.c(125) --- */ // https://issues.dlang.org/show_bug.cgi?id=22534 #line 100 // allowed: static int sun1(); int sun1() { return 0; } // allowed: static int sun2() { return 0; } int sun2(); // fail: int sun3(); static int sun3() { return 0; } int sun4() { return 0; } static int sun4(); static int rock1 = 7; int rock1; static int rock2; int rock2 = 7; int stone1 = 7; static int stone1; int stone2; static int stone2 = 7; ./ldc-1.42.0-src/tests/dmd/fail_compilation/enum_init.d0000644000175000017500000000570315205374122021565 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=8511 TEST_OUTPUT: --- fail_compilation/enum_init.d(5): Error: type `SQRTMAX` has no value --- */ #line 1 real hypot() { enum SQRTMAX; SQRTMAX/2; } /* https://issues.dlang.org/show_bug.cgi?id=21785 TEST_OUTPUT: --- fail_compilation/enum_init.d(106): Error: enum `enum_init.NoBase` is opaque and has no default initializer --- */ #line 100 enum NoBase; void fooNB() { NoBase nbv = void; NoBase nb; } /* https://issues.dlang.org/show_bug.cgi?id=21785 TEST_OUTPUT: --- fail_compilation/enum_init.d(206): Error: enum `enum_init.Xobj` is opaque and has no default initializer --- */ #line 200 enum Xobj : void*; void main() { Xobj vv = void; Xobj var; } /* https://issues.dlang.org/show_bug.cgi?id=21785 TEST_OUTPUT: --- fail_compilation/enum_init.d(306): Error: variable `enum_init.fooOB.ob` - no definition of struct `S` fail_compilation/enum_init.d(302): required by type `OpaqueBase` fail_compilation/enum_init.d(306): see https://dlang.org/spec/struct.html#opaque_struct_unions fail_compilation/enum_init.d(306): perhaps declare a variable with pointer type `OpaqueBase*` instead --- */ #line 300 struct S; enum OpaqueBase : S; void fooOB() { OpaqueBase ob; } /* TEST_OUTPUT: --- fail_compilation/enum_init.d(405): Error: enum `enum_init.forwardRef.Foo` forward reference of `Foo.init` --- */ #line 400 void forwardRef() { enum Foo { a = Foo.init } } /* https://issues.dlang.org/show_bug.cgi?id=21792 TEST_OUTPUT: --- fail_compilation/enum_init.d(503): Error: circular reference to enum base type `Bar` --- */ #line 500 void forwardRef2() { enum Bar : Bar { a } } /* TEST_OUTPUT: --- fail_compilation/enum_init.d(606): Error: enum member `enum_init.forwardRef3.Foo.b` is forward referenced looking for `.min` fail_compilation/enum_init.d(607): Error: enum member `enum_init.forwardRef3.Foo.c` is forward referenced looking for `.min` --- */ #line 600 void forwardRef3() { enum Foo { a, b = Foo.min, c } } /* TEST_OUTPUT: --- fail_compilation/enum_init.d(711): Error: circular reference to enum base type `int[Bar.sizeof]` --- */ #line 700 void forwardRef4() { enum Foo { a = Foo.sizeof, c } // pragma(msg, typeof(Foo.sizeof)); // static assert(is(Foo Base == enum) && is(Base == int)); enum Bar : int[Bar.sizeof] { a } } /* TEST_OUTPUT: --- fail_compilation/enum_init.d(809): Error: enum `enum_init.opaqueProperties.Foo` is opaque and has no default initializer fail_compilation/enum_init.d(810): Error: enum `enum_init.opaqueProperties.Foo` is opaque and has no `.min` fail_compilation/enum_init.d(811): Error: enum `enum_init.opaqueProperties.Foo` is opaque and has no `.max` --- */ #line 800 void opaqueProperties() { enum Foo; // Valid enum size = Foo.sizeof; enum s = Foo.mangleof; Foo f = Foo.init; int min = Foo.min; int max = Foo.max; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice17690.d0000644000175000017500000000022515205374122020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice17690.d(9): Error: undefined identifier `x` --- */ void main(){ scope(exit) int x=3; assert(x==3); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375k.d0000644000175000017500000000071015205374122021200 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375k.d-mixin-11(15): Error: else is dangling, add { } after condition at fail_compilation/fail4375k.d-mixin-11(12) fail_compilation/fail4375k.d-mixin-11(12): while parsing string mixin statement --- */ void main() { mixin(q{ if(true) if(true) assert(54); else assert(55); }); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7234.d0000644000175000017500000000036415205374122021027 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7234.d(14): Error: no property `empty` for type `Contract*`, perhaps `import std.range;` is needed? --- */ struct Contract { void opDispatch()(){} } void foo() { Contract* r; if (r.empty) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail311.d0000644000175000017500000000056415205374122020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail311.d(16): Error: undefined identifier `undefined` fail_compilation/fail311.d(25): Error: template instance `fail311.foo!()` error instantiating --- */ template Tuple(T...) { alias T Tuple; } void foo()() { undefined x; foreach (i; Tuple!(2)) { static assert(true); } } void main() { foo!()(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag6707.d0000644000175000017500000000054715205374122021027 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag6707.d(17): Error: mutable method `diag6707.Foo.value` is not callable using a `const` object fail_compilation/diag6707.d(13): Consider adding `const` or `inout` here --- */ module diag6707; struct Foo { @property bool value() { return true; } void test() const { auto x = value; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21353.d0000644000175000017500000000167415205374122021156 0ustar fabiofabio/* EXTRA_FILES: imports/imp21353.d TEST_OUTPUT: --- fail_compilation/test21353.d(22): Error: no property `A` for type `imports.imp21353.B` fail_compilation/imports/imp21353.d(5): struct `B` defined here fail_compilation/test21353.d(23): Error: no property `A` for type `imports.imp21353.B` fail_compilation/imports/imp21353.d(5): struct `B` defined here fail_compilation/test21353.d(24): Error: no property `A` for type `imports.imp21353.B` fail_compilation/imports/imp21353.d(5): struct `B` defined here fail_compilation/test21353.d(26): Error: undefined identifier `P` in module `imports.imp21353` fail_compilation/test21353.d(27): Error: undefined identifier `P` in module `imports.imp21353` --- */ // https://issues.dlang.org/show_bug.cgi?id=21353 import imports.imp21353; void main() { B.A; with (B) { A(0); } with (B()) { A(0); } // fixed imports.imp21353.P(); with (imports.imp21353) { P(); } // fixed } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19757_m32.d0000644000175000017500000000030515205374122021600 0ustar fabiofabio// REQUIRED_ARGS: -m32 /* TEST_OUTPUT: --- fail_compilation/fail19757_m32.d(9): Error: cannot implicitly convert expression `"oops"` of type `string` to `uint` --- */ auto s = new string("oops"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail356a.d0000644000175000017500000000041315205374122021101 0ustar fabiofabio/* EXTRA_FILES: imports/fail356.d TEST_OUTPUT: --- fail_compilation/fail356a.d(9): Error: variable `fail356a.imports` conflicts with import `fail356a.imports` at fail_compilation/fail356a.d(8) --- */ import imports.fail356; int imports; // collides with package name ./ldc-1.42.0-src/tests/dmd/fail_compilation/e15876_3.d0000644000175000017500000000237015205374122020654 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/e15876_3.d(28): Error: unexpected `(` in declarator fail_compilation/e15876_3.d(28): Error: basic type expected, not `=` fail_compilation/e15876_3.d(29): Error: found `End of File` when expecting `(` fail_compilation/e15876_3.d(29): Error: found `End of File` instead of statement fail_compilation/e15876_3.d(29): Error: expression expected, not `End of File` fail_compilation/e15876_3.d(29): Error: found `End of File` when expecting `;` following `for` condition fail_compilation/e15876_3.d(29): Error: expression expected, not `End of File` fail_compilation/e15876_3.d(29): Error: found `End of File` when expecting `)` fail_compilation/e15876_3.d(29): Error: found `End of File` instead of statement fail_compilation/e15876_3.d(29): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/e15876_3.d(28): unmatched `{` fail_compilation/e15876_3.d(29): Error: found `End of File` when expecting `)` fail_compilation/e15876_3.d(29): Error: variable name expected after type `d(_error_ = () { for (__error__ __error; __error) { __error__ } } )`, not `End of File` fail_compilation/e15876_3.d(29): Error: semicolon expected following function declaration, not `End of File` --- */ d(={for ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10102.d0000644000175000017500000000233315205374122021071 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10102.d(48): Error: variable `fail10102.main.m` - default construction is disabled for type `NotNull!(int*)` fail_compilation/fail10102.d(49): Error: variable `fail10102.main.a` - default construction is disabled for type `NotNull!(int*)[3]` fail_compilation/fail10102.d(50): Error: default construction is disabled for type `NotNull!(int*)` fail_compilation/fail10102.d(51): Error: field `S.m` must be initialized because it has no default constructor --- */ struct NotNull(T) { T p; alias p this; this(T p) { assert(p != null, "pointer is null"); this.p = p; } @disable this(); NotNull opAssign(T p) { assert(p != null, "assigning null to NotNull"); this.p = p; return this; } } void main() { struct S { NotNull!(int *) m; // should fail: an explicit constructor must be required for S } int i; NotNull!(int*) n = &i; *n = 3; assert(i == 3); n = &i; n += 1; NotNull!(int*) m; // should fail NotNull!(int*)[3] a; // should fail auto b = new NotNull!(int*)[3]; // should fail S s = S(); // should fail } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag11198.d0000644000175000017500000000067015205374122021104 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag11198.d(13): Error: version `blah` declaration must be at module level fail_compilation/diag11198.d(14): Error: debug `blah` declaration must be at module level fail_compilation/diag11198.d(15): Error: identifier expected, not `""` fail_compilation/diag11198.d(16): Error: identifier expected, not `""` --- */ void main() { version = blah; debug = blah; version = ""; debug = ""; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22812.c0000644000175000017500000000073715205374122021111 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22812 /* TEST_OUTPUT: --- fail_compilation/fail22812.c(11): Error: left parenthesis expected to follow `#pragma pack` fail_compilation/fail22812.c(12): Error: unrecognized `#pragma pack(\n)` fail_compilation/fail22812.c(13): Error: pack must be an integer positive power of 2, not 0x3 fail_compilation/fail22812.c(13): Error: right parenthesis expected to close `#pragma pack(` --- */ #pragma #pragma pack #pragma pack( #pragma pack(3 ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12673.d0000644000175000017500000000034115205374122020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12673.d(13): Error: static assert: `__traits(compiles, () pure nothrow @nogc @safe { __error__ } )` is false --- */ void main() { static assert(__traits(compiles, { abcd(); })); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22977.d0000644000175000017500000000207515205374122021167 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test22977.d(16): Error: escaping local variable through nested function `scfunc` is not allowed in a `@safe` function fail_compilation/test22977.d(22): Error: escaping local variable through nested function `scfunc2` is not allowed in a `@safe` function --- */ // Issue 22977 - [dip1000] can escape scope pointer returned by nested function // https://issues.dlang.org/show_bug.cgi?id=22977 auto p0(scope string s) @safe { string scfunc() { return s; } return scfunc(); } auto p1(scope string s) @safe { ref string scfunc2() { return s; } return scfunc2(); } // Reduced from Mir struct Tuple(T...) { T expand; } auto autoExpandAndForward(alias value)() { return value.expand[0]; } struct MapIterator { int* p; int* foo() scope { auto t = Tuple!(int*)(p); return autoExpandAndForward!t; } } // Reduced from Phobos float partial(alias fun)() { return fun(); } auto partialFunction() @safe { int function() f = () => 0; return &partial!(f); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19890b.d0000644000175000017500000000040715205374122021262 0ustar fabiofabio/* REQUIRED_ARGS: -m32 DISABLED: LDC // no static array size limits TEST_OUTPUT: --- fail_compilation/fail19890b.d(8): Error: `void[cast(size_t)4294967294]` size 1 * 4294967294 exceeds 0x7fffffff size limit for static array --- */ void[] f = cast(void[-2]) "a"; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22070.c0000644000175000017500000000032415205374122021141 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test22070.c(10): Error: cannot take address of expression `&""` because it is not an lvalue --- */ // https://issues.dlang.org/show_bug.cgi?id=22070 char(**s1)[3] = &(&""); ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13884.d0000644000175000017500000000115615205374122021110 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag13884.d(14): Error: functions cannot return a sequence (use `std.typecons.Tuple`) fail_compilation/diag13884.d(21): instantiated from here: `MapResult!((t) => t.tupleof, Foo[])` fail_compilation/diag13884.d(14): instantiated from here: `map!(Foo[])` --- */ struct Foo { int x; } void main() { [Foo(1)].map!(t => t.tupleof); } template map(fun...) { auto map(Range)(Range r) { return MapResult!(fun, Range)(r); } } struct MapResult(alias fun, R) { R _input; @property auto ref front() { return fun(_input[0]); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22825b.d0000644000175000017500000000026315205374122021252 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22825 /* TEST_OUTPUT: --- fail_compilation/fail22825b.d(7): Error: declaration expected, not `#` --- */ # line 12 ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4511.d0000644000175000017500000000057215205374122021023 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4511.d(18): Error: cannot implicitly override base class method `fail4511.test72.X.func` with `fail4511.test72.Y.func`; add `override` attribute --- */ void test72() { class A {} class B : A {} class X { abstract A func(); } class Y : X { B func() { return new A(); } } } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22361.d0000644000175000017500000000055015205374122021146 0ustar fabiofabio/* TRANSFORM_OUTPUT: remove_lines("^import path") TEST_OUTPUT: --- fail_compilation/test22361.d(9): Error: unable to read module `this_module_does_not_exist` fail_compilation/test22361.d(9): Expected 'this_module_does_not_exist.d' or 'this_module_does_not_exist/package.d' in one of the following import paths: --- */ import this_module_does_not_exist; ./ldc-1.42.0-src/tests/dmd/fail_compilation/lexer2.d0000644000175000017500000000120115205374122020764 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/lexer2.d(16): Error: odd number (3) of hex characters in hex string fail_compilation/lexer2.d(17): Error: non-hex character 'G' in hex string fail_compilation/lexer2.d(18): Error: heredoc rest of line should be blank fail_compilation/lexer2.d(20): Error: unterminated delimited string constant starting at fail_compilation/lexer2.d(20) fail_compilation/lexer2.d(22): Error: semicolon expected following auto declaration, not `End of File` --- */ // https://dlang.dawg.eu/coverage/src/lexer.c.gcov.html static s1 = x"123"; static s2 = x"123G"; static s4 = q"here notblank here"; static s5 = q"here "; ./ldc-1.42.0-src/tests/dmd/fail_compilation/goto1.d0000644000175000017500000000040715205374122020623 0ustar fabiofabio /* TEST_OUTPUT: --- fail_compilation/goto1.d(1010): Error: `return` statements cannot be in `finally` bodies --- */ void foo(); void bar(); #line 1000 void test2() { try { foo(); } finally { bar(); return; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test9176.d0000644000175000017500000000056315205374122021103 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test9176.d(14): Error: forward reference to inferred return type of function call `get()` fail_compilation/test9176.d(10): while evaluating: `static assert(!is(typeof(foo(S()))))` --- */ void foo(int x) {} static assert(!is(typeof(foo(S())))); struct S { auto get() { return get(); } alias get this; } void main(){} ./ldc-1.42.0-src/tests/dmd/fail_compilation/alignedext2.i0000644000175000017500000000053315205374122022005 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/alignedext2.i(8): Error: alignment must be an integer positive power of 2, not 0x7b fail_compilation/alignedext2.i(9): Error: alignment must be an integer positive power of 2, not 0x10000 --- */ typedef struct __attribute__((aligned(123))) U { int a; } S; struct __attribute__((aligned(65536))) V { int a; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23057.c0000644000175000017500000000026115205374122021147 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23057.c(101): Error: no type for declarator before `(` --- */ /* https://issues.dlang.org/show_bug.cgi?id=23057 */ #line 100 (a[0]) ./ldc-1.42.0-src/tests/dmd/fail_compilation/msg24094.c0000644000175000017500000000027415205374122020764 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/msg24094.c(7): Error: extended-decl-modifier expected after `__declspec(`, saw `*` instead --- */ __declspec(*) void* __cdecl _calloc_base(int, int); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix21585.d0000644000175000017500000000125215205374122020764 0ustar fabiofabio/* 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")); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23159.d0000644000175000017500000000062615205374122021160 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23159 // REQUIRED_ARGS: -betterC /* TEST_OUTPUT: --- fail_compilation/test23159.d(14): Error: `scope(failure)` cannot be used with `-fno-exceptions` fail_compilation/test23159.d(18): Error: `scope(success)` cannot be used with `-fno-exceptions` --- */ void main() { scope(failure) { int a; } scope(success) { int a; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/traits_child.d0000644000175000017500000000103215205374122022236 0ustar fabiofabio/************************************************************/ /* TEST_OUTPUT: --- fail_compilation/traits_child.d(100): Error: expected 2 arguments for `child` but had 1 fail_compilation/traits_child.d(101): Error: symbol or expression expected as first argument of __traits `child` instead of `long` fail_compilation/traits_child.d(102): Error: symbol expected as second argument of __traits `child` instead of `3` --- */ #line 100 enum a = __traits(child, long); enum b = __traits(child, long, 3); enum c = __traits(child, "hi", 3); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail352.d0000644000175000017500000000046115205374122020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail352.d(18): Error: cannot infer argument types, expected 1 argument, not 2 --- */ struct Range { bool empty; int front() { return 0; } void popFront() { empty = true; } } void main() { // no index for range foreach foreach(i, v; Range()) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15368.d0000644000175000017500000000047615205374122021166 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test15368.d(13): Error: cannot declare `auto` loop variable, omit `auto` to still get type inference --- */ // Issue 15368 - Improve error message for "auto" keyword inside "foreach" // https://issues.dlang.org/show_bug.cgi?id=15368 void main() { foreach (auto e; foo) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bug8150a.d0000644000175000017500000000066215205374122021031 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=8150: nothrow check doesn't work for constructor /* TEST_OUTPUT: --- fail_compilation/bug8150a.d(14): Error: `object.Exception` is thrown but not caught fail_compilation/bug8150a.d(12): Error: constructor `bug8150a.Foo.this` may throw but is marked as `nothrow` --- */ struct Foo { this(int) nothrow { throw new Exception("something"); } } void main() { Foo(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10964.d0000644000175000017500000000166215205374122021115 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10964.d(28): Error: function `fail10964.S.this(this)` is not `nothrow` fail_compilation/fail10964.d(29): Error: function `fail10964.S.this(this)` is not `nothrow` fail_compilation/fail10964.d(30): Error: function `fail10964.S.this(this)` is not `nothrow` fail_compilation/fail10964.d(33): Error: function `fail10964.S.this(this)` is not `nothrow` fail_compilation/fail10964.d(34): Error: function `fail10964.S.this(this)` is not `nothrow` fail_compilation/fail10964.d(35): Error: function `fail10964.S.this(this)` is not `nothrow` fail_compilation/fail10964.d(22): Error: function `fail10964.foo` may throw but is marked as `nothrow` --- */ struct S { this(this) { throw new Exception("BOOM!"); } } void foo() nothrow { S ss; S[1] sa; // TOKassign ss = ss; sa = ss; sa = sa; // TOKconstruct S ss2 = ss; S[1] sa2 = ss; S[1] sa3 = sa; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21928b.d0000644000175000017500000000040115205374122021247 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail21928b.d(18): Error: this array literal causes a GC allocation in `@nogc` function `main` --- */ @nogc: struct Shape { immutable size_t[] dims = []; } void main() { auto s = Shape(Shape.init.dims ~ 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/staticassert_sema1.d0000644000175000017500000000153515205374122023374 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/staticassert_sema1.d(17): Error: static assert: "unsupported OS" --- */ // https://issues.dlang.org/show_bug.cgi?id=24645 // Test that a static assert(0) is not drowned out by subsequent import errors. version(_NONEXISTENT_OS) { } else { static assert(0, msg); } import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; import object: _NONEXISTENT; enum msg = "unsupported OS"; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19915.d0000644000175000017500000000037615205374122021123 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19915.d(8): Error: undefined identifier `c` in module `fail19915` fail_compilation/fail19915.d(9): Error: template instance `fail19915.a!int` error instantiating --- */ class a (b) { align.c d; } alias a!(int) e; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19520.d0000644000175000017500000000163215205374122021107 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=19520 TEST_OUTPUT: --- fail_compilation/fail19520.d(17): Error: incompatible types for `(Empty) is (Empty)`: cannot use `is` with types fail_compilation/fail19520.d(17): while evaluating: `static assert((Empty) is (Empty))` fail_compilation/fail19520.d(18): Error: incompatible types for `(WithSym) is (WithSym)`: cannot use `is` with types fail_compilation/fail19520.d(18): while evaluating: `static assert((WithSym) is (WithSym))` fail_compilation/fail19520.d(19): Error: incompatible types for `(Empty) is (Empty)`: cannot use `is` with types fail_compilation/fail19520.d(20): Error: incompatible types for `(WithSym) is (WithSym)`: cannot use `is` with types --- */ struct Empty { } struct WithSym { int i; } void test() { static assert(Empty is Empty); static assert(WithSym is WithSym); assert(Empty is Empty); assert(WithSym is WithSym); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/parse12967a.d0000644000175000017500000000425315205374122021461 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/parse12967a.d(14): Error: function `parse12967a.pre_i1` without `this` cannot be `immutable` fail_compilation/parse12967a.d(15): Error: function `parse12967a.pre_i2` without `this` cannot be `immutable` fail_compilation/parse12967a.d(16): Error: function `parse12967a.pre_c1` without `this` cannot be `const` fail_compilation/parse12967a.d(17): Error: function `parse12967a.pre_c2` without `this` cannot be `const` fail_compilation/parse12967a.d(18): Error: function `parse12967a.pre_w1` without `this` cannot be `inout` fail_compilation/parse12967a.d(19): Error: function `parse12967a.pre_w2` without `this` cannot be `inout` fail_compilation/parse12967a.d(20): Error: function `parse12967a.pre_s1` without `this` cannot be `shared` fail_compilation/parse12967a.d(21): Error: function `parse12967a.pre_s2` without `this` cannot be `shared` --- */ immutable pre_i1() {} immutable void pre_i2() {} const pre_c1() {} const void pre_c2() {} inout pre_w1() {} inout void pre_w2() {} shared pre_s1() {} shared void pre_s2() {} /* TEST_OUTPUT: --- fail_compilation/parse12967a.d(36): Error: function `parse12967a.post_i1` without `this` cannot be `immutable` fail_compilation/parse12967a.d(37): Error: function `parse12967a.post_i2` without `this` cannot be `immutable` fail_compilation/parse12967a.d(38): Error: function `parse12967a.post_c1` without `this` cannot be `const` fail_compilation/parse12967a.d(39): Error: function `parse12967a.post_c2` without `this` cannot be `const` fail_compilation/parse12967a.d(40): Error: function `parse12967a.post_w1` without `this` cannot be `inout` fail_compilation/parse12967a.d(41): Error: function `parse12967a.post_w2` without `this` cannot be `inout` fail_compilation/parse12967a.d(42): Error: function `parse12967a.post_s1` without `this` cannot be `shared` fail_compilation/parse12967a.d(43): Error: function `parse12967a.post_s2` without `this` cannot be `shared` --- */ auto post_i1() immutable {} void post_i2() immutable {} auto post_c1() const {} void post_c2() const {} auto post_w1() inout {} void post_w2() inout {} auto post_s1() shared {} void post_s2() shared {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21227_win.d0000644000175000017500000000657615205374122021775 0ustar fabiofabio/* REQUIRED_ARGS: -Jfail_compilation DISABLED: linux osx freebsd dragonflybsd netbsd openbsd TEST_OUTPUT: --- fail_compilation\fail21227_win.d(2): Error: absolute path is not allowed in import expression: `"\\\\UNC\\path\\to\\file.txt"` fail_compilation\fail21227_win.d(3): Error: absolute path is not allowed in import expression: `"c:file.txt"` fail_compilation\fail21227_win.d(4): Error: absolute path is not allowed in import expression: `"c:\\file.txt"` fail_compilation\fail21227_win.d(5): Error: absolute path is not allowed in import expression: `"c:/file.txt"` fail_compilation\fail21227_win.d(6): Error: absolute path is not allowed in import expression: `"\\abs\\path\\to\\file.txt"` fail_compilation\fail21227_win.d(7): Error: absolute path is not allowed in import expression: `"/abs/path/to/file.txt"` fail_compilation\fail21227_win.d(8): Error: path refers to parent (`..`) directory: `"..\\file.txt"` fail_compilation\fail21227_win.d(9): Error: path refers to parent (`..`) directory: `"../file.txt"` fail_compilation\fail21227_win.d(10): Error: path refers to parent (`..`) directory: `"path\\to\\parent\\..\\file.txt"` fail_compilation\fail21227_win.d(11): Error: path refers to parent (`..`) directory: `"path/to/parent/../file.txt"` fail_compilation\fail21227_win.d(12): Error: `"file>txt"` is not a valid filename on this platform fail_compilation\fail21227_win.d(12): Character `'>'` is reserved and cannot be used fail_compilation\fail21227_win.d(13): Error: `"filetxt") ~ import(r"file 1)` does not match template declaration `Type(T)` fail_compilation/fail7352.d(45): Error: template instance `Type!(fun)` does not match template declaration `Type(T)` fail_compilation/fail7352.d(45): `fun` is not a type fail_compilation/fail7352.d(47): Error: template instance `Immutable!int` does not match template declaration `Immutable(T : immutable(T))` fail_compilation/fail7352.d(49): Error: template instance `Value!int` does not match template declaration `Value(string s)` fail_compilation/fail7352.d(50): Error: template instance `Value!(1)` does not match template declaration `Value(string s)` fail_compilation/fail7352.d(51): Error: template instance `Value!(fun)` does not match template declaration `Value(string s)` fail_compilation/fail7352.d(51): `fun` is not of a value of type `string` --- */ template Type(T) { } template Immutable(T : immutable(T)) { alias Immutable = T; } template Value(string s) { auto x = s; } int fun(int i) { return i; } void main() { enum a = 1; int b; Type!a testTypeValue; Type!b testTypeVar; Type!(() => 1) testTypeFuncLiteral; Type!fun testTypeFunc; Immutable!int testImmutable; auto testValueType = Value!int.x; auto testValueWrongType = Value!a.x; auto testValueFunc = Value!fun.x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/json2.d0000644000175000017500000000034615205374122020627 0ustar fabiofabio/* REQUIRED_ARGS: -Xi= LDC: just a different error msg DISABLED: LDC TEST_OUTPUT: --- Error: argument expected for switch '-Xi=' run `dmd` to print the compiler manual run `dmd -man` to open browser on manual --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22157.d0000644000175000017500000000151315205374122021105 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22157 /* TEST_OUTPUT: --- fail_compilation/fail22157.d(32): Error: `fail22157.S!true.S.foo` called with argument types `()` matches multiple overloads exactly: fail_compilation/fail22157.d(21): `fail22157.S!true.S.foo()` and: fail_compilation/fail22157.d(22): `fail22157.S!true.S.foo()` fail_compilation/fail22157.d(33): Error: `fail22157.S!false.S.foo` called with argument types `()` matches multiple overloads exactly: fail_compilation/fail22157.d(26): `fail22157.S!false.S.foo()` and: fail_compilation/fail22157.d(27): `fail22157.S!false.S.foo()` --- */ struct S(bool b) { static if(b) { void foo() {} static void foo() {} } else { static void foo() {} void foo() {} } } void main() { S!true.foo; S!false.foo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bitfields1.c0000644000175000017500000000074415205374122021623 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/bitfields1.c(103): Error: no alignment-specifier for bit field declaration fail_compilation/bitfields1.c(108): Error: no type-specifier for struct member fail_compilation/bitfields1.c(111): Error: no type-specifier for struct member fail_compilation/bitfields1.c(112): Error: no type-specifier for struct member --- */ #line 100 struct S { _Alignas(4) int a:3; }; struct T { :3; }; struct E1 { :0; int x; }; struct E2 { int x; :0; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/e15876_2.d0000644000175000017500000000072715205374122020657 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/e15876_2.d(16): Error: identifier expected following `template` fail_compilation/e15876_2.d(16): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/e15876_2.d(15): unmatched `{` fail_compilation/e15876_2.d(16): Error: found `End of File` when expecting `]` fail_compilation/e15876_2.d(16): Error: variable name expected after type `o[() { ; } ]`, not `End of File` --- */ o[{template ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17518.d0000644000175000017500000000066115205374122021115 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17518.d(21): Error: constructor `fail17518.S.this(inout(Correct) __param_0) inout` is not callable using argument types `(Wrong)` fail_compilation/fail17518.d(21): cannot pass argument `Wrong()` of type `Wrong` to parameter `inout(Correct) __param_0` --- */ struct S { this(inout Correct) inout { } } struct Correct {} struct Wrong {} S bug() { return S(Wrong()); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/biterrors3.d0000644000175000017500000000071715205374122021674 0ustar fabiofabio/* REQUIRED_ARGS: -preview=bitfields * TEST_OUTPUT: --- fail_compilation/biterrors3.d(103): Error: storage class not allowed for bitfield declaration fail_compilation/biterrors3.d(106): Error: expected `,` or `=` after identifier, not `:` fail_compilation/biterrors3.d(106): Error: found `:` when expecting `,` fail_compilation/biterrors3.d(106): Error: found `3` when expecting `identifier` --- */ #line 100 struct S { static int : 3; } enum E { d : 3 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag15186.d0000644000175000017500000000042315205374122021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag15186.d(14): Error: use `.` for member lookup, not `::` fail_compilation/diag15186.d(15): Error: use `.` for member lookup, not `->` --- */ void main() { struct S { static int x; int y; } S* s; S::x = 1; s->y = 2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag4479.d0000644000175000017500000000044215205374122021025 0ustar fabiofabio// EXTRA_SOURCES: imports/fail4479.d /* TEST_OUTPUT: --- fail_compilation/diag4479.d(10): Error: module `imports.fail4479mod` from file fail_compilation/imports/fail4479.d must be imported with 'import imports.fail4479mod;' --- */ module diag4479; import imports.fail4479; void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20637.d0000644000175000017500000000044615205374122021112 0ustar fabiofabio/* EXTRA_FILES: imports/fail20637b.d TEST_OUTPUT: --- fail_compilation/fail20637.d(13): Error: no property `foo` for type `imports.fail20637b.A` fail_compilation/imports/fail20637b.d(3): class `A` defined here --- */ module fail20637; import imports.fail20637b; void main() { A.foo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/class1.d0000644000175000017500000000032215205374122020754 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/class1.d(11): Error: class `class1.C` identity assignment operator overload is illegal --- */ class C { // Non-templated identity opAssign void opAssign(C rhs){} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15089.d0000644000175000017500000000036415205374122021116 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail15089.d(10): Error: cannot implicitly convert expression `2 ^ 128` of type `int` to `byte` --- */ enum Pieces {Rook = 2} /* line 1 */ immutable int color = 0b10000000; byte piece = Pieces.Rook ^ color; ./ldc-1.42.0-src/tests/dmd/fail_compilation/immutable_ctor.d0000644000175000017500000000043215205374122022576 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/immutable_ctor.d(18): Error: `immutable` copy constructor `immutable_ctor.S1.this` cannot construct a mutable object --- */ struct S1 { this(ref const S1 s) immutable { } int i; } void main() { const(S1) s1; S1 ms1 = s1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11375.d0000644000175000017500000000052215205374122021104 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11375.d(18): Error: constructor `fail11375.D!().D.this` is not `nothrow` which calls `this` fail_compilation/fail11375.d(16): Error: function `D main` may throw but is marked as `nothrow` --- */ class B { this() {} } class D() : B {} void main() nothrow { auto d = new D!()(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/hexstring.d0000644000175000017500000000636215205374122021613 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/hexstring.d(30): Error: array cast from `string` to `ubyte[3][1]` is not supported at compile time fail_compilation/hexstring.d(33): Error: cannot implicitly convert expression `"123F"` of type `string` to `immutable(ubyte[])` fail_compilation/hexstring.d(37): Error: hex string length 1 must be a multiple of 2 to cast to `immutable(ushort[])` fail_compilation/hexstring.d(38): Error: hex string length 3 must be a multiple of 4 to cast to `immutable(uint[])` fail_compilation/hexstring.d(39): Error: hex string length 5 must be a multiple of 8 to cast to `immutable(ulong[])` fail_compilation/hexstring.d(40): Error: array cast from `wstring` to `immutable(ulong[])` is not supported at compile time fail_compilation/hexstring.d(40): perhaps remove postfix `w` from hex string fail_compilation/hexstring.d(41): Error: array cast from `string` to `immutable(uint[])` is not supported at compile time fail_compilation/hexstring.d(42): Error: array cast from `string` to `immutable(ushort[])` is not supported at compile time fail_compilation/hexstring.d(43): Error: array cast from `string` to `immutable(uint[])` is not supported at compile time fail_compilation/hexstring.d(43): perhaps remove postfix `c` from hex string fail_compilation/hexstring.d(44): Error: hex string with `dstring` type needs to be multiple of 4 bytes, not 5 fail_compilation/hexstring.d(45): Error: cannot implicitly convert expression `x"11223344"d` of type `dstring` to `immutable(float[])` fail_compilation/hexstring.d(46): Error: cannot implicitly convert expression `x"1122"w` of type `wstring` to `immutable(ubyte[])` fail_compilation/hexstring.d(47): Error: array cast from `string` to `ubyte[3][1]` is not supported at compile time fail_compilation/hexstring.d(48): Error: array cast from `string` to `ubyte[3][1][1]` is not supported at compile time fail_compilation/hexstring.d(56): Error: array cast from `string` to `S[]` is not supported at compile time fail_compilation/hexstring.d(32): Error: cannot implicitly convert expression `x"123F"` of type `string` to `ubyte[]` --- */ immutable ubyte[] s0 = x"123F"; static assert(s0[0] == 0x12); static assert(s0[1] == 0x3F); immutable byte[] s1 = x"123F"; enum E(X) = cast(X[]) x"AABBCCDD"; static assert(E!int[0] == 0xAABBCCDD); immutable ubyte[3] s2 = cast(ubyte[3][1])x"FFAAFF"; ubyte[] f1 = x"123F"; immutable ubyte[] f2 = "123F"; immutable ubyte[] f3 = x"123F"c; immutable ubyte[] f4 = cast(string) x"123F"; immutable ushort[] f5 = cast(immutable ushort[]) x"11"; immutable uint[] f6 = cast(immutable uint[]) x"112233"; immutable ulong[] f7 = cast(immutable ulong[]) x"1122334455"; immutable ulong[] f8 = cast(immutable ulong[]) x"11223344"w; immutable uint[] f9 = cast(immutable uint[]) "ABCD"; immutable ushort[] f10 = cast(immutable ushort[]) (x"1122" ~ ""); immutable uint[] f11 = cast(immutable uint[]) x"AABBCCDD"c; immutable uint[] f12 = x"1122334455"d; immutable float[] f13 = x"11223344"d; immutable ubyte[] f14 = x"1122"w; immutable ubyte[3][1] f16 = cast(ubyte[3][1])x"FFBBFF"; immutable ubyte[3][1][1] f17 = cast(ubyte[3][1][1])x"FFCCFF"; // https://issues.dlang.org/show_bug.cgi?id=24832 struct S { ushort l0, l1, l2, l3, l4, l5; } immutable S[] returnValues = cast(S[]) x"FFFFFFFFFFFFFFFFFFFFFFFF"; ./ldc-1.42.0-src/tests/dmd/fail_compilation/empty_statement.d0000644000175000017500000000053715205374122023020 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/empty_statement.d(11): Error: use `{ }` for an empty statement, not `;` fail_compilation/empty_statement.d(12): Error: use `{ }` for an empty statement, not `;` fail_compilation/empty_statement.d(13): Error: use `{ }` for an empty statement, not `;` --- */ void main() { for (;;); if (0); while (0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23406.d0000644000175000017500000000105615205374122021105 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23406 /* TEST_OUTPUT: --- fail_compilation/fail23406.d(39): Error: cannot implicitly convert expression `0` of type `int` to `alphakey` --- */ struct flagenum { int i = 1; alias i this; auto opBinary(string s)(int j) { assert(j == 1); return typeof(this)(i*2); } auto opEquals(int a) { return false; } } enum alphakey { a = flagenum(), b,c,d,e,f,g,h,i, k,l,m,n,o,p,q,r, s,t,u,v,w,x,y,z } alphakey alpha; void main() { alpha = 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail57.d0000644000175000017500000000026015205374122020656 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail57.d(11): Error: divide by 0 fail_compilation/fail57.d(11): Error: divide by 0 --- */ int main() { int x = 1 / 0; return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag3673.d0000644000175000017500000000030615205374122021017 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag3673.d(9): Error: template constraints appear both before and after BaseClassList, put them before --- */ class A {} class B(T) if(false) : A if (true) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue21630.d0000644000175000017500000000120415205374122021312 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/issue21630.d(14): Error: cannot declare `enum` loop variables for non-unrolled foreach fail_compilation/issue21630.d(15): Error: cannot declare `alias` loop variables for non-unrolled foreach fail_compilation/issue21630.d(16): Error: cannot declare `enum` loop variables for non-unrolled foreach fail_compilation/issue21630.d(17): Error: cannot declare `alias` loop variables for non-unrolled foreach --- +/ void main() { enum a = [1, 2, 3]; foreach(enum i; a) { } // error foreach(alias i; a) { } // error foreach(enum i; 0 .. 3) { } // error foreach(alias i; 0 .. 3) { } // error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ctor_attr.d0000644000175000017500000000164215205374122021575 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ctor_attr.d(26): Error: none of the overloads of `this` can construct a mutable object with argument types `(int)` fail_compilation/ctor_attr.d(16): Candidates are: `ctor_attr.S.this(int x) const` fail_compilation/ctor_attr.d(18): `ctor_attr.S.this(string x)` fail_compilation/ctor_attr.d(17): `this()(int x) shared` fail_compilation/ctor_attr.d(28): Error: none of the overloads of `foo` are callable using a mutable object with argument types `(int)` fail_compilation/ctor_attr.d(20): Candidates are: `ctor_attr.S.foo(int x) immutable` fail_compilation/ctor_attr.d(21): `ctor_attr.S.foo(string x)` --- */ struct S { this(int x) const {} this()(int x) shared {} this(string x) {} void foo(int x) immutable {} void foo(string x) {} } void f() { auto s = S(1); S t; t.foo(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11545.d0000644000175000017500000000057115205374122021107 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11545.d(14): Error: accessing non-static variable `x` requires an instance of `C` fail_compilation/fail11545.d(18): Error: accessing non-static variable `x` requires an instance of `C` --- */ class C { int x = 42; int function() f1 = function() { return x; }; int function() f2 = { return x; }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13788.d0000644000175000017500000000107615205374122020750 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13788.d(11): Error: `pragma(mangle)` expects string literal argument for mangled name fail_compilation/ice13788.d(12): Error: `string` expected for pragma mangle argument, not `(1)` of type `int` fail_compilation/ice13788.d(13): Error: `pragma(mangle)` zero-length string not allowed for mangled name fail_compilation/ice13788.d(14): Error: `pragma(mangle)` mangled name characters can only be of type `char` --- */ pragma(mangle) void f1(); pragma(mangle, 1) void f2(); pragma(mangle, "") void f3(); pragma(mangle, "a"w) void f4(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/aaerrors.d0000644000175000017500000000311515205374122021407 0ustar fabiofabio/* TEST_OUTPUT: TRANSFORM_OUTPUT: remove_lines(called from here) --- fail_compilation\aaerrors.d-mixin-29(29): Error: `assert(aai[1] == 0)` failed fail_compilation\aaerrors.d-mixin-30(30): Error: `assert((aai[1] = 1) == 0)` failed fail_compilation\aaerrors.d-mixin-31(31): Error: `assert(*(1 in aai) == 3)` failed fail_compilation\aaerrors.d-mixin-32(32): Error: `assert(aai.remove(2))` failed fail_compilation\aaerrors.d-mixin-33(33): Error: `assert(aai != [1:2])` failed fail_compilation\aaerrors.d-mixin-34(34): Error: `assert(aai == [1:3])` failed fail_compilation\aaerrors.d-mixin-41(41): Error: `assert(aas[1].x == 0)` failed fail_compilation\aaerrors.d-mixin-42(42): Error: `assert((aas[1] = 1).x == 0)` failed fail_compilation\aaerrors.d-mixin-43(43): Error: `assert((*(1 in aas)).x == 0)` failed --- */ struct S { int x; this(int _x){ x = _x; } ref S opAssign(int _x){ x = _x; return this; } } string gentest_ii(string expr) { return "() { int[int] aai = [ 1 : 2 ]; assert(" ~ expr ~ ");\n return true; }()\n"; } const ii1 = mixin(gentest_ii("aai[1] == 0")); const ii2 = mixin(gentest_ii("(aai[1] = 1) == 0")); const ii3 = mixin(gentest_ii("*(1 in aai) == 3")); const ii4 = mixin(gentest_ii("aai.remove(2)")); const ii5 = mixin(gentest_ii("aai != [1:2]")); const ii6 = mixin(gentest_ii("aai == [1:3]")); string gentest_is(string expr) { return "() { S[int] aas = [ 1 : S(2) ]; assert(" ~ expr ~ ");\n return true; }()\n"; } const is1 = mixin(gentest_is("aas[1].x == 0")); const is2 = mixin(gentest_is("(aas[1] = 1).x == 0")); const is3 = mixin(gentest_is("(1 in aas).x == 0")); ./ldc-1.42.0-src/tests/dmd/fail_compilation/lvalue1.c0000644000175000017500000000141715205374122021144 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/lvalue1.c(19): Error: cannot modify expression `(c ? a : b).y` because it is not an lvalue fail_compilation/lvalue1.c(20): Error: cannot modify expression `c ? a.z : b.z` because it is not an lvalue fail_compilation/lvalue1.c(21): Error: conditional expression `c ? cast(short)a.x : cast(short)b.x` is not a modifiable lvalue fail_compilation/lvalue1.c(25): Error: cannot take address of register variable `ax` fail_compilation/lvalue1.c(25): Error: cannot take address of register variable `bx` --- */ typedef struct { int x, y; int z : 16; } S; void lvalue1(S a, S b, int c) { (c ? a : b).y = 1; (c ? a.z : b.z) = 2; (c ? (short)a.x : (short)b.x) = 3; register int ax; register int bx; *(c ? &ax : &bx) = 4; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice15816.d0000644000175000017500000000025415205374122020737 0ustar fabiofabio/* EXTRA_FILES: imports/a15816.d TEST_OUTPUT: --- fail_compilation/imports/a15816.d(3): Error: anonymous classes not allowed --- */ class A { import imports.a15816; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11562.d0000644000175000017500000000175215205374122021110 0ustar fabiofabio/* REQUIRED_ARGS: -o- TEST_OUTPUT: --- fail_compilation/fail11562.d(15): Error: cannot `goto` in or out of `finally` block fail_compilation/fail11562.d(36): Error: cannot `goto` in or out of `finally` block fail_compilation/fail11562.d(48): Error: cannot `goto` in or out of `finally` block fail_compilation/fail11562.d(63): Error: cannot `goto` in or out of `finally` block --- */ // Goto into finally block (forwards) int w(bool b) { if (b) goto label; try { } finally { label: {} } return 1; } // // Goto into finally block (backwards) int x(bool b) { try { } finally { label: {} } if (b) goto label; return 1; } // Goto out of finally block (forwards) int y(bool b) { try { } finally { if (b) goto label; } label: {} return 1; } // // Goto out of finally block (backwards) int z(bool b) { label: {} try { } finally { if (b) goto label; } return 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17602.d0000644000175000017500000000056015205374122021105 0ustar fabiofabio/* EXTRA_FILES: imports/imp17602.d TEST_OUTPUT: --- fail_compilation/fail17602.d(17): Error: cannot implicitly convert expression `Status.on` of type `imports.imp17602.Status` to `fail17602.Status` --- */ // https://issues.dlang.org/show_bug.cgi?id=17602 import imports.imp17602; enum Status { off } void main() { Status status = imports.imp17602.Status.on; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/parseStc4.d0000644000175000017500000000253415205374122021445 0ustar fabiofabio /* TEST_OUTPUT: --- fail_compilation/parseStc4.d(14): Error: redundant attribute `pure` fail_compilation/parseStc4.d(14): Error: redundant attribute `nothrow` fail_compilation/parseStc4.d(14): Error: conflicting attribute `@system` fail_compilation/parseStc4.d(14): Error: redundant attribute `@nogc` fail_compilation/parseStc4.d(14): Error: redundant attribute `@property` --- */ pure nothrow @safe @nogc @property int foo() pure nothrow @system @nogc @property { return 0; } /* TEST_OUTPUT: --- fail_compilation/parseStc4.d(35): Error: redundant attribute `const` fail_compilation/parseStc4.d(36): Error: redundant attribute `const` fail_compilation/parseStc4.d(36): Deprecation: `const` postblit is deprecated. Please use an unqualified postblit. fail_compilation/parseStc4.d(37): Error: redundant attribute `const` fail_compilation/parseStc4.d(39): Error: redundant attribute `pure` fail_compilation/parseStc4.d(40): Error: redundant attribute `@safe` fail_compilation/parseStc4.d(41): Error: redundant attribute `nothrow` fail_compilation/parseStc4.d(42): Error: conflicting attribute `@trusted` --- */ struct S { const this(int) const {} const this(this) const {} const ~this() const {} pure static this() pure {} @safe static ~this() @safe {} nothrow shared static this() nothrow {} @system shared static ~this() @trusted {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10630.d0000644000175000017500000000031715205374122021077 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10630.d(12): Error: cannot have `out` parameter of type `S` because the default construction is disabled --- */ struct S { @disable this(); } void foo(out S) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/gag4269f.d0000644000175000017500000000043115205374122021020 0ustar fabiofabio// REQUIRED_ARGS: -c -o- /* TEST_OUTPUT: --- fail_compilation/gag4269f.d(11): Error: undefined identifier `Y9`, did you mean interface `X9`? fail_compilation/gag4269f.d(11): Error: field `y` not allowed in interface --- */ static if(is(typeof(X9.init))) {} interface X9 { Y9 y; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test13536.d0000644000175000017500000000106415205374122021153 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test13536.d(22): Error: accessing overlapped field `U.sysDg` with pointers is not allowed in a `@safe` function fail_compilation/test13536.d(23): Error: accessing overlapped field `U.safeDg` with pointers is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=13536 struct S { void sysMethod() @system {} } void fun() @safe { union U { void delegate() @system sysDg; void delegate() @safe safeDg; } U u; S s; u.sysDg = &s.sysMethod; u.safeDg(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail273.d0000644000175000017500000000042615205374122020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail273.d(10): Error: alias `fail273.b` recursive alias declaration --- */ // https://issues.dlang.org/show_bug.cgi?id=1054 // regression: circular aliases cause compiler stack overflow alias a b; alias b a; b x; // ICE #1 a y; // ICE #2 ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail122.d0000644000175000017500000000041015205374122020724 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail122.d(12): Error: undefined identifier `y` --- */ // https://issues.dlang.org/show_bug.cgi?id=228 // Crash on inferring function literal return type after prior errors void main() { y = 2; auto x = function(){}; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22765.d0000644000175000017500000000053215205374122021156 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22765 /* TEST_OUTPUT: --- fail_compilation/test22765.d(14): Error: template instance `test22765.Template!null` internal compiler error: C++ `null` template value parameter is not supported --- */ template Template(T...) { extern(C++) const __gshared int Template = 0; } auto x = Template!(null); ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10089.d0000644000175000017500000000063315205374122021101 0ustar fabiofabio/* EXTRA_FILES: imports/diag10089a.d imports/diag10089b.d TEST_OUTPUT: --- fail_compilation/diag10089.d(16): Error: undefined identifier `chunks` in package `imports` fail_compilation/diag10089.d(18): Error: template `Foo()` does not have property `chunks` --- */ import imports.diag10089a, imports.diag10089b; template Foo() {} void main() { imports.chunks("abcdef", 2); Foo.chunks("abcdef", 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail205.d0000644000175000017500000000024315205374122020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail205.d(9): Error: shift assign by 65 is outside the range `0..63` --- */ void main() { long c; c <<= 65; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12635.d0000644000175000017500000000032615205374122021106 0ustar fabiofabio/* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/fail12635.d(13): Error: Cannot generate a segment prefix for a branching instruction --- */ void foo() { asm { L1: jmp DS:L1; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail16997.d0000644000175000017500000000555415205374122021135 0ustar fabiofabio/* REQUIRED_ARGS: -de -revert=intpromote TEST_OUTPUT: --- fail_compilation/fail16997.d(31): Deprecation: integral promotion not done for `~c`, remove '-revert=intpromote' switch or `~cast(int)(c)` fail_compilation/fail16997.d(32): Deprecation: integral promotion not done for `-c`, remove '-revert=intpromote' switch or `-cast(int)(c)` fail_compilation/fail16997.d(33): Deprecation: integral promotion not done for `+c`, remove '-revert=intpromote' switch or `+cast(int)(c)` fail_compilation/fail16997.d(36): Deprecation: integral promotion not done for `~w`, remove '-revert=intpromote' switch or `~cast(int)(w)` fail_compilation/fail16997.d(37): Deprecation: integral promotion not done for `-w`, remove '-revert=intpromote' switch or `-cast(int)(w)` fail_compilation/fail16997.d(38): Deprecation: integral promotion not done for `+w`, remove '-revert=intpromote' switch or `+cast(int)(w)` fail_compilation/fail16997.d(41): Deprecation: integral promotion not done for `~sb`, remove '-revert=intpromote' switch or `~cast(int)(sb)` fail_compilation/fail16997.d(42): Deprecation: integral promotion not done for `-sb`, remove '-revert=intpromote' switch or `-cast(int)(sb)` fail_compilation/fail16997.d(43): Deprecation: integral promotion not done for `+sb`, remove '-revert=intpromote' switch or `+cast(int)(sb)` fail_compilation/fail16997.d(46): Deprecation: integral promotion not done for `~ub`, remove '-revert=intpromote' switch or `~cast(int)(ub)` fail_compilation/fail16997.d(47): Deprecation: integral promotion not done for `-ub`, remove '-revert=intpromote' switch or `-cast(int)(ub)` fail_compilation/fail16997.d(48): Deprecation: integral promotion not done for `+ub`, remove '-revert=intpromote' switch or `+cast(int)(ub)` fail_compilation/fail16997.d(51): Deprecation: integral promotion not done for `~s`, remove '-revert=intpromote' switch or `~cast(int)(s)` fail_compilation/fail16997.d(52): Deprecation: integral promotion not done for `-s`, remove '-revert=intpromote' switch or `-cast(int)(s)` fail_compilation/fail16997.d(53): Deprecation: integral promotion not done for `+s`, remove '-revert=intpromote' switch or `+cast(int)(s)` fail_compilation/fail16997.d(56): Deprecation: integral promotion not done for `~us`, remove '-revert=intpromote' switch or `~cast(int)(us)` fail_compilation/fail16997.d(57): Deprecation: integral promotion not done for `-us`, remove '-revert=intpromote' switch or `-cast(int)(us)` fail_compilation/fail16997.d(58): Deprecation: integral promotion not done for `+us`, remove '-revert=intpromote' switch or `+cast(int)(us)` --- */ void test() { int x; char c; x = ~c; x = -c; x = +c; wchar w; x = ~w; x = -w; x = +w; byte sb; x = ~sb; x = -sb; x = +sb; ubyte ub; x = ~ub; x = -ub; x = +ub; short s; x = ~s; x = -s; x = +s; ushort us; x = ~us; x = -us; x = +us; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13187.d0000644000175000017500000000034415205374122021111 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail13187.d(12): Error: `pure` function `fail13187.test` cannot access mutable static data `my_func_ptr` --- */ int function(int) pure my_func_ptr; void test() pure { my_func_ptr(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16365.d0000644000175000017500000000126015205374122021154 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test16365.d(20): Error: taking address of member `f1` without `this` reference is not allowed in a `@safe` function fail_compilation/test16365.d(22): Error: cannot implicitly convert expression `&f2` of type `void delegate() pure nothrow @nogc @safe` to `void function() @safe` fail_compilation/test16365.d(27): Error: using `dg.funcptr` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=16365 struct S { void f1() @safe { } } void main() @safe { void function() @safe f; f = &S.f1; void f2() @safe { } f = &f2; void delegate() @safe dg; S s; dg = &s.f1; f = dg.funcptr; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail8032.d0000644000175000017500000000050515205374122021021 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail8032.d(19): Error: function `fail8032.B.f` cannot determine overridden function --- */ mixin template T() { void f() { } } class A { mixin T; mixin T; } class B : A { override void f() { } // raises "cannot determine overridden function" error. } void main(){} ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8044.d0000644000175000017500000000051715205374122021020 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8044.d(18): Error: template instance `diag8044.test!(Enum.Bar)` does not match template declaration `test(Enum en)()` with `en = Bar` must satisfy the following constraint: ` 0` --- */ enum Enum { Foo, Bar } void test(Enum en)() if(0) { } void main() { test!(Enum.Bar)(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22351.d0000644000175000017500000000152415205374122021103 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=22351 REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/fail22351.d(18): Deprecation: overriding `extern(C++)` function `fail22351.C22351.func(int*)` with `const` qualified function `fail22351.Fail22351.func(const(int*))` is deprecated fail_compilation/fail22351.d(18): Either remove `override`, or adjust the `const` qualifiers of the overriding function parameters fail_compilation/fail22351.d(19): Error: function `extern (C++) void fail22351.Fail22351.func(const(int*)**)` does not override any function, did you mean to override `extern (C++) void fail22351.C22351.func(int*)`? --- */ extern(C++) class C22351 { void func(int*) { } void func(int***) { } } extern(C++) final class Fail22351 : C22351 { override void func(const int*) { } override void func(const(int*)**) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue15103.d0000644000175000017500000000077415205374122021323 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/issue15103.d(22): Error: found `(` when expecting `;` or `=`, did you mean `Foo foo = 42`? fail_compilation/issue15103.d(23): Error: found `(` when expecting `;` or `=`, did you mean `Boo boo = 43`? fail_compilation/issue15103.d(24): Error: found `(` when expecting `;` or `=`, did you mean `string y = "a string"`? --- */ struct Foo { this(int x) {} } class Boo { this(int x) {} } void main () { Foo foo(42); Boo boo(43); string y("a string"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375q.d0000644000175000017500000000054215205374122021211 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375q.d(15): Error: else is dangling, add { } after condition at fail_compilation/fail4375q.d(11) --- */ void main() { auto x = 1; if (true) with (x) if (false) assert(90); else assert(91); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23552.d0000644000175000017500000000064715205374122021160 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23552 /* TEST_OUTPUT: --- fail_compilation/test23552.d(17): Error: cannot implicitly override base class method `test23552.Base.foo` with `test23552.Derived.foo`; add `override` attribute --- */ abstract class Base { void foo(); } class Derived : Base { void foo() { } int data() { return 0; } } class DerivedX : Derived { override int data() { return 1; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21008.d0000644000175000017500000000312615205374122021145 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test21008.d(110): Error: function `test21008.C.after` circular reference to class `C` fail_compilation/test21008.d(117): Error: calling non-static function `toString` requires an instance of type `Object` fail_compilation/test21008.d(117): Error: calling non-static function `toHash` requires an instance of type `Object` fail_compilation/test21008.d(117): Error: function `opCmp` is not callable using argument types `()` fail_compilation/test21008.d(117): too few arguments, expected 1, got 0 $p:/object.d$($n$): `object.Object.opCmp(Object o)` declared here fail_compilation/test21008.d(117): Error: function `opEquals` is not callable using argument types `()` fail_compilation/test21008.d(117): too few arguments, expected 1, got 0 $p:/object.d$($n$): `object.Object.opEquals(Object o)` declared here fail_compilation/test21008.d(117): Error: `Monitor` has no effect fail_compilation/test21008.d(117): Error: function `factory` is not callable using argument types `()` fail_compilation/test21008.d(117): too few arguments, expected 1, got 0 $p:/object.d$($n$): `object.Object.factory(string classname)` declared here fail_compilation/test21008.d(105): called from here: `handleMiddlewareAnnotation()` --- */ // https://issues.dlang.org/show_bug.cgi?id=21008 #line 100 class Base { bool after(); mixin(handleMiddlewareAnnotation); } class C : Base { override bool after(); } string handleMiddlewareAnnotation() { foreach (member; __traits(allMembers, C)) { __traits(getMember, C, member); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag2452.d0000644000175000017500000000035615205374122021016 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag2452.d(14): Error: class `diag2452.C` interface function `void f(float p)` is not implemented --- */ interface I { void f(int p); void f(float p); } class C : I { void f(int p) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9338.d0000644000175000017500000000057115205374122020663 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9338.d(13): Error: value of `this` is not known at compile time fail_compilation/ice9338.d(14): Error: value of `this` is not known at compile time --- */ class Foo { void test() { enum members1 = makeArray(); enum members2 = this.makeArray(); } string[] makeArray() { return ["a"]; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8892.d0000644000175000017500000000033115205374122021025 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8892.d(14): Error: cannot implicitly convert expression `['A']` of type `char[]` to `char[2]` --- */ struct Foo { char[2] data; } void main() { auto f = Foo(['A']); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/deprecatedTemplates.d0000644000175000017500000000211715205374122023551 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: ---- fail_compilation/deprecatedTemplates.d(103): Deprecation: template `deprecatedTemplates.AliasSeq(V...)` is deprecated fail_compilation/deprecatedTemplates.d(107): Deprecation: struct `deprecatedTemplates.S1(V...)` is deprecated fail_compilation/deprecatedTemplates.d(115): Deprecation: template `deprecatedTemplates.C(V...)` is deprecated ---- */ #line 100 deprecated alias AliasSeq(V...) = V; alias x = AliasSeq!(1, 2, 3); deprecated struct S1(V...) {} alias T1 = S1!(); deprecated template C(V...) { int i; int j; } alias D = C!(); /* TEST_OUTPUT: ---- fail_compilation/deprecatedTemplates.d(202): Deprecation: template `deprecatedTemplates.AliasSeqMsg(V...)` is deprecated - Reason ---- */ #line 200 deprecated("Reason") alias AliasSeqMsg(V...) = V; alias xMsg = AliasSeqMsg!(1, 2, 3); deprecated struct DS() { S1!() s; } deprecated struct DS2() { static struct DS3() { S1!() s; } static struct DS4 { S1!() s; } } deprecated void foo() { DS!() d1; DS2!().DS3!() d2; DS2!().DS4 d3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue3396.d0000644000175000017500000000056215205374122021251 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/issue3396.d(17): Error: call to unimplemented abstract function `void M()` fail_compilation/issue3396.d(17): declared here: fail_compilation/issue3396.d(12) --- */ module issue3396; abstract class A { abstract void M(); } class B:A { override void M(){ super.M(); } } void test() { auto b=new B(); b.M(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7424i.d0000644000175000017500000000033015205374122021172 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7424i.d(10): Error: template `this.g()() immutable` has no value --- */ struct S7424g { @property int g()() immutable { return 0; } void test() inout { int f = g; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/misc_parser_err_cov1.d0000644000175000017500000000551415205374122023705 0ustar fabiofabio/* REQUIRED_ARGS: -verrors=0 TEST_OUTPUT: --- fail_compilation/misc_parser_err_cov1.d(29): Error: basic type expected, not `)` fail_compilation/misc_parser_err_cov1.d(30): Error: basic type expected, not `)` fail_compilation/misc_parser_err_cov1.d(31): Error: `__traits(identifier, args...)` expected fail_compilation/misc_parser_err_cov1.d(31): Error: semicolon expected following auto declaration, not `o` fail_compilation/misc_parser_err_cov1.d(31): Error: expression expected, not `)` fail_compilation/misc_parser_err_cov1.d(32): Error: expected `(` following `is`, not `;` fail_compilation/misc_parser_err_cov1.d(33): Error: semicolon expected following auto declaration, not `auto` fail_compilation/misc_parser_err_cov1.d(33): Error: found `+` when expecting `(` following `mixin` fail_compilation/misc_parser_err_cov1.d(35): Error: `key:value` expected for associative array literal fail_compilation/misc_parser_err_cov1.d(36): Error: basic type expected, not `;` fail_compilation/misc_parser_err_cov1.d(36): Error: `{ members }` expected for anonymous class fail_compilation/misc_parser_err_cov1.d(38): Error: template argument expected following `!` fail_compilation/misc_parser_err_cov1.d(38): Error: missing closing `)` after `if (parseShift!()` fail_compilation/misc_parser_err_cov1.d(38): Error: found `)` when expecting `(` fail_compilation/misc_parser_err_cov1.d(39): Error: missing closing `)` after `if (` fail_compilation/misc_parser_err_cov1.d(39): Error: identifier expected following `immutable(int).`, not `+` fail_compilation/misc_parser_err_cov1.d(39): Error: expression expected, not `;` fail_compilation/misc_parser_err_cov1.d(40): Error: semicolon expected following auto declaration, not `auto` fail_compilation/misc_parser_err_cov1.d(40): Error: identifier or `new` expected following `.`, not `+` fail_compilation/misc_parser_err_cov1.d(41): Error: identifier or new keyword expected following `(...)`. fail_compilation/misc_parser_err_cov1.d(41): Error: expression expected, not `;` fail_compilation/misc_parser_err_cov1.d(42): Error: found `}` when expecting `;` following expression fail_compilation/misc_parser_err_cov1.d(41): expression: `(__error) + (__error)` fail_compilation/misc_parser_err_cov1.d(43): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/misc_parser_err_cov1.d(33): unmatched `{` --- */ module misc_parser_err_cov1; //https://issues.dlang.org/show_bug.cgi?id=19995 #line 29 void foo(in); void bar(int, const @tation); void main() { // cover errors from line 7930 to EOF #line 31 auto tt = __traits( 1 ? fact(n - 1) : 0; } void main() { fact(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail8168.d0000644000175000017500000000026215205374122021033 0ustar fabiofabio/* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/fail8168.d(9): Error: unknown opcode `unknown` --- */ void main() { asm { unknown; // wrong opcode } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9572.d0000644000175000017500000000027415205374122021036 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9572.d(10): Error: index type `ubyte` cannot cover index range 0..300 --- */ void main() { int[300] data; foreach (ubyte i, x; data) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14669.d0000644000175000017500000000243715205374122021124 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail14669.d(11): Error: `auto` can only be used as part of `auto ref` for template function parameters fail_compilation/fail14669.d(16): Error: template instance `fail14669.foo1!()` error instantiating fail_compilation/fail14669.d(12): Error: `auto` can only be used as part of `auto ref` for template function parameters fail_compilation/fail14669.d(17): Error: template `foo2` is not callable using argument types `!()(int)` fail_compilation/fail14669.d(12): Candidate is: `foo2()(auto int a)` --- */ void foo1()(auto int a) {} void foo2()(auto int a) {} void test1() { alias f1 = foo1!(); foo2(1); } /* TEST_OUTPUT: --- fail_compilation/fail14669.d(29): Error: cannot explicitly instantiate template function with `auto ref` parameter fail_compilation/fail14669.d(38): Error: template instance `fail14669.bar1!int` error instantiating fail_compilation/fail14669.d(30): Error: cannot explicitly instantiate template function with `auto ref` parameter fail_compilation/fail14669.d(40): Error: template instance `fail14669.bar2!int` error instantiating --- */ void bar1(T)(auto ref T x) {} void bar2(T)(auto ref T x) {} void test2() { int n; bar1(1); bar1(n); alias b1 = bar1!(int); alias b2 = bar2!(int); bar2(n); bar2(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21508.d0000644000175000017500000000066215205374122021110 0ustar fabiofabio/* REQUIRED_ARGS: -Ifail_compilation/imports/ EXTRA_FILES: imports/import21508.d TEST_OUTPUT: --- fail_compilation/fail21508.d(17): Error: import `fail21508.import21508` is used as a type --- */ import import21508; // import21508 is a private class, code should not compile // The compiler used to "helpfully" look inside the import, // bypassing the shadowing that this introduces. void main () { auto c = new import21508(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21740d.i0000644000175000017500000000160315205374122021253 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail21740d.i(12): Error: Bidirectional control characters in universal character names are disallowed for security reasons fail_compilation/fail21740d.i(13): Error: Bidirectional control characters in universal character names are disallowed for security reasons fail_compilation/fail21740d.i(14): Error: Bidirectional control characters in universal character names are disallowed for security reasons fail_compilation/fail21740d.i(14): Error: character 0x200e is not allowed as a start character in an identifier fail_compilation/fail21740d.i(15): Error: Bidirectional control characters in universal character names are disallowed for security reasons fail_compilation/fail21740d.i(16): Error: Bidirectional control characters in universal character names are disallowed for security reasons --- */ int \u061c; int \u061C; int \u200e; int \u202a; int \u2066; ./ldc-1.42.0-src/tests/dmd/fail_compilation/trait_loc_err.d0000644000175000017500000000105515205374122022422 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/trait_loc_err.d(14): Error: can only get the location of a symbol, not `trait_loc_err` fail_compilation/trait_loc_err.d(15): Error: can only get the location of a symbol, not `core.stdc` fail_compilation/trait_loc_err.d(16): Error: can only get the location of a symbol, not `core.stdc.stdio` --- */ module trait_loc_err; import core.stdc.stdio; void main() { __traits(getLocation, __traits(parent, main)); __traits(getLocation, __traits(parent, core.stdc.stdio)); __traits(getLocation, core.stdc.stdio); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7851.d0000644000175000017500000000152015205374122021027 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=7851 /* TEST_OUTPUT: --- fail_compilation/fail7851.d(38): Error: accessing non-static variable `__mem_field_0` requires an instance of `Tuple` fail_compilation/fail7851.d(38): Error: accessing non-static variable `__mem_field_1` requires an instance of `Tuple` fail_compilation/fail7851.d(38): Error: accessing non-static variable `__mem_field_2` requires an instance of `Tuple` --- */ template TypeTuple(TList...) { alias TList TypeTuple; } struct Tuple(Specs...) { TypeTuple!(int, long, float) mem; alias Identity!(mem[0]) _0; alias Identity!(mem[1]) _1; alias Identity!(mem[2]) _2; alias mem this; enum length = mem.length; } private template Identity(alias T) { alias T Identity; } void main() { alias Tuple!(int, long, float) TL; foreach (i; TL) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23905.d0000644000175000017500000000054315205374122021155 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23905 /* TEST_OUTPUT: --- fail_compilation/test23905.d(24): Error: enum `test23905.Foo` is opaque and has no default initializer --- */ struct SumType(T) { T storage; bool opEquals(Rhs)(Rhs rhs) if (is(typeof(Rhs.init))) { } } enum Foo; void main(){ SumType!Foo data = Foo.init; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9540.d0000644000175000017500000000161115205374122020652 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/ice9540.d(36): Error: function `dg` is not callable using argument types `()` fail_compilation/ice9540.d(36): too few arguments, expected 1, got 0 fail_compilation/ice9540.d(33): `ice9540.A.test.AddFront!(this, f).AddFront.dg(int __param_0)` declared here fail_compilation/ice9540.d(27): Error: template instance `ice9540.A.test.AddFront!(this, f)` error instantiating ---- */ template Tuple(E...) { alias E Tuple; } alias Tuple!(int) Args; void main() { (new A).test (); } void test1 (int delegate (int) f) { f (-2); } class A { int f (int a) { return a; } void test () { test1 (&AddFront!(this, f)); } } template AddFront (alias ctx, alias fun) { auto AddFront(Args args) { auto dg (Args dgArgs) { return fun (dgArgs); } dg.ptr = ctx; return dg(args); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/testhtml2.html0000644000175000017500000000147315205374122022245 0ustar fabiofabio dstress: html_line_ending_mac

// __DSTRESS_TORTURE_BLOCK__ -release
 int main(){
	try{
		assert(0);
	}catch(Throwable e){
		checkLineNumber(e);
		return 0;
	}
	assert(-1, "b");
	return 1;
}

/*
 * @WARNING@ this code depends on the phobos implementation.
 * char[]s returned by wrong assertions have to look like:
 *	 "blah blah (linenumber) blah blah"
 */
void checkLineNumber(Object o){
	string x=o.toString();

	int start;
	for(start=0; start<x.length; start++){if(x[start]=='('){break;}}

	int end;
	for(end=start+1; end<x.length; end++){if(x[end]==')'){break;}}

	assert(end-start==3);
	assert(x[start+1 .. end]=="10", x[start+1 .. end]);
}
	
./ldc-1.42.0-src/tests/dmd/fail_compilation/test22759.c0000644000175000017500000000064415205374122021164 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test22759.c(108): Error: cannot modify `const` expression `*p` fail_compilation/test22759.c(111): Error: cannot modify `const` expression `r` --- */ // https://issues.dlang.org/show_bug.cgi?id=22759 #line 100 void test() { int *const q; *q = 3; q = 0; const int *p; *p = 3; // 108 const int *const r; r = 0; // 111 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22048.d0000644000175000017500000000025715205374122021154 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22048 /* TEST_OUTPUT: --- fail_compilation/test22048.d(10): Error: unexpected identifier `p` after `int` --- */ alias a = int p; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22729.d0000644000175000017500000000107615205374122021116 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22729 /* TEST_OUTPUT: --- fail_compilation/fail22729.d(12): Error: field `getChildAtPosition` not allowed in interface --- */ interface ContainerFunctionSetI { Tuple!(WidgetI) getChildAtPosition; } interface WidgetI : ContainerFunctionSetI { } class Form : WidgetI { } template Tuple(Specs) { auto areCompatibleTuples(Tup2)(Tuple tup1, Tup2 tup2) { tup1.field == tup2; } struct Tuple { Specs field; bool opEquals(R)(R) if (areCompatibleTuples!R) { } } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag11819a.d0000644000175000017500000000565015205374122021250 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag11819a.d(30): Error: unrecognized trait `DoesNotExist` fail_compilation/diag11819a.d(31): Error: unrecognized trait `IsAbstractClass`, did you mean `isAbstractClass`? fail_compilation/diag11819a.d(32): Error: unrecognized trait `IsArithmetic`, did you mean `isArithmetic`? fail_compilation/diag11819a.d(33): Error: unrecognized trait `IsAssociativeArray`, did you mean `isAssociativeArray`? fail_compilation/diag11819a.d(34): Error: unrecognized trait `IsFinalClass`, did you mean `isFinalClass`? fail_compilation/diag11819a.d(35): Error: unrecognized trait `IsPOD`, did you mean `isPOD`? fail_compilation/diag11819a.d(36): Error: unrecognized trait `IsNested`, did you mean `isNested`? fail_compilation/diag11819a.d(37): Error: unrecognized trait `IsFloating`, did you mean `isFloating`? fail_compilation/diag11819a.d(38): Error: unrecognized trait `IsIntegral`, did you mean `isIntegral`? fail_compilation/diag11819a.d(39): Error: unrecognized trait `IsScalar`, did you mean `isScalar`? fail_compilation/diag11819a.d(40): Error: unrecognized trait `IsStaticArray`, did you mean `isStaticArray`? fail_compilation/diag11819a.d(41): Error: unrecognized trait `IsUnsigned`, did you mean `isUnsigned`? fail_compilation/diag11819a.d(42): Error: unrecognized trait `IsVirtualFunction`, did you mean `isVirtualFunction`? fail_compilation/diag11819a.d(43): Error: unrecognized trait `IsVirtualMethod`, did you mean `isVirtualMethod`? fail_compilation/diag11819a.d(44): Error: unrecognized trait `IsAbstractFunction`, did you mean `isAbstractFunction`? fail_compilation/diag11819a.d(45): Error: unrecognized trait `IsFinalFunction`, did you mean `isFinalFunction`? fail_compilation/diag11819a.d(46): Error: unrecognized trait `IsOverrideFunction`, did you mean `isOverrideFunction`? fail_compilation/diag11819a.d(47): Error: unrecognized trait `IsStaticFunction`, did you mean `isStaticFunction`? fail_compilation/diag11819a.d(48): Error: unrecognized trait `IsRef`, did you mean `isRef`? fail_compilation/diag11819a.d(49): Error: unrecognized trait `IsOut`, did you mean `isOut`? fail_compilation/diag11819a.d(50): Error: unrecognized trait `IsLazy`, did you mean `isLazy`? --- */ void main() { if (__traits(DoesNotExist)) { } if (__traits(IsAbstractClass)) { } if (__traits(IsArithmetic)) { } if (__traits(IsAssociativeArray)) { } if (__traits(IsFinalClass)) { } if (__traits(IsPOD)) { } if (__traits(IsNested)) { } if (__traits(IsFloating)) { } if (__traits(IsIntegral)) { } if (__traits(IsScalar)) { } if (__traits(IsStaticArray)) { } if (__traits(IsUnsigned)) { } if (__traits(IsVirtualFunction)) { } if (__traits(IsVirtualMethod)) { } if (__traits(IsAbstractFunction)) { } if (__traits(IsFinalFunction)) { } if (__traits(IsOverrideFunction)) { } if (__traits(IsStaticFunction)) { } if (__traits(IsRef)) { } if (__traits(IsOut)) { } if (__traits(IsLazy)) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18484.d0000644000175000017500000000075715205374122021172 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test18484.d(19): Error: returning `x.bar()` escapes a reference to local variable `x` fail_compilation/test18484.d(24): Error: escaping reference to stack allocated value returned by `S(0)` --- */ // https://issues.dlang.org/show_bug.cgi?id=18484 struct S { int* bar() @safe return; int i; } int* test1() @safe { auto x = S(); return x.bar(); // error } int* test2() @safe { return S().bar(); // error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail120.d0000644000175000017500000000054315205374122020731 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail120.d(12): Error: accessing non-static variable `nodes` requires an instance of `Foo` fail_compilation/fail120.d(13): Error: accessing non-static variable `nodes` requires an instance of `Foo` --- */ class Foo { int[2] nodes; auto left = (){ return nodes[0]; }; auto right = (){ return nodes[1]; }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7862.d0000644000175000017500000000120415205374122021030 0ustar fabiofabio/* TEST_OUTPUT: --- A: false A: false fail_compilation/fail7862.d(26): Error: template instance `nonExistent!()` template `nonExistent` is not defined fail_compilation/fail7862.d(25): Error: template instance `fail7862.B!(A)` error instantiating --- */ // https://issues.dlang.org/show_bug.cgi?id=7862 template B(T) { mixin( { foreach (name; __traits(derivedMembers, T)) {} return "struct B {}"; }() ); } struct A { pragma(msg, "A: " ~ (__traits(compiles, B!A) ? "true" : "false")); pragma(msg, "A: " ~ (__traits(compiles, B!A) ? "true" : "false")); B!A c; static if (nonExistent!()) {} } auto d = A.init.c; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19912b.d0000644000175000017500000000031715205374122021255 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19912b.d(7): Error: class `fail19912b.object` conflicts with import `fail19912b.object` at fail_compilation/fail19912b.d --- */ class object { } void fun(string) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix20867.d0000644000175000017500000000055115205374122020767 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix20867.d(14): Error: cannot use `final switch` on enum `E` while it is being defined --- */ // Test case from Issue #20867 enum E { a = 3, b = () { E e; final switch (e) // This should error out instead of segfaulting { case E.a: break; } return 4; } () } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail241.d0000644000175000017500000000114115205374122020730 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail241.d(18): Error: mutable method `fail241.Foo.f` is not callable using a `const` object fail_compilation/fail241.d(13): Consider adding `const` or `inout` here fail_compilation/fail241.d(19): Error: mutable method `fail241.Foo.g` is not callable using a `const` object fail_compilation/fail241.d(14): Consider adding `const` or `inout` here --- */ class Foo { public void f() { } private void g() { } invariant() { f(); // error, cannot call public member function from invariant g(); // ok, g() is not public } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/lexer3.d0000644000175000017500000000041115205374122020767 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/lexer3.d(9): Error: unterminated token string constant starting at fail_compilation/lexer3.d(9) fail_compilation/lexer3.d(10): Error: semicolon expected following auto declaration, not `End of File` --- */ static s1 = q{ asef; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_opover.d0000644000175000017500000000663115205374122022104 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/fail_opover.d(39): Error: no `[]` operator overload for type `object.Object` $p:object.d$($n$): perhaps define `auto opIndex() {}` for `object.Object` fail_compilation/fail_opover.d(43): Error: no `[]` operator overload for type `TestS` fail_compilation/fail_opover.d(41): perhaps define `auto opIndex() {}` for `fail_opover.test1.TestS` fail_compilation/fail_opover.d(55): Error: no `[]` operator overload for type `S` fail_compilation/fail_opover.d(48): perhaps define `auto opIndex() {}` for `fail_opover.test2.S` fail_compilation/fail_opover.d(56): Error: no `[]` operator overload for type `S` fail_compilation/fail_opover.d(48): perhaps define `auto opIndex(int) {}` for `fail_opover.test2.S` fail_compilation/fail_opover.d(57): Error: no `[1..2]` operator overload for type `S` fail_compilation/fail_opover.d(48): perhaps define `auto opSlice(int lower, int upper) {}` for `fail_opover.test2.S` fail_compilation/fail_opover.d(58): Error: no `[]` operator overload for type `S` fail_compilation/fail_opover.d(48): perhaps define `auto opIndex() {}` for `fail_opover.test2.S` fail_compilation/fail_opover.d(59): Error: no `[]` operator overload for type `S` fail_compilation/fail_opover.d(48): perhaps define `auto opIndex(int) {}` for `fail_opover.test2.S` fail_compilation/fail_opover.d(60): Error: no `[1..2]` operator overload for type `S` fail_compilation/fail_opover.d(48): perhaps define `auto opSlice(int lower, int upper) {}` for `fail_opover.test2.S` fail_compilation/fail_opover.d(61): Error: no `[]` operator overload for type `S` fail_compilation/fail_opover.d(48): perhaps define `auto opIndex() {}` for `fail_opover.test2.S` fail_compilation/fail_opover.d(62): Error: no `[]` operator overload for type `S` fail_compilation/fail_opover.d(48): perhaps define `auto opIndex(int) {}` for `fail_opover.test2.S` fail_compilation/fail_opover.d(63): Error: no `[1..2]` operator overload for type `S` fail_compilation/fail_opover.d(48): perhaps define `auto opSlice(int lower, int upper) {}` for `fail_opover.test2.S` fail_compilation/fail_opover.d(64): Error: no `[]` operator overload for type `S` fail_compilation/fail_opover.d(48): perhaps define `auto opIndex() {}` for `fail_opover.test2.S` fail_compilation/fail_opover.d(65): Error: no `[]` operator overload for type `S` fail_compilation/fail_opover.d(48): perhaps define `auto opIndex(int) {}` for `fail_opover.test2.S` fail_compilation/fail_opover.d(66): Error: no `[1..2]` operator overload for type `S` fail_compilation/fail_opover.d(48): perhaps define `auto opSlice(int lower, int upper) {}` for `fail_opover.test2.S` --- */ void test1() { Object m; m[] = error; struct TestS {} TestS s; s[] = error; } void test2() { struct S { void func(int) {} alias func this; } S s; // The errors failing aliasthis access need to be gagged for better error messages. s[]; // in ArrayExp::op_overload() s[1]; // ditto s[1..2]; // ditto +s[]; // in UnaExp::op_overload() +s[1]; // ditto +s[1..2]; // ditto s[] = 3; // in AssignExp::semantic() s[1] = 3; // ditto s[1..2] = 3; // ditto s[] += 3; // in BinAssignExp::op_overload() s[1] += 3; // ditto s[1..2] += 3; // ditto } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14406.d0000644000175000017500000000076515205374122021113 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail14406.d-mixin-20(20): Error: cannot declare field `bar_obj` because it will change the determined size of `CFrop` fail_compilation/fail14406.d-mixin-25(25): Error: field `bar_obj` not allowed in interface --- */ class Foo {} string strMixin(T)() { static if (T.tupleof.length) {} return "Bar bar_obj; static class Bar { Foo foo; }"; } class CFrop { mixin(strMixin!(typeof(this))); } interface IFrop { mixin(strMixin!(typeof(this))); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/deprecate12979c.d0000644000175000017500000000037515205374122022311 0ustar fabiofabio// REQUIRED_ARGS: -de /* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/deprecate12979c.d(12): Error: `asm` statement is assumed to use the GC - mark it with `@nogc` if it does not --- */ void foo() @nogc { asm { ret; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9439.d0000644000175000017500000000075715205374122020673 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9439.d(12): Error: calling non-static function `foo` requires an instance of type `Derived` fail_compilation/ice9439.d(12): while evaluating: `static assert(foo())` fail_compilation/ice9439.d(19): Error: template instance `ice9439.Base.boo!(foo)` error instantiating --- */ class Base { void boo(alias F)() { static assert(F()); } } class Derived : Base { int foo() { return 1; } void bug() { boo!(foo)(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/pragma2.c0000644000175000017500000000117415205374122021124 0ustar fabiofabio/* REQUIRED_ARGS: -w TEST_OUTPUT: --- fail_compilation/pragma2.c(101): Warning: current pack attribute is default fail_compilation/pragma2.c(102): Error: left parenthesis expected to follow `#pragma pack` fail_compilation/pragma2.c(103): Error: right parenthesis expected to close `#pragma pack(` fail_compilation/pragma2.c(104): Error: unrecognized `#pragma pack(&)` fail_compilation/pragma2.c(106): Error: identifier or alignment value expected following `#pragma pack(pop,` not `"foo"` --- */ #line 100 #pragma pack(show) #pragma pack #pragma pack(pop,a,b,4,8,c #pragma pack(&) #pragma pack() ;a #pragma pack (pop, "foo"); int x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14424.d0000644000175000017500000000041015205374122020723 0ustar fabiofabio// REQUIRED_ARGS: -o- -unittest // EXTRA_FILES: imports/a14424.d /* TEST_OUTPUT: --- fail_compilation/ice14424.d(13): Error: `AliasSeq!(__unittest_L3_C1)` has no effect --- */ void main() { import imports.a14424; __traits(getUnitTests, imports.a14424); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/reg6769.d0000644000175000017500000000173715205374122020712 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/reg6769.d(14): Error: reinterpreting cast from `int[]` to `int[7]*` is not supported in CTFE fail_compilation/reg6769.d(27): called from here: `reg6769a([0, 1, 2, 3, 4, 5, 6])` fail_compilation/reg6769.d(27): while evaluating: `static assert(reg6769a([0, 1, 2, 3, 4, 5, 6]) == 1)` fail_compilation/reg6769.d(20): Error: reinterpreting cast from `int[7]` to `int[]*` is not supported in CTFE fail_compilation/reg6769.d(28): called from here: `reg6769b([0, 1, 2, 3, 4, 5, 6])` fail_compilation/reg6769.d(28): while evaluating: `static assert(reg6769b([0, 1, 2, 3, 4, 5, 6]) == 1)` --- */ int reg6769a(int[] a) { int[7]* b = cast(int[7]*)&a; return (*b)[1]; } int reg6769b(int[7] a) { int[]* b = cast(int[]*)&a; return (*b)[1]; } void main() { // Both should never succeed, run-time would raise a SEGV. static assert(reg6769a([0,1,2,3,4,5,6]) == 1); static assert(reg6769b([0,1,2,3,4,5,6]) == 1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail259.d0000644000175000017500000000025715205374122020750 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail259.d(11): Error: function `fail259.C.foo` does not override any function --- */ class C { final override void foo(){} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12744.d0000644000175000017500000000632415205374122021113 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail12744.d(38): Error: incompatible parameter storage classes `ref` and `out` fail_compilation/fail12744.d(52): Error: template instance `fail12744.bar12744R!(foo12744O)` error instantiating fail_compilation/fail12744.d(38): Error: incompatible parameter storage classes `ref` and `lazy` fail_compilation/fail12744.d(53): Error: template instance `fail12744.bar12744R!(foo12744L)` error instantiating fail_compilation/fail12744.d(39): Error: incompatible parameter storage classes `out` and `ref` fail_compilation/fail12744.d(56): Error: template instance `fail12744.bar12744O!(foo12744R)` error instantiating fail_compilation/fail12744.d(39): Error: incompatible parameter storage classes `out` and `lazy` fail_compilation/fail12744.d(58): Error: template instance `fail12744.bar12744O!(foo12744L)` error instantiating fail_compilation/fail12744.d(40): Error: incompatible parameter storage classes `lazy` and `ref` fail_compilation/fail12744.d(61): Error: template instance `fail12744.bar12744L!(foo12744R)` error instantiating fail_compilation/fail12744.d(40): Error: incompatible parameter storage classes `lazy` and `out` fail_compilation/fail12744.d(62): Error: template instance `fail12744.bar12744L!(foo12744O)` error instantiating fail_compilation/fail12744.d(41): Error: incompatible parameter storage classes `auto ref` and `out` fail_compilation/fail12744.d(67): Error: template `bar12744A` is not callable using argument types `!(foo12744O)(int)` fail_compilation/fail12744.d(41): Candidate is: `bar12744A(alias f)(auto ref PTT12744!f args)` fail_compilation/fail12744.d(41): Error: incompatible parameter storage classes `auto ref` and `lazy` fail_compilation/fail12744.d(68): Error: template `bar12744A` is not callable using argument types `!(foo12744L)(int)` fail_compilation/fail12744.d(41): Candidate is: `bar12744A(alias f)(auto ref PTT12744!f args)` --- */ template PTT12744(func...) { static if (is(typeof(func[0]) P == function)) alias PTT12744 = P; else static assert(0); } void foo12744N( int x) {} void foo12744R( ref int x) {} void foo12744O( out int x) {} void foo12744L(lazy int x) {} void bar12744N(alias f)( PTT12744!f args) {} void bar12744R(alias f)( ref PTT12744!f args) {} void bar12744O(alias f)( out PTT12744!f args) {} void bar12744L(alias f)( lazy PTT12744!f args) {} void bar12744A(alias f)(auto ref PTT12744!f args) {} void main() { alias bNN = bar12744N!foo12744N; alias bNR = bar12744N!foo12744R; alias bNO = bar12744N!foo12744O; alias bNL = bar12744N!foo12744L; alias bRN = bar12744R!foo12744N; alias bRR = bar12744R!foo12744R; alias bRO = bar12744R!foo12744O; // error alias bRL = bar12744R!foo12744L; // error alias bON = bar12744O!foo12744N; alias bOR = bar12744O!foo12744R; // error alias bOO = bar12744O!foo12744O; alias bOL = bar12744O!foo12744L; // error alias bLN = bar12744L!foo12744N; alias bLR = bar12744L!foo12744R; // error alias bLO = bar12744L!foo12744O; // error alias bLL = bar12744L!foo12744L; bar12744A!foo12744N(1); bar12744A!foo12744R(1); bar12744A!foo12744O(1); // error bar12744A!foo12744L(1); // error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ctfe10995.d0000644000175000017500000000054715205374122021130 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ctfe10995.d(19): Error: cannot read uninitialized variable `a` in CTFE fail_compilation/ctfe10995.d(25): Error: cannot read uninitialized variable `a` in CTFE --- */ struct T { short a = void; } T foo() { auto t = T.init; return t; } enum i = foo().a; struct T2 { short a = void; } enum i2 = T2.init.a; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23968.d0000644000175000017500000000046715205374122021173 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23968 // REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/test23968.d(22): Deprecation: alias `test23968.a` is deprecated --- */ int fun()(int) { return 0; } deprecated alias a = fun; void main() { int v; int y = v.a!(); // No deprecation? } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag11425.d0000644000175000017500000000035515205374122021075 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag11425.d(14): Error: variable `x` is shadowing variable `diag11425.main.x` fail_compilation/diag11425.d(11): declared here --- */ void main() { int x; { int x = 1; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20998.d0000644000175000017500000001004315205374122021162 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20998 /* REQUIRED_ARGS: -verrors=context TEST_OUTPUT: --- fail_compilation/test20998.d(76): Error: undefined identifier `invalid` X x = { invalid, 2, "asd" }; ^ fail_compilation/test20998.d(76): Error: too many initializers for `X` with 2 fields X x = { invalid, 2, "asd" }; ^ fail_compilation/test20998.d(83): Error: cannot implicitly convert expression `"a"` of type `string` to `int` X2 x2 = { ptr: null, "a", ptr: 2, 444 }; ^ fail_compilation/test20998.d(83): Error: duplicate initializer for field `ptr` X2 x2 = { ptr: null, "a", ptr: 2, 444 }; ^ fail_compilation/test20998.d(83): Error: too many initializers for `X2` with 3 fields X2 x2 = { ptr: null, "a", ptr: 2, 444 }; ^ fail_compilation/test20998.d(90): Error: overlapping initialization for field `ptr` and `x` X3 x3 = { ptr: null, "a", ptr: 2, 444 }; ^ fail_compilation/test20998.d(90): Error: cannot implicitly convert expression `"a"` of type `string` to `int` X3 x3 = { ptr: null, "a", ptr: 2, 444 }; ^ fail_compilation/test20998.d(90): Error: duplicate initializer for field `ptr` X3 x3 = { ptr: null, "a", ptr: 2, 444 }; ^ fail_compilation/test20998.d(90): Error: too many initializers for `X3` with 3 fields X3 x3 = { ptr: null, "a", ptr: 2, 444 }; ^ fail_compilation/test20998.d(98): Error: field `X4.ptr` assigning to misaligned pointers is not allowed in a `@safe` function X4 x4 = { ptr: null, "a", 444, ptr: 2, true }; ^ fail_compilation/test20998.d(98): Error: cannot implicitly convert expression `"a"` of type `string` to `int` X4 x4 = { ptr: null, "a", 444, ptr: 2, true }; ^ fail_compilation/test20998.d(98): Error: too many initializers for `X4` with 2 fields X4 x4 = { ptr: null, "a", 444, ptr: 2, true }; ^ fail_compilation/test20998.d(102): called from here: `test()` auto e = test(); ^ fail_compilation/test20998.d(104): Error: cannot implicitly convert expression `1` of type `int` to `void*` X2 a5 = { ptr: 1, ptr: 2, ptr: 444, ptr: 555 }; ^ fail_compilation/test20998.d(104): Error: duplicate initializer for field `ptr` X2 a5 = { ptr: 1, ptr: 2, ptr: 444, ptr: 555 }; ^ fail_compilation/test20998.d(104): Error: duplicate initializer for field `ptr` X2 a5 = { ptr: 1, ptr: 2, ptr: 444, ptr: 555 }; ^ fail_compilation/test20998.d(104): Error: too many initializers for `X2` with 3 fields X2 a5 = { ptr: 1, ptr: 2, ptr: 444, ptr: 555 }; ^ fail_compilation/test20998.d(107): Error: too many initializers for `X2` with 3 fields X2 c6 = { null, 2, true, null }; ^ fail_compilation/test20998.d(116): Error: cannot implicitly convert expression `1` of type `int` to `immutable(char*)` immutable Struct iStruct = {1, &ch}; ^ fail_compilation/test20998.d(116): Error: too many initializers for `Struct` with 1 field immutable Struct iStruct = {1, &ch}; ^ fail_compilation/test20998.d(120): called from here: `test2()` auto t = test2(); ^ --- */ struct X { void* ptr; int x; } X x = { invalid, 2, "asd" }; struct X2 { void* ptr; int x; bool y; } X2 x2 = { ptr: null, "a", ptr: 2, 444 }; union X3 { void* ptr; int x; bool y; } X3 x3 = { ptr: null, "a", ptr: 2, 444 }; int test() @safe { align (1) struct X4 { void* ptr; int x; } X4 x4 = { ptr: null, "a", 444, ptr: 2, true }; return 0; } auto e = test(); X2 a5 = { ptr: 1, ptr: 2, ptr: 444, ptr: 555 }; X2 b5 = { ptr: null, y: true }; X2 c5 = { x: 2, true, ptr: null }; X2 c6 = { null, 2, true, null }; struct Struct { char* chptr; } int test2() { char ch = 'd'; immutable Struct iStruct = {1, &ch}; return 0; } auto t = test2(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/traits_parameters.d0000644000175000017500000000050315205374122023320 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/traits_parameters.d(9): Error: `__traits(parameters)` cannot have arguments, but `234` was supplied fail_compilation/traits_parameters.d(10): Error: `__traits(parameters)` may only be used inside a function --- */ typeof(__traits(parameters, 234)) xyz; typeof(__traits(parameters)) x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10299.d0000644000175000017500000000030515205374122021107 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10299.d(11): Error: cannot take address of expression `foo!string` because it is not an lvalue --- */ template foo(T) { } auto fp = &foo!string; // ICE ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24173.c0000644000175000017500000000262415205374122021154 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test24173.c(101): Error: missing comma or semicolon after declaration of `a`, found `i` instead fail_compilation/test24173.c(102): Error: missing comma or semicolon after declaration of `b`, found `i7` instead fail_compilation/test24173.c(103): Error: missing comma or semicolon after declaration of `c`, found `i43` instead fail_compilation/test24173.c(104): Error: invalid integer suffix fail_compilation/test24173.c(104): Error: `=`, `;` or `,` expected to end declaration instead of `0` --- */ _Static_assert(-127i8 - 1 == 0xFFFFFF80, "1"); _Static_assert(-32767i16 - 1 == 0xFFFF8000, "2"); _Static_assert(-2147483647i32 - 1 == 0x80000000, "3"); _Static_assert(-9223372036854775807i64 - 1 == 0x8000000000000000, "4"); _Static_assert(127i8 == 0x7F, "5"); _Static_assert(32767i16 == 0x7FFF, "6"); _Static_assert(2147483647i32 == 0x7FFFFFFF, "7"); _Static_assert(9223372036854775807i64 == 0x7FFFFFFFFFFFFFFF, "8"); _Static_assert(127ui8 == 0x7F, "9"); _Static_assert(32767ui16 == 0x7FFF, "10"); _Static_assert(2147483647ui32 == 0x7FFFFFFF, "11"); _Static_assert(9223372036854775807ui64 == 0x7FFFFFFFFFFFFFFF, "12"); _Static_assert(0xffui8 == 0xFF, "13"); _Static_assert(0xffffui16 == 0xFFFF, "14"); _Static_assert(0xffffffffui32 == 0xFFFFFFFF, "15"); _Static_assert(0xFFFFFFFFFFFFFFFFui64 == 0xFFFFFFFFFFFFFFFF, "16"); #line 100 int a = 2i; int b = 2i7; int c = 2ui43; int d = 2i160; ./ldc-1.42.0-src/tests/dmd/fail_compilation/e15876_6.d0000644000175000017500000000024515205374122020656 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/e15876_6.d(7): Error: identifier expected following `immutable(int).`, not `;` --- */ auto unaryExParseError = immutable(int).; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12255.d0000644000175000017500000001100615205374122021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail12255.d(29): Error: AA key type `SC1` does not have `bool opEquals(ref const SC1) const` fail_compilation/fail12255.d(30): Error: AA key type `SC2` does not support const equality fail_compilation/fail12255.d(35): Error: AA key type `SD1` should have `extern (D) size_t toHash() const nothrow @safe` if `opEquals` defined fail_compilation/fail12255.d(36): Error: AA key type `SD2` supports const equality but doesn't support const hashing fail_compilation/fail12255.d(40): Error: AA key type `SE1` should have `extern (D) size_t toHash() const nothrow @safe` if `opEquals` defined fail_compilation/fail12255.d(41): Error: AA key type `SE2` supports const equality but doesn't support const hashing --- */ void main() { /* Key comparison and hashing are based on object bit representation, * and they fully supported in runtime (TypeInfo.equals and TypeInfo.getHash) */ int[SA1] a1; // OK int[SA2] a2; // OK /* If only toHash is defined, AA assumes that is customized object hashing. */ int[SB1] b1; // OK int[SB2] b2; // OK /* If key does not support const equality, * it is disallowed, because TypeInfo.equals will throw Error. */ int[SC1] c1; // NG int[SC2] c2; // NG /* If opEquals defined for const equality, corresponding toHash method * is required to guarantee (a != b || a.toHash() == b.toHash()). */ int[SD1] d1; // NG int[SD2] d2; // NG /* same as SD cases */ int[SE1] e1; // NG int[SE2] e2; // NG } struct SA1 { int val; } struct SA2 { SA1 s; } struct SB1 { // AA assumes this is specialized hashing (?) size_t toHash() const nothrow @safe { return 0; } } struct SB2 { SB1 s; // implicit generated toHash() calls s.toHash(). } struct SC1 { // does not support const equality bool opEquals(typeof(this)) /*const*/ { return true; } } struct SC2 { SC1 s; } struct SD1 { // Supports const equality, but // does not have corresponding toHash() bool opEquals(typeof(this)) const { return true; } } struct SD2 { SD1 s; } struct SE1 { // Supports const equality, but // does not have corresponding valid toHash() bool opEquals(typeof(this)) const { return true; } size_t toHash() @system { return 0; } } struct SE2 { SE1 s; } /* TEST_OUTPUT: --- fail_compilation/fail12255.d(108): Error: bottom of AA key type `SC1` does not have `bool opEquals(ref const SC1) const` fail_compilation/fail12255.d(109): Error: bottom of AA key type `SC2` does not support const equality fail_compilation/fail12255.d(110): Error: bottom of AA key type `SD1` should have `extern (D) size_t toHash() const nothrow @safe` if `opEquals` defined fail_compilation/fail12255.d(111): Error: bottom of AA key type `SD2` supports const equality but doesn't support const hashing fail_compilation/fail12255.d(112): Error: bottom of AA key type `SE1` should have `extern (D) size_t toHash() const nothrow @safe` if `opEquals` defined fail_compilation/fail12255.d(113): Error: bottom of AA key type `SE2` supports const equality but doesn't support const hashing --- */ void testSArray() { int[SA1[1]] a1; // OK int[SA2[1]] a2; // OK int[SB1[1]] b1; // OK int[SB2[1]] b2; // OK int[SC1[1]] c1; // NG int[SC2[1]] c2; // NG int[SD1[1]] d1; // NG int[SD2[1]] d2; // NG int[SE1[1]] e1; // NG int[SE2[1]] e2; // NG } /* TEST_OUTPUT: --- fail_compilation/fail12255.d(133): Error: bottom of AA key type `SC1` does not have `bool opEquals(ref const SC1) const` fail_compilation/fail12255.d(134): Error: bottom of AA key type `SC2` does not support const equality fail_compilation/fail12255.d(135): Error: bottom of AA key type `SD1` should have `extern (D) size_t toHash() const nothrow @safe` if `opEquals` defined fail_compilation/fail12255.d(136): Error: bottom of AA key type `SD2` supports const equality but doesn't support const hashing fail_compilation/fail12255.d(137): Error: bottom of AA key type `SE1` should have `extern (D) size_t toHash() const nothrow @safe` if `opEquals` defined fail_compilation/fail12255.d(138): Error: bottom of AA key type `SE2` supports const equality but doesn't support const hashing --- */ void testDArray() { int[SA1[]] a1; // OK int[SA2[]] a2; // OK int[SB1[]] b1; // OK int[SB2[]] b2; // OK int[SC1[]] c1; // NG int[SC2[]] c2; // NG int[SD1[]] d1; // NG int[SD2[]] d2; // NG int[SE1[]] e1; // NG int[SE2[]] e2; // NG } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9620.d0000644000175000017500000000101115205374122021007 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9620.d(19): Error: `pure` function `diag9620.main.bar` cannot call impure function `diag9620.foo1` fail_compilation/diag9620.d(20): Error: `pure` function `diag9620.main.bar` cannot call impure function `diag9620.foo2!().foo2` fail_compilation/diag9620.d(13): and accessing mutable static data `x` makes it fail to infer `pure` --- */ int x; void foo1() { x = 3; } void foo2()() { x = 3; } void main() pure { void bar() { foo1(); foo2(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail236.d0000644000175000017500000000072415205374122020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail236.d(14): Error: undefined identifier `x` fail_compilation/fail236.d(22): Error: template `Templ2` is not callable using argument types `!()(int)` fail_compilation/fail236.d(12): Candidate is: `Templ2(alias a)(x)` --- */ // https://issues.dlang.org/show_bug.cgi?id=870 // contradictory error messages for templates template Templ2(alias a) { void Templ2(x) { } } void main() { int i; Templ2(i); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag12280.d0000644000175000017500000000061515205374122021074 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag12280.d(15): Error: undefined identifier `nonexistent` fail_compilation/diag12280.d(13): Error: template instance `diag12280.f!10` error instantiating fail_compilation/diag12280.d(18): 11 recursive instantiations from here: `f!0` --- */ void f(int i)() { static if (i < 10) f!(i + 1); else nonexistent(); } alias f0 = f!0; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7372.d0000644000175000017500000000041715205374122021031 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/imports/fail7372.d(7): Error: undefined identifier `X` fail_compilation/fail7372.d(4): parent scope from here: `mixin Issue7372!()` --- */ #line 1 import imports.fail7372; interface I {} class C : I { mixin Issue7372!(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag23384.d0000644000175000017500000000115415205374122021102 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23384 /* TEST_OUTPUT: --- fail_compilation/diag23384.d(28): Error: function `diag23384.Derived.fun(B b)` is not callable using argument types `(A)` fail_compilation/diag23384.d(28): Note: function `diag23384.Derived.fun` hides base class function `diag23384.Base.fun` fail_compilation/diag23384.d(28): Add `alias fun = diag23384.Base.fun;` to `diag23384.Derived`'s body to merge the overload sets --- */ struct A {} struct B {} class Base { void fun(A a) {} } class Derived : Base { void fun(B b) {} } void main() { Derived d; d.fun(A()); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21275.d0000644000175000017500000000100315205374122021077 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21275 // EXTRA_FILES: imports/fail21275a.d /* TEST_OUTPUT: --- fail_compilation/fail21275.d(17): Error: function `imports.fail21275a.Foo.x` of type `ref int() return` is not accessible from module `fail21275` fail_compilation/fail21275.d(20): Error: function `imports.fail21275a.Bar.x` of type `int(int)` is not accessible from module `fail21275` --- */ void main() { import imports.fail21275a; auto f = Foo(); f.x = 3; auto b = Bar(); b.x = 3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8510.d0000644000175000017500000000055415205374122021017 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8510.d(10): Error: alias `diag8510.a` conflicts with alias `diag8510.a` at fail_compilation/diag8510.d(9) fail_compilation/diag8510.d(15): Error: alias `diag8510.S.a` conflicts with alias `diag8510.S.a` at fail_compilation/diag8510.d(14) --- */ alias int a; alias int a; int g; struct S { alias g a; alias g a; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/newaa.d0000644000175000017500000000122315205374122020662 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/newaa.d(14): Error: cannot implicitly convert expression `new string[string]` of type `string[string]` to `int[string]` fail_compilation/newaa.d(15): Error: function expected before `()`, not `new int[int]` of type `int[int]` fail_compilation/newaa.d(17): Error: `new` cannot take arguments for an associative array --- */ #line 9 void main() { //https://issues.dlang.org/show_bug.cgi?id=11790 string[string] crash = new string[string]; //https://issues.dlang.org/show_bug.cgi?id=20547 int[string] c = new typeof(crash); auto d = new int[int](5); alias AA = char[string]; auto e = new AA(5); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diaginref.d0000644000175000017500000000056415205374122021526 0ustar fabiofabio/* REQUIRED_ARGS: -preview=in TEST_OUTPUT: --- fail_compilation/diaginref.d(11): Error: attribute `ref` is redundant with previously-applied `in` fail_compilation/diaginref.d(13): Error: attribute `in` cannot be added after `ref`: remove `ref` --- */ void foo(in string) {} void foo1(in ref string) {} void foo2(T)(in T v, string) {} void foo3(T)(ref in T v, string) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/systemvariables.d0000644000175000017500000000447715205374122023022 0ustar fabiofabio/* REQUIRED_ARGS: -preview=systemVariables TEST_OUTPUT: --- fail_compilation/systemvariables.d(39): Error: access `@system` variable `gInt` is not allowed in a `@safe` function fail_compilation/systemvariables.d(29): `gInt` is declared here fail_compilation/systemvariables.d(40): Error: access `@system` variable `gInt` is not allowed in a `@safe` function fail_compilation/systemvariables.d(29): `gInt` is declared here fail_compilation/systemvariables.d(41): Error: access `@system` variable `gArr` is not allowed in a `@safe` function fail_compilation/systemvariables.d(31): `gArr` is declared here fail_compilation/systemvariables.d(42): Error: access `@system` variable `gArr` is not allowed in a `@safe` function fail_compilation/systemvariables.d(31): `gArr` is declared here fail_compilation/systemvariables.d(43): Error: access `@system` variable `gInt` is not allowed in a `@safe` function fail_compilation/systemvariables.d(29): `gInt` is declared here fail_compilation/systemvariables.d(46): Error: access `@system` variable `lSys` is not allowed in a `@safe` function fail_compilation/systemvariables.d(45): `lSys` is declared here fail_compilation/systemvariables.d(47): Error: access `@system` variable `lSys` is not allowed in a `@safe` function fail_compilation/systemvariables.d(45): `lSys` is declared here fail_compilation/systemvariables.d(48): Error: access `@system` variable `lSys` is not allowed in a `@safe` function fail_compilation/systemvariables.d(45): `lSys` is declared here fail_compilation/systemvariables.d(50): Error: access `@system` variable `eInt` is not allowed in a `@safe` function fail_compilation/systemvariables.d(30): `eInt` is declared here --- */ // http://dlang.org/dips/1035 @system int gInt; @system enum int eInt = 3; @system { int[] gArr; } alias aliasToSys = gInt; void increment(ref int x) @safe { x++; } void incrementP(int* x) @safe { (*x)++; } void basic() @safe { gInt = 0; // error gInt++; // error gArr ~= 30; // error const c = gArr[0]; // error aliasToSys++; // error @system int lSys = 0; lSys = 0; // error increment(lSys); // error incrementP(&lSys); // error int a = eInt; // error int b = typeof(eInt).max; // allowed void f() @trusted { lSys = 0; // allowed } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11426.d0000644000175000017500000000132315205374122021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11426.d(15): Error: cannot implicitly convert expression `udarr` of type `uint[]` to `int[]` fail_compilation/fail11426.d(16): Error: cannot implicitly convert expression `usarr` of type `uint[1]` to `int[]` fail_compilation/fail11426.d(18): Error: cannot implicitly convert expression `udarr` of type `uint[]` to `int[]` fail_compilation/fail11426.d(19): Error: cannot implicitly convert expression `usarr` of type `uint[1]` to `int[]` --- */ void main() { uint[] udarr; uint[1] usarr; int[1] arr1; arr1 = udarr; // Error, OK int[1] arr2; arr2 = usarr; // Error, OK int[1] arr3 = udarr; // accepted, BAD! int[1] arr4 = usarr; // accepted, BAD! } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag3013.d0000644000175000017500000000032315205374122021002 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag3013.d(11): Error: cannot pass type `string` as a function argument --- */ int format(string, string, string); void main() { int s = string.format("abc", "def"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14277.d0000644000175000017500000000037015205374122021111 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=14277 /* TEST_OUTPUT: --- fail_compilation/fail14277.d(10): Error: cannot implicitly convert expression `new char[](9999$?:32=u|64=LU$)` of type `char[]` to `ubyte[]` --- */ ubyte[] u = new char[9999]; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ldc_llvm_inline_ir_1.d0000644000175000017500000000043315205374122023635 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ldc_llvm_inline_ir_1.d(8): Error: the `LDC_inline_ir` pragma template must have three (string, type and type tuple) or five (string, string, string, type and type tuple) parameters --- */ pragma(LDC_inline_ir) R inlineIR(int i, R, P...)(P); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13336b.d0000644000175000017500000000066315205374122021253 0ustar fabiofabio// REQUIRED_ARGS: -o- int sx; double sy; /* TEST_OUTPUT: --- fail_compilation/fail13336b.d(16): Error: cannot `ref` return expression `cast(double)sx` because it is not an lvalue fail_compilation/fail13336b.d(24): Error: cannot `ref` return expression `cast(double)sx` because it is not an lvalue --- */ ref f1(bool f) { if (f) return sx; return sy; } ref f2(bool f) { if (f) return sy; return sx; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail187.d0000644000175000017500000000071415205374122020746 0ustar fabiofabio// REQUIRED_ARGS: -d /* TEST_OUTPUT: --- fail_compilation/fail187.d(16): Error: `catch` at fail_compilation/fail187.d(20) hides `catch` at fail_compilation/fail187.d(24) --- */ // On DMD 2.000 bug only with typedef, not alias alias Exception A; alias Exception B; void main() { try { throw new A("test"); } catch (B) { // this shouldn't happen, but does } catch (A) { // this ought to happen? } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ctfe14207.d0000644000175000017500000000073715205374122021117 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ctfe14207.d(13): Error: cannot convert `&immutable(ulong)` to `ubyte[8]*` at compile time fail_compilation/ctfe14207.d(18): called from here: `nativeToBigEndian()` fail_compilation/ctfe14207.d(22): called from here: `digest()` --- */ ubyte[8] nativeToBigEndian() { immutable ulong res = 1; return *cast(ubyte[8]*) &res; } auto digest() { ubyte[8] bits = nativeToBigEndian(); return bits; } enum h = digest(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/cast_qual.d0000644000175000017500000000154315205374122021550 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 -de TEST_OUTPUT: --- fail_compilation/cast_qual.d(17): Deprecation: using the result of a cast from `const(int)` to `int` as an lvalue will become `@system` in a future release fail_compilation/cast_qual.d(19): Deprecation: using the result of a cast from `const(int)` to `int` as an lvalue will become `@system` in a future release fail_compilation/cast_qual.d(25): Error: cast from `const(Object)` to `object.Object` is not allowed in a `@safe` function fail_compilation/cast_qual.d(25): Incompatible type qualifier --- */ @safe: void main() { const int i = 3; int j = cast() i; // OK int* p = &cast() i; // this should not compile in @safe code *p = 4; // oops cast() i = 5; // NG auto q = &cast(const) j; // OK, int* to const int* } void test() { const Object co; auto o = cast() co; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/numliteral.c0000644000175000017500000000043015205374122021741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/numliteral.c(11): Error: embedded `_` not allowed --- */ int x = 0b00; // https://issues.dlang.org/show_bug.cgi?id=23410 // Test C-specific errors int y = 0_1; // https://issues.dlang.org/show_bug.cgi?id=22549 int z = 078.0 + 008. + 009e1; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20183.d0000644000175000017500000000255515205374122021111 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fail20183.d(1016): Error: function `addr` is not callable using argument types `(int)` fail_compilation/fail20183.d(1016): cannot pass rvalue argument `S(0).i` of type `int` to parameter `return ref int b` fail_compilation/fail20183.d(1004): `fail20183.addr(return ref int b)` declared here --- */ #line 1000 // https://issues.dlang.org/show_bug.cgi?id=20183 @safe: int* addr(return ref int b) { return &b; } struct S { int i; S* addrOf() return => &this; } S s() { return S(); } void test() { scope int* p = addr(S().i); // struct literal scope int* q = addr(s().i); // struct temporary scope S* r = S().addrOf(); // struct literal } /* TEST_OUTPUT: --- fail_compilation/fail20183.d(1017): Error: assigning address of expression temporary returned by `s()` to `q` with longer lifetime is not allowed in a `@safe` function fail_compilation/fail20183.d(1018): Error: assigning address of struct literal `S(0)` to `r` with longer lifetime is not allowed in a `@safe` function fail_compilation/fail20183.d(1107): Error: assigning address of expression temporary returned by `s()` to `this.ptr` with longer lifetime is not allowed in a `@safe` function --- */ #line 1100 class Foo { int* ptr; this() @safe { ptr = addr(s().i); // struct literal } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_contracts4.d0000644000175000017500000000027315205374122022652 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail_contracts4.d(8): Error: missing `do { ... }` for function literal --- */ enum x = delegate int()in(true) out(;true) out(r; true) in{} out(r){}; ./ldc-1.42.0-src/tests/dmd/fail_compilation/constraints_func3.d0000755000175000017500000000515015205374122023242 0ustar fabiofabio/* EXTRA_FILES: imports/constraints.d TEST_OUTPUT: ---- fail_compilation/constraints_func3.d(53): Error: none of the overloads of template `imports.constraints.overload` are callable using argument types `!()(int)` fail_compilation/imports/constraints.d(39): Candidates are: `overload(T)(T v)` with `T = int` must satisfy the following constraint: ` N!T` fail_compilation/imports/constraints.d(40): `overload(T)(T v)` with `T = int` must satisfy the following constraint: ` !P!T` fail_compilation/imports/constraints.d(41): `overload(T)(T v1, T v2)` fail_compilation/imports/constraints.d(42): `overload(T, V)(T v1, V v2)` fail_compilation/constraints_func3.d(54): Error: none of the overloads of template `imports.constraints.overload` are callable using argument types `!()(int, string)` fail_compilation/imports/constraints.d(39): Candidates are: `overload(T)(T v)` fail_compilation/imports/constraints.d(40): `overload(T)(T v)` fail_compilation/imports/constraints.d(41): `overload(T)(T v1, T v2)` fail_compilation/imports/constraints.d(42): `overload(T, V)(T v1, V v2)` with `T = int, V = string` must satisfy one of the following constraints: ` N!T N!V` fail_compilation/constraints_func3.d(56): Error: template `variadic` is not callable using argument types `!()()` fail_compilation/imports/constraints.d(43): Candidate is: `variadic(A, T...)(A a, T v)` fail_compilation/constraints_func3.d(57): Error: template `variadic` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(43): Candidate is: `variadic(A, T...)(A a, T v)` with `A = int, T = ()` must satisfy the following constraint: ` N!int` fail_compilation/constraints_func3.d(58): Error: template `variadic` is not callable using argument types `!()(int, int)` fail_compilation/imports/constraints.d(43): Candidate is: `variadic(A, T...)(A a, T v)` with `A = int, T = (int)` must satisfy the following constraint: ` N!int` fail_compilation/constraints_func3.d(59): Error: template `variadic` is not callable using argument types `!()(int, int, int)` fail_compilation/imports/constraints.d(43): Candidate is: `variadic(A, T...)(A a, T v)` with `A = int, T = (int, int)` must satisfy the following constraint: ` N!int` ---- */ void main() { import imports.constraints; overload(0); overload(0, ""); variadic(); variadic(0); variadic(0, 1); variadic(0, 1, 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4269d.d0000644000175000017500000000023315205374122021173 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4269d.d(9): Error: undefined identifier `Y` --- */ static if(is(typeof(X6.init))) {} alias Y X6; void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/previewin2.d0000644000175000017500000000140515205374122021663 0ustar fabiofabio/* REQUIRED_ARGS: -preview=in -preview=dip1000 TEST_OUTPUT: --- fail_compilation/previewin2.d(1): Error: cannot use `in` parameters with `extern(C)` functions fail_compilation/previewin2.d(1): parameter `a` declared as `in` here fail_compilation/previewin2.d(2): Error: cannot use `in` parameters with `extern(Windows)` functions fail_compilation/previewin2.d(2): parameter `a` declared as `in` here fail_compilation/previewin2.d(4): Error: cannot use `in` parameters with `extern(C)` functions fail_compilation/previewin2.d(4): parameter `__anonymous_param` declared as `in` here --- */ #line 1 extern(C) void wrongLink1 (in int a); extern(Windows) void wrongLink2 (in void* a); struct Large { ulong[64] data; } extern(C) void wrongLink3 (in Large); ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag20888.d0000644000175000017500000000436715205374122021121 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag20888.d(24): Error: return value `callback` of type `int function()` does not match return type `int`, and cannot be implicitly converted fail_compilation/diag20888.d(24): Did you intend to call the function pointer? fail_compilation/diag20888.d(29): Error: return value `s` of type `string` does not match return type `int`, and cannot be implicitly converted fail_compilation/diag20888.d(34): Error: return value `callback` of type `int delegate()` does not match return type `int`, and cannot be implicitly converted fail_compilation/diag20888.d(34): Did you intend to call the delegate? fail_compilation/diag20888.d(39): Error: return value `callback` of type `int delegate()` does not match return type `int`, and cannot be implicitly converted fail_compilation/diag20888.d(39): Did you intend to call the delegate? fail_compilation/diag20888.d(44): Error: return value `callback` of type `int delegate()*` does not match return type `int`, and cannot be implicitly converted fail_compilation/diag20888.d(49): Error: return value `callback` of type `int delegate()` does not match return type `string`, and cannot be implicitly converted fail_compilation/diag20888.d(54): Error: return value `() => 3755` of type `int function() pure nothrow @nogc @safe` does not match return type `int`, and cannot be implicitly converted fail_compilation/diag20888.d(54): Did you intend to call the function pointer? fail_compilation/diag20888.d(59): Error: `return` expression expected fail_compilation/diag20888.d(70): Error: return value `() => i` of type `int delegate() pure nothrow @nogc @safe` does not match return type `int`, and cannot be implicitly converted fail_compilation/diag20888.d(70): Did you intend to call the delegate? --- */ int alpha(int function() callback) { return callback; } int beta(string s) { return s; } int gamma(int delegate() callback) { return callback; } int delta(int delegate() callback) { return callback; } int epsilon(int delegate()* callback) { return callback; // no supplemental yet } string zeta(int delegate() callback) { return callback; } int eta() { return () => 0xEAB; } int theta() { return; } int kappa() { int i = 0xEAB; return () { return i; }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22127.d0000644000175000017500000000035715205374122021107 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail22127.d(101): Error: user-defined attributes are not allowed on `alias` declarations --- */ // https://issues.dlang.org/show_bug.cgi?id=22127 #line 100 alias getOne = @(0) function int () => 1; ./ldc-1.42.0-src/tests/dmd/fail_compilation/templateoverload.d0000644000175000017500000000132015205374122023134 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/templateoverload.d(17): Error: template instance `T!1` does not match any template declaration fail_compilation/templateoverload.d(17): Candidates are: fail_compilation/templateoverload.d(14): T(X) fail_compilation/templateoverload.d(15): T() fail_compilation/templateoverload.d(22): Error: template instance `V!int` does not match any template declaration fail_compilation/templateoverload.d(22): Candidates are: fail_compilation/templateoverload.d(19): V(int i) fail_compilation/templateoverload.d(20): V(T, alias a) --- */ template T(X) {} template T() {} alias t = T!1; template V(int i) {} template V(T, alias a) {} alias v = V!int; ./ldc-1.42.0-src/tests/dmd/fail_compilation/mixin_template.d0000644000175000017500000000026715205374122022615 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/mixin_template.d(10): Error: mixin `mixin_template.f!1` - `f` is a function, not a template --- */ string f() { return "int i;"; } mixin f!1; ./ldc-1.42.0-src/tests/dmd/fail_compilation/union_initialization.d0000644000175000017500000000252115205374122024030 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=20068 TEST_OUTPUT: --- fail_compilation/union_initialization.d(19): Error: accessing overlapped field `B.p` with pointers is not allowed in a `@safe` function fail_compilation/union_initialization.d(25): Error: accessing overlapped field `B.p` with pointers is not allowed in a `@safe` function --- */ union B { int i; int* p; @safe this(int* p) { this.p = p; int* x = this.p; } @safe this(int** i) { this.p = null; this.p = *i; } } /* TEST_OUTPUT: --- fail_compilation/union_initialization.d(109): Error: immutable field `p` initialized multiple times fail_compilation/union_initialization.d(108): Previous initialization is here. --- */ #line 100 union C { int i; immutable int* p; @safe this(immutable int* p) { this.p = p; this.p = null; } } /* https://issues.dlang.org/show_bug.cgi?id=21229 TEST_OUTPUT: --- fail_compilation/union_initialization.d(223): Error: field `union_` must be initialized in constructor fail_compilation/union_initialization.d(223): Error: field `proxy` must be initialized in constructor --- */ #line 200 struct NeedsInit { int var; long lo; @disable this(); } union Union { NeedsInit ni; } union Proxy { Union union_; } struct S { Union union_; Proxy proxy; this(int arg) { union_.ni.var = arg; proxy.union_.ni.var = arg; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19441.d0000644000175000017500000000140115205374122021103 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail19441.d(44): Error: cannot use `alias this` to partially initialize variable `wrap[0]` of type `Wrap10595`. Use `wrap[0].i` --- */ struct S10595 { bool b = true; bool test() { if (!b) // note: must be a check, not 'return b;' return false; return true; } } struct Wrap10595 { int i; alias i this; S10595 s; } void main() { { Wrap10595[int] wrap; wrap[0] = Wrap10595(); wrap[0].i = 0; assert(wrap[0].s.test()); // ok } { Wrap10595[int] wrap; wrap[0] = Wrap10595(); wrap[0] = 0; // note: using 'alias this' to assign assert(wrap[0].s.test()); // failure } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15616c.d0000644000175000017500000000250615205374122021255 0ustar fabiofabio/* REQUIRED_ARGS: -verror-supplements=0 TEST_OUTPUT: --- fail_compilation/fail15616c.d(44): Error: none of the overloads of `foo` are callable using argument types `(double)` fail_compilation/fail15616c.d(17): Candidates are: `fail15616c.foo(int a)` fail_compilation/fail15616c.d(20): `fail15616c.foo(int a, int b)` fail_compilation/fail15616c.d(29): `fail15616c.foo(int a, int b, int c)` fail_compilation/fail15616c.d(32): `fail15616c.foo(string a)` fail_compilation/fail15616c.d(35): `fail15616c.foo(string a, string b)` fail_compilation/fail15616c.d(38): `fail15616c.foo(string a, string b, string c)` fail_compilation/fail15616c.d(23): `foo(T)(T a)` with `T = double` must satisfy the following constraint: ` is(T == float)` fail_compilation/fail15616c.d(26): `foo(T)(T a)` with `T = double` must satisfy the following constraint: ` is(T == char)` --- */ #line 17 void foo(int a) {} void foo(int a, int b) {} void foo(T)(T a) if (is(T == float)) {} void foo(T)(T a) if (is(T == char)) {} void foo(int a, int b, int c) {} void foo(string a) {} void foo(string a, string b) {} void foo(string a, string b, string c) {} void main() { foo(3.14); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag11423.d0000644000175000017500000000021715205374122021070 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag11423.d(9): Error: undefined identifier `Foo` --- */ void main() { auto foo = new shared Foo(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19912a.d0000644000175000017500000000032115205374122021247 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19912a.d(7): Error: struct `fail19912a.object` conflicts with import `fail19912a.object` at fail_compilation/fail19912a.d --- */ struct object { } void fun(string) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17764.d0000644000175000017500000000063315205374122021163 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 * TEST_OUTPUT: --- fail_compilation/test17764.d(109): Error: assigning scope variable `c` to global variable `global` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=17764 #line 100 int** global; struct S { int** str; } void f() @safe { int* buf; S[1] c = S(&buf); global = c[0].str; /* This should be rejected. */ } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14089.d0000644000175000017500000000230015205374122021105 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail14089.d(41): Error: `1` has no effect fail_compilation/fail14089.d(41): Error: `1` has no effect fail_compilation/fail14089.d(42): Error: `1` has no effect fail_compilation/fail14089.d(42): Error: `n` has no effect fail_compilation/fail14089.d(43): Error: `1` has no effect fail_compilation/fail14089.d(43): Error: `s.val` has no effect fail_compilation/fail14089.d(44): Error: `n` has no effect fail_compilation/fail14089.d(44): Error: `1` has no effect fail_compilation/fail14089.d(45): Error: `s.val` has no effect fail_compilation/fail14089.d(45): Error: `1` has no effect --- */ bool cond; void main() { int foo() { return 0; } int n; struct S { int val; } S s; // The whole of each CondExps has side effects, So no error. cond ? foo() : n; cond ? foo() : s.val; cond ? 1 : foo(); cond ? n : foo(); cond ? s.val : foo(); cond ? (n = 1) : 1; cond ? (n = 1) : n; cond ? (n = 1) : s.val; cond ? 1 : (n = 1); cond ? n : (n = 1); cond ? s.val : (n = 1); // errors cond ? 1 : 1; cond ? 1 : n; cond ? 1 : s.val; cond ? n : 1; cond ? s.val : 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24680.d0000644000175000017500000000061115205374122021152 0ustar fabiofabio/** REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test24680.d(19): Error: escaping a reference to local variable `buf` by returning `c.peek(buf[])` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=24680 class C { final auto peek(ubyte[] buf) { return buf; } } @safe escape(C c) { ubyte[5] buf; return c.peek(buf[]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19912c.d0000644000175000017500000000032215205374122021252 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19912c.d(7): Error: alias `fail19912c.object` conflicts with import `fail19912c.object` at fail_compilation/fail19912c.d --- */ alias object = int; void fun(string) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail24485.d0000644000175000017500000000074215205374122021116 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24485 /* TEST_OUTPUT: --- fail_compilation/fail24485.d(25): Error: cannot implicitly convert expression `*a` of type `A` to `B` fail_compilation/fail24485.d(31): Error: cannot implicitly convert expression `this.a` of type `A` to `B` --- */ struct A { int i = 43; this(ref A rhs) {} } struct B { int i = 42; } ref B foo() { auto a = new A; return *a; } struct C { A a; @property ref B b() { return a; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail330.d0000644000175000017500000000030115205374122020724 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail330.d(9): Error: variable `fail330.fun.result` cannot modify result `result` in contract --- */ int fun() out(result) { result = 2; } do { return 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18130.d0000644000175000017500000000033215205374122021143 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test18130.d(8): Error: variable `test18130.foo.v` zero-length `out` parameters are not allowed. --- */ // https://issues.dlang.org/show_bug.cgi?id=18130 void foo(out byte[0] v) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail132.d0000644000175000017500000000041115205374122020726 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail132.d(19): Error: cannot construct nested class `B` because no implicit `this` reference to outer class `A` is available --- */ //import std.stdio; class A { class B { } } void main() { A.B c = new A.B; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail8691.d0000644000175000017500000000026115205374122021033 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail8691.d(7): Error: struct `fail8691.Foo` cannot have field `f` with static array of same struct type --- */ struct Foo { Foo[1] f; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test12822.d0000644000175000017500000000062115205374122021146 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test12822.d(13): Error: modifying delegate pointer `dg.ptr` is not allowed in a `@safe` function fail_compilation/test12822.d(14): Error: using `dg.funcptr` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=12822 void test2(int delegate() dg) @safe { static int i; dg.ptr = &i; dg.funcptr = &func; } int func(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11944.d0000644000175000017500000000037715205374122020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11944.d(12): Error: template instance `doCommand!(func)` does not match template declaration `doCommand(f, T)(f, T arg)` --- */ void func(int var) {} void doCommand(f, T)(f, T arg) {} auto var = &doCommand!func; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9.d0000644000175000017500000000061415205374122020576 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9.d(24): Error: no property `Vector` for type `fail9.Vector!int` fail_compilation/fail9.d(13): class `Vector` defined here --- */ template Vector(T) { int x; class Vector { } } struct Sorter { } void Vector_test_int() { alias Vector!(int).Vector vector_t; vector_t v; Sorter sorter; v.sort_with!(int)(sorter); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10207.d0000644000175000017500000000023315205374122021074 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10207.d(7): Error: user-defined attributes not allowed for `alias` declarations --- */ alias @Safe int __externC; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17419.d0000644000175000017500000000053015205374122021110 0ustar fabiofabio // https://issues.dlang.org/show_bug.cgi?id=17419 /* TEST_OUTPUT: --- fail_compilation/fail17419.d(10): Error: argument to `__traits(getLinkage, 64)` is not a declaration fail_compilation/fail17419.d(11): Error: expected 1 arguments for `getLinkage` but had 2 --- */ enum s = __traits(getLinkage, 8 * 8); enum t = __traits(getLinkage, 8, 8); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice20709.d0000644000175000017500000000037415205374122020737 0ustar fabiofabio/* EXTRA_FILES: imports/imp20709.d TEST_OUTPUT: --- fail_compilation/ice20709.d(10): Error: module `imp20709` import `Point` not found --- */ module ice20709; import imports.imp20709 : Point; immutable Point aPoint = somePoint; Point somePoint() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix22263.c0000644000175000017500000000154115205374122020756 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix22263.c(108): Error: function `fix22263.f3` conflicts with function `fix22263.f3` at fail_compilation/fix22263.c(107) fail_compilation/fix22263.c(127): Error: variable `fix22263.x4` conflicts with variable `fix22263.x4` at fail_compilation/fix22263.c(126) fail_compilation/fix22263.c(133): Error: variable `fix22263.x6` conflicts with variable `fix22263.x6` at fail_compilation/fix22263.c(132) --- */ // https://issues.dlang.org/show_bug.cgi?id=22263 #line 100 extern void f1(int); void f1(int a) { } static void f2(int); static void f2(int a) { } static void f3(int) { } static void f3(int a) { } void foo() { f1(42); f2(42); f3(42); } extern const int x1; const int x1 = 1; int x2 = 2; extern int x2; static int x3; static int x3 = 3; static int x4; int x4; int x5; int x5; int x6 = 6; int x6 = 6; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19919.d0000644000175000017500000000070415205374122021122 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19919.d(16): Error: union field `f` with default initialization `3.14F` must be before field `n` fail_compilation/fail19919.d(23): Error: union field `f` with default initialization `3.14F` must be before field `n` --- */ void main() { struct X { union { int n; float f = 3.14f; } } union U { int n; float f = 3.14f; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail245.d0000644000175000017500000000302115205374122020733 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail245.d(27): Deprecation: variable `fail245.ClassWithDeps.value` is deprecated fail_compilation/fail245.d(28): Deprecation: variable `fail245.ClassWithDeps.value` is deprecated fail_compilation/fail245.d(29): Deprecation: variable `fail245.ClassWithDeps.value` is deprecated fail_compilation/fail245.d(30): Deprecation: variable `fail245.ClassWithDeps.value` is deprecated fail_compilation/fail245.d(32): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated fail_compilation/fail245.d(33): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated fail_compilation/fail245.d(34): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated fail_compilation/fail245.d(35): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated fail_compilation/fail245.d(36): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated fail_compilation/fail245.d(37): Deprecation: variable `fail245.ClassWithDeps.staticValue` is deprecated --- */ //import std.stdio; class ClassWithDeps { deprecated int value; deprecated static int staticValue; void test(ClassWithDeps obj) { obj.value = 666; this.value = 666; auto n1 = obj.value; auto n2 = this.value; obj.staticValue = 102; this.staticValue = 103; ClassWithDeps.staticValue = 104; auto n3 = obj.staticValue; auto n4 = this.staticValue; auto n5 = ClassWithDeps.staticValue; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12908.d0000644000175000017500000000037515205374122021115 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail12908.d(14): Error: `pure` delegate `fail12908.main.__foreachbody_L12_C5` cannot call impure function `fail12908.g` --- */ void g() {} void main() pure { foreach (k, v; ["": ""]) { g(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3703.d0000644000175000017500000000145715205374122021030 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=3703 // static array assignment /* TEST_OUTPUT: --- fail_compilation/fail3703.d(18): Error: mismatched array lengths 2 and 1 for assignment `b[] = a` fail_compilation/fail3703.d(20): Error: mismatched array lengths 2 and 1 for assignment `b[] = a` fail_compilation/fail3703.d(22): Error: mismatched array lengths, 3 and 2 fail_compilation/fail3703.d(23): Error: mismatched array lengths, 2 and 3 fail_compilation/fail3703.d(25): Error: mismatched array lengths, 3 and 2 fail_compilation/fail3703.d(26): Error: mismatched array lengths, 2 and 3 --- */ void main() { int[1] a = [1]; int[2] b = a; // should make compile error b = a; // should make compile error int[3] sa3 = [1,2][]; int[2] sa2 = sa3[][]; sa3 = [1,2][]; sa2 = sa3[][]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9406.d0000644000175000017500000000036115205374122020654 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9406.d(21): Error: `s1.mixin Mixin!() t1;` has no effect --- */ mixin template Mixin() { } struct S { template t1() { mixin Mixin t1; } } void main() { S s1; s1.t1!(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17425.d0000644000175000017500000000252015205374122021152 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test17425.d(24): Error: parameter index must be in range 0..4 not 4 fail_compilation/test17425.d(27): Error: first argument to `__traits(getParameterStorageClasses, i, 4)` is not a function or a function call fail_compilation/test17425.d(29): Error: expression expected as second argument of `__traits(getParameterStorageClasses, foo, int)` fail_compilation/test17425.d(31): Error: expected 2 arguments for `getParameterStorageClasses` but had 3 --- */ // https://issues.dlang.org/show_bug.cgi?id=17425 ref int foo(return ref const int* p, scope int* a, out int b, lazy int c); //pragma(msg, __traits(getParameterStorageClasses, foo, 0)); static assert(__traits(getParameterStorageClasses, foo, 0)[0] == "return"); static assert(__traits(getParameterStorageClasses, foo, 0)[1] == "ref"); //pragma(msg, __traits(getParameterStorageClasses, foo, 1)); static assert(__traits(getParameterStorageClasses, foo, 1)[0] == "scope"); static assert(__traits(getParameterStorageClasses, foo, 2)[0] == "out"); static assert(__traits(getParameterStorageClasses, typeof(&foo), 3)[0] == "lazy"); enum a1 = __traits(getParameterStorageClasses, foo, 4); int i; enum a2 = __traits(getParameterStorageClasses, i, 4); enum a3 = __traits(getParameterStorageClasses, foo, int); enum a4 = __traits(getParameterStorageClasses, foo, 0, 1); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15896.d0000644000175000017500000000071615205374122021125 0ustar fabiofabio// 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; thebar +=1; return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21665.d0000644000175000017500000000114415205374122021154 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test21665.d(18): Error: `void` initializing a struct with an invariant is not allowed in a `@safe` function fail_compilation/test21665.d(30): Error: accessing overlapped field `U.s` with a structs invariant is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=21665 struct ShortString { private ubyte length; private char[15] data; invariant { assert(length <= data.length); } } @safe void test1() { ShortString s = void; } union U { int n; ShortString s; } @safe void test2() { U u; u.s.length = 3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail307.d0000644000175000017500000000035715205374122020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail307.d(11): Error: cannot implicitly convert expression `cast(int)(cast(double)cast(int)b + 6.1)` of type `int` to `short` --- */ void main() { ubyte b = 6; short c5 = cast(int)(b + 6.1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19948.d0000644000175000017500000000073115205374122021124 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19948 /* TEST_OUTPUT: --- fail_compilation/fail19948.d(16): Error: function `func` is not callable using argument types `(X)` fail_compilation/fail19948.d(16): cannot pass argument `X()` of type `fail19948.main.X` to parameter `const(fail19948.X)` fail_compilation/fail19948.d(19): `fail19948.func(const(X))` declared here --- */ struct X {} void main() { struct X {} func(X()); } void func(const(X)) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22686.d0000644000175000017500000000055715205374122021167 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22686 /* TEST_OUTPUT: --- fail_compilation/test22686.d(15): Error: `this` is only defined in non-static member functions, not `create` --- */ struct S { int[] data; static auto create() { auto self = &this; return { assert(data.length); return self; }; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12350.d0000644000175000017500000000077215205374122020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12350.d(15): Error: type `MyUDC` has no value fail_compilation/ice12350.d(30): Error: template instance `ice12350.testAttrs!(MyStruct)` error instantiating --- */ enum MyUDC; struct MyStruct { int a; @MyUDC int b; } void testAttrs(T)(const ref T t) if (is(T == struct)) { foreach (name; __traits(allMembers, T)) { auto tr = __traits(getAttributes, __traits(getMember, t, name)); } } void main() { MyStruct s; testAttrs(s); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice23781.d0000644000175000017500000000036015205374122020735 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/ice23781.d(10): Error: variable `b` cannot be read at compile time --- **/ struct Bar { int i; } ref const(Bar) func1 (const return ref Bar b) { return b; } immutable E1 = Bar(); enum E2 = &E1.func1(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail5435.d0000644000175000017500000000366215205374122021034 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=5435 /* TEST_OUTPUT: --- Enum5435.A Enum5435.B Enum5435.C fail_compilation/fail5435.d(38): Error: cannot implicitly convert expression `"foo"` of type `string` to `Enum5435` fail_compilation/fail5435.d(38): while evaluating `pragma(msg, foo)` fail_compilation/fail5435.d(38): Error: cannot implicitly convert expression `3.0` of type `double` to `Enum5435` fail_compilation/fail5435.d(38): while evaluating `pragma(msg, foo)` fail_compilation/fail5435.d(39): Error: cannot implicitly convert expression `Enum5435.A` of type `Enum5435` to `string` fail_compilation/fail5435.d(39): while evaluating `pragma(msg, foo)` fail_compilation/fail5435.d(39): Error: cannot implicitly convert expression `Enum5435.B` of type `Enum5435` to `string` fail_compilation/fail5435.d(39): while evaluating `pragma(msg, foo)` fail_compilation/fail5435.d(39): Error: cannot implicitly convert expression `Enum5435.C` of type `Enum5435` to `string` fail_compilation/fail5435.d(39): while evaluating `pragma(msg, foo)` foo fail_compilation/fail5435.d(39): Error: cannot implicitly convert expression `3.0` of type `double` to `string` fail_compilation/fail5435.d(39): while evaluating `pragma(msg, foo)` 0 1 2 fail_compilation/fail5435.d(40): Error: cannot implicitly convert expression `"foo"` of type `string` to `int` fail_compilation/fail5435.d(40): while evaluating `pragma(msg, foo)` fail_compilation/fail5435.d(40): Error: cannot implicitly convert expression `3.0` of type `double` to `int` fail_compilation/fail5435.d(40): while evaluating `pragma(msg, foo)` --- */ template Tuple5435(E...) { alias E Tuple5435; } enum Enum5435 { A, B, C }; void main() { alias Tuple5435!(Enum5435.A, Enum5435.B, Enum5435.C, "foo", 3.0) tup; foreach (Enum5435 foo; tup) pragma(msg, foo); foreach ( string foo; tup) pragma(msg, foo); foreach ( int foo; tup) pragma(msg, foo); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18219.d0000644000175000017500000000145215205374122021113 0ustar fabiofabio// EXTRA_SOURCES: imports/b18219.d // EXTRA_FILES: imports/a18219.d /* TEST_OUTPUT: --- fail_compilation/fail18219.d(20): Error: no property `Foobar` for type `AST` fail_compilation/imports/b18219.d(3): did you mean `b18219.Foobar`? fail_compilation/fail18219.d(21): Error: no property `Bar` for type `a18219.AST` fail_compilation/imports/a18219.d(3): struct `AST` defined here fail_compilation/fail18219.d(22): Error: no property `fun` for type `AST` fail_compilation/imports/b18219.d(15): did you mean `b18219.fun`? fail_compilation/fail18219.d(23): Error: no property `Foobar` for type `AST` fail_compilation/imports/b18219.d(3): did you mean `b18219.Foobar`? --- */ import imports.a18219; void main() { AST.Foobar t; AST.Bar l; AST.fun(); AST.Foobar.smeth(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13939.d0000644000175000017500000000051415205374122021115 0ustar fabiofabio// REQUIRED_ARGS: -o- -fPIC // DISABLED: win32 win64 LDC // LDC: works as expected /* TEST_OUTPUT: --- fail_compilation/fail13939.d(15): Error: cannot directly load global variable `val` with PIC or PIE code --- */ version(Windows) static assert(0); void test1() { __gshared int val; asm { mov EAX, val; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7178.d0000644000175000017500000000046115205374122021034 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7178.d(10): Error: undefined identifier `contents` in module `fail7178` fail_compilation/fail7178.d(12): Error: mixin `fail7178.populate!int` error instantiating --- */ template populate(overloads...) { mixin populate!(.contents); } public mixin populate!int; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20881.d0000644000175000017500000000170715205374122021160 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test20881.d(20): Error: returning scope variable `this` is not allowed in a `@safe` function fail_compilation/test20881.d(27): Error: assigning address of variable `s` to `global` with longer lifetime is not allowed in a `@safe` function fail_compilation/test20881.d(28): Error: assigning address of variable `s` to `global` with longer lifetime is not allowed in a `@safe` function fail_compilation/test20881.d(29): Error: assigning address of variable `s` to `global` with longer lifetime is not allowed in a `@safe` function --- */ @safe: // https://issues.dlang.org/show_bug.cgi?id=20881 struct S { int* ptr; auto borrowA() return /*scope inferred*/ { return ptr; } int* borrowB() return { return ptr; } int* borrowC() scope return ref { return ptr; } } void main() { static int* global; S s; global = s.borrowA; global = s.borrowB; global = s.borrowC; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21980.c0000644000175000017500000000020215205374122021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail21980.c(7): Error: functions cannot be `_Thread_local` --- */ _Thread_local void wat(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375g.d0000644000175000017500000000050615205374122021177 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375g.d(13): Error: else is dangling, add { } after condition at fail_compilation/fail4375g.d(10) --- */ void main() { static if (true) static if (true) assert(33); else assert(34); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10926.d0000644000175000017500000000040615205374122021077 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10926.d(11): Error: cannot modify expression `cast(const(int)[])c` because it is not an lvalue --- */ void main() { const(int)[] a, b; int[] c, d; (true ? a : c) ~= 20; // line 6, Error: a is not an lvalue } ./ldc-1.42.0-src/tests/dmd/fail_compilation/aa_init.d0000644000175000017500000000065715205374122021205 0ustar fabiofabio/* REQUIRED_ARGS: -vcolumns TEST_OUTPUT: --- fail_compilation/aa_init.d(13,18): Error: invalid associative array initializer `[]`, use `null` instead fail_compilation/aa_init.d(14,24): Error: missing key for value `4` in initializer fail_compilation/aa_init.d(15,9): Error: cannot implicitly convert expression `[]` of type `void[]` to `int[int]` --- */ void main() { int[int] a = []; int[int] b = [2:3, 4]; a = []; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/lexer23465.d0000644000175000017500000000170015205374122021312 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/lexer23465.d(21): Error: character 0x1f37a is not allowed as a continue character in an identifier fail_compilation/lexer23465.d(22): Error: character '\' is not a valid token fail_compilation/lexer23465.d(23): Error: octal digit expected, not `9` fail_compilation/lexer23465.d(23): Error: octal literals larger than 7 are no longer supported fail_compilation/lexer23465.d(24): Error: integer overflow fail_compilation/lexer23465.d(25): Error: unterminated /+ +/ comment fail_compilation/lexer23465.d(26): Error: found `End of File` instead of array initializer fail_compilation/lexer23465.d(26): Error: semicolon needed to end declaration of `arr`, instead of `End of File` fail_compilation/lexer23465.d(19): `arr` declared here --- */ // https://issues.dlang.org/show_bug.cgi?id=23465 // Invalid token error points to wrong line int[] arr = [ 0, x🍺, 3\, 09, 9999999999999999999999, 5, /+ ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21831.d0000644000175000017500000000131215205374122021100 0ustar fabiofabio/* REQUIRED_ARGS: -de -unittest TEST_OUTPUT: --- fail_compilation/fail21831.d(19): Deprecation: struct `fail21831.S21831` is deprecated - Deprecated type fail_compilation/fail21831.d(19): Deprecation: template `fail21831.test21831(T)(T t) if (__traits(isDeprecated, T))` is deprecated - Deprecated template fail_compilation/fail21831.d(19): Deprecation: struct `fail21831.S21831` is deprecated - Deprecated type --- */ #line 1 deprecated("Deprecated type") struct S21831 { } auto test21831(T)(T t) if (!__traits(isDeprecated, T)) { return T.init; } deprecated("Deprecated template") auto test21831(T)(T t) if (__traits(isDeprecated, T)) { return T.init; } unittest { auto b = test21831(S21831()); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/warn13679.d0000644000175000017500000000032415205374122021151 0ustar fabiofabio// REQUIRED_ARGS: -w /* TEST_OUTPUT: --- fail_compilation/warn13679.d(13): Error: cannot use `foreach_reverse` with an associative array --- */ void main() { int[int] aa; foreach_reverse(k, v; aa) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9358.d0000644000175000017500000000134615205374122021032 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9358.d(13): Error: `x` must be of integral or string type, it is a `double` fail_compilation/diag9358.d(15): Error: `case` expression must be a compile-time `string` or an integral constant, not `1.1` fail_compilation/diag9358.d(16): Error: `case` expression must be a compile-time `string` or an integral constant, not `2.1` fail_compilation/diag9358.d(26): Error: `case` expression must be a compile-time `string` or an integral constant, not `z` --- */ void main() { double x; switch (x) { case 1.1: break; case 2.1: break; default: } } void f(immutable string y) { auto z = y[0..2]; switch (y) { case z: break; default: } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail349.d0000644000175000017500000000057315205374122020751 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail349.d(15): Error: function `fail349.bug6109throwing` is not `nothrow` fail_compilation/fail349.d(13): Error: function `fail349.bug6109noThrow` may throw but is marked as `nothrow` --- */ int bug6109throwing() { throw new Exception("throws"); } int bug6109noThrow() nothrow { auto g = [4][0 .. bug6109throwing()]; return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10277.d0000644000175000017500000000475215205374122021115 0ustar fabiofabio// EXTRA_FILES: imports/fail10277.d module fail10227; /* TEST_OUTPUT: --- fail_compilation/imports/fail10277.d(3): Error: class `TypeInfo` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(4): Error: class `TypeInfo_Class` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(5): Error: class `TypeInfo_Interface` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(6): Error: class `TypeInfo_Struct` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(8): Error: class `TypeInfo_Pointer` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(9): Error: class `TypeInfo_Array` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(10): Error: class `TypeInfo_AssociativeArray` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(11): Error: class `TypeInfo_Enum` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(12): Error: class `TypeInfo_Function` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(13): Error: class `TypeInfo_Delegate` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(14): Error: class `TypeInfo_Tuple` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(15): Error: class `TypeInfo_Const` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(16): Error: class `TypeInfo_Invariant` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(17): Error: class `TypeInfo_Shared` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(18): Error: class `TypeInfo_Inout` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(19): Error: class `TypeInfo_Vector` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(20): Error: class `Object` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(21): Error: class `Throwable` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(22): Error: class `Exception` only object.d can define this reserved class name fail_compilation/imports/fail10277.d(23): Error: class `Error` only object.d can define this reserved class name --- */ import imports.fail10277; ./ldc-1.42.0-src/tests/dmd/fail_compilation/pragmas.d0000644000175000017500000000106515205374122021225 0ustar fabiofabio/************************************************************/ /* TEST_OUTPUT: --- fail_compilation/pragmas.d(103): Error: one boolean expression expected for `pragma(inline)`, not 2 fail_compilation/pragmas.d(108): Error: one boolean expression expected for `pragma(inline)`, not 2 --- */ #line 100 void test1() { pragma(inline); pragma(inline, true, false); } void test2() { pragma(inline, true, false); } void test3() { pragma(inline, "string"); // works now } void test4() { pragma(unrecognized, "string"); // permitted, just ignored } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21547.d0000644000175000017500000000147715205374122021120 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21547 /* TEST_OUTPUT: --- fail_compilation/fail21547.d(34): Error: Cannot use struct initializer syntax for struct `Bar` because it has a constructor fail_compilation/fail21547.d(34): Use `Bar( arguments )` instead of `{ initializers }` fail_compilation/fail21547.d(35): Error: Cannot use struct initializer syntax for struct `Bar1` because it has a constructor fail_compilation/fail21547.d(35): Use `Bar1( arguments )` instead of `{ initializers }` --- */ struct Bar { @disable this(int a) {} this(int a, int b) {} string a; uint b; } struct Bar1 { @disable this(int a) {} this(const ref Bar1 o) {} this(int a, int b) {} string a; uint b; } void main () { Bar b = { a: "Hello", b: 42 }; Bar1 b1 = { a: "Hello", b: 42 }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/enumtype.c0000644000175000017500000000101715205374122021435 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/enumtype.c(111): Error: enum member `enumtype.E2.A2` enum member value `549755813889L` does not fit in `int` --- */ #line 100 enum E1 { A1 = 0, B1 = sizeof(A1), C1 = 1LL, D1 = sizeof(C1), F1 = -1U, G1 }; _Static_assert(A1 == 0, "in"); _Static_assert(B1 == 4, "in"); _Static_assert(C1 == 1, "in"); _Static_assert(D1 == 8, "in"); _Static_assert(F1 == -1U, "in"); _Static_assert(G1 == 0x100000000, "in"); _Static_assert(sizeof(enum E1) == 8, "in"); enum E2 : int { A2 = 0x8000000001LL }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/e7804_2.d0000644000175000017500000000044515205374122020564 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/e7804_2.d(17): Error: `__traits(getMember, Foo, "func")` does not give a valid type --- */ module e7804_2; class Foo { void func(){} } void test() { __traits(getMember, Foo, "func") var; auto a = cast(__traits(getMember, Foo, "func")) 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/attributediagnostic.d0000644000175000017500000000321515205374122023642 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/attributediagnostic.d(21): Error: `@safe` function `attributediagnostic.layer2` cannot call `@system` function `attributediagnostic.layer1` fail_compilation/attributediagnostic.d(23): which calls `layer0` fail_compilation/attributediagnostic.d(25): which calls `system` fail_compilation/attributediagnostic.d(27): and executing an `asm` statement without `@trusted` annotation makes it fail to infer `@safe` fail_compilation/attributediagnostic.d(22): `attributediagnostic.layer1` is declared here fail_compilation/attributediagnostic.d(43): Error: `@safe` function `D main` cannot call `@system` function `attributediagnostic.system1` fail_compilation/attributediagnostic.d(32): and cast from `uint` to `int*` makes it fail to infer `@safe` fail_compilation/attributediagnostic.d(30): `attributediagnostic.system1` is declared here fail_compilation/attributediagnostic.d(44): Error: `@safe` function `D main` cannot call `@system` function `attributediagnostic.system2` fail_compilation/attributediagnostic.d(38): and calling `@system` `fsys` makes it fail to infer `@safe` fail_compilation/attributediagnostic.d(36): `attributediagnostic.system2` is declared here --- */ // Issue 17374 - Improve inferred attribute error message // https://issues.dlang.org/show_bug.cgi?id=17374 auto layer2() @safe { layer1(); } auto layer1() { layer0(); } auto layer0() { system(); } auto system() { asm {} } auto system1() { int* x = cast(int*) 0xDEADBEEF; } auto fsys = function void() @system {}; auto system2() { fsys(); } void main() @safe { system1(); system2(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/already_defined.d0000644000175000017500000000365315205374122022677 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/already_defined.d(4): Error: declaration `already_defined.func1.a` is already defined fail_compilation/already_defined.d(3): `variable` `a` is defined here fail_compilation/already_defined.d(10): Error: declaration `already_defined.func2.core` is already defined fail_compilation/already_defined.d(9): `import` `core` is defined here fail_compilation/already_defined.d(28): Error: declaration `Ident(T)` is already defined fail_compilation/already_defined.d(27): `template` `Ident(T)` is defined here fail_compilation/already_defined.d(36): Error: declaration `Tstring` is already defined fail_compilation/already_defined.d(35): `alias` `Tstring` is defined here fail_compilation/already_defined.d(42): Error: declaration `T` is already defined fail_compilation/already_defined.d(41): `alias` `T` is defined here fail_compilation/already_defined.d(48): Error: declaration `core` is already defined fail_compilation/already_defined.d(47): `import` `core` is defined here fail_compilation/already_defined.d(54): Error: declaration `core` is already defined fail_compilation/already_defined.d(53): `import` `core` is defined here --- */ #line 1 void func1 () { int a; bool a; } void func2 () { import core.stdc.stdio; string core; } void func3 () { { import core.stdc.stdio; } { // No conflict string core; } } void func4 () { template Ident (T) { alias Ident = T; } template Ident (T) { alias Ident = T; } } void func5 () { template Ident (T) { alias Ident = T; } alias Tstring = Ident!string; alias Tstring = Ident!string; } void func6 () { static if (is(int T == int)) {} static if (is(int T == int)) {} } void func7 () { import core.stdc.stdio; static if (is(int core == int)) {} } void func8 () { import core.stdc.stdio; static if (is(string : core[], core)) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20489.d0000644000175000017500000000166215205374122021164 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test20489.d(19): Error: function `pure nothrow @nogc @safe int test20489.D.f(int delegate(int) pure nothrow @nogc @safe body)` does not override any function, did you mean to override `pure nothrow @nogc @safe int test20489.B.f(scope int delegate(int) pure nothrow @nogc @safe)`? fail_compilation/test20489.d(19): Did you intend to override: fail_compilation/test20489.d(19): `pure nothrow @nogc @safe int test20489.B.f(scope int delegate(int) pure nothrow @nogc @safe)` fail_compilation/test20489.d(19): Parameter 1 is missing `scope` --- */ // Test case for https://github.com/dlang/dmd/issues/20489 // Improved error message on override mismatches class B { pure nothrow @nogc @safe int f(scope int delegate(int) pure nothrow @nogc @safe) { return 0; } } class D : B { override pure nothrow @nogc @safe int f(int delegate(int) pure nothrow @nogc @safe body) { return 0; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail198.d0000644000175000017500000000022015205374122020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail198.d(8): Error: template instance `test!42` template `test` is not defined --- */ int x = test!(42); ./ldc-1.42.0-src/tests/dmd/fail_compilation/const_ctor.d0000644000175000017500000000067715205374122021760 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/const_ctor.d(23): Error: `const` copy constructor `const_ctor.S1.this` cannot construct a mutable object fail_compilation/const_ctor.d(25): Error: `const` constructor `const_ctor.S2.this` cannot construct a mutable object --- */ struct S1 { this(ref const S1 s) const {} int* i; } struct S2 { this(int) const {} int* i; } void main() { const(S1) s1; S1 m1 = s1; S2 s2 = S2(5); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17908b.d0000644000175000017500000000036515205374122021327 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test17908b.d(13): Error: function `test17908b.foobar` cannot be used because it is annotated with `@disable` --- */ void foobar() {} @disable void foobar(int) {} alias i = foobar; void main() { i(10); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15755.d0000644000175000017500000000067715205374122021125 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail15755.d(28): Error: `AliasSeq!(123)` has no effect --- */ // https://issues.dlang.org/show_bug.cgi?id=15755 struct Foo { @(123) int a; } template Attributes(As...) { alias Attributes = As; } template getattribute(alias member, alias attrs = Attributes!(__traits(getAttributes, member))) { alias getattribute = attrs; } void main() { getattribute!(__traits(getMember, Foo, "a")); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/safe_gshared.d0000644000175000017500000000046715205374122022213 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/safe_gshared.d(13): Error: accessing `__gshared` data `x` is not allowed in a `@safe` function fail_compilation/safe_gshared.d(14): Error: accessing `__gshared` data `x` is not allowed in a `@safe` function --- */ __gshared int x; @safe int f() { x++; return x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9081.d0000644000175000017500000000047615205374122021035 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9081.d(12): Error: package `core` has no type fail_compilation/fail9081.d(13): Error: package `stdc` has no type fail_compilation/fail9081.d(14): Error: module `stdio` has no type --- */ import core.stdc.stdio; typeof(core) a; typeof(core.stdc) b; typeof(core.stdc.stdio) c; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17380spec.d0000644000175000017500000000136515205374122022033 0ustar fabiofabio/* REQUIRED_ARGS: -verrors=spec TEST_OUTPUT: --- (spec:1) fail_compilation/test17380spec.d(15): Error: cannot resolve identifier `ThisTypeDoesNotExistAndCrashesTheCompiler` (spec:1) fail_compilation/test17380spec.d(15): Error: no property `ThisTypeDoesNotExistAndCrashesTheCompiler` for `this.opCast()` of type `test17380spec.Uint128` (spec:1) fail_compilation/test17380spec.d(20): struct `Uint128` defined here fail_compilation/test17380spec.d(15): Error: undefined identifier `ThisTypeDoesNotExistAndCrashesTheCompiler` --- */ struct Int128 { Uint128 opCast() { return ThisTypeDoesNotExistAndCrashesTheCompiler; } alias opCast this; } struct Uint128 { Int128 opCast() { return Int128.init; } alias opCast this; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21164.d0000644000175000017500000000070415205374122021147 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/imports/test21164d.d(3): Error: (expression) expected following `static if` fail_compilation/imports/test21164d.d(3): Error: found `}` instead of statement fail_compilation/imports/test21164a.d(5): Error: undefined identifier `I` fail_compilation/test21164.d(12): Error: template instance `test21164a.D!(R!(O(), 1))` error instantiating --- */ import imports.test21164a; import imports.test21164b; auto GB(D!Q) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail327.d0000644000175000017500000000066315205374122020745 0ustar fabiofabio/* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/fail327.d(11): Error: executing an `asm` statement without `@trusted` annotation is not allowed in a `@safe` function fail_compilation/fail327.d(12): Deprecation: `asm` statement cannot be marked `@safe`, use `@system` or `@trusted` instead --- */ @safe void* foo() { asm { xor EAX,EAX; } asm @safe { mov [RIP], 0; } void* p; RIP: return p; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9892.d0000644000175000017500000000033015205374122021034 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=9892 /* TEST_OUTPUT: --- fail_compilation/fail9892.d(11): Error: enum member `fail9892.a` circular reference to `enum` member --- */ enum { a = b, //Segfault! b } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail34.d0000644000175000017500000000130415205374122020651 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail34.d(31): Error: duplicate `case "123"` in `switch` statement --- */ // $HeadURL$ // $Date$ // $Author$ // @author@ Thomas Kuehne // @date@ 2004-11-17 // @uri@ news:u1gr62-kjv.ln1@kuehne.cn // @url@ nntp://digitalmars.com/digitalmars.D.bugs/2288 // duplicate case "123" in switch statement module switch_12; int main() { string array = "123"; switch(array) { case "123": { assert(0); break; } case "123": { assert(1); break; } default: { return -1; // dummy } } return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail257.d0000644000175000017500000000042515205374122020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail257.d(8): Error: incompatible types for `("foo"d) == ("bar"c)`: `dstring` and `string` fail_compilation/fail257.d(8): while evaluating `pragma(msg, "foo"d == "bar"c ? "A" : "B")` --- */ pragma(msg, "foo"d == "bar"c ? "A" : "B"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice18803b.d0000644000175000017500000000033315205374122021076 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice18803b.d(9): Error: (expression) expected following `static if` fail_compilation/ice18803b.d(9): Error: declaration expected following attribute, not end of file --- */ static if ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_contracts2.d0000644000175000017500000000020415205374122022642 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail_contracts2.d(8): Error: missing `do { ... }` after `in` or `out` --- */ void foo()in{}{} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17625.d0000644000175000017500000000035415205374122021113 0ustar fabiofabio/* EXTRA_FILES: imports/a17625.d imports/b17625.d TEST_OUTPUT: --- fail_compilation/fail17625.d(16): Error: undefined identifier `boo` --- */ module fail17625; import imports.a17625; import imports.b17625; void main() { boo(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail8217.d0000644000175000017500000000053215205374122021026 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail8217.d(22): Error: `this` for `foo` needs to be type `D` not type `fail8217.D.C` --- */ class D { int x; template bar() { int foo() { return x; } } static class C { int foo() { return bar!().foo(); } } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23216.d0000644000175000017500000000133215205374122021145 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23216.d(23): Error: invalid `foreach_reverse` aggregate `r` of type `Range` fail_compilation/test23216.d(23): `foreach_reverse` works with bidirectional ranges (implementing `back` and `popBack`), aggregates implementing `opApplyReverse`, or the result of an aggregate's `.tupleof` property fail_compilation/test23216.d(23): https://dlang.org/phobos/std_range_primitives.html#isBidirectionalRange --- */ // https://issues.dlang.org/show_bug.cgi?id=23216 // Better Error Message For foreach_reverse Without Bidirectional Range struct Range { bool empty = true; int front = 0; void popFront() { } } void main() { Range r; foreach_reverse (word; r) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test12385.d0000644000175000017500000000070715205374122021157 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test12385.d(29): Error: cannot modify `immutable` expression `unbundled.x` --- */ // https://issues.dlang.org/show_bug.cgi?id=12385 class BundledState { string m_State; int x = 3; this(string state) immutable { m_State = state; } } enum States : immutable(BundledState) { unbundled = new immutable BundledState("bla"), } void main() { States.unbundled.x = 6; // Modifies x. } ./ldc-1.42.0-src/tests/dmd/fail_compilation/named_arguments_overload.d0000644000175000017500000000363615205374122024645 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/named_arguments_overload.d(33): Error: none of the overloads of `snoopy` are callable using argument types `(immutable(S), immutable(T))` fail_compilation/named_arguments_overload.d(17): Candidates are: `named_arguments_overload.snoopy(S s, int i = 0, T t = T())` fail_compilation/named_arguments_overload.d(18): `named_arguments_overload.snoopy(T t, int i, S s)` fail_compilation/named_arguments_overload.d(34): Error: none of the overloads of `snoopy` are callable using argument types `(immutable(T), immutable(S))` fail_compilation/named_arguments_overload.d(17): Candidates are: `named_arguments_overload.snoopy(S s, int i = 0, T t = T())` fail_compilation/named_arguments_overload.d(18): `named_arguments_overload.snoopy(T t, int i, S s)` fail_compilation/named_arguments_overload.d(35): Error: `named_arguments_overload.snoopy` called with argument types `(immutable(S), immutable(T), immutable(int))` matches multiple overloads after qualifier conversion: fail_compilation/named_arguments_overload.d(17): `named_arguments_overload.snoopy(S s, int i = 0, T t = T())` and: fail_compilation/named_arguments_overload.d(18): `named_arguments_overload.snoopy(T t, int i, S s)` --- */ char snoopy(S s, int i = 0, T t = T.init) { return 'B'; } char snoopy(T t, int i, S s) { return 'A'; } struct S { } struct T { } immutable S s = S.init; immutable T t = T.init; immutable int i = 0; static assert(snoopy(t, i, s ) == 'A'); static assert(snoopy(s, i, t ) == 'B'); static assert(snoopy(s:s, t:t ) == 'B'); static assert(snoopy(t:t, s:s ) == 'B'); static assert(snoopy(t:t, i, s:s) == 'A'); static assert(snoopy(s:s, t:t, i ) == 'A'); immutable err0 = snoopy(s, t); // error, neither A nor B match immutable err1 = snoopy(t, s); // error, neither A nor B match immutable err2 = snoopy(s:s, t:t, i:i); // error, ambiguous ./ldc-1.42.0-src/tests/dmd/fail_compilation/ldc_github_1822.d0000644000175000017500000000056615205374122022360 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ldc_github_1822.d(13): Error: call to unimplemented abstract function `void coreDump()` fail_compilation/ldc_github_1822.d(13): declared here: fail_compilation/ldc_github_1822.d(19) --- */ class Child : Parent { override void coreDump() { super.coreDump(); } } class Parent { abstract void coreDump(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_contracts5.d0000644000175000017500000000157715205374122022663 0ustar fabiofabio /* TEST_OUTPUT: --- fail_compilation/fail_contracts5.d(13): Error: constructor `fail_contracts5.S.this` `in` and `out` contracts can only appear without a body when they are virtual interface functions or abstract --- */ // bugzilla 12901 struct S { int a; this(int n) in { a = n; } // no body } /* TEST_OUTPUT: --- fail_compilation/fail_contracts5.d(33): Error: function `fail_contracts5.C2.foo` `in` and `out` contracts can only appear without a body when they are virtual interface functions or abstract fail_compilation/fail_contracts5.d(32): Error: constructor `fail_contracts5.C2.this` `in` and `out` contracts can only appear without a body when they are virtual interface functions or abstract --- */ // https://github.com/dlang/dmd/issues/21403 abstract class C1 {} class C2 : C1 { bool member; this() out (member) {} final void foo() out (member) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4510.d0000644000175000017500000000043015205374122021013 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4510 /* TEST_OUTPUT: --- fail_compilation/fail4510.d(12): Error: argument type mismatch, `float` to `ref double` --- */ void main() { float[] arr = [1.0, 2.5, 4.0]; foreach (ref double elem; arr) { //elem /= 2; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag6699.d0000644000175000017500000000064515205374122021040 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag6699.d(8): Error: no property `x` for type `int` --- */ alias int b6699; alias b6699.x b6699a; /* TEST_OUTPUT: --- fail_compilation/diag6699.d(18): Error: undefined identifier `junk1` fail_compilation/diag6699.d(18): Error: undefined identifier `junk2` fail_compilation/diag6699.d(19): Error: undefined identifier `junk3` --- */ class X : junk1, junk2 {} interface X2 : junk3 {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21939.d0000644000175000017500000000077515205374122021171 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21939 /* TEST_OUTPUT: --- fail_compilation/test21939.d(11): Error: invalid `foreach` aggregate `Object` of type `Object` fail_compilation/test21939.d(11): `foreach` works with input ranges (implementing `front` and `popFront`), aggregates implementing `opApply`, or the result of an aggregate's `.tupleof` property fail_compilation/test21939.d(11): https://dlang.org/phobos/std_range_primitives.html#isInputRange --- */ static foreach (a; Object) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail24389.c0000644000175000017500000000064215205374122021117 0ustar fabiofabio/* DISABLED: LDC // CAsmDeclarations supported by LDC; verified by tests/codegen/casm.c TEST_OUTPUT: --- fail_compilation/fail24389.c(10): Error: Gnu Asm not supported - compile this file with gcc or clang --- */ typedef unsigned long size_t; void __qsort_r_compat(void *, size_t, size_t, void *, int (*)(void *, const void *, const void *)); __asm__(".symver " "__qsort_r_compat" ", " "qsort_r" "@" "FBSD_1.0"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15660.d0000644000175000017500000000210115205374122021144 0ustar fabiofabio/* REQUIRED_ARGS: -preview=fixImmutableConv TEST_OUTPUT: --- fail_compilation/test15660.d(26): Error: cannot implicitly convert expression `f(v)` of type `int[]` to `immutable(int[])` fail_compilation/test15660.d(34): Error: cannot copy `const(void)[]` to `void[]` fail_compilation/test15660.d(34): Source data has incompatible type qualifier(s) fail_compilation/test15660.d(34): Use `cast(void[])` to force copy fail_compilation/test15660.d(36): Error: cannot copy `const(int*)[]` to `void[]` fail_compilation/test15660.d(36): Source data has incompatible type qualifier(s) fail_compilation/test15660.d(36): Use `cast(void[])` to force copy --- */ // https://issues.dlang.org/show_bug.cgi?id=15660 int[] f(ref void[] m) pure { auto result = new int[5]; m = result; return result; } void main() { void[] v; immutable x = f(v); } // https://issues.dlang.org/show_bug.cgi?id=17148 void f(int*[] a, const int*[] b) @system { void[] a1 = a; const(void)[] b1 = b; a1[] = b1[]; *a[0] = 0; //modify const data a1[] = new const(int*)[2]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21807.d0000644000175000017500000000205415205374122021153 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=21807 REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/test21807.d(11): Deprecation: slice of static array temporary returned by `getSArray()` assigned to longer lived variable `this.str` fail_compilation/test21807.d(12): Deprecation: slice of static array temporary returned by `getSArray()` assigned to longer lived variable `this.ca` --- */ #line 1 char[12] getSArray() pure; class Foo { string str; char[] ca; this() { str = getSArray(); // Should probably be a type error ca = getSArray(); } } /* TEST_OUTPUT: --- fail_compilation/test21807.d(117): Error: function `addr` is not callable using argument types `(int)` fail_compilation/test21807.d(117): cannot pass rvalue argument `S(0).i` of type `int` to parameter `return ref int b` fail_compilation/test21807.d(106): `test21807.addr(return ref int b)` declared here --- */ #line 100 struct S { int i; } int* addr(return ref int b) { return &b; } class Foo2 { int* ptr; this() { ptr = addr(S().i); // struct temporary } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11153.d0000644000175000017500000000062215205374122020724 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11153.d(12): Error: function declaration without return type fail_compilation/ice11153.d(12): Note that constructors are always named `this` fail_compilation/ice11153.d(12): Error: variable name expected after type `foo()`, not `{` --- */ struct S { foo(T)() {} // Parser creates a TemplateDeclaration object with ident == NULL } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19955.d0000644000175000017500000000033515205374122021122 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19955.d(7): Error: `switch` statement without a `default`; use `final switch` or add `default: assert(0);` or add `default: break;` --- */ void f() { switch(1) static assert(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15626.d0000644000175000017500000000040315205374122021105 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail15626.d(12): Error: class `fail15626.D` C++ base class `C` needs at least one virtual function --- */ extern (C++) { class C { } interface I { void f(); } class D : C, I { void f() { } } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag7050c.d0000644000175000017500000000052015205374122021151 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag7050c.d(14): Error: `@safe` destructor `diag7050c.B.~this` cannot call `@system` destructor `diag7050c.A.~this` fail_compilation/diag7050c.d(11): `diag7050c.A.~this` is declared here --- */ struct A { ~this(){} } @safe struct B { A a; } @safe void f() { auto x = B.init; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14177.d0000644000175000017500000000032715205374122020737 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/ice14177.d(8): Error: alias `ice14177.Primitive` recursive alias declaration ---- */ alias Primitive = Atom*; alias Atom = Primitive; void main() { Atom atom; atom; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375x.d0000644000175000017500000000045515205374122021223 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375x.d(13): Error: else is dangling, add { } after condition at fail_compilation/fail4375x.d(10) --- */ static if (true) abstract: static if (false) class G5 {} else class G6 {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag12678.d0000644000175000017500000000126015205374122021104 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag12678.d(21): Error: const field `cf1` initialized multiple times fail_compilation/diag12678.d(20): Previous initialization is here. fail_compilation/diag12678.d(24): Error: immutable field `if1` initialized multiple times fail_compilation/diag12678.d(23): Previous initialization is here. fail_compilation/diag12678.d(27): Error: const field `cf2` initialization is not allowed in loops or after labels --- */ struct S { const int cf1; const int cf2; immutable int if1; this(int x) { cf1 = x; cf1 = x; if1 = x; if1 = x; foreach (i; 0 .. 5) cf2 = x; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail180.d0000644000175000017500000000204415205374122020735 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail180.d(23): Error: cannot modify `this.x` in `const` function fail_compilation/fail180.d(24): Error: cannot modify `this.x` in `const` function fail_compilation/fail180.d(38): Error: cannot modify `this.x` in `const` function fail_compilation/fail180.d(39): Error: cannot modify `this.x` in `const` function fail_compilation/fail180.d(50): Error: variable `fail180.main.t` cannot be `final`, perhaps you meant `const`? fail_compilation/fail180.d(62): Error: variable `fail180.test.d` cannot be `final`, perhaps you meant `const`? --- */ struct S59 { int x; void foo() { x = 3; } const void bar() { x = 4; this.x = 5; } } class C { int x; void foo() { x = 3; } const void bar() { x = 4; this.x = 5; } } void main() { S59 s; s.foo(); s.bar(); final S59 t; t.foo(); t.bar(); } void test() { C c = new C; c.foo(); c.bar(); final C d = new C; d.foo(); d.bar(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag11132.d0000644000175000017500000000070515205374122021067 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag11132.d(23): Error: overlapping initialization for field `a` and `b` fail_compilation/diag11132.d(23): `struct` initializers that contain anonymous unions must initialize only the first member of a `union`. All subsequent non-overlapping fields are default initialized --- */ struct S { int x; union { int a; int b; } int z; } void main() { S s = { 1, 2, 3 }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/mangle2.d0000644000175000017500000000053015205374122021114 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/mangle2.d(9): Error: pragma `mangle` null character not allowed in mangled name fail_compilation/mangle2.d(10): Error: pragma `mangle` null character not allowed in mangled name --- */ //\0 chars __gshared pragma(mangle, "test\09") ubyte test9_5; __gshared extern pragma(mangle, "test\09") ubyte test9_5_e; ./ldc-1.42.0-src/tests/dmd/fail_compilation/nestedtempl0.d0000644000175000017500000000152715205374122022202 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/nestedtempl0.d(18): Error: class `nestedtempl0.K.D!(1, B!(a)).D` doesn't need a frame pointer, but super class `B` needs the frame pointer of `main` fail_compilation/nestedtempl0.d(28): Error: template instance `nestedtempl0.K.D!(1, B!(a))` error instantiating fail_compilation/nestedtempl0.d(18): Error: class `nestedtempl0.main.fun.D!(b, B!(a)).D` needs the frame pointer of `fun`, but super class `B` needs the frame pointer of `main` fail_compilation/nestedtempl0.d(33): Error: template instance `nestedtempl0.main.fun.D!(b, B!(a))` error instantiating --- */ class K { class B(alias a) { } class D(alias a, T) : T { } } void main() { int a; auto k = new K; auto d = k.new K.D!(1, K.B!a); auto fun() { int b; auto o = k.new K.D!(b, K.B!a); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ftimetrace.d0000644000175000017500000000027715205374122021722 0ustar fabiofabio/** DISABLED: LDC // different error message REQUIRED_ARGS: -ftime-trace-granularity=-800 TEST_OUTPUT: --- Error: `-ftime-trace-granularity` requires a positive number of microseconds --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11967.d0000644000175000017500000000102215205374122020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11967.d(12): Error: use `@(attributes)` instead of `[attributes]` fail_compilation/ice11967.d(12): Error: expression expected, not `%` fail_compilation/ice11967.d(12): Error: found `g` when expecting `)` fail_compilation/ice11967.d(12): Error: found `{` when expecting `]` fail_compilation/ice11967.d(13): Error: `@identifier` or `@(ArgumentList)` expected, not `@End of File` fail_compilation/ice11967.d(13): Error: declaration expected following attribute, not end of file --- */ [F(%g{@ ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice23569.d0000644000175000017500000000061715205374122020746 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23569 /* TEST_OUTPUT: --- fail_compilation/ice23569.d(24): Error: cannot compare classes for equality because `object.Object` was not declared --- */ module object; T _d_newclassT(T)() if (is(T == class)) { return null; } @safe unittest1() { class F { this(int ) { } } auto ice23569 = new F(0) == new F(0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7424c.d0000644000175000017500000000031015205374122021162 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7424c.d(10): Error: template `this.g()()` has no value --- */ struct S7424c { @property int g()() { return 0; } void test() immutable { int f = g; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375p.d0000644000175000017500000000070515205374122021211 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375p.d(17): Error: else is dangling, add { } after condition at fail_compilation/fail4375p.d(10) --- */ void main() { if (true) while (false) for (;;) scope (exit) synchronized (x) if (true) assert(90); else assert(89); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22151.d0000644000175000017500000000201615205374122021076 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22151 /* TEST_OUTPUT: --- fail_compilation/fail22151.d(17): Error: function `test` is not an lvalue and cannot be modified fail_compilation/fail22151.d(18): Error: function `test2` is not an lvalue and cannot be modified fail_compilation/fail22151.d(21): Error: function pointed to by `fp` is not an lvalue and cannot be modified fail_compilation/fail22151.d(24): Error: function pointed to by `ff` is not an lvalue and cannot be modified fail_compilation/fail22151.d(27): Error: operator `==` is not defined for function types fail_compilation/fail22151.d(28): Error: operator `is` is not defined for function types fail_compilation/fail22151.d(29): Error: comparison is not defined for function types --- */ void test() { *&test = *&test; *&test2 = *&test; void function() fp; *fp = *fp; auto ff = &test2; *ff = *&test2; // https://github.com/dlang/dmd/issues/18281 const c = *fp == *fp; const d = *fp is *fp; const e = *fp < *fp; } void test2(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7424h.d0000644000175000017500000000030415205374122021172 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7424h.d(10): Error: template `this.g()()` has no value --- */ struct S7424g { @property int g()() { return 0; } void test() inout { int f = g; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9479.d0000644000175000017500000000027015205374122021031 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9479.d(10): Error: undefined identifier `something_undefined` --- */ int delegate() bug9479() { return { return something_undefined; }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail298.d0000644000175000017500000000036115205374122020747 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail298.d(12): Error: cannot implicitly convert expression `num1 / cast(ulong)num2` of type `ulong` to `int` --- */ void main() { ulong num1 = 100; int num2 = 10; int result = num1 / num2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4269b.d0000644000175000017500000000035615205374122021177 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4269b.d(11): Error: undefined identifier `B` fail_compilation/fail4269b.d(12): Error: undefined identifier `B` --- */ enum bool WWW = is(typeof(A.x)); struct A { B blah; void foo(B b){} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail192.d0000644000175000017500000000111615205374122020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail192.d(15): Error: outer function context of `fail192.foo` is needed to `new` nested class `fail192.foo.DummyClass` fail_compilation/fail192.d(26): Error: template instance `fail192.X!(DummyClass)` error instantiating --- */ // https://issues.dlang.org/show_bug.cgi?id=1336 // Internal error when trying to construct a class declared within a unittest from a templated class. class X(T) { void bar() { auto t = new T; } } void foo() { class DummyClass { } //auto x = new X!(DummyClass); X!(DummyClass) x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375y.d0000644000175000017500000000055515205374122021225 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375y.d(15): Error: else is dangling, add { } after condition at fail_compilation/fail4375y.d(10) --- */ static if (true) align(1) extern(C) pure static if (false) void G10(){} else void G11(){} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail126.d0000644000175000017500000000017415205374122020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail126.d(8): Error: forward reference to `test` --- */ void test(typeof(test) p) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10616.d0000644000175000017500000000024615205374122020731 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10616.d(8): Error: class `ice10616.A` is forward referenced when looking for `B` --- */ class A : A.B { interface B {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13385.d0000644000175000017500000000031615205374122020735 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13385.d(9): Error: visibility attribute `package(a)` does not bind to one of ancestor packages of module `ice13385` --- */ module ice13385; package(a) void foo() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18708.d0000644000175000017500000000210515205374122021156 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test18708.d(24): Error: one path skips field `s` fail_compilation/test18708.d(29): Error: one path skips field `s` fail_compilation/test18708.d(34): Error: one path skips field `s` fail_compilation/test18708.d(39): Error: one path skips field `s` --- */ // https://issues.dlang.org/show_bug.cgi?id=18708 struct S { int y; @disable this(); } class C { S s; this(S t) { if (bar(s = t)) foo(); // OK } this(S t, int i) { i || bar(s = t); } this(S t, int i, int j) { i && bar(s = t); } this(S t, int i, long j) { i ? bar(s = t) : i; } this(S t, int i, byte j) { i ? i : bar(s = t); } } int bar(S s); int foo(); /***********************************/ class E : Exception { this(string msg, int line = 0, int pos = 0) pure nothrow @safe { if (line) super("hello"); else super(msg); } this(string msg, string file, size_t line) pure nothrow @safe { super(msg, file, line); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/moduleundefuda.d0000644000175000017500000000020315205374122022565 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/moduleundefuda.d(7): Error: undefined identifier `undef` --- */ @undef module moduleundefuda; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10862.d0000644000175000017500000001116715205374122021104 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10862.d(40): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(41): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(42): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(43): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(44): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(46): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(47): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(48): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(49): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(51): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(52): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(53): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(54): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(56): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(57): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(58): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(59): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(61): Error: undefined identifier `semanticError` fail_compilation/diag10862.d(71): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d(74): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d-mixin-77(77): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d-mixin-78(78): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d-mixin-79(79): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d-mixin-80(80): Error: using the result of a comma expression is not allowed fail_compilation/diag10862.d-mixin-80(80): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/diag10862.d-mixin-83(83): Error: cannot modify expression `a + b` because it is not an lvalue fail_compilation/diag10862.d-mixin-84(84): Error: undefined identifier `c` fail_compilation/diag10862.d(86): Error: undefined identifier `semanticError` fail_compilation/diag10862.d(93): Error: cannot modify lazy variable `bar` fail_compilation/diag10862.d(95): Error: template instance `diag10862.test3.foo!int` error instantiating --- */ void test1() { int a, b; if (a = b) {} if ((a = b) = 0) {} if ((a = b) = (a = b)) {} if (a = 0, b = 0) {} // https://issues.dlang.org/show_bug.cgi?id=15384 if (auto x = a = b) {} // this is error, today while (a = b) {} while ((a = b) = 0) {} while ((a = b) = (a = b)) {} while (a = 0, b = 0) {} // https://issues.dlang.org/show_bug.cgi?id=15384 do {} while (a = b); do {} while ((a = b) = 0); do {} while ((a = b) = (a = b)); do {} while (a = 0, b = 0); // https://issues.dlang.org/show_bug.cgi?id=15384 for (; a = b; ) {} for (; (a = b) = 0; ) {} for (; (a = b) = (a = b); ) {} for (; a = 0, b = 0; ) {} // https://issues.dlang.org/show_bug.cgi?id=15384 semanticError; } void test2() { int a, b; // (a + b) cannot be an assignment target. // However checkAssignAsCondition specilatively rerites it to EqualExp, // then the pointless error "is not an lvalue" would not happen. if (a + b = a * b) {} // The suggestion error masks "undefined identifier" error if (a = undefinedIdentifier) {} // If the condition is a mixin expression if (mixin("a = b")) {} if (mixin("(a = b) = 0")) {} if (mixin("(a = b) = (a = b)")) {} if (mixin("a = 0, b = 0")) {} if (auto x = mixin("a = b")) {} // Note: no error if (mixin("a + b = a * b")) {} // Note: "a + b is not an lvalue" if (mixin("a = c")) {} semanticError; } void test3() { void foo(T)(lazy T bar) { bar = 2; } foo(1 + 1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail5634.d0000644000175000017500000000027615205374122021033 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/fail5634.d(9): Error: function `D main()` conflicts with previous declaration at fail_compilation/fail5634.d(8) --- */ void main() { } void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/testOpApply.d0000644000175000017500000000711115205374122022055 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/testOpApply.d(27): Error: `testOpApply.SameAttr.opApply` called with argument types `(int delegate(int i) pure nothrow @nogc @safe)` matches multiple overloads after qualifier conversion: fail_compilation/testOpApply.d(13): `testOpApply.SameAttr.opApply(int delegate(int) @system dg)` and: fail_compilation/testOpApply.d(18): `testOpApply.SameAttr.opApply(int delegate(int) @system dg)` --- +/ struct SameAttr { int opApply(int delegate(int) @system dg) @system { return 0; } int opApply(int delegate(int) @system dg) @safe { return 0; } } void testSameAttr() @safe { SameAttr sa; foreach (int i; sa) {} } /+ TEST_OUTPUT: --- fail_compilation/testOpApply.d(104): Error: `testOpApply.SameAttr.opApply` called with argument types `(int delegate(int i) pure nothrow @nogc @system)` matches multiple overloads after qualifier conversion: fail_compilation/testOpApply.d(13): `testOpApply.SameAttr.opApply(int delegate(int) @system dg)` and: fail_compilation/testOpApply.d(18): `testOpApply.SameAttr.opApply(int delegate(int) @system dg)` --- +/ #line 100 void testSameAttr() @system { SameAttr sa; foreach (int i; sa) {} } /+ TEST_OUTPUT: --- fail_compilation/testOpApply.d(217): Error: `sa.opApply` matches more than one declaration: fail_compilation/testOpApply.d(203): `int(int delegate(int) dg)` and: fail_compilation/testOpApply.d(208): `int(int delegate(string) dg)` fail_compilation/testOpApply.d(217): Error: cannot uniquely infer `foreach` argument types --- +/ #line 200 struct DifferentTypes { int opApply(int delegate(int) dg) { return 0; } int opApply(int delegate(string) dg) { return 0; } } void testDifferentTypes() { DifferentTypes sa; foreach (i; sa) {} } /+ TEST_OUTPUT: --- fail_compilation/testOpApply.d(317): Error: `sa.opApply` matches more than one declaration: fail_compilation/testOpApply.d(303): `int(int delegate(int) dg)` and: fail_compilation/testOpApply.d(308): `int(int delegate(long) dg)` fail_compilation/testOpApply.d(317): Error: cannot uniquely infer `foreach` argument types --- +/ #line 300 struct CovariantTypes { int opApply(int delegate(int) dg) { return 0; } int opApply(int delegate(long) dg) { return 0; } } void testCovariantTypes() { CovariantTypes sa; foreach (i; sa) {} } /+ See https://issues.dlang.org/show_bug.cgi?id=21683 TEST_OUTPUT: --- fail_compilation/testOpApply.d(420): Error: `sa.opApply` matches more than one declaration: fail_compilation/testOpApply.d(404): `int(int delegate(int) dg)` and: fail_compilation/testOpApply.d(410): `int(int delegate(ref int) dg)` fail_compilation/testOpApply.d(420): Error: cannot uniquely infer `foreach` argument types --- +/ #line 400 struct DifferentQualifiers { int x; int opApply(int delegate(int) dg) { x = 1; return 0; } int opApply(int delegate(ref int) dg) { x = 2; return 0; } } void testDifferentQualifiers() { DifferentQualifiers sa; foreach (i; sa) {} } /+ TEST_OUTPUT: --- fail_compilation/testOpApply.d(504): Error: `sa.opApply` matches more than one declaration: fail_compilation/testOpApply.d(404): `int(int delegate(int) dg)` and: fail_compilation/testOpApply.d(410): `int(int delegate(ref int) dg)` fail_compilation/testOpApply.d(504): Error: cannot uniquely infer `foreach` argument types --- +/ #line 500 void testDifferentQualifiersRef() { DifferentQualifiers sa; foreach (ref i; sa) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11856_0.d0000644000175000017500000000102415205374122021152 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11856_0.d(19): Error: none of the overloads of template `ice11856_0.f` are callable using argument types `!()(int)` fail_compilation/ice11856_0.d(13): Candidates are: `f(T)(T t)` fail_compilation/ice11856_0.d(16): `f(T)(T t)` with `T = int` must satisfy the following constraint: ` !__traits(compiles, .f!T)` --- */ int f(T)(T t) if(!__traits(compiles,.f!T)) { return 0; } int f(T)(T t) if(!__traits(compiles,.f!T)) { return 1; } enum x=f(2); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail202.d0000644000175000017500000000035715205374122020735 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail202.d(10): Error: shift by 33 is outside the range `0..31` fail_compilation/fail202.d(10): Error: shift by 33 is outside the range `0..31` --- */ void main() { int c; c = c >> 33; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/cwords.d0000644000175000017500000000073415205374122021076 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/cwords.d(13): Error: undefined identifier `FALSE`, did you mean `false`? fail_compilation/cwords.d(14): Error: undefined identifier `TRUE`, did you mean `true`? fail_compilation/cwords.d(15): Error: undefined identifier `NULL`, did you mean `null`? fail_compilation/cwords.d(16): Error: undefined identifier `unsigned`, did you mean `uint`? --- */ void foo() { bool a = FALSE; bool b = TRUE; int* p = NULL; unsigned u; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24065.d0000644000175000017500000000106115205374122021147 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24065 /* TEST_OUTPUT: --- fail_compilation/test24065.d(12): Error: string expected as argument of __traits `getTargetInfo` instead of `int` fail_compilation/test24065.d(15): Error: string expected as argument of __traits `getTargetInfo` instead of `foo` fail_compilation/test24065.d(18): Error: string expected as argument of __traits `getTargetInfo` instead of `e` --- */ auto s1 = __traits(getTargetInfo, int); void foo() {} auto s2 = __traits(getTargetInfo, foo); enum e; auto s3 = __traits(getTargetInfo, e); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail39.d0000644000175000017500000000047415205374122020665 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail39.d(12): Error: function `fail39.main.__funcliteral_L12_C27` cannot access function `foo` in frame of function `D main` fail_compilation/fail39.d(11): `foo` declared here --- */ void main() { void foo() {} void function() bar = function void() { foo(); }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9766.d0000644000175000017500000000146515205374122021046 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9766.d(14): Error: integer constant expression expected instead of `Foo!int` fail_compilation/fail9766.d(14): Error: alignment must be an integer positive power of 2, not 0x0 fail_compilation/fail9766.d(17): Error: alignment must be an integer positive power of 2, not 0xffffffffffffffff fail_compilation/fail9766.d(20): Error: alignment must be an integer positive power of 2, not 0x0 fail_compilation/fail9766.d(23): Error: alignment must be an integer positive power of 2, not 0x3 fail_compilation/fail9766.d(26): Error: alignment must be an integer positive power of 2, not 0x80000001 --- */ #line 12 template Foo(T) {} align(Foo!int) struct S9766a {} align(-1) struct S9766b {} align(0) struct S9766c {} align(3) struct S9766d {} align((1u << 31) + 1) struct S9766e {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/noreturn_expr.d0000644000175000017500000000027215205374122022504 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/noreturn_expr.d(10): Error: type `noreturn` is not an expression --- */ int v(e)() { return e + 0; } int main() { return v!(noreturn)(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice15172.d0000644000175000017500000000225215205374122020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice15172.d(14): Error: constructor `ice15172.ThreadError.this` no match for implicit `super()` call in constructor --- */ // 1. ClassDeclaration.semantic class ThreadError : Error { // 2. FuncDeclaration.semantic // 4. FuncDeclaration.semantic3 // --> error happens this(string) { } } // 3. FuncDeclaration.semantic // 5. FuncDeclaration.semantic3 void onThreadError() { // 6. NewExp.semantic // --> cd.members.errors == false, cd.members.semantic3Errors == true // BUT, The ThreadError class constructor is not a template function, so // the errors inside its function body won't be associated with the validness of this NewExp. // Therefore, converting the semantic3Error to ErrorExp is not correct. // 7. ctfeInterpret // Finally, FuncDeclaration::interpret may encounter a function which is semantic3Errors == true. So // 7a. functionSemantic3() should return false if semantic3Errors is true. // 7b. the function body errors may not happen during ctfeInterpret call and global.errors could be unincremented. __gshared auto ThreadError = new ThreadError(null); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3290.d0000644000175000017500000000041015205374122021015 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=3290 /* TEST_OUTPUT: --- fail_compilation/fail3290.d(12): Error: argument type mismatch, `const(int)` to `ref int` --- */ void main() { const(int)[] array; foreach (ref int i; array) { //i = 42; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8825.d0000644000175000017500000000032215205374122021021 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8825.d(13): Error: undefined identifier `foo` --- */ template t(alias a){ alias int t; } void main(){ t!(foo // line 13 ) i; // line 19 return; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue20704.d0000644000175000017500000000262015205374122021316 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/issue20704.d(17): Error: cannot create default argument for `ref` / `out` parameter from constant `0` fail_compilation/issue20704.d(28): Error: template instance `issue20704.f2!int` error instantiating fail_compilation/issue20704.d(19): Error: cannot create default argument for `ref` / `out` parameter from constant `0` fail_compilation/issue20704.d(30): Error: template instance `issue20704.f4!int` error instantiating fail_compilation/issue20704.d(17): Error: cannot create default argument for `ref` / `out` parameter from expression `S(0)` because it is not an lvalue fail_compilation/issue20704.d(36): Error: template instance `issue20704.f2!(S)` error instantiating fail_compilation/issue20704.d(17): Error: cannot create default argument for `ref` / `out` parameter from expression `null` because it is not an lvalue fail_compilation/issue20704.d(38): Error: template instance `issue20704.f2!(C)` error instantiating --- */ // https://issues.dlang.org/show_bug.cgi?id=20704 void f1(T)(const auto ref T arg = T.init) {} void f2(T)(const ref T arg = T.init) {} void f3(T)(const auto ref T arg = 0) {} void f4(T)(const ref T arg = 0) {} struct S { int _; } class C { int _; } void main () { int i; f1!int(i); f2!int(i); f3!int(i); f4!int(i); f1!int(); f2!int(); f3!int(); f4!int(); f1!S(); f2!S(); f1!C(); f2!C(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23875.c0000644000175000017500000000071215205374122021160 0ustar fabiofabio/* DISABLED: win32 linux32 TEST_OUTPUT: --- fail_compilation/test23875.c(12): Error: __attribute__((vector_size(10))) must be an integer positive power of 2 and be <= 32,768 fail_compilation/test23875.c(13): Error: value for vector_size expected, not `x` --- */ // https://issues.dlang.org/show_bug.cgi?id=23875 // https://issues.dlang.org/show_bug.cgi?id=23880 int __attribute__((vector_size(10))) neptune(); int __attribute__((vector_size(x))) saturn(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14343.d0000644000175000017500000000112515205374122021102 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=14343 /* TEST_OUTPUT: --- fail_compilation/fail14343.d(21): Error: cannot modify struct instance `s` of type `S14343b` because it contains `const` or `immutable` members fail_compilation/fail14343.d(23): Error: cannot modify struct instance `s` of type `S14343b` because it contains `const` or `immutable` members --- */ struct S14343b { int i; immutable(Object) o; void opAddAssign(int j) { i += j; } void opAssign(S14343b other) {} } void test14343() { S14343b s; ++s; assert(s.i == 1); s++; assert(s.i == 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag1566.d0000644000175000017500000000153315205374122021021 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag1566.d(23): Error: multiple ! arguments are not allowed fail_compilation/diag1566.d(24): Error: multiple ! arguments are not allowed fail_compilation/diag1566.d(25): Error: multiple ! arguments are not allowed fail_compilation/diag1566.d(26): Error: multiple ! arguments are not allowed fail_compilation/diag1566.d(28): Error: multiple ! arguments are not allowed fail_compilation/diag1566.d(29): Error: multiple ! arguments are not allowed --- */ template T(int n) { template T(char c) { alias long T; } } void main() { static assert(is(long == T!(3)!('b'))); static assert(is(long == T! 3 ! 'b' )); static assert(is(long == T!(3)! 'b' )); static assert(is(long == T! 3 !('b'))); static assert(is(long == T!(3)! 'b' !"s")); static assert(is(long == T! 3 !('b')!"s")); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13131.d0000644000175000017500000000064015205374122020722 0ustar fabiofabio// EXTRA_SOURCES: imports/a13131parameters.d imports/a13131elec.d // EXTRA_FILES: imports/a13131checkpoint.d /* TEST_OUTPUT: --- +A +B fail_compilation/imports/a13131elec.d(10): Error: template instance `elecConnOf!gconn` template `elecConnOf` is not defined -B -A --- */ void main() { struct Connectivity {} auto L = Connectivity(); import imports.a13131elec; // [1] import L.initElec; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag3869.d0000644000175000017500000000621715205374122021035 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag3869.d(10): Error: template instance `diag3869.sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!(sum!int))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))` recursive expansion --- */ struct sum(A) { auto blah(int a) { return .sum!(sum)(); } } sum!(int) z; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail2450.d0000644000175000017500000000105715205374122021022 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=2450 /* TEST_OUTPUT: --- fail_compilation/fail2450.d(20): Error: function expected before `()`, not `this.mixin Event!() clicked;` of type `void` fail_compilation/fail2450.d(23): Error: function expected before `()`, not `b.mixin Event!() clicked;` of type `void` --- */ template Event() { void opCall() { } void opAddAssign(int i) { } } class Button { mixin Event clicked; void func() { clicked.opCall(); // works this.clicked(); // works auto b = new Button(); b.clicked(); // works } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10076.d0000644000175000017500000000116015205374122020725 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10076.d(18): Error: template instance `getMembersAndAttributesWhere!()` template `getMembersAndAttributesWhere` is not defined fail_compilation/ice10076.d(23): Error: template instance `ice10076.getValidaterAttrs!string` error instantiating fail_compilation/ice10076.d(13): instantiated from here: `validate!string` --- */ void main() { string s; validate(s); } template getValidaterAttrs(T) { alias getMembersAndAttributesWhere!().Elements getValidaterAttrs; } void validate(T)(T) { alias getValidaterAttrs!T memberAttrs; auto x = memberAttrs.length; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail104.d0000644000175000017500000000126215205374122020732 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=76 // Using a non-template struct as a template // Compiling leads to "Assertion failure: 's->parent' on line 1694 in file // 'template.c'" /* TEST_OUTPUT: --- fail_compilation/fail104.d(26): Error: template instance `P!()` `P` is not a template declaration, it is a alias fail_compilation/fail104.d(26): Error: mixin `fail104.C!(S).C.T!()` is not defined fail_compilation/fail104.d(31): Error: template instance `fail104.C!(S)` error instantiating --- */ struct S { template T() { void x(int i) { } } } class C(P) { mixin P!().T!(); } int main(char[][] args) { auto c = new C!(S); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13574.d0000644000175000017500000000117615205374122021115 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail13574.d(21): Error: cannot modify operator `$` fail_compilation/fail13574.d(27): Error: cannot modify operator `$` --- */ struct Foo { void opSlice(size_t a, size_t b) { } alias opDollar = length; size_t length; } void main() { Foo foo; foo[0 .. foo.length = 1]; assert(foo.length == 1); foo[0 .. $ = 2]; // assigns to the temporary dollar variable //assert(foo.length == 2); int[] arr = [1,2,3]; auto x = arr[0 .. arr.length = 1]; assert(arr.length == 1); auto y = arr[0 .. $ = 2]; // should also be disallowed //assert(arr.length == 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/staticassertargs.d0000644000175000017500000000024215205374122023155 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/staticassertargs.d(9): Error: static assert: abcxe3!! --- */ enum e = "!!"; static assert(false, "abc", ['x', 'e'], 3, e); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test19193.d0000644000175000017500000000047115205374122021161 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/test19193.d(13): Deprecation: enum member `test19193.T19193!int.A.b` is deprecated --- */ // https://issues.dlang.org/show_bug.cgi?id=19193 void main () { cast(void)T19193!int.A.b; } template T19193(T) { enum A { deprecated b } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17959.d0000644000175000017500000000103115205374122021162 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test17959.d(18): Error: assigning scope variable `this` to non-scope `this.escape` is not allowed in a `@safe` function fail_compilation/test17959.d(19): Error: assigning scope variable `this` to non-scope `this.f` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=17959 class Foo { void delegate () @safe escape; Foo f; void escfoo() @safe scope { this.escape = &this.escfoo; f = this; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19911c.d0000644000175000017500000000041415205374122021253 0ustar fabiofabio/* DFLAGS: TEST_OUTPUT: --- fail_compilation/fail19911c.d(14): Error: function `object.fun` `object.TypeInfo` could not be found, but is implicitly used in D-style variadic functions --- */ module object; class Object { } class TypeInfo_Tuple { } void fun(...) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failinout1.d0000644000175000017500000000027315205374122021646 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/failinout1.d(9): Error: cannot modify `inout` expression `x` --- */ inout(int) foo(inout(int) x) { x = 5; // cannot modify inout return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/cmodule_malformed.c0000644000175000017500000000124615205374122023251 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/cmodule_malformed.c(15): Error: identifier expected following `module` fail_compilation/cmodule_malformed.c(15): Error: no type for declarator before `"a"` fail_compilation/cmodule_malformed.c(21): Error: no type-specifier for struct member fail_compilation/cmodule_malformed.c(21): Error: identifier or `(` expected fail_compilation/cmodule_malformed.c(21): Error: expected identifier for declarator fail_compilation/cmodule_malformed.c(26): Error: found `__module` instead of statement --- */ #if __IMPORTC__ __module "a"; typedef struct S { int x; __module b; } S; void main(void) { __module c.d; } __module e; #endif ./ldc-1.42.0-src/tests/dmd/fail_compilation/parse14285.d0000644000175000017500000000022515205374122021306 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/parse14285.d(10): Error: variable name expected after type `this`, not `;` --- */ struct S { alias this; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bug4283.d0000644000175000017500000000026015205374122020665 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/bug4283.d(12): Error: declaration expected, not `}` --- */ template Foo(bool b) { static if (b) enum bool Foo = 1; else } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail229.d0000644000175000017500000000046015205374122020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail229.d(11): Error: array index 18446744073709551615 overflow fail_compilation/fail229.d(11): Error: array dimension overflow --- */ // https://issues.dlang.org/show_bug.cgi?id=1936 // Error with no line number (array dimension overflow) static int[] x = [-1: 1]; ./ldc-1.42.0-src/tests/dmd/fail_compilation/testrvaluecpctor.d0000644000175000017500000000274615205374122023213 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22593 /* TEST_OUTPUT: --- fail_compilation/testrvaluecpctor.d(16): Error: cannot define both an rvalue constructor and a copy constructor for `struct Foo` fail_compilation/testrvaluecpctor.d(24): Template instance `testrvaluecpctor.Foo!int.Foo.this!(immutable(Foo!int), immutable(Foo!int))` creates an rvalue constructor for `struct Foo` fail_compilation/testrvaluecpctor.d(24): Error: none of the overloads of `this` can construct an immutable object with argument types `(immutable(Foo!int))`. Expected `immutable(immutable(Foo!int))` fail_compilation/testrvaluecpctor.d(18): Candidates are: `testrvaluecpctor.Foo!int.Foo.this(ref scope Foo!int rhs)` fail_compilation/testrvaluecpctor.d(16): `this(Rhs, this This)(scope Rhs rhs)` --- */ struct Foo(T) { this(Rhs, this This)(scope Rhs rhs){} this(ref scope typeof(this) rhs){} } void fail22593() { immutable Foo!int a; a.__ctor(a); } // https://issues.dlang.org/show_bug.cgi?id=21613 /* TEST_OUTPUT: --- fail_compilation/testrvaluecpctor.d(40): Error: cannot define both an rvalue constructor and a copy constructor for `struct Test` fail_compilation/testrvaluecpctor.d(46): Template instance `testrvaluecpctor.Test.this!()` creates an rvalue constructor for `struct Test` --- */ struct Test { this(ref const typeof(this) rhs){} this()(const typeof(this) rhs){} // rvalue ctor } void fail21613() { const Test cb; Test b = cb; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail248.d0000644000175000017500000000020615205374122020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail248.d(9): Error: type `int` is not an expression --- */ alias int foo; typeof(foo) a; // ok ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail5953a2.d0000644000175000017500000000046115205374122021256 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail5953a2.d(11): Error: expression expected, not `,` fail_compilation/fail5953a2.d(11): Error: expression expected, not `,` fail_compilation/fail5953a2.d(11): Error: expression expected, not `,` --- */ void main() { auto a3 = [,,,]; // invalid, but compiles } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b15069.d0000644000175000017500000000054315205374122020421 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/b15069.d(15): Error: template instance `T!int` `T` is not a template declaration, it is a alias fail_compilation/b15069.d(10): Error: template instance `b15069.Stuff!(Thing!float)` error instantiating --- */ void main() { Stuff!(Thing!(float)) s; } struct Stuff(T) { T!(int) var; } struct Thing(T) { T varling; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail185.d0000644000175000017500000000046615205374122020750 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail185.d(10): Error: static assert: "An error message that spans multiple lines, and also contains such characters as a tab, \ and "." --- */ static assert (false, "An error message \tthat spans multiple lines, and also contains such characters as a tab, \\ and \"."); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7603c.d0000644000175000017500000000027315205374122021171 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7603c.d(8): Error: cannot create default argument for `ref` / `out` parameter from constant `3` --- */ enum x = 3; void test(ref int val = x) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19897.d0000644000175000017500000000033315205374122021125 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19897.d(12): Error: cannot implicitly convert expression `a.x` of type `const(char[0])` to `const(char)` --- */ struct S { char[0] x; } const a = S('a'); const char c = a.x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23745.d0000644000175000017500000000102215205374122021104 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=2374 /* TEST_OUTPUT: --- fail_compilation/fail23745.d(21): Error: undefined identifier `UndefinedType` fail_compilation/fail23745.d(14): Error: function `fun` does not override any function, did you mean to override `fail23745.A.fun`? fail_compilation/fail23745.d(21): Function `fail23745.A.fun` contains errors in its declaration, therefore it cannot be correctly overridden --- */ class B : A { override void fun() { } } class A { void fun(UndefinedType); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail332.d0000644000175000017500000000627315205374122020744 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail332.d(26): Error: function `foo` is not callable using argument types `()` fail_compilation/fail332.d(26): missing argument for parameter #1: `int __param_0` fail_compilation/fail332.d(21): `fail332.foo(int __param_0, ...)` declared here fail_compilation/fail332.d(27): Error: function `foo` is not callable using argument types `(typeof(null))` fail_compilation/fail332.d(27): cannot pass argument `null` of type `typeof(null)` to parameter `int __param_0` fail_compilation/fail332.d(21): `fail332.foo(int __param_0, ...)` declared here fail_compilation/fail332.d(29): Error: function `baz` is not callable using argument types `(string)` fail_compilation/fail332.d(29): cannot pass argument `""` of type `string` to parameter `int[] __param_0...` fail_compilation/fail332.d(22): `fail332.baz(int[] __param_0...)` declared here fail_compilation/fail332.d(30): Error: function `baz` is not callable using argument types `(int, typeof(null))` fail_compilation/fail332.d(30): cannot pass argument `null` of type `typeof(null)` to parameter `int[] __param_0...` fail_compilation/fail332.d(22): `fail332.baz(int[] __param_0...)` declared here --- */ import core.vararg; void foo(int, ...) {} void baz(int[]...) {} void test() { foo(); foo(null); baz(""); baz(3, null); } /* TEST_OUTPUT: --- fail_compilation/fail332.d(60): Error: function `bar` is not callable using argument types `()` fail_compilation/fail332.d(60): missing argument for parameter #1: `Object` fail_compilation/fail332.d(56): `fail332.bar(Object, int[2]...)` declared here fail_compilation/fail332.d(61): Error: function `bar` is not callable using argument types `(int)` fail_compilation/fail332.d(61): cannot pass argument `4` of type `int` to parameter `Object` fail_compilation/fail332.d(56): `fail332.bar(Object, int[2]...)` declared here fail_compilation/fail332.d(62): Error: function `bar` is not callable using argument types `(typeof(null))` fail_compilation/fail332.d(62): expected 2 variadic argument(s), not 0 fail_compilation/fail332.d(56): `fail332.bar(Object, int[2]...)` declared here fail_compilation/fail332.d(63): Error: function `bar` is not callable using argument types `(typeof(null), int)` fail_compilation/fail332.d(63): expected 2 variadic argument(s), not 1 fail_compilation/fail332.d(56): `fail332.bar(Object, int[2]...)` declared here fail_compilation/fail332.d(64): Error: function `bar` is not callable using argument types `(typeof(null), int, string)` fail_compilation/fail332.d(64): cannot pass argument `""` of type `string` to parameter `int[2]...` fail_compilation/fail332.d(56): `fail332.bar(Object, int[2]...)` declared here fail_compilation/fail332.d(65): Error: function `bar` is not callable using argument types `(typeof(null), int, int, int)` fail_compilation/fail332.d(65): expected 2 variadic argument(s), not 3 fail_compilation/fail332.d(56): `fail332.bar(Object, int[2]...)` declared here --- */ void bar(Object, int[2]...); void test2() { bar(); bar(4); bar(null); bar(null, 2); bar(null, 2, ""); bar(null, 2,3,4); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail270.d0000644000175000017500000000057415205374122020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail270.d(12): Error: string slice `[1 .. 0]` is out of bounds fail_compilation/fail270.d(12): Error: mixin `fail270.Tuple!int.Tuple.Tuple!()` error instantiating fail_compilation/fail270.d(14): Error: mixin `fail270.Tuple!int` error instantiating --- */ struct Tuple(TList...) { mixin .Tuple!((TList[1 .. $])) tail; } mixin Tuple!(int); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail272.d0000644000175000017500000000043615205374122020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail272.d(9): Error: circular reference to variable `fail272.Ins!(Ins).Ins` fail_compilation/fail272.d(10): Error: template instance `fail272.Ins!(Ins)` error instantiating --- */ template Ins(alias x) { const Ins = Ins!(Ins); } alias Ins!(Ins) x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10727b.d0000644000175000017500000000063315205374122021076 0ustar fabiofabio// REQUIRED_ARGS: -c // EXTRA_FILES: imports/foo10727b.d imports/stdtraits10727.d /* TEST_OUTPUT: --- fail_compilation/imports/foo10727b.d(25): Error: undefined identifier `Frop` fail_compilation/imports/foo10727b.d(17): Error: template instance `foo10727b.CirBuff!(Foo)` error instantiating fail_compilation/imports/foo10727b.d(22): instantiated from here: `Bar!(Foo)` --- */ import imports.foo10727b; ./ldc-1.42.0-src/tests/dmd/fail_compilation/cppeh2.d0000644000175000017500000000071715205374122020757 0ustar fabiofabio// DISABLED: win32 win64 /* TEST_OUTPUT: --- fail_compilation/cppeh2.d(21): Error: cannot mix catching D and C++ exceptions in the same try-catch --- */ version(Windows) static assert(0, "This test should not run on this platform"); extern (C++, std) { class exception { } } void bar(); void abc(); void foo() { try { bar(); } catch (std.exception e) { abc(); } catch (Exception e) { abc(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail254.d0000644000175000017500000000077215205374122020745 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail254.d(12): Error: integer overflow fail_compilation/fail254.d(13): Error: integer overflow fail_compilation/fail254.d(14): Error: integer overflow fail_compilation/fail254.d(15): Error: integer overflow fail_compilation/fail254.d(16): Error: integer overflow --- */ ulong v1 = 0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF; ulong v2 = 0x1_0000_0000_0000_0000; ulong v3 = 0x1_FFFF_FFFF_FFFF_FFFF; ulong v4 = 0x7_FFFF_FFFF_FFFF_FFFF; ulong v5 = 0x1_0000_FFFF_FFFF_FFFF; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag12487.d0000644000175000017500000000145515205374122021110 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag12487.d(15): Error: recursive expansion of template instance `diag12487.recTemplate!int` fail_compilation/diag12487.d(25): Error: template instance `diag12487.recTemplate!int` error instantiating fail_compilation/diag12487.d(18): Error: function `diag12487.recFunction` CTFE recursion limit exceeded fail_compilation/diag12487.d(20): called from here: `recFunction(i)` fail_compilation/diag12487.d(18): 1000 recursive calls to function `recFunction` fail_compilation/diag12487.d(27): called from here: `recFunction(0)` --- */ template recTemplate(T) { enum bool recTemplate = recTemplate!T; } bool recFunction(int i) { return recFunction(i); } void main() { enum bool value1 = recTemplate!int; enum bool value2 = recFunction(0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23710.d0000644000175000017500000000126115205374122021145 0ustar fabiofabio/* REQUIRED_ARGS: -betterC TEST_OUTPUT: --- fail_compilation/test23710.d(112): Error: array concatenation of expression `foo ~ cast(int[])a` requires the GC which is not available with -betterC --- */ // https://issues.dlang.org/show_bug.cgi?id=23710 #line 100 int test(int i) { int j; int[] foo; int[3] a = [1,2,3]; if (0) { for (;;) { import core.stdc.stdio; printf("start body\n"); foo = foo ~ a; L1: printf("foo.length = %zu\n", foo.length); j += foo.length; i += 2; if (i > 5) return j; printf("end body\n"); } } goto L1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13528.d0000644000175000017500000000077215205374122021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag13528.d(6): Error: value of `this` is not known at compile time fail_compilation/diag13528.d(6): while evaluating `pragma(msg, __traits(getMember, A, "foo"))` fail_compilation/diag13528.d(12): parent scope from here: `mixin MyTemplate!()` --- */ #line 1 mixin template MyTemplate() { void foo() { pragma(msg, __traits(getMember, typeof(this), "foo")); } } class A { mixin MyTemplate; } void main() { auto a = new A(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice19887.d0000644000175000017500000000036715205374122020760 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice19887.d(9): Error: initializer must be an expression, not `(void)` --- */ module ice19887; void func(AliasSeq!(int) params = AliasSeq!(void)) {} template AliasSeq(TList...) { alias AliasSeq = TList; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18938.d0000644000175000017500000000043615205374122021124 0ustar fabiofabio// REQUIRED_ARGS: -c -Ifail_compilation/imports/ // EXTRA_SOURCES: imports/test18938a/cache.d imports/test18938a/file.d // EXTRA_FILES: imports/test18938b/file.d /* TEST_OUTPUT: --- fail_compilation/imports/test18938b/file.d(20): Error: undefined identifier `No` --- */ void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test_switch_error.d0000644000175000017500000000713315205374122023346 0ustar fabiofabio/++ https://issues.dlang.org/show_bug.cgi?id=22514 TEST_OUTPUT: --- fail_compilation/test_switch_error.d(13): Error: undefined identifier `doesNotExist` fail_compilation/test_switch_error.d(16): Error: undefined identifier `alsoDoesNotExits` fail_compilation/test_switch_error.d(19): Error: duplicate `case 2` in `switch` statement --- ++/ void test1() { switch (doesNotExist) { case 1: alsoDoesNotExits(); break; case 2: break; case 2: break; } } /++ TEST_OUTPUT: --- fail_compilation/test_switch_error.d(105): Error: undefined identifier `doesNotExist` --- ++/ #line 100 enum foo = 1; void test2() { switch (doesNotExist) { case foo: break; } } /++ TEST_OUTPUT: --- fail_compilation/test_switch_error.d(206): Error: undefined identifier `a` fail_compilation/test_switch_error.d(207): Error: undefined identifier `b` --- ++/ #line 200 void test3() { switch (1) { case a: break; case b: break; } } /++ TEST_OUTPUT: --- fail_compilation/test_switch_error.d(303): Error: undefined identifier `doesNotExits` --- ++/ #line 300 void test4() { auto foo = doesNotExits(); switch (1) { case foo: break; case foo: break; } } /++ TEST_OUTPUT: --- fail_compilation/test_switch_error.d(405): Error: `case` variables have to be `const` or `immutable` fail_compilation/test_switch_error.d(412): Error: `case` variables not allowed in `final switch` statements --- ++/ #line 400 void test5(int i) { switch (i) { case i: break; default: break; } const int j = i; final switch (i) { case j: break; } } /++ TEST_OUTPUT: --- fail_compilation/test_switch_error.d(513): Error: undefined identifier `undefinedFunc` fail_compilation/test_switch_error.d(517): Error: `case` expression must be a compile-time `string` or an integral constant, not `Strukt(1)` fail_compilation/test_switch_error.d(518): Error: `case` variables have to be `const` or `immutable` fail_compilation/test_switch_error.d(518): Error: `case` variables not allowed in `final switch` statements fail_compilation/test_switch_error.d(519): Error: `case` variables not allowed in `final switch` statements fail_compilation/test_switch_error.d(522): Error: undefined identifier `undefinedFunc2` --- ++/ #line 500 enum Foo { one, two } struct Strukt { int i; } void errorsWithErrors(int param, immutable int constant) { final switch(undefinedFunc()) { case Foo.one: break; case Foo.two: break; case Strukt(1): break; case param: break; case constant: break; } switch (undefinedFunc2()) { case constant: break; } } /++ TEST_OUTPUT: --- fail_compilation/test_switch_error.d(622): Error: undefined identifier `undefinedFunc` fail_compilation/test_switch_error.d(624): Error: `case` expression must be a compile-time `string` or an integral constant, not `SubtypeOfInt(2)` fail_compilation/test_switch_error.d(625): Error: `case` expression must be a compile-time `string` or an integral constant, not `SubtypeOfIntMethod()` --- ++/ #line 600 struct SubtypeOfInt { int i; alias i this; } struct SubtypeOfIntMethod { int getI() { return 0; } alias getI this; } void errorsWithErrors2(int param) { final switch(param) { case SubtypeOfInt(1): break; case SubtypeOfIntMethod(): break; } // This snippet causes somewhat misleading error messages final switch(undefinedFunc()) { case SubtypeOfInt(2): break; case SubtypeOfIntMethod(): break; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail38.d0000644000175000017500000000032215205374122020654 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail38.d(12): Error: `super` is only allowed in non-static class member functions --- */ int x; void test() { super.x = 2; } int main() { test(); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test11176.d0000644000175000017500000000071615205374122021154 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test11176.d(12): Error: using `b.ptr` (instead of `&b[0])` is not allowed in a `@safe` function fail_compilation/test11176.d(16): Error: using `b.ptr` (instead of `&b[0])` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=11176 @safe ubyte oops(ubyte[] b) { return *b.ptr; } @safe ubyte oops(ubyte[0] b) { return *b.ptr; } @safe ubyte cool(ubyte[1] b) { return *b.ptr; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7603a.d0000644000175000017500000000026615205374122021171 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7603a.d(7): Error: cannot create default argument for `ref` / `out` parameter from constant `true` --- */ void test(ref bool val = true) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6968.d0000644000175000017500000000165715205374122021052 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=6968 /* TEST_OUTPUT: --- fail_compilation/fail6968.d(26): Error: cannot pass type `int` as a function argument fail_compilation/fail6968.d(26): Error: cannot pass type `long` as a function argument fail_compilation/fail6968.d(26): Error: circular initialization of variable `fail6968.PredAny!(int, long, float).PredAny` fail_compilation/fail6968.d(31): Error: template instance `fail6968.PredAny!(int, long, float)` error instantiating fail_compilation/fail6968.d(31): while evaluating `pragma(msg, PredAny!(int, long, float))` --- */ template Pred(A, B) { static if(is(B == int)) enum bool Pred = true; else enum bool Pred = false; } template PredAny(A, B...) { static if(B.length == 0) enum bool PredAny = false; else enum bool PredAny = Pred(A, B[0]) || PredAny(A, B[1..$]); } void main() { pragma(msg, PredAny!(int, long, float)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18.d0000644000175000017500000000033515205374122020656 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail18.d(14): Error: upper and lower bounds are needed to slice a pointer --- */ // 7/25 // Internal error: ..\ztc\cgcod.c 1464 void main () { int x = 3; int[] a = (&x)[]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22999.d0000644000175000017500000000102715205374122021167 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test22999.d(17): Error: switch case fallthrough - use 'goto default;' if intended fail_compilation/test22999.d(24): Error: switch case fallthrough - use 'goto case;' if intended --- */ // no switch fallthrough error with multi-valued case // https://issues.dlang.org/show_bug.cgi?id=22999 void main() { int i; switch (0) { case 0, 1: i = 20; default: assert(0); } switch (0) { default: case 0, 1: i = 20; case 2, 3: i = 30; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21045.d0000644000175000017500000000043715205374122021104 0ustar fabiofabio/* TRANSFORM_OUTPUT: remove_lines("^import path") TEST_OUTPUT: --- fail_compilation/fail21045.d(10): Error: unable to read module `__stdin` fail_compilation/fail21045.d(10): Expected '__stdin.d' or '__stdin/package.d' in one of the following import paths: --- */ import __stdin; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag3913.d0000644000175000017500000000066615205374122021025 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag3913.d(14): Error: no property `foobardoo` for type `Foo` fail_compilation/diag3913.d(13): enum `Foo` defined here fail_compilation/diag3913.d(15): Error: no property `secon` for type `Foo`. Did you mean `Foo.second` ? fail_compilation/diag3913.d(13): enum `Foo` defined here --- */ void main() { enum Foo { first, second } auto a = Foo.foobardoo; auto b = Foo.secon; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/gag4269a.d0000644000175000017500000000030015205374122021006 0ustar fabiofabio// REQUIRED_ARGS: -c -o- /* TEST_OUTPUT: --- fail_compilation/gag4269a.d(12): Error: undefined identifier `B` --- */ static if(is(typeof(A4269.sizeof))) {} class A4269 { void foo(B b); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22134.d0000644000175000017500000000043215205374122021077 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22134 /* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/fail22134.d(12): Deprecation: `this.arr[i]` has no effect --- */ struct StackBuffer { auto opIndex(size_t i) { return arr[i]; } private: void[] arr; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16589.d0000644000175000017500000000313115205374122021163 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test16589.d(26): Error: escaping a reference to parameter `this` by returning `&this.data` is not allowed in a `@safe` function fail_compilation/test16589.d(24): perhaps annotate the function with `return` fail_compilation/test16589.d(31): Error: escaping a reference to parameter `this` by returning `&this` is not allowed in a `@safe` function fail_compilation/test16589.d(29): perhaps annotate the function with `return` fail_compilation/test16589.d(37): Error: escaping a reference to parameter `s` by returning `&s.data` is not allowed in a `@safe` function fail_compilation/test16589.d(35): perhaps annotate the parameter with `return` fail_compilation/test16589.d(42): Error: escaping a reference to parameter `s` by returning `&s` is not allowed in a `@safe` function fail_compilation/test16589.d(40): perhaps annotate the parameter with `return` fail_compilation/test16589.d(47): Error: returning `&s.data` escapes a reference to parameter `s` fail_compilation/test16589.d(52): Error: returning `& s` escapes a reference to parameter `s` --- */ // https://issues.dlang.org/show_bug.cgi?id=16589 struct S { int data; @safe int* access1() { return &data; } @safe S* access2() { return &this; } } @safe int* access3(ref S s) { return &s.data; } @safe S* access4(ref S s) { return &s; } @safe int* access5(S s) { return &s.data; } @safe S* access6(S s) { return &s; } class C { int data; @safe int* access7() { return &data; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11714.d0000644000175000017500000000116615205374122021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11714.d(16): Error: variable `fail11714.c` is a thread-local class and cannot have a static initializer fail_compilation/fail11714.d(16): use `static this()` to initialize instead fail_compilation/fail11714.d(23): Error: variable `fail11714.s` is a thread-local pointer to struct and cannot have a static initializer fail_compilation/fail11714.d(23): use `static this()` to initialize instead --- */ class C11714 { int data; }; C11714 c = new C11714; // mutable class reference. struct S11714 { int data; }; S11714* s = new S11714; // mutable pointer to struct. ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag15340.d0000644000175000017500000000034015205374122021067 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag15340.d(11): Error: undefined identifier `undef1` fail_compilation/diag15340.d(12): Error: undefined identifier `undef2` --- */ class C { auto a = undef1; auto b = undef2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b23686.d0000644000175000017500000000160315205374122020423 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/b23686.d(107): Error: undefined identifier `eFN1`, did you mean template `eFN0()()`? fail_compilation/b23686.d(107): Error: `mixin(_error_)` does not give a valid type fail_compilation/b23686.d(115): while looking for match for `eload!(int, 1)` fail_compilation/b23686.d-mixin-121(121): Error: undefined identifier `FNwtf` fail_compilation/b23686.d(121): Error: `mixin(_error_)` does not give a valid type fail_compilation/b23686.d(126): while looking for match for `load!"wtf"` --- */ module b23686; #line 100 //------------------- void eFN0()() { } void eload(I, I name, alias T = mixin("eFN" ~ name.stringof))() { T!()(); } void test2() { eload!(int,0)(); eload!(int,1)(); } //------------------- void FNfoo() {} void load(string name, alias T = mixin("FN" ~ name))() {} void test1() { load!"foo"(); load!"wtf"(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/nested_template_constraint.d0000644000175000017500000000074215205374122025215 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/nested_template_constraint.d(17): Error: template `foo` is not callable using argument types `!()(string, int)` fail_compilation/nested_template_constraint.d(10): Candidate is: `foo(int x = 0)` fail_compilation/nested_template_constraint.d(11): - Containing: `foo(T, U)(T t, U u)` --- */ template foo(int x = 0) { void foo(T, U)(T t, U u) if (is(T == int) && is(U == int)) {} } void main() { foo("hello", 4); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail201.d0000644000175000017500000000036015205374122020726 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail201.d(10): Error: shift by 33 is outside the range `0..31` fail_compilation/fail201.d(10): Error: shift by 33 is outside the range `0..31` --- */ void main() { int c; c = c >>> 33; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice15688.d0000644000175000017500000000037415205374122020751 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/ice15688.d(12): Error: undefined identifier `mappings` fail_compilation/ice15688.d(12): Error: function expected before `()`, not `0` of type `int` --- */ void main() { (mappings, 0)(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_circular2.d0000644000175000017500000000134115205374122022451 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail_circular2.d(10): Error: circular initialization of variable `fail_circular2.S.d1` fail_compilation/fail_circular2.d(12): Error: circular initialization of variable `fail_circular2.S.e1` --- */ struct S { static const int d1 = S.d1; // CTFE error (expression type is determined to int) enum int e1 = S.e1; // CTFE error } /* TEST_OUTPUT: --- fail_compilation/fail_circular2.d(24): Error: circular initialization of variable `fail_circular2.C.d1` fail_compilation/fail_circular2.d(26): Error: circular initialization of variable `fail_circular2.C.e1` --- */ class C { static const int d1 = C.d1; // CTFE error enum int e1 = C.e1; // CTFE error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail195.d0000644000175000017500000000063015205374122020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail195.d(22): Error: struct `Foo` does not overload () --- */ // https://issues.dlang.org/show_bug.cgi?id=1384 // Compiler segfaults when using struct variable like a function with no opCall member. struct Foo { union { int a; int b; } } void bla() { Foo next; next(); // Error: structliteral has no effect in expression (Foo(0)) } ./ldc-1.42.0-src/tests/dmd/fail_compilation/spell23908.d0000644000175000017500000000042215205374122021314 0ustar fabiofabio/* EXTRA_FILES: imports/spell23908a.d imports/spell23908b.d TEST_OUTPUT: --- fail_compilation/imports/spell23908a.d(3): Error: module `imports.spell23908b` import `nonexistent` not found --- */ // https://issues.dlang.org/show_bug.cgi?id=23908 import imports.spell23908a; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ctfe14731.d0000644000175000017500000000064015205374122021112 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ctfe14731.d(16): Error: cannot implicitly convert expression `split("a b")` of type `string[]` to `string` fail_compilation/ctfe14731.d(17): Error: cannot implicitly convert expression `split("a b")` of type `string[]` to `string` --- */ string[] split(string a) { return [a]; } void main() { enum string list1 = "a b".split(); string list2 = "a b".split(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22298.d0000644000175000017500000000115515205374122021161 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test22298.d(18): Error: assigning scope variable `i` to `p` with longer lifetime is not allowed in a `@safe` function fail_compilation/test22298.d(29): Error: assigning scope variable `y` to `x` with longer lifetime is not allowed in a `@safe` function --- */ void g(scope void delegate(scope int*) @safe cb) @safe { int x = 42; cb(&x); } void main() @safe { int* p; void f(scope int* i) @safe { p = i; } g(&f); // address of x has escaped g assert(*p == 42); } void f() @safe { mixin("scope int* x;"); scope int* y; x = y; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21927.d0000644000175000017500000000073215205374122021157 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21927 /* TEST_OUTPUT: --- fail_compilation/test21927.d(17): Error: invalid `foreach` aggregate `this.T2(Args2...)` of type `void` fail_compilation/test21927.d(18): Error: invalid `foreach` aggregate `this.T2!()` of type `void` --- */ struct S { template T2(Args2...) {} void fun() { // original test case static foreach (p; this.T2) {} // ICE static foreach (p; this.T2!()) {} // ICE } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag4540.d0000644000175000017500000000030515205374122021010 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag4540.d(11): Error: `x` must be of integral or string type, it is a `float` --- */ void main() { float x; switch (x) { default: } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/opapplyscope.d0000644000175000017500000000124215205374122022306 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/opapplyscope.d(113): Error: function `opapplyscope.S.opApply(scope int delegate(scope int* ptr) @safe dg)` is not callable using argument types `(int delegate(int* x) nothrow @nogc @safe)` fail_compilation/opapplyscope.d(113): cannot pass argument `int(int* x) => 0` of type `int delegate(int* x) nothrow @nogc @safe` to parameter `scope int delegate(scope int* ptr) @safe dg` --- */ #line 100 struct S { int opApply(scope int delegate (scope int* ptr) @safe dg) @safe { return 0; } } void test() @safe { static int* global; S s; foreach (/*scope*/ int* x; s) { global = x; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag7420.d0000644000175000017500000000217015205374122021012 0ustar fabiofabio// REQUIRED_ARGS: -m32 /* TEST_OUTPUT: --- fail_compilation/diag7420.d(20): Error: static variable `x` cannot be read at compile time fail_compilation/diag7420.d(20): while evaluating: `static assert(x < 4)` fail_compilation/diag7420.d(21): Error: static variable `y` cannot be read at compile time fail_compilation/diag7420.d(21): while evaluating: `static assert(y == "abc")` fail_compilation/diag7420.d(22): Error: static variable `y` cannot be read at compile time fail_compilation/diag7420.d(22): while evaluating: `static assert(cast(ubyte[])y != null)` fail_compilation/diag7420.d(23): Error: static variable `y` cannot be read at compile time fail_compilation/diag7420.d(23): while evaluating: `static assert(cast(int)y[0] == 1)` fail_compilation/diag7420.d(24): Error: static variable `y` cannot be read at compile time fail_compilation/diag7420.d(24): while evaluating: `static assert(y[0..1].length == 1u)` --- */ int x = 2; char[] y = "abc".dup; static assert(x < 4); static assert(y == "abc"); static assert(cast(ubyte[])y != null); static assert(y[0] == 1); static assert(y[0..1].length == 1); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice15855.d0000644000175000017500000000201515205374122020737 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/ice15855.d(28): Error: found `End of File` when expecting `(` fail_compilation/ice15855.d(28): Error: found `End of File` instead of statement fail_compilation/ice15855.d(28): Error: expression expected, not `End of File` fail_compilation/ice15855.d(28): Error: found `End of File` when expecting `;` following `for` condition fail_compilation/ice15855.d(28): Error: expression expected, not `End of File` fail_compilation/ice15855.d(28): Error: found `End of File` when expecting `)` fail_compilation/ice15855.d(28): Error: found `End of File` instead of statement fail_compilation/ice15855.d(28): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/ice15855.d(27): unmatched `{` fail_compilation/ice15855.d(28): Error: found `End of File` when expecting `]` fail_compilation/ice15855.d(28): Error: variable name expected after type `a[() { for (__error__ __error; __error) { __error__ } } ]`, not `End of File` --- */ a[{for ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail131.d0000644000175000017500000000032515205374122020731 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail131.d(8): Error: function `D main` parameter list must be empty or accept one parameter of type `string[]` --- */ int main(lazy char[][] args) { return args.length; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19103.d0000644000175000017500000000167515205374122021113 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19103.d(14): Error: no property `puts` for `new C` of type `fail19103.C` fail_compilation/fail19103.d(26): class `C` defined here fail_compilation/fail19103.d(16): Error: no property `puts` for `s1` of type `fail19103.S1` fail_compilation/fail19103.d(30): struct `S1` defined here fail_compilation/fail19103.d(18): Error: no property `puts` for type `S2` $p:/core/stdc/stdio.d$($n$): did you mean `core.stdc.stdio.puts`? --- */ void main() { (new C).puts("OK."); // Error: no property puts for type test.C, did you mean core.stdc.stdio.puts(T...)(T args)? S1 s1; s1.puts("Hey?"); // It can be compiled and runs! S2 s2; s2.puts("OK."); // Error: no property puts for type S2, did you mean core.stdc.stdio.puts(T...)(T args)? } mixin template T() { import core.stdc.stdio; } class C { mixin T; } struct S1 { mixin T; } struct S2 { import core.stdc.stdio; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19898a.d0000644000175000017500000000040215205374122021264 0ustar fabiofabio/* REQUIRED_ARGS: -m64 TEST_OUTPUT: --- fail_compilation/fail19898a.d(10): Error: expression `__key$n$ < __limit$n$` of type `__vector(int[4])` does not have a boolean value --- */ void f (__vector(int[4]) n) { foreach (i; 0 .. n) cast(void)n; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13220.d0000644000175000017500000000047215205374122020724 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13220.d(22): Error: template instance `test!0` does not match template declaration `test(T)()` --- */ struct Tuple(T...) { T field; alias field this; } template test(T) { bool test() { return false; }; } void main() { Tuple!bool t; t[0] = test!0(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail105.d0000644000175000017500000000031315205374122020727 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail105.d(11): Error: cannot cast `"bar"` to `int` at compile time --- */ //int foo = "foo"; // just Access Violation happens. int bar = cast(int)cast(char*)"bar"; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9199.d0000644000175000017500000000313715205374122021044 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/fail9199.d(13): Error: function `fail9199.fc` without `this` cannot be `const` fail_compilation/fail9199.d(14): Error: function `fail9199.fi` without `this` cannot be `immutable` fail_compilation/fail9199.d(15): Error: function `fail9199.fw` without `this` cannot be `inout` fail_compilation/fail9199.d(16): Error: function `fail9199.fs` without `this` cannot be `shared` fail_compilation/fail9199.d(17): Error: function `fail9199.fsc` without `this` cannot be `shared const` fail_compilation/fail9199.d(18): Error: function `fail9199.fsw` without `this` cannot be `shared inout` --- */ void fc() const {} void fi() immutable {} void fw() inout {} void fs() shared {} void fsc() shared const {} void fsw() shared inout {} /* TEST_OUTPUT: --- fail_compilation/fail9199.d(33): Error: function `fail9199.C.fc` without `this` cannot be `const` fail_compilation/fail9199.d(34): Error: function `fail9199.C.fi` without `this` cannot be `immutable` fail_compilation/fail9199.d(35): Error: function `fail9199.C.fw` without `this` cannot be `inout` fail_compilation/fail9199.d(36): Error: function `fail9199.C.fs` without `this` cannot be `shared` fail_compilation/fail9199.d(37): Error: function `fail9199.C.fsc` without `this` cannot be `shared const` fail_compilation/fail9199.d(38): Error: function `fail9199.C.fsw` without `this` cannot be `shared inout` --- */ class C { static void fc() const {} static void fi() immutable {} static void fw() inout {} static void fs() shared {} static void fsc() shared const {} static void fsw() shared inout {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3990.d0000644000175000017500000000056515205374122021037 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail3990.d(12): Error: using `*` on an array is no longer supported; use `*(arr1).ptr` instead fail_compilation/fail3990.d(14): Error: using `*` on an array is no longer supported; use `*(arr2).ptr` instead --- */ void main() { int[] arr1 = [1, 2, 3]; assert(*arr1 == 1); int[3] arr2 = [1, 2, 3]; assert(*arr2 == 1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23861.d0000644000175000017500000000050415205374122021107 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23861 /* TEST_OUTPUT: --- fail_compilation/fail23861.d(24): Error: cannot implicitly convert expression `3` of type `int` to `Foo` --- */ Foo global; struct Foo { ref Foo get() { return global; } alias get this; } void main() { Foo g; g = 3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15897.d0000644000175000017500000000061215205374122021165 0ustar fabiofabio// REQUIRED_ARGS: -de // EXTRA_FILES: imports/test15897.d /* TEST_OUTPUT: --- fail_compilation/test15897.d(20): Error: no property `create` for `cat` of type `imports.test15897.Cat` fail_compilation/imports/test15897.d(4): class `Cat` defined here --- */ module test15897; import imports.test15897; class Animal { private void create() {} } void foo(Cat cat) { cat.create(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail63.d0000644000175000017500000000020515205374122020652 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail63.d(11): Error: debug `Foo` defined after use --- */ debug (Foo) int x; debug = Foo; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10624.d0000644000175000017500000000207315205374122020730 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10624.d(39): Error: no operator `<` for type `Tuple` fail_compilation/ice10624.d(13): perhaps overload it with `int opCmp(Tuple!(Msg) other) const {}` fail_compilation/ice10624.d(49): Error: template instance `ice10624.Variant.handler!(Tuple!(Msg))` error instantiating fail_compilation/ice10624.d(22): instantiated from here: `opAssign!(Tuple!(Msg))` --- */ struct Msg {} struct Tuple(Specs...) { Specs expand; alias expand this; } void main() { Variant data; data = Tuple!Msg(); } struct Variant { ptrdiff_t function() fptr = &handler!(void); static ptrdiff_t handler(A : void)() { return 0; } static ptrdiff_t handler(A)() { A* zis; A* rhsPA; { return *zis < *rhsPA ? -1 : 1; // Tuple!(Msg) < Tuple!(Msg) // Tuple!(Msg).expand < Tuple!(Msg).expand // -> should be error } return 0; } Variant opAssign(T)(T rhs) { fptr = &handler!(T); return this; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_isZeroInit.d0000644000175000017500000000044515205374122022666 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail_isZeroInit.d(11): Error: type expected as second argument of __traits `isZeroInit` instead of `a` --- */ void test() { int a = 3; // Providing a specific variable rather than a type isn't allowed. enum bool az = __traits(isZeroInit, a); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6889.d0000644000175000017500000000645415205374122021054 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail6889.d(16): Error: cannot `goto` out of `scope(success)` block fail_compilation/fail6889.d(17): Error: cannot `goto` in to `scope(success)` block fail_compilation/fail6889.d(19): Error: `return` statements cannot be in `scope(success)` bodies fail_compilation/fail6889.d(23): Error: `continue` is not allowed inside `scope(success)` bodies fail_compilation/fail6889.d(24): Error: `break` is not allowed inside `scope(success)` bodies fail_compilation/fail6889.d(29): Error: `continue` is not allowed inside `scope(success)` bodies fail_compilation/fail6889.d(30): Error: `break` is not allowed inside `scope(success)` bodies --- */ void test_success() { L1: scope(success) { L2: goto L1; } // NG goto L2; // NG scope(success) { return; } // NG (from fail102.d) foreach (i; 0..1) { scope(success) continue; // NG scope(success) break; // NG } foreach (i; Aggr()) { scope(success) continue; // NG scope(success) break; // NG } /+ // is equivalent with: switch ( Aggr().opApply((int i){ scope(success) return 0; // NG scope(success) return 1; // NG return 0; })) { default: break; } +/ } /* TEST_OUTPUT: --- fail_compilation/fail6889.d(56): Error: cannot `goto` in to `scope(failure)` block --- */ void test_failure() { L1: scope(failure) { L2: goto L1; } // OK goto L2; // NG foreach (i; 0..1) { scope(failure) continue; // OK scope(failure) break; // OK } foreach (i; Aggr()) { scope(failure) continue; // OK scope(failure) break; // OK } /+ // is equivalent with: switch ( Aggr().opApply((int i){ scope(failure) return 0; // OK scope(failure) return 1; // OK return 0; })) { default: break; } +/ } /* TEST_OUTPUT: --- fail_compilation/fail6889.d(100): Error: cannot `goto` out of `scope(exit)` block fail_compilation/fail6889.d(101): Error: cannot `goto` in to `scope(exit)` block fail_compilation/fail6889.d(103): Error: `return` statements cannot be in `scope(exit)` bodies fail_compilation/fail6889.d(107): Error: `continue` is not allowed inside `scope(exit)` bodies fail_compilation/fail6889.d(108): Error: `break` is not allowed inside `scope(exit)` bodies fail_compilation/fail6889.d(113): Error: `continue` is not allowed inside `scope(exit)` bodies fail_compilation/fail6889.d(114): Error: `break` is not allowed inside `scope(exit)` bodies --- */ void test_exit() { L1: scope(exit) { L2: goto L1; } // NG goto L2; // NG scope(exit) { return; } // NG (from fail102.d) foreach (i; 0..1) { scope(exit) continue; // NG scope(exit) break; // NG } foreach (i; Aggr()) { scope(exit) continue; // NG scope(exit) break; // NG } /+ // is equivalent with: switch ( Aggr().opApply((int i){ scope(exit) return 0; // NG scope(exit) return 1; // NG return 0; })) { default: break; } +/ } struct Aggr { int opApply(int delegate(int) dg) { return dg(0); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail212.d0000644000175000017500000000064115205374122020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail212.d(10): Error: function `fail212.baz` without `this` cannot be `const` fail_compilation/fail212.d(10): did you mean to use `const(int)` as the return type? fail_compilation/fail212.d(18): Error: function `fail212.S.bar` without `this` cannot be `const` --- */ const int baz(); struct S { void foo() const { } static void bar() const { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/named_arguments_ifti_error.d0000644000175000017500000000215515205374122025171 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/named_arguments_ifti_error.d(20): Error: template `f` is not callable using argument types `!()(int, int)` fail_compilation/named_arguments_ifti_error.d(20): parameter `x` assigned twice fail_compilation/named_arguments_ifti_error.d(16): Candidate is: `f(T, U)(T x, U y)` fail_compilation/named_arguments_ifti_error.d(21): Error: template `f` is not callable using argument types `!()(int, int)` fail_compilation/named_arguments_ifti_error.d(21): argument `3` goes past end of parameter list fail_compilation/named_arguments_ifti_error.d(16): Candidate is: `f(T, U)(T x, U y)` fail_compilation/named_arguments_ifti_error.d(22): Error: template `f` is not callable using argument types `!()(int)` fail_compilation/named_arguments_ifti_error.d(22): missing argument for parameter #1: `T x` fail_compilation/named_arguments_ifti_error.d(16): Candidate is: `f(T, U)(T x, U y)` --- */ void f(T, U)(T x, U y) {} void main() { f(x: 3, x: 3); // double assignment of x f(y: 3, 3); // overflow past last parameter f(y: 3); // skipping parameter x } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19913.d0000644000175000017500000000034715205374122021117 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19913.d(11): Error: no property `b` for `a` of type `int` fail_compilation/fail19913.d(11): Error: mixin `fail19913.S.b!()` is not defined --- */ struct S { mixin a.b; enum { a } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22857.d0000644000175000017500000000074115205374122021116 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22857 // EXTRA_FILES: imports/import22857.d /* TEST_OUTPUT: --- fail_compilation/imports/import22857.d(4): Error: (expression) expected following `static if` fail_compilation/imports/import22857.d(4): Error: declaration expected, not `}` fail_compilation/fail22857.d(17): Error: template instance `unaryFun!()` template `unaryFun` is not defined --- */ void isPrettyPropertyName() { import imports.import22857; unaryFun!(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20522.d0000644000175000017500000000055615205374122021151 0ustar fabiofabio/* REQUIRED_ARGS: -w TEST_OUTPUT: --- fail_compilation/test20522.d(19): Error: undefined identifier `non_existent` --- */ // https://issues.dlang.org/show_bug.cgi?id=20522 struct File { ~this() {} } void main() { { auto test = File(); // <- Essential non_existent; } // Warning: statement is not reachable string[] is_this_unreachable_question_mark; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail275.d0000644000175000017500000000024415205374122020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail275.d(10): Error: circular reference to variable `fail275.C.x` --- */ // REQUIRED_ARGS: -d struct C { const x = C.x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/gccasm2.c0000644000175000017500000000426515205374122021116 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/gccasm2.c(27): Error: `const` is not a valid `asm` qualifier fail_compilation/gccasm2.c(28): Error: `restrict` is not a valid `asm` qualifier fail_compilation/gccasm2.c(33): Error: duplicate `asm` qualifier `volatile` fail_compilation/gccasm2.c(34): Error: duplicate `asm` qualifier `volatile` fail_compilation/gccasm2.c(35): Error: duplicate `asm` qualifier `volatile` fail_compilation/gccasm2.c(36): Error: duplicate `asm` qualifier `goto` fail_compilation/gccasm2.c(37): Error: duplicate `asm` qualifier `goto` fail_compilation/gccasm2.c(38): Error: duplicate `asm` qualifier `goto` fail_compilation/gccasm2.c(40): Error: duplicate `asm` qualifier `volatile` fail_compilation/gccasm2.c(41): Error: duplicate `asm` qualifier `volatile` fail_compilation/gccasm2.c(42): Error: duplicate `asm` qualifier `volatile` fail_compilation/gccasm2.c(43): Error: duplicate `asm` qualifier `inline` fail_compilation/gccasm2.c(44): Error: duplicate `asm` qualifier `inline` fail_compilation/gccasm2.c(45): Error: duplicate `asm` qualifier `inline` fail_compilation/gccasm2.c(47): Error: duplicate `asm` qualifier `inline` fail_compilation/gccasm2.c(48): Error: duplicate `asm` qualifier `inline` fail_compilation/gccasm2.c(49): Error: duplicate `asm` qualifier `inline` fail_compilation/gccasm2.c(50): Error: duplicate `asm` qualifier `goto` fail_compilation/gccasm2.c(51): Error: duplicate `asm` qualifier `goto` fail_compilation/gccasm2.c(52): Error: duplicate `asm` qualifier `goto` --- */ void test1() { asm const (""); asm restrict (""); } void test2() { asm goto volatile volatile (""); asm volatile goto volatile (""); asm volatile volatile goto (""); asm goto goto volatile (""); asm goto volatile goto (""); asm volatile goto goto (""); asm inline volatile volatile (""); asm volatile inline volatile (""); asm volatile volatile inline (""); asm inline inline volatile (""); asm inline volatile inline (""); asm volatile inline inline (""); asm goto inline inline (""); asm inline goto inline (""); asm inline inline goto (""); asm goto goto inline (""); asm goto inline goto (""); asm inline goto goto (""); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice1358.d0000644000175000017500000000155215205374122020655 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice1358.d(29): Error: invalid UTF character \U80000000 --- */ // https://issues.dlang.org/show_bug.cgi?id=1358 // ICE(root.c) on Unicode codepoints greater than 0x7FFFFFFF /* 1358. Assertion failure: '0' on line 1548 in file '..\root\root.c' This one is trivial. PATCH(lexer.c, Lexer::escapeSequence()). --- lexer.c (revision 24) +++ lexer.c (working copy) @@ -1281,8 +1281,10 @@ break; } } - if (ndigits != 2 && !utf_isValidDchar(v)) + if (ndigits != 2 && !utf_isValidDchar(v)) { error("invalid UTF character \\U%08x", v); + v = 0; // prevent ICE + } c = v; } else */ auto bla = "\U80000000"; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test8751.d0000644000175000017500000000024015205374122021071 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test8751.d(7): Error: undefined identifier `Bar` --- */ Bar foo3(ref const int x) pure { return y => x > y; // error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18282.d0000644000175000017500000000503615205374122021161 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test18282.d(25): Error: returning scope variable `aa` is not allowed in a `@safe` function fail_compilation/test18282.d(34): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function fail_compilation/test18282.d(35): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function fail_compilation/test18282.d(36): Error: returning scope variable `staa` is not allowed in a `@safe` function fail_compilation/test18282.d(44): Error: escaping a reference to local variable `i` by copying `S2000(& i)` into allocated memory is not allowed in a `@safe` function fail_compilation/test18282.d(53): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function fail_compilation/test18282.d(53): Error: escaping a reference to local variable `c` by copying `& c` into allocated memory is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=18282 string* f() @safe { scope string*[] ls = [null]; return ls[0]; } int* g() @safe { scope int*[3] aa; return aa[0]; } @safe: auto bar1() { int i = void; int*[1] staa = [ &i ]; auto dyna = [ &i ]; int*[ ] dynb = [ &i ]; return staa[0]; } struct S2000 { int* p; } S2000 bar2() { int i; S2000[] arr = [ S2000(&i) ]; return arr[0]; } void bar3() { int i; char c; char*[int*] aa = [ &i : &c ]; } /****************************** TEST_OUTPUT: --- fail_compilation/test18282.d(1007): Error: escaping a reference to local variable `foo` by copying `& foo` into allocated memory is not allowed in a `@safe` function fail_compilation/test18282.d(1008): Error: escaping a reference to local variable `foo` by copying `& foo` into allocated memory is not allowed in a `@safe` function fail_compilation/test18282.d(1009): Error: escaping a reference to local variable `foo` by copying `& foo` into allocated memory is not allowed in a `@safe` function fail_compilation/test18282.d(1016): Error: escaping a reference to parameter `this` by copying `&this` into allocated memory is not allowed in a `@safe` function --- */ #line 1000 // https://issues.dlang.org/show_bug.cgi?id=18282 void test18282() @safe { string foo = "foo"; scope string*[] ls; ls = ls ~ &foo; ls = &foo ~ ls; ls ~= &foo; } struct S { auto fun() { arr ~= &this; } S*[] arr; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7424d.d0000644000175000017500000000033015205374122021165 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7424d.d(10): Error: template `this.g()() immutable` has no value --- */ struct S7424d { @property int g()() immutable { return 0; } void test() const { int f = g; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bitintro.d0000644000175000017500000000205515205374122021425 0ustar fabiofabio/* REQUIRED_ARGS: -preview=bitfields */ struct S { int a; int b:5, c:6; } static if (0) { pragma(msg, __traits(isBitfield, S.a)); pragma(msg, __traits(isBitfield, S.b)); pragma(msg, S.b.bitoffsetof); pragma(msg, S.b.bitwidth); pragma(msg, S.c.bitoffsetof); pragma(msg, S.c.bitwidth); pragma(msg, S.a.bitoffsetof); pragma(msg, S.a.bitwidth); } static assert(__traits(isBitfield, S.a) == false); static assert(__traits(isBitfield, S.b) == true); static assert(S.b.bitoffsetof == 0); static assert(S.b.bitwidth == 5); static assert(S.c.bitoffsetof == 5); static assert(S.c.bitwidth == 6); /* TEST_OUTPUT: --- fail_compilation/bitintro.d(6): Error: `a` is not a bitfield, cannot apply `bitoffsetof` fail_compilation/bitintro.d(37): while evaluating: `static assert(a.bitoffsetof)` fail_compilation/bitintro.d(6): Error: `a` is not a bitfield, cannot apply `bitwidth` fail_compilation/bitintro.d(38): while evaluating: `static assert(a.bitwidth)` --- */ static assert(S.a.bitoffsetof); static assert(S.a.bitwidth); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test12979.d0000644000175000017500000000050615205374122021165 0ustar fabiofabio/***********************************************/ /* TEST_OUTPUT: --- fail_compilation/test12979.d(304): Error: `const`/`immutable`/`shared`/`inout` attributes are not allowed on `asm` blocks --- */ // https://issues.dlang.org/show_bug.cgi?id=12979 #line 300 void test3() { asm const shared { ret; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail251.d0000644000175000017500000000047415205374122020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail251.d(12): Error: undefined identifier `xs` fail_compilation/fail251.d(16): called from here: `foo()` fail_compilation/fail251.d(16): while evaluating: `static assert(foo())` --- */ bool foo() { foreach (x; xs) {} return true; } static assert(foo()); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20149.d0000644000175000017500000000066415205374122021156 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 * TEST_OUTPUT: --- fail_compilation/test20149.d(28): Error: escaping reference to stack allocated value returned by `S('\xff').this(1)` --- */ // https://issues.dlang.org/show_bug.cgi?id=20149#c10 @safe: struct S { this(int){ } char[] opSlice() return { return buf[]; } char[4] buf; } S bar(); char[] fun() { return S(1)[]; } void main() { auto x = fun(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8648.d0000644000175000017500000000214515205374122021031 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8648.d(18): Error: undefined identifier `X` fail_compilation/diag8648.d(29): Error: template `foo` is not callable using argument types `!()(Foo!(int, 1))` fail_compilation/diag8648.d(18): Candidate is: `foo(T, n)(X!(T, n))` fail_compilation/diag8648.d(20): Error: undefined identifier `a` fail_compilation/diag8648.d(31): Error: template `bar` is not callable using argument types `!()(Foo!(int, 1))` fail_compilation/diag8648.d(20): Candidate is: `bar(T)(Foo!(T, a))` fail_compilation/diag8648.d(20): Error: undefined identifier `a` fail_compilation/diag8648.d(32): Error: template `bar` is not callable using argument types `!()(Foo!(int, f))` fail_compilation/diag8648.d(20): Candidate is: `bar(T)(Foo!(T, a))` --- */ struct Foo(T, alias a) {} void foo(T, n)(X!(T, n) ) {} // undefined identifier 'X' void bar(T)(Foo!(T, a) ) {} // undefined identifier 'a' void main() { template f() {} Foo!(int, 1) x; Foo!(int, f) y; foo(x); bar(x); // expression '1' vs undefined Type 'a' bar(y); // symbol 'f' vs undefined Type 'a' } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23058.c0000644000175000017500000000063115205374122021151 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23058.c(105): Error: array index 4 is out of bounds `[0..3]` fail_compilation/test23058.c(110): Error: array index 5 is out of bounds `[0..4]` --- */ /* https://issues.dlang.org/show_bug.cgi?id=23058 */ #line 100 int arr[3][4] = { { 1,2,3,4 }, { 5,6,7,8 }, { 9,10,11,12 } }; void test1() { int *p1 = &arr[4][2]; } void test2() { int *p2 = &arr[2][5]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13609a.d0000644000175000017500000000060415205374122021241 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag13609a.d(16): Error: `}` expected following members in `struct` declaration fail_compilation/diag13609a.d(15): struct starts here fail_compilation/diag13609a.d(16): Error: `}` expected following members in `class` declaration fail_compilation/diag13609a.d(11): class `C` starts here --- */ class C { void foo() {} struct { ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail301.d0000644000175000017500000000064115205374122020731 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail301.d(11): Error: accessing non-static variable `guard` requires an instance of `bug3305b` fail_compilation/fail301.d(22): Error: template instance `fail301.bug3305!0` error instantiating --- */ struct bug3305(alias X = 0) { auto guard = bug3305b!(0).guard; } struct bug3305b(alias X = 0) { bug3305!(X) goo; auto guard = 0; } void test() { bug3305!(0) a; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail240.d0000644000175000017500000000022015205374122020724 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail240.d(9): Error: type `F` is not an expression --- */ class F { int x; } alias typeof(typeof(F).x) b; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17892.d0000644000175000017500000000143615205374122021167 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test17892.d(27): Error: returning `s.pointer1()` escapes a reference to local variable `s` fail_compilation/test17892.d(29): Error: returning `s.pointer2()` escapes a reference to local variable `s` fail_compilation/test17892.d(31): Error: returning `s.pointer3()` escapes a reference to local variable `s` --- */ // https://issues.dlang.org/show_bug.cgi?id=17892 struct S { @safe: int x; int[1] y; auto pointer1() return { return &x; } auto pointer2() return { return &y[0]; } auto pointer3() return { return &y[0..1][0]; } } @safe int* testPointer(int b) { S s; if (b == 1) return s.pointer1(); else if (b == 2) return s.pointer2(); else return s.pointer3(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6458.d0000644000175000017500000000020115205374122021024 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail6458.d(10): Error: Invalid trailing code unit --- */ void main() { char d = ''; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/faildottypeinfo.d0000644000175000017500000000052515205374122022773 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/faildottypeinfo.d(12): Error: no property `typeinfo` for `0` of type `int` fail_compilation/faildottypeinfo.d(13): Error: no property `typeinfo` for type `object.Object` $p:/object.d$($n$): class `Object` defined here --- */ void main() { auto x = 0.typeinfo; auto y = Object.typeinfo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22006.d0000644000175000017500000000146015205374122021077 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail22006.d(15): Error: cannot implicitly convert expression `4$?:32=u|64=LU$` of type `$?:32=uint|64=ulong$` to `bool` fail_compilation/fail22006.d(16): Error: index type `bool` cannot cover index range 0..4 fail_compilation/fail22006.d(19): Error: cannot implicitly convert expression `4$?:32=u|64=LU$` of type `$?:32=uint|64=ulong$` to `bool` fail_compilation/fail22006.d(20): Error: index type `bool` cannot cover index range 0..4 --- */ void test22006() { alias AliasSeq(TList...) = TList; { alias aseq = AliasSeq!(0, 1, 2, 3); static foreach (bool i; 0 .. aseq.length) {} static foreach (bool i, x; aseq) {} } { static foreach (bool i; 0 .. [0, 1, 2, 3].length) {} static foreach (bool i, x; [0, 1, 2, 3]) {} } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/missingbrace.d0000644000175000017500000000033715205374122022242 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/missingbrace.d(11): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/missingbrace.d(9): unmatched `{` --- */ void main() { int a; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11453a.d0000644000175000017500000000047515205374122021251 0ustar fabiofabio// REQUIRED_ARGS: -Ifail_compilation/extra-files // EXTRA_SOURCES: extra-files/foo11453.d extra-files/bar11453.d /* TEST_OUTPUT: --- fail_compilation/extra-files/bar11453.d(1): Error: package name 'foo11453' conflicts with usage as a module name in file fail_compilation/extra-files/foo11453.d --- */ void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag_funclit.d0000644000175000017500000000414215205374122022222 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/diag_funclit.d(103): Error: function literal `(x, y, z) { return 42; }` is not callable using argument types `()` fail_compilation/diag_funclit.d(103): too few arguments, expected 3, got 0 fail_compilation/diag_funclit.d(106): Error: `(x, y, z) { return 42; }` is not callable using argument types `(int, string, int, int)` fail_compilation/diag_funclit.d(106): too many arguments, expected 3, got 4 fail_compilation/diag_funclit.d(108): Error: `(x, y, string z = "Hello") { return x; }` is not callable using argument types `(int, int, string, string)` fail_compilation/diag_funclit.d(108): too many arguments, expected 3, got 4 fail_compilation/diag_funclit.d(110): Error: `(x, y, string z = "Hello") { return x; }` is not callable using argument types `(int)` fail_compilation/diag_funclit.d(110): too few arguments, expected 3, got 1 fail_compilation/diag_funclit.d(112): Error: `(x, y, z) { return x; }` is not callable using argument types `(int)` fail_compilation/diag_funclit.d(112): too few arguments, expected 3, got 1 fail_compilation/diag_funclit.d(115): Error: `(x, y, ...) { return x; }` is not callable using argument types `(int)` fail_compilation/diag_funclit.d(115): too few arguments, expected 2, got 1 fail_compilation/diag_funclit.d(117): Error: `(x, y, string z = "Hey", ...) { return x; }` is not callable using argument types `(int)` fail_compilation/diag_funclit.d(117): too few arguments, expected 3, got 1 --- */ #line 100 void main() { // No argument (x, y, z) { return 42; }(); // Too many args, non-variadic (x, y, z) { return 42; }(42, "Hello", 42, 42); // Too many args, non-variadic, default param (x, y, string z = "Hello") { return x; }(42, 42, "Nope", "Noooope"); // Too few args, non-variadic (x, y, string z = "Hello") { return x; }(42); // Too few args, non-variadic, default param (x, y, z) { return x; }(42); // Too few args, variadic (x, y, ...) { return x; }(42); // Too few args, variadic, default param (x, y, string z = "Hey", ...) { return x; }(42); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag15669.d0000644000175000017500000000033015205374122021104 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag15669.d(14): Error: variable `__b_field_0` cannot be read at compile time --- */ alias AliasSeq(A ...) = A; void foo() { AliasSeq!int a; AliasSeq!int b; a[b]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/editions.d0000644000175000017500000000037215205374122021411 0ustar fabiofabio/** Test language editions (currently experimental) TEST_OUTPUT: --- fail_compilation/editions.d(15): Error: scope parameter `x` may not be returned --- */ @__edition_latest_do_not_use module editions; @safe: int* f(scope int* x) { return x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failexpression2.d0000644000175000017500000003506615205374122022720 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte += float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte -= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte *= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte /= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte %= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte += double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte -= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte *= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte /= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte %= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte += real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte -= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte *= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte /= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `byte %= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte += float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte -= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte *= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte /= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte %= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte += double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte -= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte *= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte /= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte %= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte += real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte -= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte *= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte /= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ubyte %= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short += float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short -= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short *= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short /= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short %= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short += double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short -= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short *= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short /= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short %= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short += real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short -= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short *= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short /= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `short %= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort += float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort -= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort *= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort /= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort %= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort += double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort -= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort *= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort /= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort %= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort += real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort -= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort *= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort /= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ushort %= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int += float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int -= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int *= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int /= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int %= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int += double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int -= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int *= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int /= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int %= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int += real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int -= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int *= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int /= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `int %= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint += float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint -= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint *= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint /= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint %= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint += double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint -= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint *= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint /= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint %= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint += real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint -= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint *= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint /= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `uint %= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long += float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long -= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long *= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long /= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long %= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long += double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long -= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long *= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long /= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long %= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long += real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long -= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long *= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long /= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `long %= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong += float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong -= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong *= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong /= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong %= float` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong += double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong -= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong *= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong /= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong %= double` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong += real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong -= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong *= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong /= real` is performing truncating conversion fail_compilation/failexpression2.d-mixin-140(140): Deprecation: `ulong %= real` is performing truncating conversion fail_compilation/failexpression2.d(150): Error: template instance `failexpression2.X!(integral, floating, arith)` error instantiating fail_compilation/failexpression2.d(155): instantiated from here: `OpAssignCases!(TestOpAssignAssign)` --- */ template TT(T...) { alias T TT; } void TestOpAssignAssign(Tx, Ux, ops)() { foreach(T; Tx.x) foreach(U; Ux.x) foreach(op; ops.x) { T a = cast(T)1; U b = cast(U)1; T r; mixin("r = a " ~ op ~ " cast(U)1;"); } } struct integral { alias TT!(byte, ubyte, short, ushort, int, uint, long, ulong) x; } struct floating { alias TT!(float, double, real) x; } struct arith { alias TT!("+=", "-=", "*=", "/=", "%=") x; } void OpAssignCases(alias X)() { X!(integral, floating, arith)(); } void main() { OpAssignCases!TestOpAssignAssign(); // was once disabled due to bug 7436 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12362.d0000644000175000017500000000024015205374122020723 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12362.d(12): Error: initializer must be an expression, not `foo` --- */ enum foo; void main() { enum bar = foo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23145.d0000644000175000017500000000243115205374122021147 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test23145.d(117): Error: `scope` allocation of `c` with a non-`scope` constructor is not allowed in a `@safe` function fail_compilation/test23145.d(111): is the location of the constructor fail_compilation/test23145.d(124): Error: `scope` allocation of `c` with a non-`scope` constructor is not allowed in a `@safe` function fail_compilation/test23145.d(111): is the location of the constructor fail_compilation/test23145.d(125): Error: `@safe` function `test23145.bax` cannot call `@system` function `test23145.inferred` fail_compilation/test23145.d(131): and `scope` allocation of `c` with a non-`scope` constructor makes it fail to infer `@safe` fail_compilation/test23145.d(129): `test23145.inferred` is declared here --- */ // https://issues.dlang.org/show_bug.cgi?id=23145 #line 100 class D { C c; } class C { D d; int x=3; this(int i) scope @safe @nogc; this(D d) @safe @nogc; } C foo(D d) @nogc @safe { scope e = new C(1); // ok scope c = new C(d); // error return c.d.c; } C bax(D d) @safe { scope e = new C(1); // ok scope c = new C(d); // error inferred(d); return c.d.c; } auto inferred(D d) { scope c = new C(d); // infer system } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail190.d0000644000175000017500000000045615205374122020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail190.d(9): Error: cannot have pointer to `(int, int, int)` fail_compilation/fail190.d(16): Error: template instance `fail190.f!(int, int, int)` error instantiating --- */ T* f(T...)(T x) { return null; } void main() { auto x = f(2,3,4); *x = *x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/constraints_tmpl.d0000755000175000017500000000304715205374122023203 0ustar fabiofabio/* EXTRA_FILES: imports/constraints.d TEST_OUTPUT: --- fail_compilation/constraints_tmpl.d(35): Error: template instance `imports.constraints.dummy!()` does not match template declaration `dummy()()` must satisfy the following constraint: ` false` fail_compilation/constraints_tmpl.d(37): Error: template instance `imports.constraints.message_nice!(int, int)` does not match template declaration `message_nice(T, U)()` with `T = int, U = int` must satisfy the following constraint: ` N!U` fail_compilation/constraints_tmpl.d(38): Error: template instance `imports.constraints.message_ugly!int` does not match template declaration `message_ugly(T)(T v)` with `T = int` must satisfy the following constraint: ` N!T` fail_compilation/constraints_tmpl.d(40): Error: template instance `args!int` does not match template declaration `args(T, U)()` fail_compilation/constraints_tmpl.d(41): Error: template instance `imports.constraints.args!(int, float)` does not match template declaration `args(T, U)()` with `T = int, U = float` must satisfy one of the following constraints: ` N!T N!U` fail_compilation/constraints_tmpl.d(43): Error: template instance `constraints_tmpl.main.lambda!((a) => a)` does not match template declaration `lambda(alias pred)()` with `pred = (a) => a` must satisfy the following constraint: ` N!int` --- */ void main() { import imports.constraints; dummy!(); message_nice!(int, int); message_ugly!int; args!int; args!(int, float); lambda!(a => a)(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail24208.d0000644000175000017500000000067215205374122021111 0ustar fabiofabio/+ REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fail24208.d(19): Error: assigning reference to local variable `n` to non-scope parameter `p` calling `escape` is not allowed in a `@safe` function fail_compilation/fail24208.d(15): which is not `scope` because of `escaped = p` --- +/ void test() @safe { int* escaped; void escape(int* p) @safe { escaped = p; } int n; escape(&n); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failasm.d0000644000175000017500000000055315205374122021210 0ustar fabiofabio/* DISABLED: LDC_not_x86 REQUIRED_ARGS: -m32 TEST_OUTPUT: --- fail_compilation/failasm.d(111): Error: unknown operand size `long` --- */ #line 100 // https://issues.dlang.org/show_bug.cgi?id=21181 uint func() { asm { naked; inc byte ptr [EAX]; inc short ptr [EAX]; inc int ptr [EAX]; inc long ptr [EAX]; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/union_conv.d0000644000175000017500000000046415205374122021752 0ustar fabiofabio/* REQUIRED_ARGS: -preview=fixImmutableConv TEST_OUTPUT: --- fail_compilation/union_conv.d(18): Error: cannot implicitly convert expression `c` of type `const(U)` to `U` because union `U` contains pointers or references --- */ union U { int i; int* p; } void main() { const U c; U m = c; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12907.d0000644000175000017500000000022615205374122020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12907.d(10): Error: template lambda has no type --- */ auto f(void function() g) { return x => (*g)(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23135.d0000644000175000017500000000104115205374122021076 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=23135 REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/fail23135.d(16): Deprecation: overriding `extern(C++)` function `fail23135.C23135.func()` with `const` qualified function `fail23135.Fail23135.func() const` is deprecated fail_compilation/fail23135.d(16): Either remove `override`, or adjust the `const` qualifiers of the overriding function type --- */ extern(C++) class C23135 { void func() { } } extern(C++) final class Fail23135 : C23135 { override void func() const { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test8662.d0000644000175000017500000000173715205374122021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test8662.d(22): Error: label `Label` is already defined fail_compilation/test8662.d(21): first definition is here fail_compilation/test8662.d(25): Error: label `Label` is already defined fail_compilation/test8662.d(21): first definition is here fail_compilation/test8662.d(31): Error: label `Label2` is duplicated fail_compilation/test8662.d(31): labels cannot be used in a static foreach with more than 1 iteration fail_compilation/test8662.d(36): Error: label `Label3` is duplicated fail_compilation/test8662.d(36): labels cannot be used in a static foreach with more than 1 iteration --- */ // Issue 8662 - Labels rejected in static foreach loop alias AliasSeq(T...) = T; void f() { { Label: Label: } { Label: Label: } // static foreach foreach (x; AliasSeq!(1, 2, 3, 4, 5)) { Label2: } static foreach (x; 0 .. 3) { Label3: } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/circ10280.d0000644000175000017500000000046715205374122021113 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/circ10280.d(11): Error: circular initialization of variable `circ10280.q10280` fail_compilation/circ10280.d(10): called from here: `foo10280()` --- */ // https://issues.dlang.org/show_bug.cgi?id=10280 const int q10280 = foo10280(); int foo10280() { return q10280; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/notype.d0000644000175000017500000000127515205374122021114 0ustar fabiofabiostruct S(int var = 3) { int a; } S s; alias A() = int; A a; enum e() = 5; e val; interface I() { } I i; template t() { } t tv; /* TEST_OUTPUT: --- fail_compilation/notype.d(4): Error: template struct `notype.S(int var = 3)` is used as a type without instantiation; to instantiate it use `S!(arguments)` fail_compilation/notype.d(7): Error: template `notype.A()` is used as a type fail_compilation/notype.d(10): Error: template `notype.e()` is used as a type fail_compilation/notype.d(15): Error: template interface `notype.I()` is used as a type without instantiation; to instantiate it use `I!(arguments)` fail_compilation/notype.d(20): Error: template `notype.t()` is used as a type --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue20422.d0000644000175000017500000000075415205374122021321 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20422 /* REQUIRED_ARGS: -m32 TEST_OUTPUT: --- fail_compilation/issue20422.d(15): Error: missing length argument for array fail_compilation/issue20422.d(16): Error: negative array dimension `-1` fail_compilation/issue20422.d(17): Error: negative array dimension `-2147483648` fail_compilation/issue20422.d(18): Error: too many arguments for array --- */ void main() { new int[]; new int[-1]; new int[](int.min); new int[](1, 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23672.i0000644000175000017500000000036615205374122021166 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23672.i(9): Error: found `End of File` when expecting `)` fail_compilation/test23672.i(9): Error: `=`, `;` or `,` expected to end declaration instead of `End of File` --- */ extern int feof (FILE *__strea ./ldc-1.42.0-src/tests/dmd/fail_compilation/makedeps_nofile.d0000644000175000017500000000077615205374122022730 0ustar fabiofabio/* DISABLED: LDC // irrelevant CLI difference PERMUTE_ARGS: REQUIRED_ARGS: -makedeps= -Jcompilable/extra-files -Icompilable/extra-files TEST_OUTPUT: --- Error: expected filename after -makedeps= run `dmd` to print the compiler manual run `dmd -man` to open browser on manual --- */ module makedeps_nofile; // Test import statement import makedeps_a; // Test import expression enum text = import("makedeps-import.txt"); static assert(text == "Imported text\x0a"); void main() { a_func(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail154.d0000644000175000017500000000043515205374122020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail154.d(18): Error: template instance `X!(MYP!int)` does not match template declaration `X(T : Policy!T, alias Policy)` --- */ class X(T:Policy!(T), alias Policy) { mixin Policy!(T); } template MYP(T) { void foo(T); } X!(MYP!(int)) x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14.d0000644000175000017500000000423715205374122020657 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail14.d(10): Error: template instance `fail14.A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!(A!int))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))` recursive expansion exceeded allowed nesting limit --- */ class A(T) { .A!(A) x; } void main() { A!(int); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/biterrors5.d0000644000175000017500000000165315205374122021676 0ustar fabiofabio/* REQUIRED_ARGS: -preview=bitfields * TEST_OUTPUT: --- fail_compilation/biterrors5.d(25): Error: bitfield symbol expected not struct `biterrors5.S` fail_compilation/biterrors5.d(26): Error: bitfield symbol expected not variable `biterrors5.test0.i` fail_compilation/biterrors5.d(35): Error: cannot take address of bitfield `a.x` fail_compilation/biterrors5.d(35): Error: cannot take address of bitfield `a.y` --- */ struct S { int a,b; int :2, c:3; } static assert(__traits(getBitfieldOffset, S.b) == 0); static assert(__traits(getBitfieldWidth, S.b) == 32); static assert(__traits(getBitfieldOffset, S.c) == 2); static assert(__traits(getBitfieldWidth, S.c) == 3); void test0() { int i; i = __traits(getBitfieldOffset, S); i = __traits(getBitfieldOffset, i); } /****************************************/ struct B { int x: 3; int y: 5; } void test1(int val, int choice, B a) { (choice ? a.x : a.y) = val; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23982.d0000644000175000017500000000120215205374122021153 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test23982.d(35): Error: assigning scope variable `a` to non-scope parameter `a` calling `foo2` is not allowed in a `@safe` function fail_compilation/test23982.d(26): which is not `scope` because of `b = a` --- */ // https://issues.dlang.org/show_bug.cgi?id=23982 // Issue 23982 - segfault when printing scope inference failure @safe: struct B() { this(int* a) { this.a = a; } int* a; } class C() { int* foo2(int* a) { auto b = B!()(a); return b.a; } } void main() { scope int* a; C!() c; c.foo2(a); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice18753.d0000644000175000017500000000203015205374122020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice18753.d(21): Error: variable `ice18753.isInputRange!(Group).isInputRange` - type `void` is inferred from initializer `ReturnType(func...)`, and variables cannot be of type `void` fail_compilation/ice18753.d(23): Error: template instance `ice18753.isInputRange!(Group)` error instantiating fail_compilation/ice18753.d(18): instantiated from here: `isForwardRange!(Group)` fail_compilation/ice18753.d(18): while evaluating: `static assert(isForwardRange!(Group))` --- */ // https://issues.dlang.org/show_bug.cgi?id=18753 struct ChunkByImpl { struct Group { } static assert(isForwardRange!Group); } enum isInputRange(R) = ReturnType; enum isForwardRange(R) = isInputRange!R is ReturnType!(() => r); template ReturnType(func...) { static if (is(FunctionTypeOf!func R == return)) ReturnType R; } template FunctionTypeOf(func...) { static if (is(typeof(func[0]) T)) static if (is(T Fptr ) ) alias FunctionTypeOf = Fptr; } template Select() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/shared.d0000644000175000017500000001714515205374122021047 0ustar fabiofabio/* REQUIRED_ARGS: -preview=nosharedaccess * TEST_OUTPUT: --- fail_compilation/shared.d(1010): Error: direct access to shared `j` is not allowed, see `core.atomic` fail_compilation/shared.d(1011): Error: direct access to shared `j` is not allowed, see `core.atomic` fail_compilation/shared.d(1012): Error: direct access to shared `*p` is not allowed, see `core.atomic` fail_compilation/shared.d(1013): Error: direct access to shared `a[0]` is not allowed, see `core.atomic` fail_compilation/shared.d(1014): Error: direct access to shared `s.si` is not allowed, see `core.atomic` fail_compilation/shared.d(1015): Error: direct access to shared `t.i` is not allowed, see `core.atomic` --- */ #line 1000 struct S { shared(int) si; int i; } int test1(shared int j, shared(int)* p, shared(int)[] a, ref S s, ref shared S t) { int i; j = i; i = j; i = *p; i = a[0]; i = s.si; return t.i; } /**************************************/ void byref(ref shared int); void byptr(shared(int)*); shared int x; void test2() { byref(x); // ok byptr(&x); // ok } /**************************************/ /* * TEST_OUTPUT: --- fail_compilation/shared.d(2008): Error: direct access to shared `i` is not allowed, see `core.atomic` fail_compilation/shared.d(2009): Error: direct access to shared `j` is not allowed, see `core.atomic` fail_compilation/shared.d(2010): Error: direct access to shared `k` is not allowed, see `core.atomic` --- */ #line 2000 void func(int); shared int i; void test3(shared int k) { shared int j = void; func(i); func(j); func(k); } /**************************************/ void test4() // no errors for initialization { shared int x; shared int y = 3; } /* * TEST_OUTPUT: --- fail_compilation/shared.d(2105): Error: direct access to shared `*pi` is not allowed, see `core.atomic` fail_compilation/shared.d(2112): Error: direct access to shared `**pi` is not allowed, see `core.atomic` fail_compilation/shared.d(2136): Error: direct access to shared `*c` is not allowed, see `core.atomic` fail_compilation/shared.d(2142): Error: direct access to shared `*c` is not allowed, see `core.atomic` fail_compilation/shared.d(2148): Error: direct access to shared `*c` is not allowed, see `core.atomic` fail_compilation/shared.d(2154): Error: direct access to shared `*c.c1` is not allowed, see `core.atomic` fail_compilation/shared.d(2160): Error: direct access to shared `*c.c1.c1` is not allowed, see `core.atomic` fail_compilation/shared.d(2181): Error: direct access to shared `k` is not allowed, see `core.atomic` fail_compilation/shared.d(2187): Error: direct access to shared `k.k2.k1.value` is not allowed, see `core.atomic` fail_compilation/shared.d(2194): Error: direct access to shared `(new shared(K2)).k1` is not allowed, see `core.atomic` fail_compilation/shared.d(2202): Error: direct access to shared `c` is not allowed, see `core.atomic` fail_compilation/shared.d(2206): Error: function `shared.test_inference_2` function returns `shared` but cannot be inferred `ref` fail_compilation/shared.d(2208): Error: returning `c` escapes a reference to parameter `c` fail_compilation/shared.d(2214): Error: function `shared.test_inference_3` function returns `shared` but cannot be inferred `ref` fail_compilation/shared.d(2216): return value `getSharedObject()` is not an lvalue fail_compilation/shared.d(2222): Error: direct access to shared `a` is not allowed, see `core.atomic` fail_compilation/shared.d(2220): Error: function `shared.test_inference_4` function returns `shared` but cannot be inferred `ref` fail_compilation/shared.d(2222): cannot implicitly convert `a` of type `shared(const(Object))` to `object.Object` fail_compilation/shared.d(2222): Error: return value `a` of type `shared(const(Object))` does not match return type `object.Object`, and cannot be implicitly converted --- */ #line 2100 // Derived from https://issues.dlang.org/show_bug.cgi?id=20908 ref shared(int) test20908() { shared int* pi; // Single indirection, but the pointer is `shared` return *pi; } ref shared(int) test20908_2() { shared(int*)* pi; // Double indirection, external pointer is not `shared` return **pi; } // DotVarExp tests: See matching tests in `compilable/shared.d` struct C1 { int value; } struct C2 { C1* c1; } struct C3 { C2 c1; C2* c2; } // Reading a shared pointer: not okay ref shared(int) test_dotvarexp_1(return shared C1* c) { return c.value; } // Ditto, but explicitly dereferenced ref shared(int) test_dotvarexp_2(return shared C1* c) { return (*c).value; } // Even taking the address (which offset the pointers) requires a load shared(int)* test_dotvarexp_3(return shared C1* c) { return &c.value; } // First level DotVarExp dereferencing ref shared(int) test_dotvarexp_4(return ref shared C2 c) { return c.c1.value; } // Second level DotVarExp dereferencing ref shared(int) test_dotvarexp_5(return ref shared C3 c) { return c.c1.c1.value; } class K1 { int value; } class K2 { shared K1 k1; } class K3 { K2 k2; } // A class is a pointer under the hood, and `shared` applies to the pointer ref shared(int) test_dotvarexp_6(return shared K1 k) { return k.value; } // Using `k.ke.k1` would be okay, but not `value` ref shared(int) test_dotvarexp_7(return ref K3 k) { return k.k2.k1.value; } // The returned value is `shared` so we shouldn't be able to access it // The pointer could already be shared, e.g. by the ctor ref shared(K1) test_newexp_1() { return new shared(K2)().k1; } // Inference tests // Fails because no `ref` auto test_inference_1(return ref shared C3 c) { return c; } // Fails because no `return` => Escapes auto ref test_inference_2(shared C3 c) { return c; } shared(Object) getSharedObject() { assert(0); } // Fails because rvalue auto ref test_inference_3() { return getSharedObject(); } // Fails because `const` conversion auto ref Object test_inference_4(const return ref shared Object a) { return a; } // https://issues.dlang.org/show_bug.cgi?id=23226 // Allow accessing non-shared `this` struct BitRange { int bits; void f() { this.bits++; } } /* TEST_OUTPUT: --- fail_compilation/shared.d(3004): Error: cast from `void*` to `shared(int*)` is not allowed in a `@safe` function fail_compilation/shared.d(3004): `void` data may contain pointers and target element type is mutable fail_compilation/shared.d(3005): Error: cast from `void*` to `shared(const(int*))` is not allowed in a `@safe` function fail_compilation/shared.d(3005): Source type is incompatible with target type containing a pointer fail_compilation/shared.d(3008): Error: cast from `shared(void*)` to `int*` is not allowed in a `@safe` function fail_compilation/shared.d(3008): `void` data may contain pointers and target element type is mutable fail_compilation/shared.d(3009): Error: cast from `shared(void*)` to `shared(const(int*))` is not allowed in a `@safe` function fail_compilation/shared.d(3009): Source type is incompatible with target type containing a pointer --- */ #line 3000 void test_casting_safe() @safe { void *p; auto t1 = cast(shared(int*))p; auto t2 = cast(const(shared(int*)))p; shared void* s; auto x1 = cast(int*)s; auto x2 = cast(const(shared(int*)))s; } #line 3100 // https://issues.dlang.org/show_bug.cgi?id=23783 /* TEST_OUTPUT: --- fail_compilation/shared.d(3114): Error: direct access to shared `x` is not allowed, see `core.atomic` fail_compilation/shared.d(3115): Error: direct access to shared `x` is not allowed, see `core.atomic` --- */ void test23783() { shared int x = 3; assert(x == 3); bool b = x == 3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag_debug_conditional.d0000644000175000017500000000060615205374122024230 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/diag_debug_conditional.d(1): Error: identifier expected inside `debug(...)`, not `alias` fail_compilation/diag_debug_conditional.d(2): Error: identifier expected inside `version(...)`, not `alias` fail_compilation/diag_debug_conditional.d(3): Error: declaration expected following attribute, not end of file --- */ #line 1 debug(alias) version(alias) ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail204.d0000644000175000017500000000024315205374122020731 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail204.d(9): Error: shift assign by 65 is outside the range `0..63` --- */ void main() { long c; c >>= 65; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/objc_offsetof.d0000644000175000017500000000056315205374122022405 0ustar fabiofabio// EXTRA_OBJC_SOURCES: /* TEST_OUTPUT: --- fail_compilation/objc_offsetof.d(13): Error: no property `offsetof` for member `a` of type `int` fail_compilation/objc_offsetof.d(13): `offsetof` is not available for members of Objective-C classes. Please use the Objective-C runtime instead --- */ extern (Objective-C) class Foo { int a; } enum o = Foo.a.offsetof; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail267.d0000644000175000017500000000026515205374122020746 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail267.d(15): Error: template `Bar()` does not have property `foo` --- */ class C { template Bar() { } } typeof(C.Bar.foo) quux; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19912d.d0000644000175000017500000000031515205374122021255 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19912d.d(7): Error: enum `fail19912d.object` conflicts with import `fail19912d.object` at fail_compilation/fail19912d.d --- */ enum object { } void fun(string) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail261.d0000644000175000017500000000107715205374122020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail261.d(20): Error: invalid `foreach` aggregate `range` of type `MyRange` fail_compilation/fail261.d(20): `foreach` works with input ranges (implementing `front` and `popFront`), aggregates implementing `opApply`, or the result of an aggregate's `.tupleof` property fail_compilation/fail261.d(20): https://dlang.org/phobos/std_range_primitives.html#isInputRange --- */ //import std.stdio; struct MyRange { } void main() { MyRange range; foreach (r; range) { //writefln("%s", r.toString()); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/t1252.d0000644000175000017500000000063515205374122020352 0ustar fabiofabio/* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/t1252.d(20): Error: end of instruction expected, not `int` --- */ module t1252; version(D_InlineAsm_X86) version = doTest; else version(D_InlineAsm_X86_64) version = doTest; version(doTest) { void main() { asm { mov EAX, int.; } } } // still need to fail compilation ! else static assert(false); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20108.d0000644000175000017500000000137715205374122021107 0ustar fabiofabio// REQUIRED_ARGS: -preview=dip1000 /* TEST_OUTPUT: --- fail_compilation/fail20108.d(15): Error: assigning address of variable `y` to `x` with longer lifetime is not allowed in a `@safe` function fail_compilation/fail20108.d(16): Error: scope parameter `x` may not be returned fail_compilation/fail20108.d(23): Error: assigning address of variable `y` to `x` with longer lifetime is not allowed in a `@safe` function fail_compilation/fail20108.d(24): Error: returning scope variable `x` is not allowed in a `@safe` function --- */ @safe auto test(scope int* x) { int y = 69; x = &y; //bad return x; } @safe auto test2() { scope int* x; int y = 69; x = &y; //bad return x; } void main() { auto y = test(null); auto z = test2(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_arrayexp.d0000644000175000017500000000312615205374122022421 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail_arrayexp.d(24): Error: cannot use `[]` operator on expression of type `int` fail_compilation/fail_arrayexp.d(25): Error: cannot use `[]` operator on expression of type `void` fail_compilation/fail_arrayexp.d(26): Error: static array of `const(int)[]` with multiple lengths not allowed fail_compilation/fail_arrayexp.d(27): Error: only one index allowed to index `string` fail_compilation/fail_arrayexp.d(28): Error: no `[]` operator overload for type `U` fail_compilation/fail_arrayexp.d(16): perhaps define `auto opIndex() {}` for `fail_arrayexp.U` fail_compilation/fail_arrayexp.d(29): Error: only one index allowed to index `(int, string)` --- */ int i; string str; union U {} alias typeAlias = const(int)[]; void getVoid(); alias getTuple(T...) = T; void test19534() // https://issues.dlang.org/show_bug.cgi?id=19534 { U agg; #line 24 auto p = i[0]; auto q = getVoid()[0]; alias r = getTuple!(typeAlias[0, 1]); auto s = str[0, 1, 2]; auto t = agg[]; auto u = getTuple!(int, string)[1, 2]; } /* TEST_OUTPUT: --- fail_compilation/fail_arrayexp.d(49): Error: no `[3.."4"]` operator overload for type `S` fail_compilation/fail_arrayexp.d(42): perhaps define `auto opSlice(int lower, string upper) {}` for `fail_arrayexp.S` fail_compilation/fail_arrayexp.d(50): Error: no `[]` operator overload for type `S` fail_compilation/fail_arrayexp.d(42): perhaps define `auto opIndex(int, string, char) {}` for `fail_arrayexp.S` --- */ struct S { } void testSlice() { S s; const b = s[3 .. "4"]; const c = s[3, "4", 'c']; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failoffset.d0000644000175000017500000000043315205374122021713 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/failoffset.d(12): Error: no property `offset` for `b` of type `int` fail_compilation/failoffset.d(12): while evaluating: `static assert(b.offset == 4)` --- */ void main() { struct S { int a, b; } static assert(S.b.offset == 4); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13644.d0000644000175000017500000000052215205374122020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13644.d(22): Error: foreach: index cannot be of non-integral type `string` --- */ struct Tuple(T...) { T field; alias field this; } Tuple!(string, string)[] foo() { Tuple!(string, string)[] res; return res; } void main() { foreach (string k2, string v2; foo()) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue16020.d0000644000175000017500000000115115205374122021310 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/issue16020.d(14): Error: user-defined attributes not allowed for `alias` declarations fail_compilation/issue16020.d(15): Error: semicolon expected to close `alias` declaration, not `(` fail_compilation/issue16020.d(15): Error: semicolon needed to end declaration of `t` instead of `)` fail_compilation/issue16020.d(15): Error: declaration expected, not `)` fail_compilation/issue16020.d(16): Deprecation: storage class `final` has no effect in type aliases --- */ module issue16020; struct UDA{} alias Fun = @UDA void(); alias FunTemplate = void(T)(T t); alias F2 = final int(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20549.d0000644000175000017500000000031115205374122021147 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/test20549.d(12): Error: variable `test.__a_field_0` - variables cannot be of type `void` ---- */ module test; alias AliasSeq(T...) = T; enum a = AliasSeq!test; ./ldc-1.42.0-src/tests/dmd/fail_compilation/must_use_union.d0000644000175000017500000000040515205374122022644 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/must_use_union.d(15): Error: ignored value of `@mustuse` type `must_use_union.U`; prepend a `cast(void)` if intentional --- +/ import core.attribute; @mustuse union U {} U fun() { return U(); } void test() { fun(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13601.d0000644000175000017500000000100415205374122021072 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail13601.d(13): Error: variable `__ctfe` cannot be read at compile time fail_compilation/fail13601.d(14): Error: variable `__ctfe` cannot be read at compile time fail_compilation/fail13601.d(15): Error: variable `__ctfe` cannot be read at compile time fail_compilation/fail13601.d(16): Error: variable `__ctfe` cannot be read at compile time --- */ void test() { static if (__ctfe) {} enum a = __ctfe ? "a" : "b"; static int b = __ctfe * 2; int[__ctfe] sarr; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11453b.d0000644000175000017500000000047015205374122021245 0ustar fabiofabio// REQUIRED_ARGS: -Ifail_compilation/extra-files // EXTRA_SOURCES: extra-files/bar11453.d extra-files/foo11453.d /* TEST_OUTPUT: --- fail_compilation/extra-files/foo11453.d(1): Error: module `foo11453` from file fail_compilation/extra-files/foo11453.d conflicts with package name foo11453 --- */ void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice15788.d0000644000175000017500000000070115205374122020744 0ustar fabiofabio/* EXTRA_FILES: imports/range15788.d TEST_OUTPUT: --- fail_compilation/ice15788.d(20): Error: none of the overloads of `iota` are callable using argument types `!()(S, S)` fail_compilation/imports/range15788.d(3): Candidates are: `iota(B, E, S)(B, E, S)` fail_compilation/ice15788.d(13): `ice15788.iota()` --- */ import imports.range15788 : iota; void iota() {} struct S {} void main() { S s; iota(s, s); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3753.d0000644000175000017500000000067315205374122021034 0ustar fabiofabio/* DISABLED: dragonflybsd freebsd linux osx win32 openbsd LDC TEST_OUTPUT: --- Error: cannot mix `core.std.stdlib.alloca()` and exception handling in `_Dmain()` --- */ import core.stdc.stdlib : alloca; import core.stdc.stdio; struct TheStruct { ~this() { printf("dtor()\n"); } } void bar() { printf("bar()\n"); } void main() { auto s = TheStruct(); bar(); auto a = alloca(16); printf("test()\n"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6561.d0000644000175000017500000000027015205374122021025 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail6561.d(9): Error: undefined identifier `x` --- */ struct S { alias x this; // should cause undefined identifier error } void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9420.d0000644000175000017500000000057115205374122021017 0ustar fabiofabio/* TEST_OUTPUT: --- 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 --- */ mixin template Mixin() { } struct S { template t3(T...) { void tx(T){} alias t3 = tx; } } void main() { S s1; s1.t3!()(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix23138.d0000644000175000017500000000041715205374122020762 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix23138.d(14): Error: function `fix23138.C2.foo` cannot override `@safe` method `fix23138.C1.foo` with a `@system` attribute --- */ class C1 { void foo() @safe {} } class C2 : C1 { override void foo() @system {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/gag4269b.d0000644000175000017500000000025315205374122021016 0ustar fabiofabio// REQUIRED_ARGS: -c -o- /* TEST_OUTPUT: --- fail_compilation/gag4269b.d(10): Error: undefined identifier `Y` --- */ static if(is(typeof(X2.init))) {} struct X2 { Y y; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/constraints_func2.d0000755000175000017500000001037015205374122023241 0ustar fabiofabio/* EXTRA_FILES: imports/constraints.d TEST_OUTPUT: --- fail_compilation/constraints_func2.d(94): Error: template `test13` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(23): Candidate is: `test13(T)(T v)` with `T = int` must satisfy one of the following constraints: ` N!T !P!T` fail_compilation/constraints_func2.d(95): Error: template `test14` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(24): Candidate is: `test14(T)(T v)` with `T = int` must satisfy one of the following constraints: ` !P!T N!T` fail_compilation/constraints_func2.d(96): Error: template `test15` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(25): Candidate is: `test15(T)(T v)` with `T = int` must satisfy one of the following constraints: ` !P!T !P!T` fail_compilation/constraints_func2.d(97): Error: template `test16` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(26): Candidate is: `test16(T)(T v)` with `T = int` must satisfy one of the following constraints: ` N!T N!T` fail_compilation/constraints_func2.d(98): Error: template `test17` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(27): Candidate is: `test17(T)(T v)` with `T = int` must satisfy the following constraint: ` N!T` fail_compilation/constraints_func2.d(99): Error: template `test18` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(28): Candidate is: `test18(T)(T v)` with `T = int` must satisfy one of the following constraints: ` N!T N!T` fail_compilation/constraints_func2.d(100): Error: template `test19` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(29): Candidate is: `test19(T)(T v)` with `T = int` must satisfy one of the following constraints: ` N!T !P!T N!T` fail_compilation/constraints_func2.d(101): Error: template `test20` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(30): Candidate is: `test20(T)(T v)` with `T = int` must satisfy the following constraint: ` N!T` fail_compilation/constraints_func2.d(102): Error: template `test21` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(31): Candidate is: `test21(T)(T v)` with `T = int` must satisfy one of the following constraints: ` N!T N!T` fail_compilation/constraints_func2.d(103): Error: template `test22` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(32): Candidate is: `test22(T)(T v)` with `T = int` must satisfy one of the following constraints: ` !P!T !P!T` fail_compilation/constraints_func2.d(104): Error: template `test23` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(33): Candidate is: `test23(T)(T v)` with `T = int` must satisfy one of the following constraints: ` !P!T N!T !P!T` fail_compilation/constraints_func2.d(105): Error: template `test24` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(34): Candidate is: `test24(R)(R r)` with `R = int` must satisfy the following constraint: ` __traits(hasMember, R, "stuff")` fail_compilation/constraints_func2.d(106): Error: template `test25` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(35): Candidate is: `test25(T)(T v)` with `T = int` must satisfy the following constraint: ` N!T` fail_compilation/constraints_func2.d(107): Error: template `test26` is not callable using argument types `!(float)(int)` fail_compilation/imports/constraints.d(36): Candidate is: `test26(T, U)(U u)` with `T = float, U = int` must satisfy the following constraint: ` N!U` --- */ void main() { import imports.constraints; test13(0); test14(0); test15(0); test16(0); test17(0); test18(0); test19(0); test20(0); test21(0); test22(0); test23(0); test24(0); test25(0); test26!float(5); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12730b.d0000644000175000017500000000035415205374122021245 0ustar fabiofabio/* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/fail12730b.d(13): Error: expected integer operand(s) for `-` --- */ // https://issues.dlang.org/show_bug.cgi?id=12730 void test() { asm { mov ECX,-EAX; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18985.d0000644000175000017500000000103715205374122021124 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail18985.d(20): Error: operator `+=` not supported for `foo` of type `C` fail_compilation/fail18985.d(13): perhaps implement `auto opOpAssign(string op : "+")(int) {}` fail_compilation/fail18985.d(21): Error: operator `+=` not supported for `bar` of type `C` fail_compilation/fail18985.d(13): perhaps implement `auto opOpAssign(string op : "+")(int) {}` --- */ // https://issues.dlang.org/show_bug.cgi?id=18985 class C {} C foo; shared C bar; void main() { foo += 1; bar += 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19729.d0000644000175000017500000000166115205374122021124 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19729.d(35): Error: `fail19729.C.__ctor` called with argument types `(string)` matches multiple overloads exactly: fail_compilation/fail19729.d(18): `fail19729.C.Templ!string.this(string t)` and: fail_compilation/fail19729.d(18): `fail19729.C.Templ!string.this(string t)` fail_compilation/fail19729.d(36): Error: `fail19729.D.__ctor` called with argument types `(string)` matches multiple overloads after qualifier conversion: fail_compilation/fail19729.d(18): `fail19729.D.Templ!(const(char)[]).this(const(char)[] t)` and: fail_compilation/fail19729.d(18): `fail19729.D.Templ!(const(char)*).this(const(char)* t)` --- */ module fail19729; mixin template Templ(T) { this(T t) { } } class C { mixin Templ!string; mixin Templ!string; } class D { mixin Templ!(const(char)*); mixin Templ!(const(char)[]); } void main() { new C("conflict"); new D("conflict"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b16967.d0000644000175000017500000000075315205374122020434 0ustar fabiofabio/* * TEST_OUTPUT: --- fail_compilation/b16967.d(15): Error: switch case fallthrough - use 'goto default;' if intended fail_compilation/b16967.d(25): Error: switch case fallthrough - use 'goto default;' if intended --- */ int foo(int x) in { switch (x) { case 1: assert(x != 0); default: break; } } out(v) { switch(v) { case 42: assert(x != 0); default: break; } } do { return 42; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail356c.d0000644000175000017500000000040715205374122021106 0ustar fabiofabio/* EXTRA_FILES: imports/fail356.d TEST_OUTPUT: --- fail_compilation/fail356c.d(9): Error: variable `fail356c.foo` conflicts with import `fail356c.foo` at fail_compilation/fail356c.d(8) --- */ import foo = imports.fail356; int foo; // collides with renamed import ./ldc-1.42.0-src/tests/dmd/fail_compilation/test5412c.d0000644000175000017500000000045715205374122021235 0ustar fabiofabio/* EXTRA_FILES: test5412c2.di imports/test5412a.d TEST_OUTPUT: --- fail_compilation/test5412c.d(11): Error: import `test5412c.test5412c2` conflicts with import `test5412c.test5412c2` at fail_compilation/test5412c.d(10) --- */ module test5412c; import test5412c2 = imports.test5412a; import test5412c2; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_typeof.d0000644000175000017500000000253115205374122022073 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail_typeof.d(15): Error: undefined identifier `this` fail_compilation/fail_typeof.d(20): Error: `this` is not in a class or struct scope fail_compilation/fail_typeof.d(25): Error: undefined identifier `super` fail_compilation/fail_typeof.d(30): Error: `super` is not in a class scope fail_compilation/fail_typeof.d(37): Error: undefined identifier `this`, did you mean `typeof(this)`? fail_compilation/fail_typeof.d(47): Error: undefined identifier `super` fail_compilation/fail_typeof.d(52): Error: `super` is not in a class scope fail_compilation/fail_typeof.d(60): Error: undefined identifier `this`, did you mean `typeof(this)`? fail_compilation/fail_typeof.d(70): Error: undefined identifier `super`, did you mean `typeof(super)`? --- */ enum E1 : this { fail, } enum E2 : typeof(this) { fail, } enum E3 : super { fail, } enum E4 : typeof(super) { fail, } struct S1 { enum E1 : this { fail, } enum E2 : typeof(this) { ok = S1(), } enum E3 : super { fail, } enum E4 : typeof(super) { fail, } } class C1 { enum E1 : this { fail, } enum E2 : typeof(this) { ok = new C1, } enum E3 : super { fail, } enum E4 : typeof(super) { ok = new C1, } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/dbitfields.d0000644000175000017500000000104215205374122021677 0ustar fabiofabio/* REQUIRED_ARGS: -preview=bitfields * TEST_OUTPUT: --- fail_compilation/dbitfields.d(118): Error: reinterpretation through overlapped field `e` is not allowed in CTFE fail_compilation/dbitfields.d(121): called from here: `testu()` fail_compilation/dbitfields.d(121): while evaluating: `static assert(testu() == 1)` --- */ #line 100 union U { uint a:3; uint b:1; ulong c:64; int d:3; int e:1; long f:64; int i; } int testu() { U u; u.d = 9; return u.e; } static assert(testu() == 1); ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9250.d0000644000175000017500000000072215205374122021016 0ustar fabiofabio// REQUIRED_ARGS: -m32 /* TEST_OUTPUT: --- fail_compilation/diag9250.d(19): Error: cannot implicitly convert expression `10u` of type `uint` to `Foo` fail_compilation/diag9250.d(22): Error: cannot implicitly convert expression `10u` of type `uint` to `void*` --- */ struct Foo { ubyte u; } void main() { uint[10] bar; Foo x = bar.length; // error here void* y = bar.length ? bar.length : // error here bar.length; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22634.d0000644000175000017500000000025715205374122021111 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail22634.d(9): Error: more than 65535 symbols with name `i` generated --- */ void main() { static foreach(i; 0..65537) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/biterrors2.d0000644000175000017500000000062715205374122021673 0ustar fabiofabio/* REQUIRED_ARGS: -preview=bitfields * TEST_OUTPUT: --- fail_compilation/biterrors2.d(100): Error: variable `biterrors2.a` - bitfield must be member of struct, union, or class fail_compilation/biterrors2.d(104): Error: bitfield `b` has zero width fail_compilation/biterrors2.d(105): Error: bitfield type `float` is not an integer type --- */ #line 100 int a : 2; struct S { int b:0; float c:3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19182.d0000644000175000017500000000037615205374122021117 0ustar fabiofabio// REQUIRED_ARGS: -c /* TEST_OUTPUT: --- gigi fail_compilation/fail19182.d(12): Error: `pragma(msg)` is missing a terminating `;` --- */ void foo() { pragma(msg, "gigi") // Here static foreach (e; []) { pragma(msg, "lili"); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/mixin.d0000644000175000017500000000062615205374122020721 0ustar fabiofabio// REQUIRED_ARGS: -mixin=${RESULTS_DIR}/fail_compilation/mixin_test.mixin /* TEST_OUTPUT: --- {{RESULTS_DIR}}/fail_compilation/mixin_test.mixin(7): Error: undefined identifier `b` --- */ // https://issues.dlang.org/show_bug.cgi?id=1870 // https://issues.dlang.org/show_bug.cgi?id=12790 string get() { return q{int x; int y; int z = x + b;}; } void main() { mixin(get()); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test19176.d0000644000175000017500000000061015205374122021155 0ustar fabiofabio/* REQUIRED_ARGS: -unittest TEST_OUTPUT: --- fail_compilation/test19176.d(13): Error: argument `foo()` to __traits(getUnitTests) must be a module or aggregate, not a template --- */ // https://issues.dlang.org/show_bug.cgi?id=19176 void main() { __traits(getUnitTests, foo); } template foo() { static if(true) { enum bar; } else { enum bar; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/gccasm1.c0000644000175000017500000000050215205374122021103 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/gccasm1.c(12): Error: string literal expected for Assembler Template, not `%` --- */ #define __fldcw(addr) asm volatile(%0 : : "m" (*(addr))) static __inline void __fnldcw(unsigned short _cw, unsigned short _newcw) { __fldcw(&_newcw); } void main() { __fnldcw(1, 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13320.d0000644000175000017500000000145315205374122021071 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag13320.d(20): Error: operator `++` not supported for `f` of type `Foo` fail_compilation/diag13320.d(14): perhaps implement `auto opUnary(string op : "++")() {}` or `auto opOpAssign(string op : "+")(int) {}` fail_compilation/diag13320.d(21): Error: expression `f` of type `Foo` does not have a boolean value fail_compilation/diag13320.d(14): perhaps add Cast Operator Overloading with `bool opCast(T : bool)() => ...` fail_compilation/diag13320.d(22): Error: expression `Foo()` of type `E` does not have a boolean value fail_compilation/diag13320.d(14): perhaps add Cast Operator Overloading with `bool opCast(T : bool)() => ...` --- */ struct Foo {} enum E : Foo { a = Foo.init } void main() { Foo f; ++f; if (f) {} assert(E.a); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10169.d0000644000175000017500000000043415205374122021077 0ustar fabiofabio/* EXTRA_FILES: imports/a10169.d TEST_OUTPUT: --- fail_compilation/diag10169.d(13): Error: no property `x` for `B(0)` of type `imports.a10169.B` fail_compilation/imports/a10169.d(3): struct `B` defined here --- */ import imports.a10169; void main() { auto a = B.init.x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice15441.d0000644000175000017500000000057215205374122020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice15441.d(22): Error: `s1.front` is `void` and has no value fail_compilation/ice15441.d(25): Error: cannot infer argument types, expected 1 argument, not 2 --- */ struct S1 { auto front()() {} } struct S2 { auto front()() { return 1; } } void main() { S1 s1; foreach (p, e; s1) {} S2 s2; foreach (p, e; s2) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail216.d0000644000175000017500000000075615205374122020745 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail216.d(16): Error: expression `foo()` is `void` and has no value fail_compilation/fail216.d(14): Error: function `fail216.bar` has no `return` statement, but is expected to return a value of type `int` fail_compilation/fail216.d(19): called from here: `bar()` --- */ // https://issues.dlang.org/show_bug.cgi?id=1744 // CTFE: crash on assigning void-returning function to variable void foo() {} int bar() { int x = foo(); } const y = bar(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/gag4269e.d0000644000175000017500000000030415205374122021016 0ustar fabiofabio// REQUIRED_ARGS: -c -o- /* TEST_OUTPUT: --- fail_compilation/gag4269e.d(10): Error: undefined identifier `Y8`, did you mean class `X8`? --- */ static if(is(typeof(X8.init))) {} class X8 : Y8 {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/opApply_return.d0000644000175000017500000000164215205374122022617 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/opApply_return.d(18): Deprecation: cannot return non-zero compile-time value from `opApply` fail_compilation/opApply_return.d(18): Any non-zero value must be the result of calling its delegate fail_compilation/opApply_return.d(19): Deprecation: cannot return non-zero compile-time value from `opApply` fail_compilation/opApply_return.d(19): Any non-zero value must be the result of calling its delegate fail_compilation/opApply_return.d(20): Deprecation: cannot return non-zero compile-time value from `opApply` fail_compilation/opApply_return.d(20): Any non-zero value must be the result of calling its delegate --- */ class Tree { Tree lhs; Tree rhs; int opApply(int delegate(Tree) dg) { if (lhs && lhs.opApply(dg)) return 1; if (dg(this)) return 1; if (rhs && rhs.opApply(dg)) return 1; return 0; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail319.d0000644000175000017500000000047615205374122020750 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail319.d(16): Error: template instance `fail319.f!(int, int)` does not match template declaration `f(T...)()` with `T = (int, int)` must satisfy the following constraint: ` T.length > 20` --- */ void f(T...)() if (T.length > 20) {} void main() { f!(int, int)(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail312.d0000644000175000017500000000047715205374122020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail312.d(13): Error: incompatible types for `(a[]) == (b)`: `int[]` and `short` fail_compilation/fail312.d(14): Error: incompatible types for `(a[]) <= (b)`: `int[]` and `short` --- */ void main() { int[1] a = 1; short b = 1; assert(a[] == b); assert(a[] <= b); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail37_m64.d0000644000175000017500000000042715205374122021347 0ustar fabiofabio// REQUIRED_ARGS: -m64 /* TEST_OUTPUT: --- fail_compilation/fail37_m64.d(9): Error: `cast(float)4LU / cast(float)8LU - cast(float)2147483647` is not of integral type, it is a `float` --- */ ulong[cast(uint)((cast(float)int.sizeof/ulong.sizeof)-int.max>>2)+int.max>>2] hexarray; ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue22826.d0000644000175000017500000000023415205374122021324 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/issue22826.d(6): Error: found `3` when expecting new line following `#line` directive --- */ #line 12 "issue22826.d" 3 ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9273a.d0000644000175000017500000000062515205374122021022 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9273a.d(19): Error: constructor `ice9273a.C.this!().this` no match for implicit `super()` call in constructor fail_compilation/ice9273a.d(23): Error: template instance `ice9273a.C.this!()` error instantiating --- */ template CtorMixin() { this(T)() {} } class B { mixin CtorMixin!(); } class C : B { this()() {} } void main() { auto c = new C(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_arrayop3b.d0000644000175000017500000000106015205374122022463 0ustar fabiofabio/* REQUIRED_ARGS: -o- TEST_OUTPUT: ---- $p:core/internal/array/operations.d$($n$): Error: static assert: "Binary op `+=` not supported for types `string` and `string`." $p:core/internal/array/operations.d$($n$): instantiated from here: `typeCheck!(true, string, string, "+=")` $p:object.d$($n$): instantiated from here: `arrayOp!(string[], string[], "+=")` fail_compilation/fail_arrayop3b.d(15): instantiated from here: `_arrayOp!(string[], string[], "+=")` --- */ void test11376() { string[] s1; string[] s2; s2[] += s1[]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail52.d0000644000175000017500000000027715205374122020661 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail52.d(10): Error: class `fail52.C` circular inheritance --- */ class A : B { void f(); } class B : C { override void g(); } class C : A { void g(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail125.d0000644000175000017500000000112215205374122020730 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail125.d(15): Error: sequence index `[2]` is outside bounds `[0 .. 2]` fail_compilation/fail125.d(18): Error: template instance `fail125.main.recMove!(1, a, b)` error instantiating fail_compilation/fail125.d(25): instantiated from here: `recMove!(0, a, b)` --- */ template recMove(int i, X...) { void recMove() { X[i] = X[i+1]; // I know the code is logically wrong, should test (i+2 < X.length) static if (i+1 < X.length) recMove!(i+1, X); } } void main() { int a, b; recMove!(0, a, b); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11982.d0000644000175000017500000000160015205374122020733 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11982.d(22): Error: basic type expected, not `scope` fail_compilation/ice11982.d(22): Error: found `scope` when expecting `;` following expression fail_compilation/ice11982.d(22): expression: `new _error_` fail_compilation/ice11982.d(22): Error: basic type expected, not `}` fail_compilation/ice11982.d(22): Error: missing `{ ... }` for function literal fail_compilation/ice11982.d(22): Error: C style cast illegal, use `cast(funk)function _error_() { } ` fail_compilation/ice11982.d(22): Error: found `}` when expecting `;` following expression fail_compilation/ice11982.d(22): expression: `cast(funk)function _error_() { } ` fail_compilation/ice11982.d(23): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/ice11982.d(22): unmatched `{` --- */ void main() { new scope ( funk ) function } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail217.d0000644000175000017500000000067215205374122020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail217.d(22): Error: mutable constructor `fail217.Message.this` cannot construct a `immutable` object fail_compilation/fail217.d(13): Consider adding `const` or `inout` here --- */ class Message { public int notifier; this( int notifier_object ) { notifier = notifier_object; } } void main() { auto m2 = new immutable(Message)(2); m2.notifier = 3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail50.d0000644000175000017500000000041715205374122020653 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail50.d(12): Error: taking the address of non-static variable `a` requires an instance of `Marko` fail_compilation/fail50.d(12): Error: variable `a` cannot be read at compile time --- */ struct Marko { int a; int* m = &a; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/goto3.d0000644000175000017500000000107515205374122020627 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/goto3.d(1010): Error: case cannot be in different `try` block level from `switch` fail_compilation/goto3.d(1012): Error: default cannot be in different `try` block level from `switch` --- */ void foo(); void bar(); #line 1000 void test1() { int i; switch (i) { case 1: try { foo(); case 2: { } default: { } } finally { bar(); } break; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/format.d0000644000175000017500000000525315205374122021066 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/format.d(101): Error: `pragma(printf)` function `printf1` must have `extern(C)` or `extern(C++)` linkage, not `extern(D)` fail_compilation/format.d(102): Error: `pragma(printf)` function `printf2` must have signature `int printf2([parameters...], const(char)*, ...)` not `extern (C) int(const(int)*, ...)` fail_compilation/format.d(103): Error: `pragma(printf)` function `printf3` must have signature `int printf3([parameters...], const(char)*, va_list)` fail_compilation/format.d(104): Error: `pragma(printf)` function `printf4` must have signature `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: `pragma(printf)` function `vprintf1` must have `extern(C)` or `extern(C++)` linkage, not `extern(D)` fail_compilation/format.d(204): Error: `pragma(printf)` function `vprintf2` must have signature `int vprintf2([parameters...], const(char)*, va_list)` fail_compilation/format.d(205): Error: `pragma(printf)` function `vprintf3` must have signature `int vprintf3([parameters...], const(char)*, va_list)` fail_compilation/format.d(206): Error: `pragma(printf)` function `vprintf4` must have signature `int vprintf4([parameters...], const(char)*, va_list)` fail_compilation/format.d(207): Error: `pragma(printf)` function `vprintf5` must have C-style variadic `...` or `va_list` parameter fail_compilation/format.d(208): Error: `pragma(scanf)` function `vscanf1` must have `extern(C)` or `extern(C++)` linkage, not `extern(Windows)` fail_compilation/format.d(208): Error: `pragma(scanf)` function `vscanf1` must have signature `int vscanf1([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(char*, int[] a...); pragma(scanf) extern (Windows) int vscanf1(); 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); ./ldc-1.42.0-src/tests/dmd/fail_compilation/alignas2.c0000644000175000017500000000174015205374122021272 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/alignas2.c(101): Error: no alignment-specifier for typedef declaration fail_compilation/alignas2.c(103): Error: no alignment-specifier for function declaration fail_compilation/alignas2.c(107): Error: no alignment-specifier for `register` storage class fail_compilation/alignas2.c(110): Error: no alignment-specifier for parameters fail_compilation/alignas2.c(115): Error: no alignment-specifier for parameters fail_compilation/alignas2.c(116): Error: storage class and type are not allowed in identifier-list fail_compilation/alignas2.c(121): Error: no alignment-specifier for bit field declaration fail_compilation/alignas2.c(122): Error: no alignment-specifier for bit field declaration --- */ #line 100 typedef _Alignas(4) int x; _Alignas(8) int mercury(); void venus() { register _Alignas(8) int x; } void earth(_Alignas(4) int x) { } void mars(x) _Alignas(4) int x; { } struct B { _Alignas(4) int bf : 3; _Alignas(8) int : 0; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag12124.d0000644000175000017500000000125315205374122021070 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag12124.d(14): Error: struct `diag12124.S1` `static opCall` is hidden by constructors and can never be called fail_compilation/diag12124.d(14): Please use a factory method instead, or replace all constructors with `static opCall`. fail_compilation/diag12124.d(20): Error: struct `diag12124.S2` `static opCall` is hidden by constructors and can never be called fail_compilation/diag12124.d(20): Please use a factory method instead, or replace all constructors with `static opCall`. --- */ struct S1 { this(int) {} static S1 opCall() { assert(0); } } struct S2 { this(int) {} static S2 opCall()() { assert(0); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test11006.d0000644000175000017500000000145515205374122021145 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test11006.d(11): Error: cannot subtract pointers to different types: `void*` and `int*`. fail_compilation/test11006.d(11): while evaluating: `static assert(cast(void*)8 - cast(int*)0 == 2L)` fail_compilation/test11006.d(12): Error: cannot subtract pointers to different types: `int*` and `void*`. fail_compilation/test11006.d(12): while evaluating: `static assert(cast(int*)8 - cast(void*)0 == 8L)` fail_compilation/test11006.d(13): Error: cannot subtract pointers to different types: `ushort*` and `ubyte*`. fail_compilation/test11006.d(13): while evaluating: `static assert(null - null == 0)` --- */ static assert(cast(void*)8 - cast(int*) 0 == 2L); static assert(cast(int*) 8 - cast(void*)0 == 8L); static assert((ushort*).init - (ubyte*).init == 0); ./ldc-1.42.0-src/tests/dmd/fail_compilation/gag4269c.d0000644000175000017500000000030615205374122021016 0ustar fabiofabio// REQUIRED_ARGS: -c -o- /* TEST_OUTPUT: --- fail_compilation/gag4269c.d(10): Error: undefined identifier `T3`, did you mean function `X3`? --- */ static if(is(typeof(X3.init))) {} void X3(T3) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375o.d0000644000175000017500000000052715205374122021212 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375o.d(14): Error: else is dangling, add { } after condition at fail_compilation/fail4375o.d(10) --- */ void main() { if (true) for (; false;) if (true) assert(82); else assert(83); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11518.d0000644000175000017500000000051515205374122020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11518.d(17): Error: class `ice11518.B` matches more than one template declaration: fail_compilation/ice11518.d(12): `B(T : A!T)` and: fail_compilation/ice11518.d(13): `B(T : A!T)` --- */ class A(T) {} class B(T : A!T) {} class B(T : A!T) {} void main() { new B!(A!void); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag20268.d0000644000175000017500000000050615205374122021100 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20268 /* TEST_OUTPUT: --- fail_compilation/diag20268.d(12): Error: template `__lambda_L11_C1` is not callable using argument types `!()(int)` fail_compilation/diag20268.d(11): Candidate is: `__lambda_L11_C1(__T1, __T2)(x, y)` --- */ alias f = (x,y) => true; auto x = f(1); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21206.d0000644000175000017500000000062415205374122021101 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21206 /* TEST_OUTPUT: --- fail_compilation/fail21206.d(10): Error: function `toString` cannot return type `string` because its linkage is `extern(C++)` fail_compilation/fail21206.d(10): slices are specific to D and do not have a counterpart representation in C++ --- */ extern(C++) struct Obj { string toString() { return "ret"; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/udaparams.d0000644000175000017500000000564415205374122021557 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/udaparams.d(31): Error: variadic parameter cannot have user-defined attributes fail_compilation/udaparams.d(32): Error: variadic parameter cannot have user-defined attributes fail_compilation/udaparams.d(34): Error: user-defined attributes cannot appear as postfixes fail_compilation/udaparams.d(35): Error: user-defined attributes cannot appear as postfixes fail_compilation/udaparams.d(36): Error: user-defined attributes cannot appear as postfixes fail_compilation/udaparams.d(38): Error: `@safe` attribute for function parameter is not supported fail_compilation/udaparams.d(39): Error: `@safe` attribute for function parameter is not supported fail_compilation/udaparams.d(40): Error: `@safe` attribute for function parameter is not supported fail_compilation/udaparams.d(43): Error: `@system` attribute for function parameter is not supported fail_compilation/udaparams.d(44): Error: `@trusted` attribute for function parameter is not supported fail_compilation/udaparams.d(45): Error: `@nogc` attribute for function parameter is not supported fail_compilation/udaparams.d(51): Error: cannot put a storage-class in an `alias` declaration. fail_compilation/udaparams.d(52): Error: cannot put a storage-class in an `alias` declaration. fail_compilation/udaparams.d(53): Error: semicolon expected to close `alias` declaration, not `=>` fail_compilation/udaparams.d(53): Error: declaration expected, not `1` fail_compilation/udaparams.d(54): Error: semicolon expected to close `alias` declaration, not `=>` fail_compilation/udaparams.d(54): Error: declaration expected, not `1` fail_compilation/udaparams.d(57): Error: basic type expected, not `@` fail_compilation/udaparams.d(57): Error: identifier expected for template value parameter fail_compilation/udaparams.d(57): Error: found `@` when expecting `)` fail_compilation/udaparams.d(57): Error: basic type expected, not `3` fail_compilation/udaparams.d(57): Error: found `3` when expecting `)` fail_compilation/udaparams.d(57): Error: semicolon expected following function declaration, not `)` fail_compilation/udaparams.d(57): Error: variable name expected after type `T`, not `)` fail_compilation/udaparams.d(57): Error: declaration expected, not `)` --- */ void vararg1(int a, @(10) ...); extern(C) void vararg2(int a, @(10) ...); void rhsuda(int a @(10)); void rhsuda2(int @(10)); void rhsuda3(int[] arr @(10) ...); void wrongAttr1(@safe int); void wrongAttr2(@safe void function()); void wrongAttr3(@safe void delegate()); void test16(A)(A a @system); void test16(A)(A a @trusted); void test16(A)(A a @nogc); // lambdas without parentheses alias test19a = @safe b => 1 + 2; alias test19b = @system b => 1 + 2; alias test19c = @nogc b => 1 + 2; alias test19d = @(2) @system b => 1 + 2; alias test19e = @safe @(2) b => 1 + 2; alias test19f = extern(C++) b => 1 + 2; alias test19g = align(2) b => 1 + 2; // UDAs on Template parameter aren't supported void test21(@(3) T)(T t) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4544.d0000644000175000017500000000122215205374122021022 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4544.d(15): Error: character constant has multiple characters fail_compilation/fail4544.d(16): Error: `0x` isn't a valid integer literal, use `0x0` instead fail_compilation/fail4544.d(16): Error: variable name expected after type `int`, not `0` fail_compilation/fail4544.d(17): Error: unterminated character constant fail_compilation/fail4544.d(18): Error: character constant has multiple characters --- */ int foo(char n, int m) { int k = 5; char c = 'asd'; int 0x = 'k'; foo('dasadasdaasdasdaslkdhasdlashdsalk, xxx); goo('asdasdsa'); for (int i = 0; i < 10; i++) { k++; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375c.d0000644000175000017500000000051715205374123021176 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375c.d(14): Error: else is dangling, add { } after condition at fail_compilation/fail4375c.d(10) --- */ void main() { if (true) if (false) { assert(6.1); } else { assert(6.2); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10415.d0000644000175000017500000000135015205374123021070 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10415.d(36): Error: none of the overloads of `x` are callable using argument types `(int) const` fail_compilation/diag10415.d(13): Candidates are: `diag10415.C.x() const` fail_compilation/diag10415.d(18): `diag10415.C.x(int __param_0)` fail_compilation/diag10415.d(39): Error: d.x is not an lvalue --- */ class C { @property int x() const { return 0; } @property void x(int) { } } template AddProp() { @property int x() { return 1; } } template AddFunc() { void x(int, int) {} } class D { // overloadset mixin AddProp; mixin AddFunc; } void main() { const c = new C(); c.x = 1; auto d = new D(); d.x = 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag11769.d0000644000175000017500000000073315205374123021111 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag11769.d(18): Error: `diag11769.foo!string.bar` called with argument types `(string)` matches multiple overloads after implicit conversions: fail_compilation/diag11769.d(13): `diag11769.foo!string.bar(wstring __param_0)` and: fail_compilation/diag11769.d(14): `diag11769.foo!string.bar(dstring __param_0)` --- */ template foo(T) { void bar(wstring) {} void bar(dstring) {} } void main() { foo!string.bar("abc"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12501.d0000644000175000017500000000243015205374123020722 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/ice12501.d(33): Error: function `foo` is not callable using argument types `(int, int)` fail_compilation/ice12501.d(33): expected 1 argument(s), not 2 fail_compilation/ice12501.d(40): `ice12501.foo(int value)` declared here fail_compilation/ice12501.d(33): Error: function `foo` is not callable using argument types `(int, int)` fail_compilation/ice12501.d(33): expected 1 argument(s), not 2 fail_compilation/ice12501.d(40): `ice12501.foo(int value)` declared here fail_compilation/ice12501.d(47): Error: template instance `ice12501.reduce!(foo, foo).reduce!(Tuple!(int, int), int[])` error instantiating ---- */ struct Tuple(T...) { alias Types = T; T field; alias field this; } Tuple!A tuple(A...)(A args) { return typeof(return)(args); } template reduce(fun...) { auto reduce(Args...)(Args args) { alias seed = args[0]; alias r = args[1]; Args[0] result = seed; for (; r.length != 0; r = r[1..$]) { foreach (i, Unused; Args[0].Types) { result[i] = fun[i](result[i], r[0]); } } return result; } } int foo(int value) { return value; } void main() { reduce!(foo, foo)(tuple(0, 0), [ 1 ]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13281.d0000644000175000017500000000333415205374123021100 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag13281.d(20): Error: cannot implicitly convert expression `123` of type `int` to `string` fail_compilation/diag13281.d(21): Error: cannot implicitly convert expression `123u` of type `uint` to `string` fail_compilation/diag13281.d(22): Error: cannot implicitly convert expression `123L` of type `long` to `string` fail_compilation/diag13281.d(23): Error: cannot implicitly convert expression `123LU` of type `ulong` to `string` fail_compilation/diag13281.d(24): Error: cannot implicitly convert expression `123.4` of type `double` to `int` fail_compilation/diag13281.d(25): Error: cannot implicitly convert expression `123.4F` of type `float` to `int` fail_compilation/diag13281.d(26): Error: cannot implicitly convert expression `123.4L` of type `real` to `int` fail_compilation/diag13281.d(27): Error: cannot implicitly convert expression `123.4i` of type `idouble` to `int` fail_compilation/diag13281.d(28): Error: cannot implicitly convert expression `123.4Fi` of type `ifloat` to `int` fail_compilation/diag13281.d(29): Error: cannot implicitly convert expression `123.4Li` of type `ireal` to `int` fail_compilation/diag13281.d(30): Error: cannot implicitly convert expression `123.4 + 5.6i` of type `cdouble` to `int` fail_compilation/diag13281.d(31): Error: cannot implicitly convert expression `123.4F + 5.6Fi` of type `cfloat` to `int` fail_compilation/diag13281.d(32): Error: cannot implicitly convert expression `123.4L + 5.6Li` of type `creal` to `int` --- */ string x1 = 123; string x2 = 123u; string x3 = 123L; string x4 = 123uL; int y1 = 123.4; int y2 = 123.4f; int y3 = 123.4L; int y4 = 123.4i; int y5 = 123.4fi; int y6 = 123.4Li; int y7 = 123.4 +5.6i; int y8 = 123.4f+5.6fi; int y9 = 123.4L+5.6Li; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22541.d0000644000175000017500000000064715205374123021156 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test22541.d(104): Error: escaping a reference to parameter `i` by returning `i` is not allowed in a `@safe` function fail_compilation/test22541.d(102): perhaps annotate the parameter with `return` --- */ /* https://issues.dlang.org/show_bug.cgi?id=22541 */ #line 100 @safe ref int newe(ref return scope int i) // ref, error { return i; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10980.d0000644000175000017500000000322215205374123021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10980.d(22): Error: variable `fail10980.s1b` of type struct `immutable(S1)` uses `this(this)`, which is not allowed in static initialization fail_compilation/fail10980.d(28): Error: variable `fail10980.s1d` of type struct `immutable(S1)` uses `this(this)`, which is not allowed in static initialization fail_compilation/fail10980.d(27): Error: static variable `s1x` cannot be read at compile time fail_compilation/fail10980.d(28): called from here: `bar1()` fail_compilation/fail10980.d(38): Error: variable `fail10980.s2b` of type struct `immutable(S2)` uses `this(this)`, which is not allowed in static initialization fail_compilation/fail10980.d(44): Error: variable `fail10980.s2d` of type struct `immutable(S2)` uses `this(this)`, which is not allowed in static initialization fail_compilation/fail10980.d(43): Error: static variable `s2x` cannot be read at compile time fail_compilation/fail10980.d(44): called from here: `bar2()` --- */ struct S1 { this(int) immutable {} this(this) {} } alias immutable(S1) IS1; static immutable S1 s1a = IS1(1); // OK static immutable S1 s1b = s1a; // NG S1 foo1() { S1 s1x; S1 s1y = s1x; return s1y; } static immutable S1 s1c = foo1(); // OK ref S1 bar1() { static S1 s1x; return s1x; } static immutable S1 s1d = bar1(); // NG struct S2 { int val; this(this) {} } alias immutable(S2) IS2; static immutable S2 s2a = IS2(1); // OK static immutable S2 s2b = s2a; // NG S2 foo2() { S2 s2x; S2 s2y = s2x; return s2y; } static immutable S2 s2c = foo2(); // OK ref S2 bar2() { static S2 s2x; return s2x; } static immutable S2 s2d = bar2(); // NG ./ldc-1.42.0-src/tests/dmd/fail_compilation/failob1.d0000644000175000017500000000242215205374123021107 0ustar fabiofabio/* REQUIRED_ARGS:-preview=dip1021 TEST_OUTPUT: --- fail_compilation/failob1.d(104): Error: variable `failob1.test1.a1` is not disposed of before return fail_compilation/failob1.d(105): Error: variable `failob1.test2.a2` is not disposed of before return fail_compilation/failob1.d(107): Error: variable `failob1.test4.s4` is not disposed of before return fail_compilation/failob1.d(108): Error: variable `failob1.test5.dg5` is not disposed of before return fail_compilation/failob1.d(115): Error: variable `failob1.test12.p12` is not disposed of before return --- */ struct S { int i; int* f; } struct T { int i; const(int)* f; } class C { int i; int* f; } #line 100 @live { // Test what is and is not a trackable variable void test1(int[] a1) { } // error void test2(int*[3] a2) { } // error void test3(const int*[3] a) { } // ok void test4(S s4) { } // error void test5(int delegate() dg5) { } // error void test6(const(int*)[3] a) { } // ok void test7(const(int)*[3] a) { } // ok void test8(const(int)* p) { } // ok void test9(T t) { } // ok void test10(C c) { } // ok void test11(int i) { } // ok void test12(int* p12) { } // error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18607.d0000644000175000017500000000056015205374123021160 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test18607.d(10): Error: function `test18607.test!int.test` no `return exp;` or `assert(0);` at end of function & test --- */ // https://issues.dlang.org/show_bug.cgi?id=18607 int* test(T...)() pure @safe { L:foreach(_; T) { continue L; return null; } } pragma(msg, &test!(int)); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19922.d0000644000175000017500000000035015205374123021112 0ustar fabiofabio/* DFLAGS: TEST_OUTPUT: --- fail_compilation/fail19922.d(16): Error: `object.TypeInfo_Class` could not be found, but is implicitly used --- */ module object; class Object {} void test() { Object o; auto ti = typeid(o); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail109.d0000644000175000017500000000407115205374123020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail109.d(12): Error: enum member `fail109.Bool.Unknown` initialization with `Bool.True+1` causes overflow for type `bool` --- */ enum Bool : bool { False, True, Unknown } /* https://issues.dlang.org/show_bug.cgi?id=11088 TEST_OUTPUT: --- fail_compilation/fail109.d(25): Error: enum member `fail109.E.B` initialization with `E.A+1` causes overflow for type `int` fail_compilation/fail109.d(31): Error: enum member `fail109.E1.B` initialization with `E1.A+1` causes overflow for type `short` --- */ enum E { A = int.max, B } enum E1 : short { A = short.max, B } /* https://issues.dlang.org/show_bug.cgi?id=14950 TEST_OUTPUT: --- fail_compilation\fail109.d(48): Error: cannot automatically assign value to enum member `fail109.B.end` because base type `C` is an enum; provide an explicit value --- */ enum C { start, end } enum B { start = C.end, end } /* https://issues.dlang.org/show_bug.cgi?id=11849 TEST_OUTPUT: --- fail_compilation/fail109.d(70): Error: enum member `fail109.RegValueType1a.Unknown` is forward referenced looking for `.max` fail_compilation/fail109.d(77): Error: enum member `fail109.RegValueType1b.Unknown` is forward referenced looking for `.max` fail_compilation/fail109.d(82): Error: enum member `fail109.RegValueType2a.Unknown` is forward referenced looking for `.min` fail_compilation/fail109.d(89): Error: enum member `fail109.RegValueType2b.Unknown` is forward referenced looking for `.min` --- */ alias DWORD = uint; enum : DWORD { REG_DWORD = 4 } enum RegValueType1a : DWORD { Unknown = DWORD.max, DWORD = REG_DWORD, } enum RegValueType1b : DWORD { DWORD = REG_DWORD, Unknown = DWORD.max, } enum RegValueType2a : DWORD { Unknown = DWORD.min, DWORD = REG_DWORD, } enum RegValueType2b : DWORD { DWORD = REG_DWORD, Unknown = DWORD.min, } /* TEST_OUTPUT: --- fail_compilation/fail109.d(105): Error: enum member `fail109.d` initialization with `__anonymous.c+1` causes overflow for type `Q` --- */ struct Q { enum max = Q(); } enum { c = Q(), d } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7424f.d0000644000175000017500000000031415205374123021172 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7424f.d(10): Error: template `this.g()() shared` has no value --- */ struct S7424f { @property int g()() shared { return 0; } void test() { int f = g; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12539.d0000644000175000017500000000036115205374123020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12539.d(15): Error: sequence index `[0]` is outside bounds `[0 .. 0]` --- */ alias TypeTuple(E...) = E; void main () { int[string] map; alias Foo = TypeTuple!(); auto a = map[Foo[0]]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/vector_types.d0000644000175000017500000000175115205374123022324 0ustar fabiofabio/* REQUIRED_ARGS: -o- TEST_OUTPUT: DISABLED: LDC freebsd32 openbsd32 linux32 osx32 win32 --- fail_compilation/vector_types.d(15): Error: 32 byte vector type `__vector(double[4])` is not supported on this platform fail_compilation/vector_types.d(16): Error: 32 byte vector type `__vector(float[8])` is not supported on this platform fail_compilation/vector_types.d(17): Error: 32 byte vector type `__vector(ulong[4])` is not supported on this platform fail_compilation/vector_types.d(18): Error: 32 byte vector type `__vector(uint[8])` is not supported on this platform fail_compilation/vector_types.d(19): Error: 32 byte vector type `__vector(ushort[16])` is not supported on this platform fail_compilation/vector_types.d(20): Error: 32 byte vector type `__vector(ubyte[32])` is not supported on this platform --- */ alias a = __vector(double[4]); alias b = __vector(float[8]); alias c = __vector(ulong[4]); alias d = __vector(uint[8]); alias e = __vector(ushort[16]); alias f = __vector(ubyte[32]); ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag11819b.d0000644000175000017500000000507515205374123021253 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag11819b.d(27): Error: unrecognized trait `HasMember`, did you mean `hasMember`? fail_compilation/diag11819b.d(28): Error: unrecognized trait `Identifier`, did you mean `identifier`? fail_compilation/diag11819b.d(29): Error: unrecognized trait `GetProtection`, did you mean `getProtection`? fail_compilation/diag11819b.d(30): Error: unrecognized trait `Parent`, did you mean `parent`? fail_compilation/diag11819b.d(31): Error: unrecognized trait `GetMember`, did you mean `getMember`? fail_compilation/diag11819b.d(32): Error: unrecognized trait `GetOverloads`, did you mean `getOverloads`? fail_compilation/diag11819b.d(33): Error: unrecognized trait `GetVirtualFunctions`, did you mean `getVirtualFunctions`? fail_compilation/diag11819b.d(34): Error: unrecognized trait `GetVirtualMethods`, did you mean `getVirtualMethods`? fail_compilation/diag11819b.d(35): Error: unrecognized trait `ClassInstanceSize`, did you mean `classInstanceSize`? fail_compilation/diag11819b.d(36): Error: unrecognized trait `AllMembers`, did you mean `allMembers`? fail_compilation/diag11819b.d(37): Error: unrecognized trait `DerivedMembers`, did you mean `derivedMembers`? fail_compilation/diag11819b.d(38): Error: unrecognized trait `IsSame`, did you mean `isSame`? fail_compilation/diag11819b.d(39): Error: unrecognized trait `Compiles`, did you mean `compiles`? fail_compilation/diag11819b.d(40): Error: unrecognized trait `GetAliasThis`, did you mean `getAliasThis`? fail_compilation/diag11819b.d(41): Error: unrecognized trait `GetAttributes`, did you mean `getAttributes`? fail_compilation/diag11819b.d(42): Error: unrecognized trait `GetFunctionAttributes`, did you mean `getFunctionAttributes`? fail_compilation/diag11819b.d(43): Error: unrecognized trait `GetUnitTests`, did you mean `getUnitTests`? fail_compilation/diag11819b.d(44): Error: unrecognized trait `GetVirtualIndex`, did you mean `getVirtualIndex`? --- */ void main() { if (__traits(HasMember)) { } if (__traits(Identifier)) { } if (__traits(GetProtection)) { } if (__traits(Parent)) { } if (__traits(GetMember)) { } if (__traits(GetOverloads)) { } if (__traits(GetVirtualFunctions)) { } if (__traits(GetVirtualMethods)) { } if (__traits(ClassInstanceSize)) { } if (__traits(AllMembers)) { } if (__traits(DerivedMembers)) { } if (__traits(IsSame)) { } if (__traits(Compiles)) { } if (__traits(GetAliasThis)) { } if (__traits(GetAttributes)) { } if (__traits(GetFunctionAttributes)) { } if (__traits(GetUnitTests)) { } if (__traits(GetVirtualIndex)) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10598.d0000644000175000017500000000064715205374123020750 0ustar fabiofabio// 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() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10285.d0000644000175000017500000000136515205374123021112 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10285.d(16): Error: no identifier for declarator `int` fail_compilation/fail10285.d(17): Error: expected `,` or `=` after identifier, not `y` fail_compilation/fail10285.d(17): Error: initializer required after `x` when type is specified fail_compilation/fail10285.d(18): Error: no identifier for declarator `int` fail_compilation/fail10285.d(18): Error: found `bool` when expecting `,` fail_compilation/fail10285.d(19): Error: no identifier for declarator `j` fail_compilation/fail10285.d(19): Error: found `int` when expecting `,` fail_compilation/fail10285.d(21): Error: initializer required after `z` when type is specified --- */ enum { int = 5, int x y, int bool i = 3, j int k = 3, int z } ./ldc-1.42.0-src/tests/dmd/fail_compilation/noreturn_expr2.d0000644000175000017500000000032215205374123022563 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/noreturn_expr2.d(8): Error: cannot cast `noreturn` to `int` at compile time --- */ enum E {e1 = 1, e2 = 2, illegal = noreturn} void main() { E e; e = E.illegal; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix22108.d0000644000175000017500000000043015205374123020752 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fix22108.d(12): Error: returning scope variable `p` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=22108 @safe ref int test(return ref scope int* p) { return *p; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13498.d0000644000175000017500000000054715205374123021124 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail13498.d(11): Error: return value `"foo"` of type `string` does not match return type `int`, and cannot be implicitly converted fail_compilation/fail13498.d(16): Error: template instance `fail13498.foo!()` error instantiating --- */ int foo()() { return "foo"; // should fail as well } void main() { foo(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail235.d0000644000175000017500000000076715205374123020751 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail235.d(12): Error: template instance `Tuple!(typeid(char))` expression `typeid(char)` is not a valid template value argument --- */ template Tuple(TPL...) { alias TPL Tuple; } auto K = Tuple!(typeid(char)); /* TEST_OUTPUT: --- fail_compilation/fail235.d(24): Error: template instance `Alias!(typeid(char))` expression `typeid(char)` is not a valid template value argument --- */ template Alias(alias A) { alias A Alias; } auto A = Alias!(typeid(char)); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11653.d0000644000175000017500000000102315205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11653.d(18): Error: switch case fallthrough - use 'goto case;' if intended fail_compilation/fail11653.d(23): Error: switch case fallthrough - use 'goto default;' if intended --- */ void main() { int test = 12412; int output = 0; switch(test) { case 1: output = 1; //break; //Oops.. case 2: .. case 3: output = 2; break; case 4: output = 3; default: output = 4; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16443.d0000644000175000017500000000052715205374123021157 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test16443.d(10): Error: incompatible types for `(null) + (null)`: both operands are of type `typeof(null)` fail_compilation/test16443.d(11): Error: incompatible types for `(null) - (null)`: both operands are of type `typeof(null)` --- */ void foo() { auto a = null + null; auto b = null - null; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9961.d0000644000175000017500000000100215205374123021020 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9961.d(11): Error: cannot implicitly convert expression `""` of type `string` to `int` fail_compilation/diag9961.d(14): Error: template instance `diag9961.foo!int` error instantiating fail_compilation/diag9961.d(11): Error: cannot implicitly convert expression `""` of type `string` to `int` fail_compilation/diag9961.d(15): Error: template instance `diag9961.foo!char` error instantiating --- */ void foo(T)(T) { int x = ""; } void main() { 100.foo(); 'a'.foo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail16206b.d0000644000175000017500000000040215205374123021242 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail16206b.d(14): Error: expected 2 arguments for `hasMember` but had 3 --- */ struct S { static int foo()() { return 0; } } alias AliasSeq(T...) = T; alias allFoos = AliasSeq!(__traits(hasMember, S, "foo", true)); ./ldc-1.42.0-src/tests/dmd/fail_compilation/e15876_1.d0000644000175000017500000000124615205374123020654 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/e15876_1.d(17): Error: valid scope identifiers are `exit`, `failure`, or `success`, not `x` fail_compilation/e15876_1.d(18): Error: found `End of File` when expecting `)` fail_compilation/e15876_1.d(18): Error: found `End of File` instead of statement fail_compilation/e15876_1.d(18): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/e15876_1.d(17): unmatched `{` fail_compilation/e15876_1.d(18): Error: found `End of File` when expecting `]` fail_compilation/e15876_1.d(18): Error: variable name expected after type `o[() { scope(exit) __error__ } ]`, not `End of File` --- */ o[{scope(x ./ldc-1.42.0-src/tests/dmd/fail_compilation/alias_instance_member2.d0000644000175000017500000000137315205374123024164 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/alias_instance_member2.d(26): Error: cannot alias variable member `v` of variable `f` fail_compilation/alias_instance_member2.d(26): Use `typeof(f)` instead to preserve behaviour fail_compilation/alias_instance_member2.d(30): Error: cannot alias function member `fun` of variable `f` fail_compilation/alias_instance_member2.d(30): Use `typeof(f)` instead to preserve behaviour --- */ @__edition_latest_do_not_use module aim; struct Foo { int v; static int w; enum x = 5; void fun() {} static void gun() {} } struct Bar { Foo f; alias v = f.v; alias v2 = typeof(f).v; // OK alias w = f.w; // OK alias x = f.x; // OK alias fun = f.fun; alias gun = f.gun; // OK } ./ldc-1.42.0-src/tests/dmd/fail_compilation/testnothrow.c0000644000175000017500000000131215205374123022166 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/testnothrow.c(105): Error: function `testnothrow.throwing` is not `nothrow` fail_compilation/testnothrow.c(103): Error: function `testnothrow.mul` may throw but is marked as `nothrow` fail_compilation/testnothrow.c(111): Error: function `testnothrow.throwing` is not `nothrow` fail_compilation/testnothrow.c(109): Error: function `testnothrow.add` may throw but is marked as `nothrow` --- */ // https://issues.dlang.org/show_bug?id=21938 #line 100 void throwing() { } __attribute__((nothrow)) int mul(int x) { throwing(); return x * x; } __declspec(nothrow) int add(int x) { throwing(); return x + x; } int doSquare(int x) { return mul(x) + add(x); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10382.d0000644000175000017500000000027215205374123020731 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10382.d(14): Error: can only catch class objects, not `int` --- */ void main () { try { int b = 3; } catch (int a) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20096.d0000644000175000017500000000056215205374123021155 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test20096.d(15): Error: cannot `goto` into `try` block --- */ // https://issues.dlang.org/show_bug.cgi?id=20096 void test() { int x; try { L2: goto L1; try { L1: ++x; goto L2; } finally { ++x; } } finally {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9679.d0000644000175000017500000000524115205374123021037 0ustar fabiofabio/* REQUIRED_ARGS: -verrors=0 TEST_OUTPUT: --- fail_compilation/diag9679.d(93): Deprecation: `auto` and `ref` storage classes should be adjacent fail_compilation/diag9679.d(93): Deprecation: `auto` and `ref` storage classes should be adjacent fail_compilation/diag9679.d(94): Deprecation: `auto ref` return type must have `auto` and `ref` adjacent fail_compilation/diag9679.d(100): Deprecation: `auto ref` return type must have `auto` and `ref` adjacent fail_compilation/diag9679.d(16): Error: rvalue `1` cannot be assigned to `ref n` fail_compilation/diag9679.d(17): Error: variable `diag9679.main.n` - storage class `auto` has no effect if type is not inferred, did you mean `scope`? fail_compilation/diag9679.d(18): Error: variable `diag9679.main.S.a` - field declarations cannot be `ref` fail_compilation/diag9679.d(25): Error: returning `r` escapes a reference to local variable `i` --- */ void main() { if (ref n = 1) {} if (auto int n = 1) {} struct S { ref int a; } } ref int test2() { int i; ref r = i; return r; } ref int test3() { extern int i; ref r = i; return r; } struct S { int a; } void test4() { S s; ref int r1 = s.a; r1 = 3; __gshared S t2; ref int r2 = t2.a; static S t3; ref int r3 = t3.a; extern S t4; ref int r4 = t4.a; } /* TEST_OUTPUT: --- fail_compilation/diag9679.d(66): Error: variable `diag9679.test5.r5` - initializer is required for `ref` variable fail_compilation/diag9679.d(66): Error: rvalue `0` cannot be assigned to `ref r5` fail_compilation/diag9679.d(71): Error: rvalue `4` cannot be assigned to `ref x` fail_compilation/diag9679.d(72): Error: returning `x` escapes a reference to local variable `x` fail_compilation/diag9679.d(77): Error: type `immutable(int)` cannot be assigned to `ref int x` fail_compilation/diag9679.d(84): Error: returning `x` escapes a reference to local variable `x` fail_compilation/diag9679.d(89): Error: variable `diag9679.test9.x` - void initializer not allowed for `ref` variable fail_compilation/diag9679.d(90): Error: variable `diag9679.test9.y` - void initializer not allowed for `ref` variable fail_compilation/diag9679.d(96): Error: variable `x` - `auto ref` variable must have `auto` and `ref` adjacent --- */ void test5() { ref int r5; } ref int test6() { ref int x = 4; return x; } void test7(immutable int y) { ref int x = y; x = 5; } ref int test8() { auto ref int x = 3; return x; } void test9() { ref int x = void; auto ref int y = void; } void testKeywordOrder()(ref auto int x, auto const ref float y) {}; ref auto int testKeywordOrder() { ref auto int x = 3; return 3; } auto { ref int autoFromScope() => 3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail8262.d0000644000175000017500000000125015205374123021025 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail8262.d(32): Error: initializer must be an expression, not `Tuple8262!1` fail_compilation/fail8262.d(27): Error: template instance `fail8262.T8262!(Tuple8262!1)` error instantiating fail_compilation/fail8262.d(19): Error: cannot implicitly convert expression `S(0)` of type `S` to `int` --- * https://issues.dlang.org/show_bug.cgi?id=8262 */ template Seq(T...) { alias T Seq; } struct S { int s; alias Seq!s _; alias _ this; } int si = S.init; struct Tuple8262(T...) { alias T expand; alias expand this; } auto data = T8262!(Tuple8262!1); //pragma(msg, data); template T8262(T) { immutable(int) T8262 = T; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/needspkgmod.d0000644000175000017500000000102215205374123022065 0ustar fabiofabio// LDC: exclude `-i=` (equivalent to `-i` for LDC), which links fine // arg_sets: -i=, // ARG_SETS: -i=imports.pkgmod313, // ARG_SETS: -i=,imports.pkgmod313 // ARG_SETS: -i=imports.pkgmod313,-imports.pkgmod313.mod // ARG_SETS: -i=imports.pkgmod313.package,-imports.pkgmod313.mod // REQUIRED_ARGS: -Icompilable -L--no-demangle // LINK: /* TEST_OUTPUT: ---- $r:.+(_D7imports9pkgmod3133mod3barFZv|imports\.pkgmod313\.mod\.bar).*$ Error: $r:.+$ failed with status: $n$ ---- */ import imports.pkgmod313.mod; void main() { bar(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7859.d0000644000175000017500000000031715205374123021043 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7859.d(9): Error: undefined identifier `NonExistent` --- */ template A(alias B) {} mixin template C(alias B = cast(NonExistent)null) { alias A!B D; } mixin C!(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/sarifmultiple_test.d0000644000175000017500000000232115205374123023507 0ustar fabiofabio// REQUIRED_ARGS: -verror-style=sarif /* TEST_OUTPUT: --- { "version": "2.1.0", "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json", "runs": [{ "tool": { "driver": { "name": "LDC", "version": "$r:\d+\.\d+\.\d+$", "informationUri": "https://dlang.org/dmd.html" } }, "invocations": [{ "executionSuccessful": false }], "results": [ { "ruleId": "DMD-error", "message": { "text": "undefined identifier `x`" }, "level": "error", "locations": [{ "physicalLocation": { "artifactLocation": { "uri": "fail_compilation/sarifmultiple_test.d" }, "region": { "startLine": 63, "startColumn": 5 } } }] }, { "ruleId": "DMD-error", "message": { "text": "undefined identifier `y`" }, "level": "error", "locations": [{ "physicalLocation": { "artifactLocation": { "uri": "fail_compilation/sarifmultiple_test.d" }, "region": { "startLine": 64, "startColumn": 5 } } }] } ] }] } --- */ void main() { x = 5; // Undefined variable to trigger the error y = 5; // Undefined variable to trigger the error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/nogc1.d0000644000175000017500000000431215205374123020601 0ustar fabiofabio// REQUIRED_ARGS: -o- /***************** NewExp *******************/ struct S1 { } struct S2 { this(int); } struct S3 { this(int) @nogc; } /* TEST_OUTPUT: --- fail_compilation/nogc1.d(23): Error: allocating with `new` causes a GC allocation in `@nogc` function `testNew` fail_compilation/nogc1.d(25): Error: allocating with `new` causes a GC allocation in `@nogc` function `testNew` fail_compilation/nogc1.d(26): Error: allocating with `new` causes a GC allocation in `@nogc` function `testNew` fail_compilation/nogc1.d(28): Error: allocating with `new` causes a GC allocation in `@nogc` function `testNew` fail_compilation/nogc1.d(29): Error: `@nogc` function `nogc1.testNew` cannot call non-@nogc constructor `nogc1.S2.this` fail_compilation/nogc1.d(30): Error: allocating with `new` causes a GC allocation in `@nogc` function `testNew` fail_compilation/nogc1.d(32): Error: allocating with `new` causes a GC allocation in `@nogc` function `testNew` --- */ @nogc void testNew() { int* p1 = new int; int[] a1 = new int[3]; int[][] a2 = new int[][](2, 3); S1* ps1 = new S1(); S2* ps2 = new S2(1); S3* ps3 = new S3(1); Object o1 = new Object(); } /* TEST_OUTPUT: --- fail_compilation/nogc1.d(48): Error: allocating with `new` causes a GC allocation in `@nogc` function `testNewScope` fail_compilation/nogc1.d(50): Error: allocating with `new` causes a GC allocation in `@nogc` function `testNewScope` fail_compilation/nogc1.d(51): Error: allocating with `new` causes a GC allocation in `@nogc` function `testNewScope` fail_compilation/nogc1.d(53): Error: allocating with `new` causes a GC allocation in `@nogc` function `testNewScope` fail_compilation/nogc1.d(54): Error: `@nogc` function `nogc1.testNewScope` cannot call non-@nogc constructor `nogc1.S2.this` fail_compilation/nogc1.d(55): Error: allocating with `new` causes a GC allocation in `@nogc` function `testNewScope` --- */ @nogc void testNewScope() { scope int* p1 = new int; scope int[] a1 = new int[3]; scope int[][] a2 = new int[][](2, 3); scope S1* ps1 = new S1(); scope S2* ps2 = new S2(1); scope S3* ps3 = new S3(1); scope Object o1 = new Object(); // no error scope o2 = new Object(); // no error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fnconstraint.d0000644000175000017500000000124115205374123022300 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fnconstraint.d(14): Error: template constraint must follow parameter lists and attributes fail_compilation/fnconstraint.d(15): Error: declaration expected, not `{` fail_compilation/fnconstraint.d(23): Error: template constraint must follow parameter lists and attributes fail_compilation/fnconstraint.d(23): Error: declaration expected, not `{` fail_compilation/fnconstraint.d(27): Error: `}` expected following members in `struct` declaration fail_compilation/fnconstraint.d(19): struct `S` starts here --- */ void foo()() in(true) if (true) {} alias f = foo!(); struct S { this()() if (true) if (true) {} } S s; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9790.d0000644000175000017500000000104315205374123021034 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9790.d(13): Error: undefined identifier `_Unused_` fail_compilation/fail9790.d(20): Error: template instance `fail9790.foo!()` error instantiating fail_compilation/fail9790.d(18): Error: undefined identifier `_Unused_` fail_compilation/fail9790.d(21): Error: template instance `fail9790.bar!()` error instantiating --- */ template foo() { enum bool _foo = _Unused_._unused_; enum bool foo = _foo; } template bar() { enum bool bar = _Unused_._unused_; } alias Foo = foo!(); alias Bar = bar!(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/deprecate12979b.d0000644000175000017500000000037015205374123022304 0ustar fabiofabio// REQUIRED_ARGS: -de /* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/deprecate12979b.d(12): Error: `asm` statement is assumed to be impure - mark it with `pure` if it is not --- */ void foo() pure { asm { ret; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail265.d0000644000175000017500000000036015205374123020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail265.d-mixin-11(11): Error: found `End of File` instead of statement fail_compilation/fail265.d-mixin-11(11): while parsing string mixin statement --- */ void main() { mixin(`for(;;)`); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23574.d0000644000175000017500000000146015205374123021113 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23574 /* TEST_OUTPUT: --- fail_compilation/fail23574.d(26): Error: function `object._xopEquals` has no `return` statement, but is expected to return a value of type `bool` Error: undefined identifier `size_t` in module `object` fail_compilation/fail23574.d(34): Error: template instance `object.S17915!(MyClass)` error instantiating fail_compilation/fail23574.d(30): Error: function `object.SDL_GetKeyName` has no `return` statement, but is expected to return a value of type `const(char)` --- */ module object; class Object { } bool opEquals(LHS, RHS)(LHS lhs, RHS) { opEquals(cast()lhs); } class TypeInfo { } bool _xopEquals() { } const(char)SDL_GetKeyName() { class MyClass { S17915!MyClass m_member; } } struct S17915(T) { T owner; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10341.d0000644000175000017500000000022015205374123020715 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10341.d(10): Error: case range not in `switch` statement --- */ void main() { case 1: .. case 2: } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11965.d0000644000175000017500000000075015205374123020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11965.d(16): Error: variable name expected after type `b*`, not `End of File` fail_compilation/ice11965.d(16): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/ice11965.d(15): unmatched `{` fail_compilation/ice11965.d(16): Error: found `End of File` when expecting `]` fail_compilation/ice11965.d(16): Error: variable name expected after type `u[() { b* A; } ]`, not `End of File` --- */ u[{b*A, ./ldc-1.42.0-src/tests/dmd/fail_compilation/test12228.d0000644000175000017500000000067315205374123021156 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test12228.d(12): Error: undefined identifier `this`, did you mean `typeof(this)`? fail_compilation/test12228.d(18): Error: undefined identifier `super`, did you mean `typeof(super)`? fail_compilation/test12228.d(19): Error: undefined identifier `super`, did you mean `typeof(super)`? --- */ class C { shared(this) x; } class D : C { alias x = typeof(super).x; shared(super) a; super b; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag14875.d0000644000175000017500000000361015205374123021107 0ustar fabiofabio// REQUIRED_ARGS: -o- deprecated class Dep { } deprecated immutable int depVar = 10; /* TEST_OUTPUT: --- fail_compilation/diag14875.d(16): Deprecation: class `diag14875.Dep` is deprecated 1: Dep 2: Dep 3: Dep --- */ alias X = Foo!Dep; // deprecation template Foo(T) { pragma(msg, "1: ", T); // no message enum Foo = cast(void*)Bar!T; } template Bar(T) { pragma(msg, "2: ", T); // no message enum Bar = &Baz!T; } template Baz(T) { pragma(msg, "3: ", T); // no message immutable Baz = 1234; } // --- /* TEST_OUTPUT: --- fail_compilation/diag14875.d(52): Deprecation: class `diag14875.Dep` is deprecated fail_compilation/diag14875.d(56): Deprecation: variable `diag14875.depVar` is deprecated fail_compilation/diag14875.d(52): instantiated from here: `Voo!(Dep)` 4: Dep fail_compilation/diag14875.d(63): Deprecation: variable `diag14875.depVar` is deprecated fail_compilation/diag14875.d(59): instantiated from here: `Var!(Dep)` fail_compilation/diag14875.d(52): instantiated from here: `Voo!(Dep)` fail_compilation/diag14875.d(64): Deprecation: template `diag14875.Vaz(T)` is deprecated fail_compilation/diag14875.d(59): instantiated from here: `Var!(Dep)` fail_compilation/diag14875.d(52): instantiated from here: `Voo!(Dep)` --- */ alias Y = Voo!Dep; // deprecation template Voo(T) { enum n = depVar; // deprecation struct A { alias B = T; } // no message pragma(msg, "4: ", A.B); // B is not deprecated enum Voo = cast(void*)Var!T; } template Var(T) { enum n = depVar; // deprecation enum Var = &Vaz!T; // deprecation } deprecated template Vaz(T) { enum n = depVar; // no message immutable Vaz = 1234; } /* TEST_OUTPUT: --- fail_compilation/diag14875.d(80): Error: static assert: `0` is false --- */ void main() { static assert(0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail16689.d0000644000175000017500000000042315205374123021122 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail16689.d(3): Error: static assert: "false" fail_compilation/fail16689.d(6): instantiated from here: `mixin Issue16689!();` --- */ #line 1 mixin template Issue16689() { static assert(false, "false"); } mixin Issue16689!(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9398.d0000644000175000017500000000030415205374123021030 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9398.d(11): Error: incompatible types for `(f) : (s)`: `float` and `string` --- */ void main() { float f; string s; auto a = (true ? f : s); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13028.d0000644000175000017500000000150215205374123021072 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag13028.d(15): Error: variable `dg` cannot be read at compile time fail_compilation/diag13028.d(22): Error: variable `a` cannot be read at compile time fail_compilation/diag13028.d(28): Error: CTFE failed because of previous errors in `foo` fail_compilation/diag13028.d(28): while evaluating: `static assert(foo(() pure nothrow @nogc @safe => 1) == 1)` fail_compilation/diag13028.d(29): Error: CTFE failed because of previous errors in `bar` fail_compilation/diag13028.d(29): while evaluating: `static assert(bar(delegate int() pure nothrow @nogc @safe => 1) == 1)` --- */ int foo(int delegate() dg) { enum b = dg(); return b; } int bar(lazy int a) { enum b = a; return a; } void main() { static assert(foo(() => 1) == 1); static assert(bar(1) == 1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail172.d0000644000175000017500000000105215205374123020735 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail172.d(25): Error: cannot modify `const` expression `c1.x` fail_compilation/fail172.d(26): Error: cannot modify `const` expression `c2.x` fail_compilation/fail172.d(30): Error: cannot modify `const` expression `s1.x` fail_compilation/fail172.d(31): Error: cannot modify `const` expression `s2.x` --- */ class C { int x; } struct S { int x; } void main() { const(C) c1 = new C(); const C c2 = new C(); c1.x = 3; c2.x = 3; const(S) s1; const S s2; s1.x = 3; s2.x = 3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix17751.d0000644000175000017500000000076415205374123020774 0ustar fabiofabio/* REQUIRED_ARGS: -m64 * DISABLED: LDC // unsupported __simd syntax * TEST_OUTPUT: --- fail_compilation/fix17751.d(15): Error: last parameter to `__simd()` must be a constant --- */ // https://issues.dlang.org/show_bug.cgi?id=17751 import core.simd; pure @safe V1 simd(XMM opcode, V1, V2)(V1 op1, V2 op2, ubyte imm8) if (is(V1 == __vector) && is(V2 == __vector)) { return cast(V1)__simd(opcode, op1, op2, imm8); } void main() { float4 a, b; a = simd!(XMM.CMPPD)(a, b, 0x7A); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/attributediagnostic_nogc.d0000644000175000017500000000335215205374123024653 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/attributediagnostic_nogc.d(21): Error: `@nogc` function `attributediagnostic_nogc.layer2` cannot call non-@nogc function `attributediagnostic_nogc.layer1` fail_compilation/attributediagnostic_nogc.d(22): which calls `layer0` fail_compilation/attributediagnostic_nogc.d(23): which calls `gc` fail_compilation/attributediagnostic_nogc.d(27): and executing an `asm` statement without `@nogc` annotation makes it fail to infer `@nogc` fail_compilation/attributediagnostic_nogc.d(43): Error: `@nogc` function `D main` cannot call non-@nogc function `attributediagnostic_nogc.gc1` fail_compilation/attributediagnostic_nogc.d(32): and allocating with `new` makes it fail to infer `@nogc` fail_compilation/attributediagnostic_nogc.d(44): Error: `@nogc` function `D main` cannot call non-@nogc function `attributediagnostic_nogc.gc2` fail_compilation/attributediagnostic_nogc.d(38): and calling non-@nogc `fgc` makes it fail to infer `@nogc` fail_compilation/attributediagnostic_nogc.d(45): Error: `@nogc` function `D main` cannot call non-@nogc function `attributediagnostic_nogc.gcClosure` fail_compilation/attributediagnostic_nogc.d(48): and allocating a closure for `gcClosure()` makes it fail to infer `@nogc` --- */ #line 18 // Issue 17374 - Improve inferred attribute error message // https://issues.dlang.org/show_bug.cgi?id=17374 auto layer2() @nogc { layer1(); } auto layer1() { layer0(); } auto layer0() { gc(); } auto gc() { asm {} } auto gc1() { int* x = new int; } auto fgc = function void() {new int[10];}; auto gc2() { fgc(); } void main() @nogc { gc1(); gc2(); gcClosure(); } auto gcClosure() { int x; int bar() { return x; } return &bar; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21244.c0000644000175000017500000000040115205374123021140 0ustar fabiofabio// https://github.com/dlang/dmd/issues/21244 // This used to segfault the compiler. The below error message can change. /* * TEST_OUTPUT: --- fail_compilation/test21244.c(9): Error: no size for type `extern (C) int(int)` --- */ int x = sizeof(int()(int)); ./ldc-1.42.0-src/tests/dmd/fail_compilation/json.d0000644000175000017500000000034415205374123020544 0ustar fabiofabio/* REQUIRED_ARGS: -Xi LDC: just a different error msg DISABLED: LDC TEST_OUTPUT: --- Error: argument expected for switch '-Xi' run `dmd` to print the compiler manual run `dmd -man` to open browser on manual --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/protattr2.d0000644000175000017500000000043115205374123021531 0ustar fabiofabio/* EXTRA_FILES: protection/subpkg/test2.d TEST_OUTPUT: --- fail_compilation/protection/subpkg/test2.d(3): Error: visibility attribute `package(protection.subpkg2)` does not bind to one of ancestor packages of module `protection.subpkg.test2` --- */ import protection.subpkg.test2; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag14163.d0000644000175000017500000000043715205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag14163.d(16): Error: constructor `diag14163.Bar.this` cannot call `super()` implicitly because it is annotated with `@disable` --- */ class Foo { @disable this(); } class Bar : Foo { @disable this(); this(int i) {} } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19687.d0000644000175000017500000000042615205374123021126 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19687.d(17): Error: no property `nonexisting` for `""` of type `string` --- */ struct S { void opDispatch(string name)() {} void opDispatch(string name)(string value) {} } void main() { S n; n.foo = "".nonexisting(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail2456.d0000644000175000017500000000425215205374123021031 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail2456.d(14): Error: cannot put `scope(success)` statement inside `finally` block --- */ void test_success() { try { } finally { scope(success) {} // NG } } /* TEST_OUTPUT: --- fail_compilation/fail2456.d(31): Error: cannot put `scope(failure)` statement inside `finally` block --- */ void test_failure() { try { } finally { scope(failure) {} // NG } } /* TEST_OUTPUT: --- --- */ void test_exit() { try { } finally { scope(exit) {} // OK } } /* TEST_OUTPUT: --- fail_compilation/fail2456.d(64): Error: cannot put `scope(success)` statement inside `scope(success)` fail_compilation/fail2456.d(65): Error: cannot put `scope(failure)` statement inside `scope(success)` fail_compilation/fail2456.d(78): Error: cannot put `scope(success)` statement inside `scope(exit)` fail_compilation/fail2456.d(79): Error: cannot put `scope(failure)` statement inside `scope(exit)` --- */ void test2456a() { scope(success) { scope(success) {} // NG scope(failure) {} // NG scope(exit) {} // OK } scope(failure) { scope(success) {} // OK scope(failure) {} // OK scope(exit) {} // OK } scope(exit) { scope(success) {} // NG scope(failure) {} // NG scope(exit) {} // OK } } /* TEST_OUTPUT: --- fail_compilation/fail2456.d(96): Error: cannot put `catch` statement inside `scope(success)` fail_compilation/fail2456.d(108): Error: cannot put `catch` statement inside `scope(exit)` --- */ void test2456b() { scope(success) { try {} catch (Throwable) {} // NG } scope(failure) { try {} catch (Throwable) {} // OK } scope(exit) { try {} catch (Throwable) {} // NG } } /* TEST_OUTPUT: --- fail_compilation/fail2456.d(121): Deprecation: can only catch mutable or const qualified types, not `immutable(Exception)` --- */ void main() { try { throw new Exception(""); } catch (immutable Exception e) { assert(0); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13756.d0000644000175000017500000000125315205374123021114 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail13756.d(14): Error: `foreach`: index parameter `ref k` must be type `const(int)`, not `int` fail_compilation/fail13756.d(17): Error: cannot implicitly convert expression `__applyArg0` of type `int` to `string` fail_compilation/fail13756.d(19): Error: cannot implicitly convert expression `__applyArg1` of type `int` to `char` fail_compilation/fail13756.d(20): Error: `foreach`: value parameter `ref val` must be type `int`, not `dchar` --- */ void maiin() { int[int] aa = [1:2]; foreach (ref int k, v; aa) { } foreach (string key, val; aa) {} foreach (key, char val; aa) {} foreach (key, ref dchar val; aa) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19447.d0000644000175000017500000000053415205374123021120 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19447.d(110): Error: static variable `mh` cannot be read at compile time fail_compilation/fail19447.d(110): called from here: `g19447(mh)` --- */ #line 100 int [2] mh = [1, 2]; int g19447(ref int[2] a) { int[2] b=2; a=b; assert(a[0]==2); return 1; } immutable int i = g19447(mh); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23607.d0000644000175000017500000000053415205374123021155 0ustar fabiofabio//https://issues.dlang.org/show_bug.cgi?id=23607 /* TEST_OUTPUT: --- fail_compilation/test23607.d(15): Error: template `to(T)()` does not have property `bad` fail_compilation/test23607.d(16): Error: template `to(T)()` does not have property `bad` --- */ template to(T) { void to(T)(){} } alias comb = to!int.bad!0; auto combe = to!int.bad!0; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13221.d0000644000175000017500000000044615205374123020727 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13221.d(20): Error: variable `r` cannot be read at compile time --- */ struct Tuple(T...) { T field; alias field this; } template test(T) {} void main() { foreach (r; 0 .. 0) { enum i = r; test!(Tuple!bool[i]); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice19950.d0000644000175000017500000000045015205374123020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice19950.d(8): Error: undefined identifier `NotHere` fail_compilation/ice19950.d(9): Error: template instance `ice19950.baz!()` does not match template declaration `baz()(Foo)` --- */ alias Foo = NotHere; alias Bar = baz!(); void baz()(Foo) if (true) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23882.d0000644000175000017500000000065615205374123021167 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23882 /* TEST_OUTPUT: --- fail_compilation/test23882.d(26): Error: `typeof((*YC).S).init` is used as a type --- */ struct G(H) { Tuple!(R) S; } struct BB(H) { H* YC; alias YC this; } struct R { BB!(G!float) CB; alias CB this; this(typeof(CB.S).init); } struct Tuple(Specs) { Specs expand; this(Specs values) { expand = values; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail74.d0000644000175000017500000000025215205374123020657 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail74.d(13): Error: cannot append type `C[1]` to type `C[1]` --- */ class C { C[1] c; this() { c ~= c; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20691.d0000644000175000017500000000125415205374123021111 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fail20691.d(106): Error: taking address of `scope` variable `sa` with pointers is not allowed in a `@safe` function fail_compilation/fail20691.d(107): Error: taking address of `scope` variable `sa` with pointers is not allowed in a `@safe` function fail_compilation/fail20691.d(108): Error: taking address of `scope` variable `sa` with pointers is not allowed in a `@safe` function --- */ #line 100 // https://issues.dlang.org/show_bug.cgi?id=20691 void bar() @safe { scope char[][2] sa; scope char[][] da = cast(char[][])sa; scope char[][] ca = sa; foo(sa); } void foo(scope char[][] a) @safe; ./ldc-1.42.0-src/tests/dmd/fail_compilation/mixin_gc.d0000644000175000017500000000063615205374123021374 0ustar fabiofabio// REQUIRED_ARGS: -mixin=${RESULTS_DIR}/fail_compilation/mixin_test.mixin -lowmem /* TEST_OUTPUT: --- {{RESULTS_DIR}}/fail_compilation/mixin_test.mixin(7): Error: undefined identifier `b` --- */ // https://issues.dlang.org/show_bug.cgi?id=1870 // https://issues.dlang.org/show_bug.cgi?id=12790 string get() { return q{int x; int y; int z = x + b;}; } void main() { mixin(get()); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18970.d0000644000175000017500000000166415205374123021125 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail18970.d(26): Error: no property `y` for `S()` of type `fail18970.S` fail_compilation/fail18970.d(19): Error: undefined identifier `x` fail_compilation/fail18970.d(26): Error: template instance `fail18970.S.opDispatch!"y"` error instantiating fail_compilation/fail18970.d(33): Error: no property `yyy` for `this` of type `fail18970.S2` fail_compilation/fail18970.d(38): Error: undefined identifier `x` fail_compilation/fail18970.d(33): Error: template instance `fail18970.S2.opDispatch!"yyy"` error instantiating --- */ // https://issues.dlang.org/show_bug.cgi?id=18970 struct S { auto opDispatch(string name)(int) { alias T = typeof(x); static assert(!is(T.U)); return 0; } } void f() { S().y(1); } struct S2 { this(int) { this.yyy; } auto opDispatch(string name)() { alias T = typeof(x); static if(is(T.U)) {} } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24084.d0000644000175000017500000000071315205374123021154 0ustar fabiofabio/* REQUIRED_ARGS: -nothrow * TEST_OUTPUT: --- fail_compilation/test24084.d(110): Error: cannot use `throw` statements with `-fno-exceptions` fail_compilation/test24084.d(112): Error: cannot use try-catch statements with `-nothrow` --- */ // https://issues.dlang.org/show_bug.cgi?id=24084 #line 100 struct S { int x; ~this() { } } void xyzzy() { S s; throw new Exception("xx"); try { int y; } catch (Exception) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15785b.d0000644000175000017500000000077315205374123021334 0ustar fabiofabio// EXTRA_FILES: imports/test15785.d /* TEST_OUTPUT: --- fail_compilation/test15785b.d(14): Error: `imports.test15785.Base.T` is not visible from module `test15785b` fail_compilation/test15785b.d(15): Error: `imports.test15785.Base.T` is not visible from module `test15785b` fail_compilation/test15785b.d(16): Error: `imports.test15785.IBase2.T` is not visible from module `test15785b` --- */ import imports.test15785; class Derived : Base, IBase2 { typeof(super).T t; Base.T t2; IBase2.T t3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11042.d0000644000175000017500000000050315205374123021073 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11042.d(8): Error: undefined identifier `error`, did you mean class `Error`? fail_compilation/fail11042.d(9): Error: undefined identifier `error`, did you mean class `Error`? --- */ static if ({ return true || error; }()) {} // NG static if ({ return false && error; }()) {} // NG ./ldc-1.42.0-src/tests/dmd/fail_compilation/testCols.d0000644000175000017500000000025115205374123021370 0ustar fabiofabio// REQUIRED_ARGS: -vcolumns /* TEST_OUTPUT: --- fail_compilation/testCols.d(12,5): Error: undefined identifier `nonexistent` --- */ void test() { nonexistent(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4611.d0000644000175000017500000000056115205374123021023 0ustar fabiofabio/* REQUIRED_ARGS: -m32 DISABLED: LDC // no arraysize limit to work around an optlink bug (https://issues.dlang.org/show_bug.cgi?id=14859) TEST_OUTPUT: --- fail_compilation/fail4611.d(15): Error: `Vec[cast(size_t)2147483647]` size 4 * 2147483647 exceeds 0x7fffffff size limit for static array --- */ struct Vec { int x; } void main() { Vec[ptrdiff_t.max] a; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice20057.d0000644000175000017500000000053515205374123020733 0ustar fabiofabio/* EXTRA_FILES: imports/i20057.d TEST_OUTPUT: --- fail_compilation/ice20057.d(10): Error: alias `ice20057.BlackHole` conflicts with struct `ice20057.BlackHole(alias T)` at fail_compilation/ice20057.d(9) --- */ struct BlackHole(alias T){T t;} import imports.i20057: BlackHole; extern(C++) interface Inter { void func(); } BlackHole!Inter var; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17976.d0000644000175000017500000000051115205374123021120 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17976.d(11): Error: constructor `fail17976.S.this` parameter `this.a` is already defined fail_compilation/fail17976.d(11): Error: constructor `fail17976.S.this` parameter `this.a` is already defined --- */ struct S { this(string a, string a, string a) { } } void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail59.d0000644000175000017500000000121615205374123020663 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail59.d(50): Error: cannot construct nested class `C2` because no implicit `this` reference to outer class `C1` is available --- */ class C1 { int c1; this() { c1 = 2; } class C2 { class C3 { int c3; this(int n) { c3 = n + c1 + c2; } } int c2; C3 foo() { return new C3(8); } this(int k) { c2 = k + 7; } } C2 bar() { return new C2(17); } } void main() { C1.C2 q = new C1.C2(3); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/iasm1.d0000644000175000017500000000442115205374123020605 0ustar fabiofabio// DISABLED: LDC_not_x86 // REQUIRED_ARGS: -m64 /* // LDC: compiles test_output: --- fail_compilation/iasm1.d(103): Error: `and` instruction requires operands of matching type/size fail_compilation/iasm1.d(104): Error: `and` instruction requires operands of matching type/size --- */ // https://issues.dlang.org/show_bug.cgi?id=15999 #line 100 void test100(ulong bar) { asm { and RAX, 0xFFFFFFFF00000000; ret; } asm { and RAX, 0x00000000FFFFFFFF; ret; } } /***********************************************/ /* TEST_OUTPUT: --- fail_compilation/iasm1.d(213): Error: invalid operand fail_compilation/iasm1.d(213): Error: invalid operand --- */ // https://issues.dlang.org/show_bug.cgi?id=15239 #line 200 struct T { template opDispatch(string Name, P...) { static void opDispatch(P) {} } } void test2() { asm { call T.foo; } } /*********************************************/ /* TEST_OUTPUT: --- fail_compilation/iasm1.d(306): Error: end of instruction expected, not `R8` fail_compilation/iasm1.d(307): Error: end of instruction expected, not `RDX` fail_compilation/iasm1.d(310): Error: end of instruction expected, not `RCX` --- */ // https://issues.dlang.org/show_bug.cgi?id=17616 // https://issues.dlang.org/show_bug.cgi?id=18373 #line 300 void test3() { asm { naked; mov RAX,[R9][R10]R8; mov RAX,[3]RDX; mov RAX,[RIP][RIP]; mov RAX,[RIP][RCX]; mov RAX,[RIP]RCX; } } /*********************************************/ /* TEST_OUTPUT: --- fail_compilation/iasm1.d(403): Error: missing `]` --- */ #line 400 void test4() { asm { inc [; } } /*********************************************/ /* TEST_OUTPUT: --- fail_compilation/iasm1.d(505): Error: function `iasm1.test5` label `L1` is undefined --- */ #line 500 void test5() { asm { jmp L1; L2: nop; } } /*********************************************/ /* // LDC: compiles test_output: --- fail_compilation/iasm1.d(615): Error: delegate `iasm1.test6.__foreachbody_L611_C5` label `L1` is undefined --- */ #line 600 struct S { static int opApply(int delegate(ref int) dg) { return 0; } } void test6() { foreach(f; S) { asm { jmp L1; } goto L1; } L1:; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/systemvariables_void_init.d0000644000175000017500000000364315205374123025061 0ustar fabiofabio/** REQUIRED_ARGS: -preview=systemVariables TEST_OUTPUT: --- fail_compilation/systemvariables_void_init.d(48): Error: `void` initializing a type with unsafe bit patterns is not allowed in a `@safe` function fail_compilation/systemvariables_void_init.d(49): Error: `void` initializing a type with unsafe bit patterns is not allowed in a `@safe` function fail_compilation/systemvariables_void_init.d(50): Error: `void` initializing a type with unsafe bit patterns is not allowed in a `@safe` function fail_compilation/systemvariables_void_init.d(51): Error: void intializing a bool (which must always be 0 or 1) is not allowed in a `@safe` function fail_compilation/systemvariables_void_init.d(52): Error: void intializing a bool (which must always be 0 or 1) is not allowed in a `@safe` function fail_compilation/systemvariables_void_init.d(53): Error: `void` initializing a type with unsafe bit patterns is not allowed in a `@safe` function fail_compilation/systemvariables_void_init.d(54): Error: `void` initializing a type with unsafe bit patterns is not allowed in a `@safe` function --- */ struct S { int x; @system int y; } struct C { S[2] x; } enum E : C { x = C.init, } enum B : bool { x, } struct SB { bool x; } struct SSB { SB sb; } void main() @safe { S s = void; C c = void; E e = void; const bool b = void; B bb = void; SB sb = void; SSB ssb = void; } // The following test is reduced from Phobos. The compiler generates this `opAssign`: // (CopyPreventer __swap2 = void;) , __swap2 = this , (this = p , __swap2.~this()); // The compiler would give an error about void initialization a struct with a bool, // but it can be trusted in this case because it's a compiler generated temporary. auto staticArray(T)(T a) @safe { T c; c = a; } void assignmentTest() @safe { static struct CopyPreventer { bool on; this(this) @safe {} ~this() { } } staticArray(CopyPreventer()); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/chkformat.d0000644000175000017500000003065115205374123021555 0ustar fabiofabio/* 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*`$?:windows= fail_compilation/chkformat.d(122): Deprecation: argument `0LU` for format specification `"%lu"` must be `uint`, not `ulong` fail_compilation/chkformat.d(122): C `long` is 4 bytes on your system|32= fail_compilation/chkformat.d(122): Deprecation: argument `0LU` for format specification `"%lu"` must be `uint`, not `ulong` fail_compilation/chkformat.d(122): C `long` is 4 bytes on your system$ fail_compilation/chkformat.d(123): Deprecation: argument `p` for format specification `"%n"` must be `int*`, not `const(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 `core.stdc.stdint.uintmax_t*`, 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); } void test20() { printf("%lu", ulong.init); } void test22() { int i; const(int)* p = &i; printf("%n", p); } #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(); } /* TEST_OUTPUT: --- fail_compilation/chkformat.d(401): Deprecation: argument `p` for format specification `"%u"` must be `uint`, not `char*` fail_compilation/chkformat.d(402): Deprecation: argument `p` for format specification `"%d"` must be `int`, not `char*` fail_compilation/chkformat.d(403): Deprecation: argument `p` for format specification `"%hhu"` must be `ubyte`, not `char*` fail_compilation/chkformat.d(404): Deprecation: argument `p` for format specification `"%hhd"` must be `byte`, not `char*` fail_compilation/chkformat.d(405): Deprecation: argument `p` for format specification `"%hu"` must be `ushort`, not `char*` fail_compilation/chkformat.d(406): Deprecation: argument `p` for format specification `"%hd"` must be `short`, not `char*` fail_compilation/chkformat.d(407): Deprecation: argument `p` for format specification `"%lu"` must be `$?:windows=uint|32=uint|64=ulong$`, not `char*` fail_compilation/chkformat.d(408): Deprecation: argument `p` for format specification `"%ld"` must be `$?:windows=int|32=int|64=long$`, not `char*` fail_compilation/chkformat.d(409): Deprecation: argument `p` for format specification `"%llu"` must be `ulong`, not `char*` fail_compilation/chkformat.d(410): Deprecation: argument `p` for format specification `"%lld"` must be `long`, not `char*` fail_compilation/chkformat.d(411): Deprecation: argument `p` for format specification `"%ju"` must be `core.stdc.stdint.uintmax_t`, not `char*` fail_compilation/chkformat.d(412): Deprecation: argument `p` for format specification `"%jd"` must be `core.stdc.stdint.intmax_t`, not `char*` --- */ #line 400 void test401() { char* p; printf("%u", p); } void test402() { char* p; printf("%d", p); } void test403() { char* p; printf("%hhu", p); } void test404() { char* p; printf("%hhd", p); } void test405() { char* p; printf("%hu", p); } void test406() { char* p; printf("%hd", p); } void test407() { char* p; printf("%lu", p); } void test408() { char* p; printf("%ld", p); } void test409() { char* p; printf("%llu", p); } void test410() { char* p; printf("%lld", p); } void test411() { char* p; printf("%ju", p); } void test412() { char* p; printf("%jd", p); } /* https://issues.dlang.org/show_bug.cgi?id=23247 TEST_OUTPUT: --- fail_compilation/chkformat.d(501): Deprecation: argument `p` for format specification `"%a"` must be `double`, not `char*` fail_compilation/chkformat.d(502): Deprecation: argument `p` for format specification `"%La"` must be `real`, not `char*` fail_compilation/chkformat.d(503): Deprecation: argument `p` for format specification `"%a"` must be `float*`, not `char*` fail_compilation/chkformat.d(504): Deprecation: argument `p` for format specification `"%la"` must be `double*`, not `char*` fail_compilation/chkformat.d(505): Deprecation: argument `p` for format specification `"%La"` must be `real*`, not `char*` --- */ #line 500 void test501() { char* p; printf("%a", p); } void test502() { char* p; printf("%La", p); } void test503() { char* p; scanf("%a", p); } void test504() { char* p; scanf("%la", p); } void test505() { char* p; scanf("%La", p); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4958.d0000644000175000017500000000030215205374123021032 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4958.d(8): Error: enum member `fail4958.FloatEnum.B` has inexact value due to loss of precision --- */ enum FloatEnum : float { A = float.max/2, B, C } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9291.d0000644000175000017500000000020715205374123020656 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9291.d(10): Error: undefined identifier `F` --- */ void main() nothrow { throw new F(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test64.d0000644000175000017500000000047315205374123020727 0ustar fabiofabio/* EXTRA_FILES: imports/test64a.d TEST_OUTPUT: --- fail_compilation/imports/test64a.d(1): Error: module `imports` from file fail_compilation/imports/test64a.d conflicts with package name imports --- */ //import std.stdio; import imports.test64a; int main(string[] args) { //writefln(file1); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/cppmangle2.d0000644000175000017500000000031715205374123021623 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/cppmangle2.d(9): Error: namespace `cppmangle2.ns` conflicts with variable `cppmangle2.ns` at fail_compilation/cppmangle2.d(8) --- */ enum ns = "ns"; extern(C++, ns) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13081.d0000644000175000017500000000111515205374123020725 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13081.d(17): Error: undefined identifier `node` fail_compilation/ice13081.d(17): Error: undefined identifier `data` fail_compilation/ice13081.d(17): Error: undefined identifier `node` fail_compilation/ice13081.d(28): Error: template instance `ice13081.Cube!(SparseDataStore)` error instantiating --- */ struct Cube(StorageT) { StorageT datastore; alias datastore this; auto seed() { this[] = node.data ? data : node.data; } } class SparseDataStore { auto opSlice() {} } void main() { Cube!SparseDataStore c; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice22377.d0000644000175000017500000000030015205374123020730 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice22377.d(8): Error: function `foo` cannot have parameter of type `string` because its linkage is `extern(C++)` --- */ extern(C++) void foo(string a) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375e.d0000644000175000017500000000047215205374123021200 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375e.d(13): Error: else is dangling, add { } after condition at fail_compilation/fail4375e.d(10) --- */ void main() { version (A) if (true) assert(24); else assert(25); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ldc_github_1864.d0000644000175000017500000000104015205374123022353 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ldc_github_1864.d(16): Error: function `ldc_github_1864.templateDecl!(Aggr!(var)).templateDecl` cannot access frame of function `ldc_github_1864.foo` --- */ struct Aggr(alias V) { alias Value = V; } template templateDecl( Vs... ) { void templateDecl() { foreach (v; Vs) static if ( is( v : Aggr!A, alias A ) ) assert(A.length == 3); } } alias templateInst(alias V) = templateDecl!( Aggr!V ); void foo() { string var = "var"; templateInst!var(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/responsefile.d0000644000175000017500000000017615205374123022274 0ustar fabiofabio// REQUIRED_ARGS: @ABC /* LDC: expected output slightly adapted TEST_OUTPUT: --- Error: Could not read response file. --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9312.d0000644000175000017500000000030015205374123021006 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9312.d(10): Error: `with` expression types must be enums or aggregates or pointers to them, not `int` --- */ void main() { with (1) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20376.d0000644000175000017500000000047415205374123021114 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20376 /* TEST_OUTPUT: --- fail_compilation/fail20376.d(17): Error: return value `Foo()` of type `Foo` does not match return type `ubyte`, and cannot be implicitly converted --- */ struct Foo { this(ref scope Foo); } ubyte fun() { return Foo(); } void main(){} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21443.d0000644000175000017500000000066015205374123021151 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21443 // REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/test21443.d(14): Deprecation: `return` statements cannot be in `scope(failure)` bodies. fail_compilation/test21443.d(14): Use try-catch blocks for this purpose --- */ ulong get () @safe nothrow { scope (failure) return 10; throw new Error(""); } void main () @safe { assert(get() == 10); // passes } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16188.d0000644000175000017500000000153515205374123021165 0ustar fabiofabio/* REQUIRED_ARGS: -preview=bitfields * TEST_OUTPUT: --- fail_compilation/test16188.d(101): Error: no property `name` for `Where()` of type `test16188.Where` fail_compilation/test16188.d(107): Error: undefined identifier `getMember` fail_compilation/test16188.d(101): Error: template instance `test16188.Where.opDispatch!"name"` error instantiating --- */ // https://issues.dlang.org/show_bug.cgi?id=16188 /* This produces the message: * Error: no property 'name' for type 'Where' * when the actual error is 'getMember is undefined'. * This happens because errors are gagged when opDispatch() is compiled, * I don't understand why. */ #line 100 void where() { Where().name; } struct Where { void opDispatch(string name)() { alias FieldType = typeof(getMember); WhereField!FieldType; } } struct WhereField(FieldType) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20655.d0000644000175000017500000000174215205374123021157 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/test20655.d(26): Deprecation: `@safe` function `g` calling `f1` fail_compilation/test20655.d(21): and accessing overlapped field `U.s` with pointers makes it fail to infer `@safe` fail_compilation/test20655.d(27): Deprecation: `@safe` function `g` calling `f2` fail_compilation/test20655.d(22): and accessing overlapped field `U.s` with pointers makes it fail to infer `@safe` fail_compilation/test20655.d(28): Deprecation: `@safe` function `g` calling `f3` fail_compilation/test20655.d(25): and accessing overlapped field `U.s` with pointers makes it fail to infer `@safe` --- */ union U { string s; int x; } U u; auto f1() { auto s = u.s; } /* Should be inferred as @system. */ void f2()() { auto s = u.s; } /* ditto */ void g() @safe { void f3() { auto s = u.s; } /* ditto */ f1(); /* Should be rejected with error "cannot call @system function". */ f2(); /* ditto */ f3(); /* ditto */ } ./ldc-1.42.0-src/tests/dmd/fail_compilation/objc_class2.d0000644000175000017500000000054715205374123021764 0ustar fabiofabio// EXTRA_OBJC_SOURCES: /* TEST_OUTPUT: --- fail_compilation/objc_class2.d(14): Error: function `objc_class2.A.test` number of colons in Objective-C selector must match number of parameters --- */ import core.attribute : selector; extern (Objective-C) extern class A { void test(int a, int b, int c) @selector("test:"); // non-matching number of colon } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail8373.d0000644000175000017500000000153015205374123021031 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail8373.d(21): Error: `fail8373.fun1` called with argument types `(int)` matches multiple overloads exactly: fail_compilation/fail8373.d(15): `fail8373.fun1!().fun1!int.fun1(int)` and: fail_compilation/fail8373.d(16): `fail8373.fun1!int.fun1(int)` fail_compilation/fail8373.d(22): Error: `fail8373.fun2` called with argument types `(int)` matches multiple overloads exactly: fail_compilation/fail8373.d(18): `fail8373.fun2!int.fun2(int)` and: fail_compilation/fail8373.d(19): `fail8373.fun2!().fun2!int.fun2(int)` --- */ template fun1(a...) { auto fun1(T...)(T args){ return 1; } } auto fun1(T...)(T args){ return 2; } auto fun2(T...)(T args){ return 2; } template fun2(a...) { auto fun2(T...)(T args){ return 1; } } enum x1 = fun1(0); enum x2 = fun2(0); ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13082.d0000644000175000017500000000116715205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- 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` --- */ class C { this(int a) {} } struct S { this(int a) {} } void main() { string b; auto c = new C(b); auto s = new S(b); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag11727.d0000644000175000017500000000077315205374123021107 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag11727.d(10): Error: type `n` is not an expression --- */ auto returnEnum() { enum n; return n; } void main() { assert(returnEnum() == 0); } /* TEST_OUTPUT: --- fail_compilation/diag11727.d(26): Error: type `void` is not an expression --- */ auto returnVoid() { alias v = void; return v; } /* TEST_OUTPUT: --- fail_compilation/diag11727.d(38): Error: template `t()` has no type --- */ auto returnTemplate() { template t() {} return t; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix21165.d0000644000175000017500000000102415205374123020754 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix21165.d(12): Error: undefined identifier `foo` fail_compilation/fix21165.d(16): Error: undefined identifier `foo` fail_compilation/fix21165.d(21): Error: undefined identifier `foo` fail_compilation/fix21165.d(30): Error: undefined identifier `foo` --- */ // Test case from Issue #21165 foo f() {} // Test case from Issue #21171 foo bar; // Test case from Issue #21169 void fun( foo x ) {} // Test case from Issue #21168 enum plusOne(int x) = x + 1; alias fooPlusOne = plusOne ! foo; ./ldc-1.42.0-src/tests/dmd/fail_compilation/named_arguments_struct_literal.d0000644000175000017500000000036515205374123026067 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/named_arguments_struct_literal.d(14): Error: trying to initialize past the last field `z` of `S` --- */ // https://issues.dlang.org/show_bug.cgi?id=24281 struct S { int y, z = 3; } S s = S( z: 2, 3, ); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail246.d0000644000175000017500000000046415205374123020745 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail246.d-mixin-12(12): Error: identifier expected, not `End of File` fail_compilation/fail246.d-mixin-12(12): Error: `;` expected after `mixin` fail_compilation/fail246.d-mixin-12(12): while parsing string mixin statement --- */ void a() { mixin(`mixin`); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail194.d0000644000175000017500000000037615205374123020751 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail194.d(18): Error: function `& foo` is overloaded --- */ import core.vararg; void bar(int i, ...) { } void foo() { } void foo(int) { } void main() { //bar(1, cast(void function())&foo); bar(1, &foo); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/finalswitch_verbose.d0000644000175000017500000000313115205374123023630 0ustar fabiofabio/* REQUIRED_ARGS: -v TRANSFORM_OUTPUT: remove_lines("^(predefs|binary|version|config|DFLAG|parse|import|\(imported|semantic|entry|\s*$)") TEST_OUTPUT: --- fail_compilation/finalswitch_verbose.d(40): Error: missing cases for `enum` members in `final switch`: fail_compilation/finalswitch_verbose.d(40): `m1` fail_compilation/finalswitch_verbose.d(40): `m2` fail_compilation/finalswitch_verbose.d(40): `m3` fail_compilation/finalswitch_verbose.d(40): `m4` fail_compilation/finalswitch_verbose.d(40): `m5` fail_compilation/finalswitch_verbose.d(40): `m6` fail_compilation/finalswitch_verbose.d(40): `m7` fail_compilation/finalswitch_verbose.d(40): `m8` fail_compilation/finalswitch_verbose.d(40): `m9` fail_compilation/finalswitch_verbose.d(40): `m10` fail_compilation/finalswitch_verbose.d(40): `m11` fail_compilation/finalswitch_verbose.d(40): `m12` fail_compilation/finalswitch_verbose.d(40): `m13` fail_compilation/finalswitch_verbose.d(40): `m14` fail_compilation/finalswitch_verbose.d(40): `m15` fail_compilation/finalswitch_verbose.d(40): `m16` fail_compilation/finalswitch_verbose.d(40): `m17` fail_compilation/finalswitch_verbose.d(40): `m18` fail_compilation/finalswitch_verbose.d(40): `m19` fail_compilation/finalswitch_verbose.d(40): `m20` --- */ // https://issues.dlang.org/show_bug.cgi?id=22038 enum H { m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16, m17, m18, m19, m20 } void test22038() { final switch (H.init) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10419.d0000644000175000017500000000031215205374123020725 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10419.d(12): Error: cannot modify expression `arr().length` because it is not an lvalue --- */ int[] arr() { return []; } void main() { arr().length = 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21241.d0000644000175000017500000000120315205374123021137 0ustar fabiofabio/* REQUIRED_ARGS: runnable/imports/imp21241a.c runnable/imports/imp21241b.c */ // https://github.com/dlang/dmd/issues/21241 /* LDC: no 'fix' for LDC (moved from runnable/ to fail_compilation/); make sure a warning is emitted instead see https://github.com/ldc-developers/ldc/pull/4949#issuecomment-2972894481 REQUIRED_ARGS: -w TEST_OUTPUT: --- runnable/imports/imp21241a.c(3): Warning: skipping definition of function `imp21241a.foo` due to previous definition for the same mangled name: foo --- */ import imp21241a; import imp21241b; void main(){ int x = getA(); assert(x==aValue); x = getB(); assert(x==bValue); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21414.d0000644000175000017500000000247615205374123021112 0ustar fabiofabio// https://github.com/dlang/dmd/issues/21414 /* REQUIRED_ARGS: -o- TEST_OUTPUT: --- fail_compilation/fail21414.d(42): Error: moving variable `__rvalue(s)` with `__rvalue` is not allowed in a `@safe` function fail_compilation/fail21414.d(42): Error: moving variable `__rvalue(s)` with `__rvalue` is not allowed in a `@safe` function fail_compilation/fail21414.d(44): Error: calling `__rvalue`-annotated function `unsafeMove` is not allowed in a `@safe` function fail_compilation/fail21414.d(44): Error: calling `__rvalue`-annotated function `unsafeMove` is not allowed in a `@safe` function fail_compilation/fail21414.d(46): Error: moving result of `ref` function `id` with `__rvalue` is not allowed in a `@safe` function fail_compilation/fail21414.d(46): Error: moving result of `ref` function `id` with `__rvalue` is not allowed in a `@safe` function --- */ @safe: struct S { int x; this(int x) { this.x = x; } ~this() { } this(S s) { } } void foo(S s, immutable(S) t) { assert(t.x == 2); s.x = 3; assert(t.x == 2); } ref unsafeMove(T)(ref T arg) __rvalue => arg; ref id(T)(return ref T arg) => arg; void main() { auto s = S(2); foo(__rvalue(s), __rvalue(s)); auto t = S(2); foo(unsafeMove(t), unsafeMove(t)); auto u = S(2); foo(__rvalue(id(u)), __rvalue(id(u))); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag14235.d0000644000175000017500000000076215205374123021102 0ustar fabiofabio/* EXTRA_FILES: imports/a14235.d TEST_OUTPUT: --- fail_compilation/diag14235.d(12): Error: undefined identifier `Undefined` in module `imports.a14235` fail_compilation/diag14235.d(13): Error: undefined identifier `Something` in module `imports.a14235`, did you mean struct `SomeThing(T...)`? fail_compilation/diag14235.d(14): Error: `SomeClass` isn't a template --- */ import imports.a14235; imports.a14235.Undefined!Object a; imports.a14235.Something!Object b; imports.a14235.SomeClass!Object c; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14621.d0000644000175000017500000000073515205374123020735 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice14621.d(22): Error: static assert: `false` is false fail_compilation/ice14621.d(28): instantiated from here: `erroneousTemplateInstantiation!()` --- */ void main() { S s; s.foo(); } struct S { float[] array; alias array this; template erroneousTemplateInstantiation() { static assert(false); } void foo() { S ret; ret[] = erroneousTemplateInstantiation!(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17354.d0000644000175000017500000000105315205374123021110 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17354.d(12): Error: cannot implicitly override base class method `object.Object.opEquals` with `fail17354.Foo.opEquals`; add `override` attribute fail_compilation/fail17354.d(17): Error: cannot implicitly override base class method `object.Object.opEquals` with `fail17354.Bar.opEquals`; add `override` attribute --- */ // https://issues.dlang.org/show_bug.cgi?id=17354 final class Foo { bool opEquals(const Object) const {return true;} } class Bar { bool opEquals(const Object) const {return true;} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test14496.d0000644000175000017500000000235615205374123021167 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test14496.d(21): Error: `void` initializing a pointer is not allowed in a `@safe` function fail_compilation/test14496.d(24): Error: `void` initializing a pointer is not allowed in a `@safe` function fail_compilation/test14496.d(28): Error: `void` initializing a pointer is not allowed in a `@safe` function fail_compilation/test14496.d(48): Error: `void` initializers for pointers is not allowed in a `@safe` function fail_compilation/test14496.d(49): Error: `void` initializers for pointers is not allowed in a `@safe` function fail_compilation/test14496.d(50): Error: `void` initializers for pointers is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=14496 @safe void foo() { struct Foo { int* indirection1; Object indirection2; string[] indirection3; } Foo f = void; struct Bar { Foo foo = void; } struct Baz { int* x = void; } } struct Foo { int* indirection1; Object indirection2; string[] indirection3; } struct Bar { Foo foo = void; } struct Baz { int* x = void; } @safe void sinister() { Bar bar; Baz baz; Bar[2] bars; // https://issues.dlang.org/show_bug.cgi?id=23412 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23108a.d0000644000175000017500000000036515205374123021250 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23108 /* TEST_OUTPUT: --- fail_compilation/fail23108a.d(9): Error: undefined identifier `_xopEquals` in module `object` --- */ module object; struct Interface { void[] vtbl; } class TypeInfo { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22853a.i0000644000175000017500000000023315205374123021255 0ustar fabiofabio/+ https://issues.dlang.org/show_bug.cgi?id=22853 +/ /* TEST_OUTPUT: --- fail_compilation/fail22853a.i(1): Error: no type for declarator before `/` --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag11840.d0000644000175000017500000000033015205374123021070 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag11840.d(12): Error: undefined identifier `i` fail_compilation/diag11840.d(12): Error: undefined identifier `j` --- */ void main() { int[10] data; data[i .. j] = 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/must_use.d0000644000175000017500000000060315205374123021435 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/must_use.d(17): Error: ignored value of `@mustuse` type `must_use.S`; prepend a `cast(void)` if intentional fail_compilation/must_use.d(18): Error: ignored value of `@mustuse` type `must_use.S`; prepend a `cast(void)` if intentional --- +/ import core.attribute; @mustuse struct S {} S fun(); void test() { int x; fun(); fun(), x++; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20164.d0000644000175000017500000000035515205374123021105 0ustar fabiofabio// REQUIRED_ARGS: -de // EXTRA_FILES: imports/fail20164.d /* TEST_OUTPUT: --- fail_compilation/fail20164.d(13): Deprecation: module `imports.fail20164` is deprecated --- */ module fail20164; void foo() { import imports.fail20164; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13382.d0000644000175000017500000000172015205374123020733 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13382.d(18): Error: incompatible types for `(a) == (0)`: `int[]` and `int` fail_compilation/ice13382.d(19): Error: incompatible types for `(a) >= (0)`: `int[]` and `int` fail_compilation/ice13382.d(20): Error: incompatible types for `(0) == (a)`: `int` and `int[]` fail_compilation/ice13382.d(21): Error: incompatible types for `(0) >= (a)`: `int` and `int[]` fail_compilation/ice13382.d(22): Error: incompatible types for `(a) is (0)`: `int[]` and `int` fail_compilation/ice13382.d(23): Error: incompatible types for `(a) !is (0)`: `int[]` and `int` fail_compilation/ice13382.d(24): Error: incompatible types for `(0) is (a)`: `int` and `int[]` fail_compilation/ice13382.d(25): Error: incompatible types for `(0) !is (a)`: `int` and `int[]` --- */ void main () { int[] a; if (a == 0) {} if (a >= 0) {} if (0 == a) {} if (0 >= a) {} if (a is 0) {} if (a !is 0) {} if (0 is a) {} if (0 !is a) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15785.d0000644000175000017500000000065215205374123021166 0ustar fabiofabio// EXTRA_FILES: imports/test15785.d /* TEST_OUTPUT: --- fail_compilation/test15785.d(17): Error: no property `foo` for `super` of type `imports.test15785.Base` fail_compilation/imports/test15785.d(3): class `Base` defined here fail_compilation/test15785.d(18): Error: undefined identifier `bar` --- */ import imports.test15785; class Derived : Base { void test() { super.foo(); bar(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4448.d0000644000175000017500000000071515205374123021034 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4448.d(19): Error: label `L1` has no `break` fail_compilation/fail4448.d(26): called from here: `bug4448()` fail_compilation/fail4448.d(26): while evaluating: `static assert(bug4448() == 3)` --- */ int bug4448() { int n=2; L1:{ switch(n) { case 5: return 7; default: n = 5; break L1; } int w = 7; } return 3; } static assert(bug4448()==3); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail61.d0000644000175000017500000000176115205374123020661 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail61.d(25): Error: no property `B` for type `fail61.A.B` fail_compilation/fail61.d(16): class `B` defined here fail_compilation/fail61.d(26): Error: no property `B` for type `fail61.A.B` fail_compilation/fail61.d(16): class `B` defined here fail_compilation/fail61.d(35): Error: no property `A2` for type `fail61.B2` fail_compilation/fail61.d(30): class `B2` defined here fail_compilation/fail61.d(44): Error: calling non-static function `foo` requires an instance of type `B3` --- */ class A { class B : A { static const int C = 5; } } void main() { int n1 = A.B.C; int n2 = A.B.B.C; // Line22 int n3 = A.B.B.B.C; // Line23 } class A2 { void foo(){ assert(0);} } class B2 : A2 { override void foo(){} } class C2 : B2 { void bar() { B2.A2.foo(); // Line32 } } class B3 { void foo(){ assert(0); } } class C3 { void bar() { B3.foo(); // Line41 } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag19225.d0000644000175000017500000000065315205374123021105 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag19225.d(14): Error: basic type expected, not `else` fail_compilation/diag19225.d(14): There's no `static else`, use `else` instead. fail_compilation/diag19225.d(14): Error: found `else` without a corresponding `if`, `version` or `debug` statement fail_compilation/diag19225.d(15): Error: unmatched closing brace --- */ void main() { static if (true) {} static else {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/systemvariables_deprecation.d0000644000175000017500000000121015205374123025356 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/systemvariables_deprecation.d(15): Deprecation: `@safe` function `main` calling `middle` fail_compilation/systemvariables_deprecation.d(20): which calls `inferred` fail_compilation/systemvariables_deprecation.d(26): and access `@system` variable `x0` makes it fail to infer `@safe` --- */ // test deprecation messages before -preview=systemVariables becomes default void main() @safe { middle(); // nested deprecation } auto middle() { return inferred(); // no deprecation, inferredC is not explicit `@safe` } auto inferred() { @system int* x0; x0 = null; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21868b.d0000644000175000017500000000067015205374123021263 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fail21868b.d(19): Error: escaping a reference to parameter `s` by returning `&s.x` is not allowed in a `@safe` function fail_compilation/fail21868b.d(17): perhaps change the `return scope` into `scope return` --- */ // https://issues.dlang.org/show_bug.cgi?id=21868 struct S { int x; int* y; } int* test(ref return scope S s) @safe { return &s.x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7443.d0000644000175000017500000000063015205374123021026 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7443.d(11): Error: `static` has no effect on a constructor inside a `static` block. Use `static this()` fail_compilation/fail7443.d(12): Error: `shared static` has no effect on a constructor inside a `shared static` block. Use `shared static this()` --- */ class Foo { public static { this() {}} public shared static { this() {}} public {this(int) {}} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10016.d0000644000175000017500000000136615205374123020730 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10016.d(33): Error: undefined identifier `unknownIdentifier` fail_compilation/ice10016.d(47): Error: template instance `ice10016.RefCounted!(S)` error instantiating --- */ struct RefCounted(T) { struct RefCountedStore { struct Impl { T _payload; } Impl* _store; } RefCountedStore _refCounted; void opAssign(typeof(this)) { } void opAssign(T) { } @property refCountedPayload() { return _refCounted._store._payload; } alias refCountedPayload this; } struct S { int i = unknownIdentifier; } class C {} class N { this(C) {} C c() { return null; } } class D : N { this() { super(c); } RefCounted!S _s; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/must_use_comma.d0000644000175000017500000000045315205374123022614 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/must_use_comma.d(16): Error: ignored value of `@mustuse` type `must_use_comma.S`; prepend a `cast(void)` if intentional --- +/ import core.attribute; @mustuse struct S {} S fun() { return S(); } void sideEffect() {} void test() { (fun(), sideEffect()); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag7998.d0000644000175000017500000000023015205374123021032 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag7998.d(10): Error: static assert: "abcxe" --- */ module diag7998; static assert(false, "abc" ~['x'] ~ "e"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail54.d0000644000175000017500000000174215205374123020662 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail54.d(27): Error: incompatible types for `(0) == (Exception)`: cannot use `==` with types fail_compilation/fail54.d(28): Error: incompatible types for `("") == (int)`: cannot use `==` with types fail_compilation/fail54.d(29): Error: incompatible types for `(true) == (int)`: cannot use `==` with types fail_compilation/fail54.d(29): while evaluating: `static assert(true == (int))` fail_compilation/fail54.d(30): Error: incompatible types for `(true) == (int[string])`: cannot use `==` with types fail_compilation/fail54.d(30): while evaluating: `static assert(true == (int[string]))` --- */ // $HeadURL$ // $Date$ // $Author$ // @author@ zwang // @date@ 2005-02-03 // @uri@ news:ctthp6$25b$1@digitaldaemon.com // __DSTRESS_ELINE__ 14 module dstress.nocompile.bug_mtype_507_C; void test() { 0 == Exception; "" == int; static assert(is(int) == int); static assert(is(int[string]) == int[string]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11355.d0000644000175000017500000000056715205374123021114 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11355.d(28): Error: struct `fail11355.A` is not copyable because it has a disabled postblit --- */ T move(T)(ref T source) { return T.init; // Dummy rvalue } struct A { ~this() {} @disable this(this); // Prevent copying } struct B { A a; alias a this; } void main() { B b; A a = move(b); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10938.d0000644000175000017500000000100215205374123020730 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10938.d(14): Error: no property `opts` for `this` of type `ice10938.C` fail_compilation/ice10938.d(19): Error: can't infer return type in function `opDispatch` fail_compilation/ice10938.d(14): Error: template instance `ice10938.C.opDispatch!"opts"` error instantiating --- */ class C { this() { this.opts["opts"] = 1; } auto opDispatch(string field : "opts")() { return this.opts; // ICE -> compile time error } } void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22366.d0000644000175000017500000000251115205374123021107 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fail22366.d(22): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function fail_compilation/fail22366.d(25): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function fail_compilation/fail22366.d(26): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function fail_compilation/fail22366.d(27): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function fail_compilation/fail22366.d(28): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function fail_compilation/fail22366.d(31): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function fail_compilation/fail22366.d(32): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function --- */ // Test escaping scope variables through AA keys / values // https://issues.dlang.org/show_bug.cgi?id=22366 // https://issues.dlang.org/show_bug.cgi?id=23531 void fun(scope string s) @safe { int[string] aa; aa[s] ^^= 3; string[string] saa; saa[""] = s; saa[""] ~= s; saa[s] = ""; saa[s] ~= ""; string[string][string] snaa; snaa[s][""] = ""; snaa[""][s] = ""; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail5953a1.d0000644000175000017500000000024015205374123021251 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail5953a1.d(9): Error: expression expected, not `,` --- */ void main() { auto a2 = [,]; // invalid, but compiles } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail278.d0000644000175000017500000000071515205374123020751 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail278.d(11): Error: template instance `NONEXISTENT!()` template `NONEXISTENT` is not defined fail_compilation/fail278.d(12): Error: template instance `fail278.F!()` error instantiating fail_compilation/fail278.d(13): instantiated from here: `Bar!(Foo)` --- */ template Id(xs...) { const Id = xs[0]; } template Foo() { mixin Id!(NONEXISTENT!()); } template Bar(alias F) { const int Bar = F!(); } alias Bar!(Foo) x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9414c.d0000644000175000017500000000607015205374123021175 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9414c.d(47): Error: variable `fail9414c.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414c.d(34): Error: variable `fail9414c.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414c.d(35): Error: variable `fail9414c.C.foo.bar.y` cannot modify parameter `y` in contract fail_compilation/fail9414c.d(40): Error: variable `fail9414c.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414c.d(41): Error: variable `fail9414c.C.foo.bar.y` cannot modify parameter `y` in contract fail_compilation/fail9414c.d(42): Error: variable `fail9414c.C.foo.bar.s` cannot modify result `s` in contract fail_compilation/fail9414c.d(52): Error: variable `fail9414c.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414c.d(75): Error: variable `fail9414c.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414c.d(76): Error: variable `fail9414c.C.foo.r` cannot modify result `r` in contract fail_compilation/fail9414c.d(60): Error: variable `fail9414c.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414c.d(61): Error: variable `fail9414c.C.foo.r` cannot modify result `r` in contract fail_compilation/fail9414c.d(62): Error: variable `fail9414c.C.foo.baz.y` cannot modify parameter `y` in contract fail_compilation/fail9414c.d(67): Error: variable `fail9414c.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414c.d(68): Error: variable `fail9414c.C.foo.r` cannot modify result `r` in contract fail_compilation/fail9414c.d(69): Error: variable `fail9414c.C.foo.baz.y` cannot modify parameter `y` in contract fail_compilation/fail9414c.d(70): Error: variable `fail9414c.C.foo.baz.s` cannot modify result `s` in contract fail_compilation/fail9414c.d(81): Error: variable `fail9414c.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414c.d(82): Error: variable `fail9414c.C.foo.r` cannot modify result `r` in contract --- */ class C { private int foo(int x) in { int a; int bar(int y) in { x = 10; // err y = 10; // err a = 1; // OK } out(s) { x = 10; // err y = 10; // err s = 10; // err a = 1; // OK } do { x = 10; // err y = 1; // OK a = 1; // OK return 2; } x = 10; // err } out(r) { int a; int baz(int y) in { x = 10; // err r = 10; // err y = 10; // err a = 1; // OK } out(s) { x = 10; // err r = 10; // err y = 10; // err s = 10; // err a = 1; // OK } do { x = 10; // err r = 10; // err y = 1; // OK a = 1; // OK return 2; } x = 10; // err r = 10; // err } do { return 1; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail53.d0000644000175000017500000000121315205374123020652 0ustar fabiofabio/* TEST_OUTPUT: --- 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` --- */ // $HeadURL$ // $Date$ // $Author$ // @author@ Thomas Kuehne // @date@ 2005-01-22 // @uri@ news:csvvet$2g4$1@digitaldaemon.com // @url@ nntp://news.digitalmars.com/digitalmars.D.bugs/2741 // __DSTRESS_ELINE__ 17 module dstress.nocompile.bug_mtype_507_A; int main() { Object o; int i; if (i == o) { return -1; } return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag3438.d0000644000175000017500000000244015205374123021020 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag3438.d(16): Error: constructor `diag3438.F1.this` all parameters have default arguments, but structs cannot have default constructors. fail_compilation/diag3438.d(17): Error: constructor `diag3438.F2.this` all parameters have default arguments, but structs cannot have default constructors. fail_compilation/diag3438.d(20): Error: constructor `diag3438.F5.this` is marked `@disable`, so it cannot have default arguments for all parameters. fail_compilation/diag3438.d(20): Use `@disable this();` if you want to disable default initialization. fail_compilation/diag3438.d(21): Error: constructor `diag3438.F6.this` is marked `@disable`, so it cannot have default arguments for all parameters. fail_compilation/diag3438.d(21): Use `@disable this();` if you want to disable default initialization. fail_compilation/diag3438.d(22): Error: constructor `diag3438.F7.this` all parameters have default arguments, but structs cannot have default constructors. --- */ import core.vararg; struct F1 { this(int x = 1) { } } struct F2 { this(int x = 1, ...) { } } struct F3 { this(...) { } } // ok struct F4 { this(int[] x...) { } } // ok struct F5 { @disable this(int x = 1); } struct F6 { @disable this(int x = 1) { } } struct F7 { this(int x = 1, int y = 2) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/deprecate1553.d0000644000175000017500000000036015205374123022043 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/deprecate1553.d(16): Error: cannot use `foreach_reverse` with a delegate --- */ struct S { int dg(int delegate(ref int a)) { return 0; } } void main() { S s; foreach_reverse(a; &s.dg) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11163.d0000644000175000017500000000047715205374123021111 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11163.d(12): Error: cannot implicitly convert expression `foo()` of type `int[]` to `immutable(int[])` fail_compilation/fail11163.d(13): while evaluating `pragma(msg, a)` --- */ int[] foo() { return [1]; } void main() { immutable a = foo(); pragma(msg, a); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/cppmangle.d0000644000175000017500000000104615205374123021541 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/cppmangle.d(11): Error: expected valid identifier for C++ namespace but got `""` fail_compilation/cppmangle.d(15): Error: expected valid identifier for C++ namespace but got `"0num"` fail_compilation/cppmangle.d(19): Error: compile time string constant (or sequence) expected, not `2` fail_compilation/cppmangle.d(23): Error: expected valid identifier for C++ namespace but got `"invalid@namespace"` --- */ extern(C++, "") { } extern(C++, "0num") { } extern(C++, 1+1) { } extern(C++, "invalid@namespace") { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20565.d0000644000175000017500000000055115205374123021154 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test20565.d(107): Error: function `test20565.test.box` the same declaration cannot be in multiple scopes with non-D linkage --- */ // https://issues.dlang.org/show_bug.cgi?id=20565 #line 100 void test() { { extern (C++) int box() { return 3; } } { extern (C++) int box() { return 4; } } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/generic2.c0000644000175000017500000000030115205374123021261 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/generic2.c(103): Error: only one `default` allowed in generic-assoc-list --- */ #line 100 void test() { int e3 = _Generic(1, default:2, default:3); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/mixinprop.d0000644000175000017500000000027615205374123021624 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/mixinprop.d(12): Error: no property `x` for `mixin Foo!() F;` of type `void` --- */ mixin template Foo() { } void main() { mixin Foo F; F.x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9254b.d0000644000175000017500000000155215205374123021023 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9254b.d(17): Error: using the result of a comma expression is not allowed fail_compilation/ice9254b.d(17): Error: using the result of a comma expression is not allowed fail_compilation/ice9254b.d(17): Error: using the result of a comma expression is not allowed fail_compilation/ice9254b.d(17): Error: using the result of a comma expression is not allowed fail_compilation/ice9254b.d(17): Error: using the result of a comma expression is not allowed fail_compilation/ice9254b.d(17): Error: invalid `foreach` aggregate `false` of type `bool` --- */ class C { synchronized void foo() { foreach(divisor; !(2, 3, 4, 8, 7, 9)) { // ice in ForeachRangeStatement::usesEH() foreach (v; 0..uint.max) {} // ice in WhileStatement::usesEH() while (1) {} } } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ctfe10989.d0000644000175000017500000000155415205374123021133 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ctfe10989.d(11): Error: uncaught CTFE exception `object.Exception("abc"c)` fail_compilation/ctfe10989.d(14): called from here: `throwing()` fail_compilation/ctfe10989.d(14): while evaluating: `static assert(throwing())` --- */ int throwing() { throw new Exception(['a', 'b', 'c']); return 0; } static assert(throwing()); /* TEST_OUTPUT: --- fail_compilation/ctfe10989.d(33): Error: uncaught CTFE exception `object.Exception("abc"c)` fail_compilation/ctfe10989.d(36): called from here: `throwing2()` fail_compilation/ctfe10989.d(36): while evaluating: `static assert(throwing2())` --- */ int throwing2() { string msg = "abc"; char[] arr; arr.length = msg.length; arr = arr[0 .. $]; arr[] = msg; throw new Exception(cast(string)arr); return 0; } static assert(throwing2()); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13311.d0000644000175000017500000000031115205374123020716 0ustar fabiofabio/* EXTRA_FILES: imports/a13311.d TEST_OUTPUT: --- fail_compilation/imports/a13311.d(8): Error: undefined identifier `PieceTree` --- */ module ice13311; struct TextPiece { import imports.a13311; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9665b.d0000644000175000017500000000363515205374123021210 0ustar fabiofabio/***************************************************/ // with disable this() struct struct X { @disable this(); this(int) {} } /+ TEST_OUTPUT: --- fail_compilation/fail9665b.d(32): Error: one path skips field `x2` fail_compilation/fail9665b.d(33): Error: one path skips field `x3` fail_compilation/fail9665b.d(35): Error: one path skips field `x5` fail_compilation/fail9665b.d(36): Error: one path skips field `x6` fail_compilation/fail9665b.d(30): Error: field `x1` must be initialized in constructor fail_compilation/fail9665b.d(30): Error: field `x4` must be initialized in constructor --- +/ struct S1 { X x1; X x2; X x3; X[2] x4; X[2] x5; X[2] x6; this(int) { if (true) x2 = X(1); auto n = true ? (x3 = X(1)) : X.init; if (true) x5 = X(1); auto m = true ? (x6 = X(1)) : typeof(x6).init; } } /***************************************************/ // with nested struct /+ TEST_OUTPUT: --- fail_compilation/fail9665b.d(65): Error: one path skips field `x2` fail_compilation/fail9665b.d(66): Error: one path skips field `x3` fail_compilation/fail9665b.d(68): Error: one path skips field `x5` fail_compilation/fail9665b.d(69): Error: one path skips field `x6` fail_compilation/fail9665b.d(63): Error: field `x1` must be initialized in constructor, because it is nested struct fail_compilation/fail9665b.d(63): Error: field `x4` must be initialized in constructor, because it is nested struct fail_compilation/fail9665b.d(76): Error: template instance `fail9665b.S2!(X)` error instantiating --- +/ struct S2(X) { X x1; X x2; X x3; X[2] x4; X[2] x5; X[2] x6; this(X x) { if (true) x2 = x; auto a = true ? (x3 = x) : X.init; if (true) x5 = x; auto b = true ? (x6 = x) : typeof(x6).init; } } void test2() { struct X { this(int) {} } static assert(X.tupleof.length == 1); S2!(X) s = X(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/xmmslice.d0000644000175000017500000000051015205374123021407 0ustar fabiofabio /* REQUIRED_ARGS: -mcpu=avx DISABLED: win32 freebsd32 openbsd32 linux32 osx32 LDC_not_x86 TEST_OUTPUT: --- fail_compilation/xmmslice.d(110): Error: `__vector(int[4])` cannot be sliced with `[]` --- */ #line 100 import core.simd; int4 testz4() { return [0,0,0,0]; } void test() { assert(testz4()[] == [0,0,0,0]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18719.d0000644000175000017500000000117615205374123021124 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=18719 /* TEST_OUTPUT: --- fail_compilation/fail18719.d(29): Error: immutable field `x` initialized multiple times Previous initialization is here. --- */ struct S { int x = -1; this(int y) immutable { x = y; import core.stdc.stdio; printf("Ctor called with %d\n", y); } void opAssign(int) immutable; } class C { S x; this() immutable { this(42); /* Initializes x. */ x = 13; /* Breaking immutable, or ok? */ } this(int x) immutable { this.x = x; } } void main() { new immutable C; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/alignas4.c0000644000175000017500000000056315205374123021277 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/alignas4.c(12): Error: `_Alignas` specifier cannot be less strict than alignment of `c` fail_compilation/alignas4.c(13): Error: alignment must be an integer positive power of 2, not 0x1 --- */ int main() { _Alignas(1) _Alignas(int) int a; _Alignas(1) _Alignas(16) int b; _Alignas(1) int c; _Alignas((void*)1) int d; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/named_arguments_parse.d0000644000175000017500000000060515205374123024136 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/named_arguments_parse.d(13): Error: named arguments not allowed here fail_compilation/named_arguments_parse.d(14): Error: named arguments not allowed here --- */ // @(attribute: 3) Currently gives an ugly parse error, will be better when named template arguments are implemented void main() { mixin(thecode: "{}"); pragma(msg, themsg: "hello"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15989.d0000644000175000017500000000203615205374123021172 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test15989.d(41): Error: variable `test15989.main.ctRegex` : Unable to initialize enum with class or pointer to struct fail_compilation/test15989.d(41): use static const variable instead fail_compilation/test15989.d(50): Error: variable `test15989.test.c` : Unable to initialize enum with class or pointer to struct fail_compilation/test15989.d(50): use static const variable instead fail_compilation/test15989.d(51): Error: cannot use non-constant CTFE pointer in an initializer `new int(3)` --- */ // https://issues.dlang.org/show_bug.cgi?id=15989 import core.stdc.stdio; interface Kickstart{ bool foo( int ); } class ShiftOr : Kickstart { bool foo( int i ) { printf("i = %d\n", i); return false; } } struct Regex { Kickstart kickstart; } Regex regex() { return Regex(new ShiftOr()); } void main() { enum ctRegex = regex(); Regex r = ctRegex; r.kickstart.foo(7); } class C { } void test() { enum c = new C(); enum pi = new int(3); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4206.d0000644000175000017500000000023015205374123021014 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4206.d(9): Error: initializer must be an expression, not `s` --- */ struct s {} enum var = s; void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_casting2.d0000644000175000017500000000066315205374123022304 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/fail_casting2.d(15): Error: type `int` is not an expression fail_compilation/fail_casting2.d(17): Error: template lambda has no type fail_compilation/fail_casting2.d(20): Error: template `Templ()` has no type --- */ void test15214() { alias Type = int; cast(void)(Type); cast(void)(x => mixin(x)("mixin(x);")); template Templ() {} cast(void)(Templ); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/aacmp10381.d0000644000175000017500000000032115205374123021244 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/aacmp10381.d(12): Error: `>` is not defined for associative arrays --- */ bool test10381() { int[int] aa1 = [0: 1]; int[int] aa2 = [0: 1]; return aa1 > aa2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test9701.d0000644000175000017500000000541715205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test9701.d(38): Error: `@safe` is not a valid attribute for enum members fail_compilation/test9701.d(39): Error: `@system` is not a valid attribute for enum members fail_compilation/test9701.d(40): Error: `@trusted` is not a valid attribute for enum members fail_compilation/test9701.d(41): Error: `@nogc` is not a valid attribute for enum members fail_compilation/test9701.d(42): Error: found `pure` when expecting `identifier` fail_compilation/test9701.d(43): Error: found `shared` when expecting `identifier` fail_compilation/test9701.d(44): Error: found `inout` when expecting `identifier` fail_compilation/test9701.d(45): Error: found `immutable` when expecting `identifier` fail_compilation/test9701.d(46): Error: found `const` when expecting `identifier` fail_compilation/test9701.d(47): Error: found `synchronized` when expecting `identifier` fail_compilation/test9701.d(48): Error: found `scope` when expecting `identifier` fail_compilation/test9701.d(49): Error: found `auto` when expecting `identifier` fail_compilation/test9701.d(50): Error: found `ref` when expecting `identifier` fail_compilation/test9701.d(51): Error: found `__gshared` when expecting `identifier` fail_compilation/test9701.d(52): Error: found `final` when expecting `identifier` fail_compilation/test9701.d(53): Error: found `extern` when expecting `identifier` fail_compilation/test9701.d(54): Error: found `export` when expecting `identifier` fail_compilation/test9701.d(55): Error: found `nothrow` when expecting `identifier` fail_compilation/test9701.d(56): Error: found `public` when expecting `identifier` fail_compilation/test9701.d(57): Error: found `private` when expecting `identifier` fail_compilation/test9701.d(58): Error: found `package` when expecting `identifier` fail_compilation/test9701.d(59): Error: found `static` when expecting `identifier` fail_compilation/test9701.d(60): Error: found `static` when expecting `identifier` fail_compilation/test9701.d(61): Error: found `static` when expecting `identifier` fail_compilation/test9701.d(62): Error: found `static` when expecting `identifier` --- */ // This test exists to verify that parsing of enum member attributes rejects invalid attributes // https://issues.dlang.org/show_bug.cgi?id=9701 enum Enum { @safe safe, @system system, @trusted trusted, @nogc nogc, pure pure_, shared shared_, inout inout_, immutable immutable_, const const_, synchronized synchronized_, scope scope_, auto auto_, ref ref_, __gshared __gshared_, final final_, extern extern_, export export_, nothrow nothrow_, public public_, private private_, package package_, static static1, @("a") static static2, static @("a") static3, @("a") static @("b") static3, } ./ldc-1.42.0-src/tests/dmd/fail_compilation/testInference.d0000644000175000017500000002205715205374123022376 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/testInference.d(24): Error: return value `this.a` of type `inout(A8998)` does not match return type `immutable(A8998)`, and cannot be implicitly converted --- */ class A8998 { int i; } class C8998 { A8998 a; this() { a = new A8998(); } // WRONG: Returns immutable(A8998) immutable(A8998) get() inout pure { return a; // should be error } } /* TEST_OUTPUT: --- fail_compilation/testInference.d(39): Error: return value `s` of type `const(char[])` does not match return type `string`, and cannot be implicitly converted fail_compilation/testInference.d(44): Error: return value `a` of type `int[]` does not match return type `immutable(int[])`, and cannot be implicitly converted fail_compilation/testInference.d(49): Error: return value `a` of type `int[]` does not match return type `immutable(int[])`, and cannot be implicitly converted fail_compilation/testInference.d(54): Error: return value `a` of type `int[]` does not match return type `immutable(int[])`, and cannot be implicitly converted --- */ string foo(in char[] s) pure { return s; // } immutable(int[]) x1() /*pure*/ { int[] a = new int[](10); return a; // } immutable(int[]) x2(int len) /*pure*/ { int[] a = new int[](len); return a; } immutable(int[]) x3(immutable(int[]) org) /*pure*/ { int[] a = new int[](org.length); return a; // } /* TEST_OUTPUT: --- fail_compilation/testInference.d(94): Error: return value `c` of type `testInference.C1` does not match return type `immutable(C1)`, and cannot be implicitly converted fail_compilation/testInference.d(95): Error: return value `c` of type `testInference.C1` does not match return type `immutable(C1)`, and cannot be implicitly converted fail_compilation/testInference.d(96): Error: return value `c` of type `testInference.C3` does not match return type `immutable(C3)`, and cannot be implicitly converted fail_compilation/testInference.d(97): Error: return value `c` of type `testInference.C3` does not match return type `immutable(C3)`, and cannot be implicitly converted fail_compilation/testInference.d(100): Error: undefined identifier `X1`, did you mean function `x1`? fail_compilation/testInference.d(106): Error: return value `s` of type `S1` does not match return type `immutable(S1)`, and cannot be implicitly converted fail_compilation/testInference.d(109): Error: return value `a` of type `int*[]` does not match return type `immutable(int*[])`, and cannot be implicitly converted fail_compilation/testInference.d(110): Error: return value `a` of type `const(int)*[]` does not match return type `immutable(int*[])`, and cannot be implicitly converted fail_compilation/testInference.d(114): Error: return value `s` of type `S2` does not match return type `immutable(S2)`, and cannot be implicitly converted fail_compilation/testInference.d(115): Error: return value `s` of type `S2` does not match return type `immutable(S2)`, and cannot be implicitly converted fail_compilation/testInference.d(116): Error: return value `s` of type `S2` does not match return type `immutable(S2)`, and cannot be implicitly converted fail_compilation/testInference.d(118): Error: return value `a` of type `const(int)*[]` does not match return type `immutable(int*[])`, and cannot be implicitly converted --- */ immutable(Object) get(inout int*) pure { auto o = new Object; return o; // should be ok } immutable(Object) get(immutable Object) pure { auto o = new Object; return o; // should be ok } inout(Object) get(inout Object) pure { auto o = new Object; return o; // should be ok (, but cannot in current conservative rule) } class C1 { C2 c2; } class C2 { C3 c3; } class C3 { C1 c1; } immutable(C1) recursive1(C3 pc) pure { auto c = new C1(); return c; } // should be error, because pc.c1 == C1 immutable(C1) recursive2(C2 pc) pure { auto c = new C1(); return c; } // should be error, because pc.c3.c1 == C1 immutable(C3) recursive3(C1 pc) pure { auto c = new C3(); return c; } // should be error, c.c1 may be pc immutable(C3) recursive4(C2 pc) pure { auto c = new C3(); return c; } // should be error, c.c1.c2 may be pc immutable(C1) recursive5(shared C2 pc) pure { auto c = new C1(); return c; } immutable(C1) recursive6(immutable C2 pc) pure { auto c = new C1(); return c; } immutable(C1) recursiveE(immutable C2 pc) pure { auto c = new X1(); return c; } class C4 { C4[] arr; } immutable(C4)[] recursive7(int[] arr) pure { auto a = new C4[](1); return a; } struct S1 { int* ptr; } immutable(S1) foo1a( int*[] prm) pure { S1 s; return s; } // NG immutable(S1) foo1b( const int*[] prm) pure { S1 s; return s; } // OK immutable(S1) foo1c(immutable int*[] prm) pure { S1 s; return s; } // OK immutable(int*[]) bar1a( S1 prm) pure { int *[] a; return a; } // NG immutable(int*[]) bar1b( S1 prm) pure { const(int)*[] a; return a; } // NG immutable(int*[]) bar1c( S1 prm) pure { immutable(int)*[] a; return a; } // OK struct S2 { const(int)* ptr; } immutable(S2) foo2a( int*[] prm) pure { S2 s; return s; } // OK immutable(S2) foo2b( const int*[] prm) pure { S2 s; return s; } // NG immutable(S2) foo2c(immutable int*[] prm) pure { S2 s; return s; } // NG immutable(int*[]) bar2a( S2 prm) pure { int *[] a; return a; } // OK immutable(int*[]) bar2b( S2 prm) pure { const(int)*[] a; return a; } // NG immutable(int*[]) bar2c( S2 prm) pure { immutable(int)*[] a; return a; } // OK /* TEST_OUTPUT: --- fail_compilation/testInference.d(134): Error: return value `f10063(cast(inout(void*))p)` of type `inout(void)*` does not match return type `immutable(void)*`, and cannot be implicitly converted --- */ inout(void)* f10063(inout void* p) pure { return p; } immutable(void)* g10063(inout int* p) pure { return f10063(p); } /* TEST_OUTPUT: --- fail_compilation/testInference.d(154): Error: `pure` function `testInference.bar14049` cannot call impure function `testInference.foo14049!int.foo14049` fail_compilation/testInference.d(149): which calls `() => impure14049()` fail_compilation/testInference.d(148): which calls `impure14049` fail_compilation/testInference.d(143): and accessing mutable static data `i` makes it fail to infer `pure` --- */ #line 143 auto impure14049() { static int i = 1; return i; } void foo14049(T)(T val) { auto n = () @trusted { return impure14049(); }(); } void bar14049() pure { foo14049(1); } /* TEST_OUTPUT: --- fail_compilation/testInference.d(166): Error: `pure` function `testInference.f14160` cannot access mutable static data `g14160` --- */ int g14160; int* f14160() pure { return &g14160; // should be rejected } /* TEST_OUTPUT: --- fail_compilation/testInference.d(180): Error: `pure` function `testInference.test12422` cannot call impure function `testInference.test12422.bar12422!().bar12422` fail_compilation/testInference.d(179): which calls `foo12422` --- */ #line 175 int g12422; void foo12422() { ++g12422; } void test12422() pure { void bar12422()() { foo12422(); } bar12422(); } /* TEST_OUTPUT: --- fail_compilation/testInference.d(198): Error: `pure` function `testInference.test13729a` cannot call impure function `testInference.test13729a.foo` fail_compilation/testInference.d(196): and accessing mutable static data `g13729` makes it fail to infer `pure` fail_compilation/testInference.d(206): Error: `pure` function `testInference.test13729b` cannot call impure function `testInference.test13729b.foo!().foo` fail_compilation/testInference.d(204): and accessing mutable static data `g13729` makes it fail to infer `pure` --- */ #line 190 int g13729; void test13729a() pure { static void foo() // typed as impure { g13729++; } foo(); // cannot call impure function } void test13729b() pure { static void foo()() // inferred to impure { g13729++; } foo(); // cannot call impure function } /* TEST_OUTPUT: --- fail_compilation/testInference.d(225): Error: `testInference.test17086` called with argument types `(bool)` matches multiple overloads exactly: fail_compilation/testInference.d(219): `testInference.test17086!(bool, false).test17086(bool x)` and: fail_compilation/testInference.d(220): `testInference.test17086!(bool, false).test17086(bool y)` --- */ void test17086 (T, T V = T.init) (T x) { assert(x.foo); } void test17086 (T, T V = T.init) (T y) { assert(y.bar); } void test17086_call () { bool f; test17086(f); } /* TEST_OUTPUT: --- fail_compilation/testInference.d(238): Error: `pure` function `testInference.test20047_pure_function` cannot call impure function `testInference.test20047_pure_function.bug` fail_compilation/testInference.d(237): which calls `test20047_impure_function` --- */ #line 234 void test20047_impure_function() {} void test20047_pure_function() pure { static void bug() { return test20047_impure_function(); } bug(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice15127.d0000644000175000017500000000120315205374123020726 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice15127.d(17): Error: basic type expected, not `struct` fail_compilation/ice15127.d(17): Error: identifier expected for template value parameter fail_compilation/ice15127.d(17): Error: found `struct` when expecting `)` fail_compilation/ice15127.d(17): Error: found `ExampleStruct` when expecting `=` fail_compilation/ice15127.d(17): Error: semicolon expected following auto declaration, not `)` fail_compilation/ice15127.d(17): Error: declaration expected, not `)` --- */ struct ExampleStruct(S) { } template ExampleTemplate(K) { enum ExampleTemplate(struct ExampleStruct(K)) = K; } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test128.i0000644000175000017500000000071115205374123021010 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test128.i(12): Error: unsigned __int128 not supported fail_compilation/test128.i(12): Error: __int128 not supported --- */ // https://issues.dlang.org/show_bug.cgi?id=23614 unsigned long long _mulx_u64(unsigned long long __X, unsigned long long __Y, unsigned long long *__P) { unsigned __int128 __res = (__int128) __X * __Y; *__P = (unsigned long long) (__res >> 64); return (unsigned long long) __res; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/pragmamangle1.d0000644000175000017500000001010115205374123022277 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/pragmamangle1.d(35): Error: `pragma(mangle)` expects string literal argument for mangled name fail_compilation/pragmamangle1.d(37): Error: `pragma(mangle)` expects string literal argument for mangled name fail_compilation/pragmamangle1.d(44): Error: `pragma(mangle)` must be attached to a declaration fail_compilation/pragmamangle1.d(46): Error: `pragma(mangle)` must be attached to a declaration fail_compilation/pragmamangle1.d(53): Error: `pragma(mangle)` expects string literal argument for mangled name fail_compilation/pragmamangle1.d(56): Error: `pragma(mangle)` zero-length string not allowed for mangled name fail_compilation/pragmamangle1.d(59): Error: pragma(mangle)` expects 1 or 2 arguments fail_compilation/pragmamangle1.d(62): Error: `pragma(mangle)` cannot apply to a template declaration fail_compilation/pragmamangle1.d(62): use `template cannot_apply(Args...) { pragma(mangle, "template") ... }` fail_compilation/pragmamangle1.d(65): Error: `pragma(mangle)` takes a single argument that must be a string literal fail_compilation/pragmamangle1.d(68): Error: `pragma(mangle)` takes a single argument that must be a string literal fail_compilation/pragmamangle1.d(71): Error: `string` expected for pragma mangle argument, not `(T)` of type `T` fail_compilation/pragmamangle1.d(74): Error: `string` expected for pragma mangle argument, not `(T[T])` of type `T[T]` fail_compilation/pragmamangle1.d(77): Error: `pragma(mangle)` can only apply to a single declaration fail_compilation/pragmamangle1.d(85): Error: `class` or `struct` type expected for pragma mangle argument, not `"mangle"` of type `string` fail_compilation/pragmamangle1.d(88): Error: `class` or `struct` type expected for pragma mangle argument, not `F()` of type `T` fail_compilation/pragmamangle1.d(91): Error: `class` or `struct` type expected for pragma mangle argument, not `F()` of type `T` fail_compilation/pragmamangle1.d(94): Error: `string` expected for pragma mangle argument, not `(F())` of type `T` fail_compilation/pragmamangle1.d(97): Error: `string` expected for pragma mangle argument, not `(F())` of type `T` fail_compilation/pragmamangle1.d(100): Error: `string` expected for pragma mangle argument, not `(V)` of type `T` fail_compilation/pragmamangle1.d(103): Error: `string` expected for pragma mangle argument, not `(V)` of type `T` fail_compilation/pragmamangle1.d(106): Error: `string` expected for pragma mangle argument, not `T` of type `T` fail_compilation/pragmamangle1.d(109): Error: `class` or `struct` type expected for pragma mangle argument, not `int` of type `int` fail_compilation/pragmamangle1.d(112): Error: `class` or `struct` type expected for pragma mangle argument, not `T[T]` of type `T[T]` --- */ struct T { } T F() { return T(); } T V; alias A = T[T]; pragma(mangle); pragma(mangle) { nothrow: pure: @nogc: @property { } } pragma(mangle, "no_declaration"); pragma(mangle, "no_declaration") { nothrow: pure: @nogc: @property { } } pragma(mangle) void no_string_literal(); pragma(mangle, "") void empty_string_mangle(); pragma(mangle, "too", "many", "arguments") void expects_less_arguments(); pragma(mangle, "template") template cannot_apply(T) { } pragma(mangle, "func", "mangle") void func_too_many_arguments(); pragma(mangle, "var", "mangle") int var_too_many_arguments; pragma(mangle, T) void func_arg1_not_a_string(); pragma(mangle, A) int var_arg1_not_a_string; pragma(mangle, "too_many_declarations") { nothrow pure: void func1(); @nogc: extern(C++) void func2(); } pragma(mangle, "struct", "mangle") struct arg2_must_be_symbol { } pragma(mangle, "struct", F) struct struct_wrong_symbol { } pragma(mangle, "class", F) class class_wrong_symbol { } pragma(mangle, F(), T) struct arg1_not_ctfe_string { } pragma(mangle, T, F()) struct arg2_not_ctfe_string { } pragma(mangle, V, T) struct arg1_not_string { } pragma(mangle, T, V) struct arg2_not_string { } pragma(mangle, T, T) struct arg2_expect_string { } pragma(mangle, int) struct arg1_not_class_or_struct { } pragma(mangle, "struct", A) struct arg2_not_class_or_struct { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failcstuff4b.i0000644000175000017500000000033715205374123022156 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/failcstuff4b.i(605): Error: invalid flag for line marker directive --- */ /****************************************************/ #line 605 #650 "fail_compilation/failcstuff4.c" invalid ./ldc-1.42.0-src/tests/dmd/fail_compilation/deprecated6760.d0000644000175000017500000000100115205374123022205 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/deprecated6760.d(13): Deprecation: `deprecated6760.Foo.opEquals` cannot be annotated with `@disable` because it is overriding a function in the base class fail_compilation/deprecated6760.d(18): Deprecation: `deprecated6760.Bar.opEquals` cannot be marked as `deprecated` because it is overriding a function in the base class --- */ class Foo { @disable override bool opEquals(Object); } class Bar { deprecated override bool opEquals(Object); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail306.d0000644000175000017500000000024415205374123020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail306.d(11): Error: cannot perform array operations on `void[]` arrays --- */ void bar() { void [] x; x[] = -x[]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11503b.d0000644000175000017500000000044615205374123021245 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11503b.d(17): Error: cannot implicitly convert expression `makes()` of type `immutable(int[])` to `int[]` --- */ immutable int[] x = [1, 2, 3]; auto makes() pure { return x; } int main() { auto a = x; int[] b = makes(); return b[1]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/enum9921.d0000644000175000017500000000054415205374123021066 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/enum9921.d(9): Error: enum `enum9921.X` base type must not be `void` fail_compilation/enum9921.d(11): Error: enum `enum9921.Z` base type must not be `void` fail_compilation/enum9921.d(13): Error: variable `enum9921.x` - manifest constants must have initializers --- */ enum X : void; enum Z : void { Y }; enum int x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/systemvariables_struct.d0000644000175000017500000000365315205374123024422 0ustar fabiofabio/* REQUIRED_ARGS: -preview=systemVariables TEST_OUTPUT: --- fail_compilation/systemvariables_struct.d(31): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function fail_compilation/systemvariables_struct.d(32): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function fail_compilation/systemvariables_struct.d(33): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function fail_compilation/systemvariables_struct.d(36): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function fail_compilation/systemvariables_struct.d(37): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function fail_compilation/systemvariables_struct.d(38): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function fail_compilation/systemvariables_struct.d(54): Error: accessing `@system` field `S2.syst` is not allowed in a `@safe` function fail_compilation/systemvariables_struct.d(55): Error: accessing `@system` field `S2.syst` is not allowed in a `@safe` function fail_compilation/systemvariables_struct.d(56): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function fail_compilation/systemvariables_struct.d(57): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function --- */ // http://dlang.org/dips/1035 struct S { @system S* syst; @safe S* safe; } void aggregate() @safe { S s0; // write access s0.syst = null; __traits(getMember, s0, "syst") = null; s0.tupleof[0] = null; // read access auto a0 = s0.syst; auto a1 = __traits(getMember, s0, "syst"); auto a2 = s0.tupleof[0]; S s1; s1 = s0; // allowed } struct S2 { @system S syst; @safe S safe; } @safe S2 gs2; void aggregate2() @safe { gs2.syst.syst = null; gs2.syst.safe = null; gs2.safe.syst = null; gs2.safe.syst.safe = null; gs2.safe.safe = null; // allowed } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag_template_this.d0000644000175000017500000000065715205374123023430 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/diag_template_this.d(1): Error: identifier expected for template `this` parameter fail_compilation/diag_template_this.d(1): Error: found `this` when expecting `(` fail_compilation/diag_template_this.d(1): Error: semicolon expected following function declaration, not `(` fail_compilation/diag_template_this.d(1): Error: declaration expected, not `)` --- */ #line 1 void func1(this this)() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail2789.d0000644000175000017500000000524015205374123021040 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=18385 TEST_OUTPUT: --- fail_compilation/fail2789.d(15): Error: function `fail2789.A2789.m()` conflicts with previous declaration at fail_compilation/fail2789.d(10) --- */ #line 7 class A2789 { int m() { return 1; } float m() // conflict { return 2.0; } float m() const // doen't conflict { return 3.0; } static void m() // no conflict { } } /* TEST_OUTPUT: --- fail_compilation/fail2789.d(49): Error: function `fail2789.f4()` conflicts with previous declaration at fail_compilation/fail2789.d(48) fail_compilation/fail2789.d(55): Error: function `fail2789.f6()` conflicts with previous declaration at fail_compilation/fail2789.d(54) --- */ void f1(); void f1() {} // ok void f2() {} void f2(); // ok void f3(); void f3(); // ok void f4() {} void f4() {} // conflict void f5() @safe {} void f5() @system {} // no conflict because of attribute based overloading in in extern(D) auto f6() { return 10; } // int() auto f6() { return ""; } // string(), conflict /* TEST_OUTPUT: --- fail_compilation/fail2789.d(67): Error: function `fail2789.f_ExternC1()` conflicts with previous declaration at fail_compilation/fail2789.d(66) fail_compilation/fail2789.d(70): Error: function `fail2789.f_ExternC2` cannot overload `extern(C)` function at fail_compilation/fail2789.d(69) fail_compilation/fail2789.d(73): Error: function `fail2789.f_ExternC3` cannot overload `extern(C)` function at fail_compilation/fail2789.d(72) --- */ extern(C) void f_ExternC1() {} extern(C) void f_ExternC1() {} // conflict extern(C) void f_ExternC2() {} extern(C) void f_ExternC2(int) {} // conflict extern(C) void f_ExternC3(int) {} extern(C) void f_ExternC3() {} // conflict extern (D) void f_MixExtern1() {} extern (C) void f_MixExtern1() {} // no conflict because of different mangling extern (D) void f_MixExtern2(int) {} extern (C) void f_MixExtern2() {} // no error extern (C) void f_ExternC4(int sig); extern (C) void f_ExternC4(int sig) @nogc; // no error extern (C) void f_ExternC5(int sig) {} extern (C) void f_ExternC5(int sig) @nogc; // no error extern (C) void f_ExternC6(int sig); extern (C) void f_ExternC6(int sig) @nogc {} // no error /* TEST_OUTPUT: --- fail_compilation/fail2789.d(103): Error: function `fail2789.mul14147(const(int[]) left, const(int[]) right)` conflicts with previous declaration at fail_compilation/fail2789.d(99) --- */ struct S14147(alias func) { } pure auto mul14147(const int[] left, const int[] right) { S14147!(a => a) s; } pure auto mul14147(const int[] left, const int[] right) { S14147!(a => a) s; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/switch_skip.d0000644000175000017500000000157615205374123022132 0ustar fabiofabio/* REQUIRED_ARGS: -verrors=context TEST_OUTPUT: --- fail_compilation/switch_skip.d(22): Error: `switch` skips declaration of variable `switch_skip.test3.j` switch (i) ^ fail_compilation/switch_skip.d(26): declared here int j; ^ fail_compilation/switch_skip.d(39): Error: `switch` skips declaration of variable `switch_skip.test.z` final switch(n) ^ fail_compilation/switch_skip.d(41): declared here int z = 5; ^ --- */ void test3(int i) { switch (i) { case 1: { int j; case 2: ++j; break; } default: break; } } // https://issues.dlang.org/show_bug.cgi?id=18858 int test(int n) { final switch(n) { int z = 5; enum e = 6; case 1: int y = 2; return y; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail106.d0000644000175000017500000000037315205374123020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail106.d(12): Error: cannot modify `immutable` expression `"ABC"[2]` --- */ // https://issues.dlang.org/show_bug.cgi?id=239 // Internal error: changing string literal elements void main() { "ABC"[2] = 's'; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13701.d0000644000175000017500000000100515205374123021075 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail13701.d(16): Error: cannot modify `immutable` expression `this.aa[10]` fail_compilation/fail13701.d(23): Error: cannot modify `immutable` expression `aa[10]` fail_compilation/fail13701.d(24): Error: cannot modify `immutable` expression `aa[10]` --- */ struct S { immutable(int)[int] aa; this(int n) { aa[10] = 20; // initializing aa[10] = 30; // assignment } } void main() { immutable(int)[int] aa; aa[10] = 20; aa[10]++; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9635.d0000644000175000017500000000057015205374123021027 0ustar fabiofabio// REQUIRED_ARGS: -m32 /* TEST_OUTPUT: --- fail_compilation/diag9635.d(17): Error: accessing non-static variable `i` requires an instance of `Foo` fail_compilation/diag9635.d(18): Error: calling non-static function `foo` requires an instance of type `Foo` --- */ struct Foo { int i; void foo()() { } static void bar() { i = 4; foo(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice15092.d0000644000175000017500000000104415205374123020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice15092.d(13): Error: struct `ice15092.A.S` conflicts with struct `ice15092.A.S` at fail_compilation/ice15092.d(12) fail_compilation/ice15092.d(16): Error: class `ice15092.A.C` conflicts with class `ice15092.A.C` at fail_compilation/ice15092.d(15) fail_compilation/ice15092.d(19): Error: interface `ice15092.A.I` conflicts with interface `ice15092.A.I` at fail_compilation/ice15092.d(18) --- */ class A { struct S {} struct S {} class C {} class C {} interface I {} interface I {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10688.d0000644000175000017500000000055015205374123021105 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10688.d(12): Error: function `diag10688.Bar.foo` `private` method is not virtual and cannot override fail_compilation/diag10688.d(14): Error: function `diag10688.Bar.bar` `package` method is not virtual and cannot override --- */ class Bar { private: override void foo() { } package: override void bar() { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/deprecate12979d.d0000644000175000017500000000037015205374123022306 0ustar fabiofabio /* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/deprecate12979d.d(11): Error: executing an `asm` statement without `@trusted` annotation is not allowed in a `@safe` function --- */ void foo() @safe { asm { ret; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_arrayop3a.d0000644000175000017500000000127615205374123022474 0ustar fabiofabio/* REQUIRED_ARGS: -o- TEST_OUTPUT: ---- $p:core/internal/array/operations.d$($n$): Error: static assert: "Binary `*` not supported for types `X` and `X`." $p:core/internal/array/operations.d$($n$): instantiated from here: `typeCheck!(true, X, X, X, "*", "=")` $p:object.d$($n$): instantiated from here: `arrayOp!(X[], X[], X[], "*", "=")` fail_compilation/fail_arrayop3a.d(19): instantiated from here: `_arrayOp!(X[], X[], X[], "*", "=")` ---- */ void test11376() { struct X { } auto x1 = [X()]; auto x2 = [X()]; auto x3 = [X()]; x1[] = x2[] * x3[]; string[] s1; string[] s2; s2[] += s1[]; int*[] pa1; int*[] pa2; pa1[] *= pa2[]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail51.d0000644000175000017500000000032315205374123020651 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail51.d(11): Error: interface `fail51.B` circular inheritance of interface --- */ // interface A { void f(); } interface A : B { void f(); } interface B : A { void g(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/malformed_cmain.c0000644000175000017500000000071515205374123022711 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/malformed_cmain.c(12): Error: function `malformed_cmain.main` parameters must match one of the following signatures fail_compilation/malformed_cmain.c(12): `main()` fail_compilation/malformed_cmain.c(12): `main(int argc, char** argv)` fail_compilation/malformed_cmain.c(12): `main(int argc, char** argv, char** environ)` [POSIX extension] --- */ int main(int argc, char** argv, ...) { return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9861.d0000644000175000017500000000034615205374123021031 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9861.d(8): Error: no property `epsilon` for type `int` fail_compilation/diag9861.d(9): while looking for match for `Foo!int` --- */ struct Foo(T, real x = T.epsilon) {} Foo!(int) q; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4269c.d0000644000175000017500000000035515205374123021200 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4269c.d(11): Error: undefined identifier `B` fail_compilation/fail4269c.d(12): Error: undefined identifier `B` --- */ enum bool WWW = is(typeof(A.x)); class A { B blah; void foo(B b){} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/finalswitch.d0000644000175000017500000000400315205374123022102 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/finalswitch.d(37): Error: missing cases for `enum` members in `final switch`: fail_compilation/finalswitch.d(37): `B` fail_compilation/finalswitch.d(55): Error: missing cases for `enum` members in `final switch`: fail_compilation/finalswitch.d(55): `b` fail_compilation/finalswitch.d(69): Error: missing cases for `enum` members in `final switch`: fail_compilation/finalswitch.d(69): `B` fail_compilation/finalswitch.d(87): Error: missing cases for `enum` members in `final switch`: fail_compilation/finalswitch.d(87): `m3` fail_compilation/finalswitch.d(87): `m4` fail_compilation/finalswitch.d(87): `m5` fail_compilation/finalswitch.d(87): `m6` fail_compilation/finalswitch.d(87): `m7` fail_compilation/finalswitch.d(87): `m9` fail_compilation/finalswitch.d(92): Error: missing cases for `enum` members in `final switch`: fail_compilation/finalswitch.d(92): `m1` fail_compilation/finalswitch.d(92): `m2` fail_compilation/finalswitch.d(92): `m3` fail_compilation/finalswitch.d(92): `m4` fail_compilation/finalswitch.d(92): `m5` fail_compilation/finalswitch.d(92): `m6` fail_compilation/finalswitch.d(92): ... (4 more, -v to show) ... --- */ // https://issues.dlang.org/show_bug.cgi?id=4517 enum E : ushort { A, B } void test4517() { E e; final switch(e) { case E.A: break; } } // https://issues.dlang.org/show_bug.cgi?id=9368 enum E1 { a, b } void test9368() { alias E1 F; F f; final switch (f) { case F.a: } } enum G { A,B,C } void test286() { G e; final switch (e) { case G.A: // case G.B: case G.C: {} } } // https://issues.dlang.org/show_bug.cgi?id=22038 enum H { m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, } void test22038() { final switch (H.init) { case H.m1, H.m2, H.m8, H.m10: break; } final switch (H.init) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/obsolete_body.d0000644000175000017500000000032215205374123022420 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/obsolete_body.d(11): Error: usage of identifer `body` as a keyword is obsolete. Use `do` instead. --- */ @__edition_latest_do_not_use module m; void test() in { } body { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail215.d0000644000175000017500000000025115205374123020733 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail215.d(10): Error: function `fail215.b.k` cannot be both `final` and `abstract` --- */ class b { final abstract void k(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failcstuff1.c0000644000175000017500000002154615205374123022010 0ustar fabiofabio// check the expression parser /* TEST_OUTPUT: --- fail_compilation/failcstuff1.c(100): Error: no members for `enum E21962` fail_compilation/failcstuff1.c(101): Error: no members for anonymous enum fail_compilation/failcstuff1.c(152): Error: `;` or `,` expected fail_compilation/failcstuff1.c(153): Error: `void` has no value fail_compilation/failcstuff1.c(153): Error: missing comma fail_compilation/failcstuff1.c(153): Error: `;` or `,` expected fail_compilation/failcstuff1.c(157): Error: identifier not allowed in abstract-declarator fail_compilation/failcstuff1.c(203): Error: storage class not allowed in specifier-qualified-list fail_compilation/failcstuff1.c(204): Error: storage class not allowed in specifier-qualified-list fail_compilation/failcstuff1.c(205): Error: storage class not allowed in specifier-qualified-list fail_compilation/failcstuff1.c(206): Error: storage class not allowed in specifier-qualified-list fail_compilation/failcstuff1.c(207): Error: storage class not allowed in specifier-qualified-list fail_compilation/failcstuff1.c(208): Error: storage class not allowed in specifier-qualified-list fail_compilation/failcstuff1.c(251): Error: identifier or `(` expected fail_compilation/failcstuff1.c(251): Error: expected identifier for declarator fail_compilation/failcstuff1.c(251): Error: expected identifier for declaration fail_compilation/failcstuff1.c(252): Error: identifier or `(` expected fail_compilation/failcstuff1.c(252): Error: expected identifier for declarator fail_compilation/failcstuff1.c(252): Error: expected identifier for declaration fail_compilation/failcstuff1.c(253): Error: identifier or `(` expected fail_compilation/failcstuff1.c(253): Error: expected identifier for declarator fail_compilation/failcstuff1.c(253): Error: expected identifier for declaration fail_compilation/failcstuff1.c(258): Error: identifier or `(` expected fail_compilation/failcstuff1.c(258): Error: expected identifier for declarator fail_compilation/failcstuff1.c(259): Error: identifier or `(` expected fail_compilation/failcstuff1.c(259): Error: expected identifier for declarator fail_compilation/failcstuff1.c(260): Error: identifier or `(` expected fail_compilation/failcstuff1.c(260): Error: expected identifier for declarator fail_compilation/failcstuff1.c(301): Error: illegal type combination fail_compilation/failcstuff1.c(352): Error: found `2` when expecting `:` fail_compilation/failcstuff1.c(352): Error: found `:` instead of statement fail_compilation/failcstuff1.c(450): Error: static array parameters are not supported fail_compilation/failcstuff1.c(450): Error: static or type qualifier used in non-outermost array type derivation fail_compilation/failcstuff1.c(451): Error: static or type qualifier used in non-outermost array type derivation fail_compilation/failcstuff1.c(451): Error: array type has incomplete element type `int[0]` fail_compilation/failcstuff1.c(452): Error: array type has incomplete element type `int[0]` fail_compilation/failcstuff1.c(453): Error: array type has incomplete element type `int[0]` fail_compilation/failcstuff1.c(454): Error: found `const` when expecting `,` fail_compilation/failcstuff1.c(458): Error: static array parameters are not supported fail_compilation/failcstuff1.c(458): Error: static or type qualifier used outside of function prototype fail_compilation/failcstuff1.c(459): Error: static or type qualifier used outside of function prototype fail_compilation/failcstuff1.c(460): Error: variable length arrays are not supported fail_compilation/failcstuff1.c(460): Error: variable length array used outside of function prototype fail_compilation/failcstuff1.c(461): Error: array type has incomplete element type `int[0]` fail_compilation/failcstuff1.c(462): Error: `=`, `;` or `,` expected to end declaration instead of `const` fail_compilation/failcstuff1.c(502): Error: no type-specifier for parameter fail_compilation/failcstuff1.c(502): Error: found `0` when expecting `,` fail_compilation/failcstuff1.c(502): Error: expected identifier for declarator fail_compilation/failcstuff1.c(504): Error: expected identifier for declarator fail_compilation/failcstuff1.c(551): Error: missing comma or semicolon after declaration of `pluto`, found `p` instead fail_compilation/failcstuff1.c(601): Error: `=`, `;` or `,` expected to end declaration instead of `'s'` fail_compilation/failcstuff1.c(652): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(653): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(654): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(655): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(656): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(657): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(658): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(659): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(660): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(661): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(662): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(663): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(664): Error: multiple storage classes in declaration specifiers fail_compilation/failcstuff1.c(666): Error: `inline` and `_Noreturn` function specifiers not allowed for `_Thread_local` fail_compilation/failcstuff1.c(667): Error: `inline` and `_Noreturn` function specifiers not allowed for `_Thread_local` fail_compilation/failcstuff1.c(700): Error: `auto` and `register` storage class not allowed for global --- */ /********************************/ // https://issues.dlang.org/show_bug.cgi?id=21937 #line 50 void test21962() __attribute__((noinline)) { } /********************************/ // https://issues.dlang.org/show_bug.cgi?id=21962 #line 100 enum E21962 { }; enum { }; /********************************/ // https://issues.dlang.org/show_bug.cgi?id=22028 #line 150 struct S22028 { int init = 1; void vfield nocomma; struct { }; }; int test22028 = sizeof(struct S22028 ident); /********************************/ // https://issues.dlang.org/show_bug.cgi?id=22029 #line 200 struct S22029 { int field; typedef int tfield; extern int efield; static int sfield; _Thread_local int lfield; auto int afield; register int rfield; }; // https://issues.dlang.org/show_bug.cgi?id=22030 #line 250 int; int *; int &; int , int; struct S22030 { int; int *; int &; int, int; int _; }; void test22030(struct S22030, struct S22030*, struct S22030[4]); // https://issues.dlang.org/show_bug.cgi?id=22032 #line 300 struct S22032 { int field; } int test22032; // https://issues.dlang.org/show_bug.cgi?id=22035 #line 350 void test22035() { case 1 2: } // https://issues.dlang.org/show_bug.cgi?id=21932 #line 400 enum ENUM; // https://issues.dlang.org/show_bug.cgi?id=22103 #line 450 void test22103a(int array[4][static 4]); void test22103b(int array[4][restrict]); void test22103c(int array[4][]); void test22103d(int array[][]); void test22103e(int array[4] const); void test22103e() { int array1[static volatile 4]; int array2[restrict 4]; int array3[4][*]; int array4[][]; int array4[4] const; } // https://issues.dlang.org/show_bug.cgi?id=22102 #line 500 void test22102() { int(0); int var1; int(); int var2; } /****************************************************/ #line 550 int * pluto p; // https://issues.dlang.org/show_bug.cgi?id=22909 #line 600 char c22909 = u8's'; /****************************************************/ #line 650 void testDeclSpec() { static extern int aa; static auto int ab; static register int ac; static typedef int ad; extern auto int ah; extern register int ai; extern typedef int aj; auto register int an; auto typedef int ao; auto _Thread_local int ar; register typedef int as; register _Thread_local int av; typedef _Thread_local int ay; // Mixing function-specifiers with _Thread_local inline _Thread_local int ba; _Noreturn _Thread_local int bb; // Valid code as per C11 spec static _Thread_local int ag; extern _Thread_local int am; // Mixing declaration and function specifiers meaningless, but ignored. static inline int ae; static _Noreturn int af; extern inline int ak; extern _Noreturn int al; auto inline int ap; auto _Noreturn int aq; register inline int at; register _Noreturn int au; typedef inline int aw; typedef _Noreturn int ax; inline _Noreturn int az; } /****************************************************/ #line 700 register char *stack_pointer; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ldc_llvm_inline_ir_3.d0000644000175000017500000000061115205374123023636 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ldc_llvm_inline_ir_3.d(18): Error: can't parse inline LLVM IR: `ret i32 %0` ^ value doesn't match function result type 'float' The input string was: `define float @inline.ir.0(i32) { ret i32 %0 }` --- */ pragma(LDC_inline_ir) R inlineIR(string s, R, P...)(P); alias foo = inlineIR!(`ret i32 %0`, float, int); float bar(int p) { return foo(p); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12047.d0000644000175000017500000000124515205374123021105 0ustar fabiofabio// REQUIRED_ARGS: -d /* TEST_OUTPUT: --- fail_compilation/fail12047.d(15): Error: undefined identifier `asdf` fail_compilation/fail12047.d(16): Error: undefined identifier `asdf` fail_compilation/fail12047.d(17): Error: undefined identifier `asdf` fail_compilation/fail12047.d(18): Error: undefined identifier `asdf` fail_compilation/fail12047.d(19): Error: undefined identifier `asdf` fail_compilation/fail12047.d(20): Error: undefined identifier `asdf` fail_compilation/fail12047.d(21): Error: undefined identifier `asdf` --- */ @asdf void func() { } @asdf int var = 1; @asdf enum E : int { a } @asdf struct S {} @asdf class C {} @asdf interface I {} @asdf alias int myint; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22227.d0000644000175000017500000000063015205374123021147 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test22227.d(12): Error: returning scope variable `foo` is not allowed in a `@safe` function fail_compilation/test22227.d(14): Error: returning scope variable `foo` is not allowed in a `@safe` function --- */ int[] foo() @safe { if (scope foo = [1]) return foo; while (scope foo = [1]) return foo; return []; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8178.d0000644000175000017500000000025715205374123021032 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8178.d(14): Error: cannot modify manifest constant `s` --- */ struct Foo { enum string s = ""; } void main() { Foo.s = ""; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15703.d0000644000175000017500000000317115205374123021153 0ustar fabiofabio/* DISABLED: LDC_not_x86 // because of -m32 REQUIRED_ARGS: -m32 TEST_OUTPUT: --- fail_compilation/test15703.d(23): Error: cast from `Object[]` to `uint[]` is not allowed in a `@safe` function fail_compilation/test15703.d(23): Target element type is mutable and source element type contains a pointer fail_compilation/test15703.d(25): Error: cast from `object.Object` to `const(uint)*` is not allowed in a `@safe` function fail_compilation/test15703.d(25): Source type is incompatible with target type containing a pointer fail_compilation/test15703.d(28): Error: cast from `uint[]` to `Object[]` is not allowed in a `@safe` function fail_compilation/test15703.d(28): Target element type contains a pointer fail_compilation/test15703.d(44): Error: cast from `int[]` to `S[]` is not allowed in a `@safe` function fail_compilation/test15703.d(44): Target element type is opaque fail_compilation/test15703.d(45): Error: cast from `S[]` to `int[]` is not allowed in a `@safe` function fail_compilation/test15703.d(45): Source element type is opaque --- */ // https://issues.dlang.org/show_bug.cgi?id=15703 void test() @safe { auto objs = [ new Object() ]; auto longs = cast(size_t[]) objs; // error auto longc = cast(const(size_t)[]) objs; // ok auto longp = cast(const(size_t)*) objs[0]; // error size_t[] al; objs = cast(Object[]) al; // error auto am = cast(int[])[]; } void test2() @safe { const(ubyte)[] a; auto b = cast(const(uint[])) a; } struct S; void opaque() @safe { auto a = [1, 2]; S[] b = cast(S[]) a; a = cast(int[]) b; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15414.d0000644000175000017500000000077315205374123021113 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=15414 // REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail15414.d(20): Deprecation: `__traits(getAttributes)` may only be used for individual functions, not the overload set `fun` fail_compilation/fail15414.d(20): the result of `__traits(getOverloads)` may be used to select the desired function to extract attributes from --- */ @("gigi") void fun() {} @("mimi") void fun(int) {} void main() { auto t = __traits(getAttributes, fun); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17284.d0000644000175000017500000000057715205374123021170 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test17284.d(17): Error: accessing overlapped field `U.c` with pointers is not allowed in a `@safe` function pure nothrow @safe void(U t) --- REQUIRED_ARGS: -preview=bitfields */ // https://issues.dlang.org/show_bug.cgi?id=17284 class C { } union U { C c; int i; } @safe void func(T)(T t) { t.c = new C; } pragma(msg, typeof(func!U)); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10600.d0000644000175000017500000000110015205374123020711 0ustar fabiofabio/* EXTRA_FILES: imports/ice10600a.d imports/ice10600b.d TEST_OUTPUT: --- fail_compilation/ice10600.d(31): Error: template instance `to!(int, double)` does not match template declaration `to(T)` --- */ import imports.ice10600a; import imports.ice10600b; template Tuple(Specs...) { struct Tuple { string toString() { Appender!string w; // issue! return ""; } } } Tuple!T tuple(T...)(T args) { return typeof(return)(); } void main() { auto a = to!int(""); auto b = to!(int, double)(""); tuple(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail341.d0000644000175000017500000000062315205374123020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail341.d(26): Error: struct `fail341.S` is not copyable because field `t` is not copyable fail_compilation/fail341.d(27): Error: function `fail341.foo` cannot be used because it is annotated with `@disable` --- */ struct T { @disable this(this) { } } struct S { T t; } @disable void foo() { } void main() { S s; auto t = s; foo(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag20518.d0000644000175000017500000000103515205374123021075 0ustar fabiofabio// EXTRA_FILES: imports/diag20518a.d imports/diag20518a/b.d /* TEST_OUTPUT: --- fail_compilation/diag20518.d(11): Error: module `diag20518a` from file fail_compilation/imports/diag20518a.d conflicts with package `imports.diag20518a` --- */ import imports.diag20518a.b; // from here 'imports.diag20518a' represents a package and you can optionally // import its package.d with 'import imports.diag20518a;', but anyway import imports.diag20518a; // if 'imports/diag20518a.d' exists it will conflict with it. ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice20545.d0000644000175000017500000000022615205374123020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice20545.d(8): Error: initializer expression expected following colon, not `]` --- */ static initial = [{ }: ]; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17977.d0000644000175000017500000000057715205374123021201 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=15399 REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test17977.d(19): Error: assigning address of variable `__slList$n$` to `elem` with longer lifetime is not allowed in a `@safe` function --- */ @safe: struct List { int* data; ~this(); int* front() return; } void test() { auto elem = List().front; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/disable.d0000644000175000017500000000520615205374123021200 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/disable.d(56): Error: function `disable.DisabledOpAssign.opAssign` cannot be used because it is annotated with `@disable` fail_compilation/disable.d(59): Error: function `disable.DisabledPostblit.opAssign` cannot be used because it is annotated with `@disable` fail_compilation/disable.d(62): Error: function `disable.HasDtor.opAssign` cannot be used because it is annotated with `@disable` fail_compilation/disable.d(66): Error: generated function `disable.Nested!(DisabledOpAssign).Nested.opAssign` cannot be used because it is annotated with `@disable` fail_compilation/disable.d(69): Error: generated function `disable.Nested!(DisabledPostblit).Nested.opAssign` cannot be used because it is annotated with `@disable` fail_compilation/disable.d(72): Error: generated function `disable.Nested!(HasDtor).Nested.opAssign` cannot be used because it is annotated with `@disable` fail_compilation/disable.d(76): Error: generated function `disable.NestedDtor!(DisabledOpAssign).NestedDtor.opAssign` cannot be used because it is annotated with `@disable` fail_compilation/disable.d(79): Error: generated function `disable.NestedDtor!(DisabledPostblit).NestedDtor.opAssign` cannot be used because it is annotated with `@disable` fail_compilation/disable.d(82): Error: generated function `disable.NestedDtor!(HasDtor).NestedDtor.opAssign` cannot be used because it is annotated with `@disable` fail_compilation/disable.d(84): Error: enum member `disable.Enum1.value` cannot be used because it is annotated with `@disable` --- */ struct DisabledOpAssign { int x; @disable void opAssign(const DisabledOpAssign); } struct DisabledPostblit { int x; @disable void opAssign(const DisabledPostblit); // Doesn't require opAssign @disable this(this); } struct HasDtor { int x; @disable void opAssign(const HasDtor); ~this() {} // Makes opAssign mandatory } struct Nested (T) { T b; } struct NestedDtor (T) { T b; // Requires an identity opAssign ~this() {} } enum Enum1 { @disable value } void main () { DisabledOpAssign o; o = DisabledOpAssign(); DisabledPostblit p; p = DisabledPostblit(); HasDtor d; d = HasDtor(); Nested!(DisabledOpAssign) no; no = Nested!(DisabledOpAssign)(); Nested!(DisabledPostblit) np; np = Nested!(DisabledPostblit)(); Nested!(HasDtor) nd; nd = Nested!(HasDtor)(); NestedDtor!(DisabledOpAssign) ndo; ndo = NestedDtor!(DisabledOpAssign)(); NestedDtor!(DisabledPostblit) ndp; ndp = NestedDtor!(DisabledPostblit)(); NestedDtor!(HasDtor) ndd; ndd = NestedDtor!(HasDtor)(); auto v1 = Enum1.value; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test143.d0000644000175000017500000000043315205374123021001 0ustar fabiofabio// REQUIRED_ARGS: -de // https://issues.dlang.org/show_bug.cgi?id=143 // EXTRA_FILES: imports/test143.d /* TEST_OUTPUT: --- fail_compilation/test143.d(20): Error: undefined identifier `x` --- */ module test143; import imports.test143; void bar(int) { } void foo() { bar(x); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16381.d0000644000175000017500000000043015205374123021151 0ustar fabiofabio/* REQUIRED_ARGS: -m64 TEST_OUTPUT: --- fail_compilation/test16381.d(15): Error: cannot take address of expression `foo()` because it is not an lvalue --- */ // https://issues.dlang.org/show_bug.cgi?id=16381 __vector(float[4]) foo(); void bar() { float g = foo().ptr[0]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22.d0000644000175000017500000000032715205374123020653 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail22.d(13): Error: variable name expected after type `char`, not `;` --- */ // infinite loop on DMD0.080 void main() { char[] bug = "Crash"; foreach(char ; bug) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7848.d0000644000175000017500000000300115205374123021032 0ustar fabiofabio// REQUIRED_ARGS: -unittest /* TEST_OUTPUT: --- fail_compilation/fail7848.d(27): Error: `pure` function `fail7848.C.__unittest_L25_C30` cannot call impure function `fail7848.func` fail_compilation/fail7848.d(27): Error: `@safe` function `fail7848.C.__unittest_L25_C30` cannot call `@system` function `fail7848.func` fail_compilation/fail7848.d(21): `fail7848.func` is declared here fail_compilation/fail7848.d(27): Error: `@nogc` function `fail7848.C.__unittest_L25_C30` cannot call non-@nogc function `fail7848.func` fail_compilation/fail7848.d(27): Error: function `fail7848.func` is not `nothrow` fail_compilation/fail7848.d(25): Error: function `fail7848.C.__unittest_L25_C30` may throw but is marked as `nothrow` fail_compilation/fail7848.d(32): Error: `pure` function `fail7848.C.invariant` cannot call impure function `fail7848.func` fail_compilation/fail7848.d(32): Error: `@safe` function `fail7848.C.invariant` cannot call `@system` function `fail7848.func` fail_compilation/fail7848.d(21): `fail7848.func` is declared here fail_compilation/fail7848.d(32): Error: `@nogc` function `fail7848.C.invariant` cannot call non-@nogc function `fail7848.func` fail_compilation/fail7848.d(32): Error: function `fail7848.func` is not `nothrow` fail_compilation/fail7848.d(30): Error: function `fail7848.C.invariant` may throw but is marked as `nothrow` --- */ void func() {} class C { @safe pure nothrow @nogc unittest { func(); } @safe pure nothrow @nogc invariant { func(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail73.d0000644000175000017500000000064315205374123020662 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail73.d(20): Error: `case` not in `switch` statement --- */ // segfault DMD 0.120 // https://www.digitalmars.com/d/archives/digitalmars/D/bugs/4634.html void main() { int u=2; switch(u) { case 1: void j() { case 2: u++; } break; default: break; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail139.d0000644000175000017500000000023615205374123020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail139.d(8): Error: forward reference to `test` --- */ void test(typeof(&test) p) { } void main() { test(null); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3144.d0000644000175000017500000000045015205374123021020 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail3144.d(12): Error: `break` is not inside a loop or `switch` fail_compilation/fail3144.d(15): Error: `break` is not inside a loop or `switch` --- */ void main() { switch (1) default: {} break; final switch (1) case 1: {} break; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail62.d0000644000175000017500000000021315205374123020651 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail62.d(11): Error: version `Foo` defined after use --- */ version (Foo) int x; version = Foo; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ctfe14465.d0000644000175000017500000000063215205374123021120 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ctfe14465.d(19): Error: uncaught CTFE exception `ctfe14465.E("message")` fail_compilation/ctfe14465.d(22): called from here: `foo()` fail_compilation/ctfe14465.d(22): while evaluating: `static assert(foo())` --- */ class E : Exception { this(string msg) { super(msg); } } bool foo() { throw new E("message"); } static assert(foo()); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail184.d0000644000175000017500000000016115205374123020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail184.d(8): Error: redundant attribute `final` --- */ final final int x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/jsonBadField2.d0000644000175000017500000000044515205374123022203 0ustar fabiofabio/* LDC: just a different error msg DISABLED: LDC REQUIRED_ARGS: -Xi=,! TEST_OUTPUT: --- Error: unknown JSON field `-Xi=,!`, expected one of `compilerInfo`, `buildInfo`, `modules`, `semantics` run `dmd` to print the compiler manual run `dmd -man` to open browser on manual --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail8631.d0000644000175000017500000000072615205374123021034 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail8631.d(14): Error: function `shared const int fail8631.D.foo()` does not override any function, did you mean to override `immutable int fail8631.B.foo()`? --- */ class B { int foo() immutable { return 2; } int foo() const { return 2; } } class D : B { override int foo() immutable { return 2; } override int foo() const shared { return 2; } // doesn't override any override int foo() const { return 2; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11532.d0000644000175000017500000000121615205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11532.d(17): Error: cannot pass static arrays to `extern(C)` vararg functions fail_compilation/fail11532.d(18): Error: cannot pass dynamic arrays to `extern(C)` vararg functions fail_compilation/fail11532.d(19): Error: cannot pass static arrays to `extern(C++)` vararg functions fail_compilation/fail11532.d(20): Error: cannot pass dynamic arrays to `extern(C++)` vararg functions --- */ extern(C) void cvararg(int, ...); extern(C++) void cppvararg(int, ...); void main() { int[2] arr = [0x99999999, 0x88888888]; cvararg(0, arr); cvararg(0, arr[]); cppvararg(0, arr); cppvararg(0, arr[]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19898b.d0000644000175000017500000000100415205374123021265 0ustar fabiofabio/* REQUIRED_ARGS: -m64 TEST_OUTPUT: --- fail_compilation/fail19898b.d(17): Error: cannot implicitly convert expression `m` of type `S` to `__vector(int[4])` fail_compilation/fail19898b.d(17): Error: expression `__key$n$ != __limit$n$` of type `__vector(int[4])` does not have a boolean value fail_compilation/fail19898b.d(17): Error: cannot cast expression `__key$n$` of type `__vector(int[4])` to `S` --- */ struct S { int a; } void f (__vector(int[4]) n, S m) { foreach (i; m .. n) cast(void)n; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15667.d0000644000175000017500000000046115205374123021117 0ustar fabiofabio// REQUIRED_ARGS: -o- // EXTRA_FILES: imports/a15667.d /* TEST_OUTPUT: --- fail_compilation/imports/a15667.d(16): Error: basic type expected, not `;` fail_compilation/imports/a15667.d(19): Error: declaration expected following attribute, not end of file --- */ void main() { import imports.a15667; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23786.d0000644000175000017500000000261115205374123021163 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23786.d(22): Error: function `foo` is not callable using argument types `(double)` fail_compilation/test23786.d(22): cannot pass argument `1.0` of type `double` to parameter `int i` fail_compilation/test23786.d(19): `test23786.foo(int i)` declared here fail_compilation/test23786.d(29): Error: function `bar` is not callable using argument types `(int*)` fail_compilation/test23786.d(29): cannot pass argument `& i` of type `int*` to parameter `int i` fail_compilation/test23786.d(26): `test23786.bar(int i)` declared here fail_compilation/test23786.d(37): Error: function `baz` is not callable using argument types `(int*)` fail_compilation/test23786.d(37): cannot pass argument `& i` of type `int*` to parameter `int i` fail_compilation/test23786.d(34): `test23786.baz(int i)` declared here --- */ // https://issues.dlang.org/show_bug.cgi?id=23786 module test23786; void foo(int i) { static assert(__traits(parent, {}).mangleof == "_D9test237863fooFiZv"); __traits(parent, {})(1.0); } void foo(int* p) {} void bar(int i) { static assert(__traits(parent, {}).mangleof == "_D9test237863barFiZv"); __traits(parent, {})(&i); } void bar(int* p) {} void baz(int* p) {} void baz(int i) { static assert(__traits(parent, {}).mangleof == "_D9test237863bazFiZv"); __traits(parent, {})(&i); } void baz(float* p) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/lexer4.d0000644000175000017500000000256715205374123021007 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/lexer4.d(22): Error: unterminated character constant fail_compilation/lexer4.d(24): Error: unterminated character constant fail_compilation/lexer4.d(25): Error: unterminated character constant fail_compilation/lexer4.d(26): Error: binary digit expected, not `2` fail_compilation/lexer4.d(27): Error: octal digit expected, not `8` fail_compilation/lexer4.d(27): Error: octal literals larger than 7 are no longer supported fail_compilation/lexer4.d(28): Error: decimal digit expected, not `a` fail_compilation/lexer4.d(29): Error: repeated integer suffix `U` fail_compilation/lexer4.d(30): Error: exponent required for hex float fail_compilation/lexer4.d(31): Error: lower case integer suffix 'l' is not allowed. Please use 'L' instead fail_compilation/lexer4.d(32): Error: use 'i' suffix instead of 'I' fail_compilation/lexer4.d(34): Error: line number `1234567891234567879` out of range fail_compilation/lexer4.d(36): Error: positive integer argument expected following `#line` fail_compilation/lexer4.d(19): Error: found `"file"` when expecting new line following `#line` directive --- */ static c1 = ' ; static c2 = ''; static c3 = 'a; int i = 0b12; int j = 0128; int k = 12a; int l = 12UU; int f = 0x1234.0; int m = 12l; static n = 12.1I; #line 1234567891234567879 #line whatever #line 18 __FILE__ #line 20 "file" "file" /** asdf *//** asdf2 */ int o; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15191.d0000644000175000017500000000345615205374123021162 0ustar fabiofabio/* TEST_OUTPUT: REQUIRED_ARGS: -preview=dip1000 --- fail_compilation/test15191.d(34): Error: returning `&identity(x)` escapes a reference to local variable `x` fail_compilation/test15191.d(40): Error: returning `&identityPtr(x)` escapes a reference to local variable `x` fail_compilation/test15191.d(46): Error: returning `&identityPtr(x)` escapes a reference to local variable `x` fail_compilation/test15191.d(67): Error: taking address of `scope` variable `x` with pointers is not allowed in a `@safe` function fail_compilation/test15191.d(69): Error: taking address of `scope` variable `x` with pointers is not allowed in a `@safe` function --- */ // Test taking the address of a `ref return` using & and [] operators // https://issues.dlang.org/show_bug.cgi?id=15191 // https://issues.dlang.org/show_bug.cgi?id=22519 // https://issues.dlang.org/show_bug.cgi?id=22539 @safe: ref int foo(return ref int s) { return s; } int* bar(return ref int s) { return &foo(s); } ref int identity(return ref int x) {return x;} ref int* identityPtr(return ref int* x) {return x;} int* addrOfRefEscape() { int x; return &identity(x); } int** addrOfRefSystem() @system { int* x; return &identityPtr(x); } int** addrOfRefTransitive() { int* x; return &identityPtr(x); } int gInt; ref int getGlobalInt() {return gInt;} int* addrOfRefGlobal() { return &getGlobalInt(); } // Slice: ref int*[1] identityArr(return ref scope int*[1] x) { return x; } int*[] sliceOfRefEscape() { int stackVar = 0xFF; scope int*[1] x = [&stackVar]; auto y = identityArr(x)[]; // check transitive scope in assignment cast(void) y; return identityArr(x)[]; // check transitive scope in return statement } // https://issues.dlang.org/show_bug.cgi?id=23079 int** p; ref int* get() @safe { return *p; } int** g1() @safe { return &get(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail44.d0000644000175000017500000000037615205374123020663 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail44.d(18): Error: expression `bar[i]` is `void` and has no value --- */ void Foo() { void[] bar; void[] foo; bar.length = 50; foo.length = 50; for(size_t i=0; i<50; i++) { foo[i] = bar[i]; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11513b.d0000644000175000017500000000037615205374123021075 0ustar fabiofabio/* EXTRA_FILES: imports/ice11513y.d TEST_OUTPUT: --- fail_compilation/imports/ice11513y.d(1): Error: package name 'ice11513b' conflicts with usage as a module name in file fail_compilation/ice11513b.d --- */ module ice11513b; import imports.ice11513y; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail158.d0000644000175000017500000000030015205374123020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail158.d(17): Error: too many initializers for `S` with 2 fields --- */ struct S { int i; int j = 3; } void main() { S s = S( 1, 5, 6 ); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375f.d0000644000175000017500000000050015205374123021171 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375f.d(13): Error: else is dangling, add { } after condition at fail_compilation/fail4375f.d(10) --- */ void main() { version (A) version (B) assert(25.1); else assert(25.2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375d.d0000644000175000017500000000050015205374123021167 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375d.d(14): Error: else is dangling, add { } after condition at fail_compilation/fail4375d.d(10) --- */ void main() { if (true) label2: if (true) assert(15); else assert(16); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9414a.d0000644000175000017500000000631515205374123021175 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9414a.d(47): Error: variable `fail9414a.C.foo.__require.x` cannot modify parameter `x` in contract fail_compilation/fail9414a.d(34): Error: variable `fail9414a.C.foo.__require.x` cannot modify parameter `x` in contract fail_compilation/fail9414a.d(35): Error: variable `fail9414a.C.foo.__require.bar.y` cannot modify parameter `y` in contract fail_compilation/fail9414a.d(40): Error: variable `fail9414a.C.foo.__require.x` cannot modify parameter `x` in contract fail_compilation/fail9414a.d(41): Error: variable `fail9414a.C.foo.__require.bar.y` cannot modify parameter `y` in contract fail_compilation/fail9414a.d(42): Error: variable `fail9414a.C.foo.__require.bar.s` cannot modify result `s` in contract fail_compilation/fail9414a.d(52): Error: variable `fail9414a.C.foo.__require.x` cannot modify parameter `x` in contract fail_compilation/fail9414a.d(75): Error: variable `fail9414a.C.foo.__ensure.x` cannot modify result `x` in contract fail_compilation/fail9414a.d(76): Error: variable `fail9414a.C.foo.__ensure.r` cannot modify result `r` in contract fail_compilation/fail9414a.d(60): Error: variable `fail9414a.C.foo.__ensure.x` cannot modify result `x` in contract fail_compilation/fail9414a.d(61): Error: variable `fail9414a.C.foo.__ensure.r` cannot modify result `r` in contract fail_compilation/fail9414a.d(62): Error: variable `fail9414a.C.foo.__ensure.baz.y` cannot modify parameter `y` in contract fail_compilation/fail9414a.d(67): Error: variable `fail9414a.C.foo.__ensure.x` cannot modify result `x` in contract fail_compilation/fail9414a.d(68): Error: variable `fail9414a.C.foo.__ensure.r` cannot modify result `r` in contract fail_compilation/fail9414a.d(69): Error: variable `fail9414a.C.foo.__ensure.baz.y` cannot modify parameter `y` in contract fail_compilation/fail9414a.d(70): Error: variable `fail9414a.C.foo.__ensure.baz.s` cannot modify result `s` in contract fail_compilation/fail9414a.d(81): Error: variable `fail9414a.C.foo.__ensure.x` cannot modify result `x` in contract fail_compilation/fail9414a.d(82): Error: variable `fail9414a.C.foo.__ensure.r` cannot modify result `r` in contract --- */ class C { int foo(int x) in { int a; int bar(int y) in { x = 10; // err y = 10; // err a = 1; // OK } out(s) { x = 10; // err y = 10; // err s = 10; // err a = 1; // OK } do { x = 10; // err y = 1; // OK a = 1; // OK return 2; } x = 10; // err } out(r) { int a; int baz(int y) in { x = 10; // err r = 10; // err y = 10; // err a = 1; // OK } out(s) { x = 10; // err r = 10; // err y = 10; // err s = 10; // err a = 1; // OK } do { x = 10; // err r = 10; // err y = 1; // OK a = 1; // OK return 2; } x = 10; // err r = 10; // err } do { return 1; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag14876.d0000644000175000017500000000165415205374123021116 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag14876.d(17): Deprecation: class `diag14876.Dep` is deprecated fail_compilation/diag14876.d(18): Deprecation: class `diag14876.Dep` is deprecated fail_compilation/diag14876.d(19): Deprecation: class `diag14876.Dep` is deprecated fail_compilation/diag14876.d(20): Deprecation: class `diag14876.Dep` is deprecated fail_compilation/diag14876.d(21): Deprecation: class `diag14876.Dep` is deprecated fail_compilation/diag14876.d(22): Deprecation: class `diag14876.Dep` is deprecated fail_compilation/diag14876.d(23): Deprecation: class `diag14876.Dep` is deprecated fail_compilation/diag14876.d(23): Error: can only slice type sequences, not `diag14876.Dep` --- */ deprecated class Dep { class Mem {} } alias X1 = Foo!(Dep[]); alias X2 = Foo!(Dep[1]); alias X3 = Foo!(Dep[int]); alias X4 = Foo!(int[Dep]); alias X5 = Foo!(Dep*); alias X6 = Foo!(Dep.Mem); alias X7 = Foo!(Dep[3..4]); template Foo(T) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice17831.d0000644000175000017500000000375015205374123020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice17831.d(23): Error: `case` variables have to be `const` or `immutable` fail_compilation/ice17831.d(23): Error: `case` variable `i` declared at fail_compilation/ice17831.d(21) cannot be declared in `switch` body fail_compilation/ice17831.d(37): Error: `case` variables have to be `const` or `immutable` fail_compilation/ice17831.d(37): Error: `case` variable `i` declared at fail_compilation/ice17831.d(35) cannot be declared in `switch` body fail_compilation/ice17831.d(52): Error: `case` variables have to be `const` or `immutable` fail_compilation/ice17831.d(52): Error: `case` variable `i` declared at fail_compilation/ice17831.d(49) cannot be declared in `switch` body fail_compilation/ice17831.d(65): Error: `case` variables have to be `const` or `immutable` fail_compilation/ice17831.d(65): Error: `case` variable `i` declared at fail_compilation/ice17831.d(64) cannot be declared in `switch` body fail_compilation/ice17831.d(77): Error: `case` variables have to be `const` or `immutable` fail_compilation/ice17831.d(77): Error: `case` variable `i` declared at fail_compilation/ice17831.d(76) cannot be declared in `switch` body --- */ void test17831a() { switch (0) { foreach (i; 0 .. 5) { case i: break; } default: break; } } void test17831b() { switch (0) { for (int i = 0; i < 5; i++) { case i: break; } default: break; } } void test17831c() { switch (0) { int i = 0; while (i++ < 5) { case i: break; } default: break; } } void test17831d() { switch (0) { int i = 0; case i: break; default: break; } } void test17831e() { switch (0) { static int i = 0; case i: break; default: break; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15373.d0000644000175000017500000000102115205374123021146 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test15373.d(21): Error: runtime type information is not supported for `extern(C++)` classes --- */ // https://issues.dlang.org/show_bug.cgi?id=15373 // Using `typeid` on an `extern(C++) class` type is ok as it is evaluated at compile-time // See test/runnable/test15373.d // Using `typeid` on an `extern(C++) class` instance is not ok because `extern(C++) class` // instances are not rooted in `Object` extern(C++) class C { } void foo() { C c = new C(); auto ti = typeid(c); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag6373.d0000644000175000017500000000057615205374123021031 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/diag6373.d(15): Error: class `diag6373.Bar` use of `diag6373.Foo.method(double x)` is hidden by `Bar`; use `alias method = Foo.method;` to introduce base class overload set --- */ class Foo { void method(int x) { } void method(double x) { } } class Bar : Foo { override void method(int x) { } } void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17722a.d0000644000175000017500000000046715205374123021260 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17722a.d(12): Error: static assert: `__traits(compiles, a1 && a2)` is false --- */ // https://issues.dlang.org/show_bug.cgi?id=17722 void fail17722a() { byte[16] a1, a2; static assert(__traits(compiles, a1 && a2)); // diagnostic was (__error) && (__error) } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6592.sh0000755000175000017500000000031015205374123021217 0ustar fabiofabio#!/usr/bin/env bash ! $DMD -c ${EXTRA_FILES}/fail6592.d -H -Hf${RESULTS_DIR}/fail_compilation/fail6592.di 2> /dev/null if [ -f ${RESULTS_DIR}/fail_compilation/fail6592.di ]; then exit 1; fi exit 0 ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21092.d0000644000175000017500000000152515205374123021106 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21092 /* TEST_OUTPUT: --- fail_compilation/fail21092.d(19): Error: using the result of a comma expression is not allowed fail_compilation/fail21092.d(19): Error: using `*` on an array is no longer supported; use `*(T , U).ptr` instead fail_compilation/fail21092.d(19): Error: `*(T , cast(real*)U)` has no effect fail_compilation/fail21092.d(26): Error: using the result of a comma expression is not allowed fail_compilation/fail21092.d(26): Error: using `*` on an array is no longer supported; use `*(w , SmallStirlingCoeffs).ptr` instead fail_compilation/fail21092.d(26): Error: `*(w , cast(real*)SmallStirlingCoeffs)` has no effect --- */ real[] T; real[] U = []; real erf() { *(T, U); } real gammaStirling() { static real[] SmallStirlingCoeffs = []; real w; *(w, SmallStirlingCoeffs); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9494.d0000644000175000017500000000067515205374123020674 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9494.d(10): Error: circular reference to variable `ice9494.test` fail_compilation/ice9494.d(14): Error: circular reference to variable `ice9494.Foo.test` fail_compilation/ice9494.d(19): Error: circular reference to variable `ice9494.Bar.test` --- */ int[test] test; // stack overflow class Foo { int[this.test] test; // stack overflow } struct Bar { int[this.test] test; // stack overflow } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ldc_diag8425.d0000644000175000017500000000032015205374123021636 0ustar fabiofabio/* REQUIRED_ARGS: -m64 -o- PERMUTE_ARGS: TEST_OUTPUT: --- fail_compilation/ldc_diag8425.d(10): Error: T in __vector(T) must be a static array, not `void` --- */ alias a = __vector(void); // not static array ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3581b.d0000644000175000017500000000034715205374123021174 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail3581b.d(9): Error: function `fail3581b.B.f` `private` method is not virtual and cannot override --- */ class A { void f() {} } class B : A { private override void f() {}; } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test19097.d0000644000175000017500000000602715205374123021170 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 * TEST_OUTPUT: --- fail_compilation/test19097.d(44): Error: returning scope variable `s` is not allowed in a `@safe` function fail_compilation/test19097.d(48): Error: returning scope variable `s1` is not allowed in a `@safe` function fail_compilation/test19097.d(77): Error: assigning scope variable `z` to `ref` variable `refPtr` with longer lifetime is not allowed in a `@safe` function fail_compilation/test19097.d(108): Error: returning scope variable `s4` is not allowed in a `@safe` function fail_compilation/test19097.d(126): Error: returning scope variable `s5c` is not allowed in a `@safe` function fail_compilation/test19097.d(130): Error: returning scope variable `s5m` is not allowed in a `@safe` function fail_compilation/test19097.d(147): Error: returning scope variable `s6c` is not allowed in a `@safe` function fail_compilation/test19097.d(151): Error: returning scope variable `s6m` is not allowed in a `@safe` function --- */ // Test extended return-scope / return-ref semantics, e.g. assigning to `this` or the first parameter // https://issues.dlang.org/show_bug.cgi?id=19097 @safe: void betty(ref scope int* r, return scope int* p) { r = p; } void freddy(out scope int* r, return scope int* p) { r = p; } struct S { int* a; this(return scope int* b) scope { a = b; } int* c; void mem(return scope int* d) scope { c = d; } } S thorin() { int i; S s = S(&i); // should infer scope for s return s; // so this should error S s1; s1.mem(&i); return s1; } /************************/ struct S2(T) { int* p; void silent(lazy void dg); void foo() { char[] name; silent(name = parseType()); } char[] parseType(char[] name = null); } S2!int s2; /************************/ struct S3 { int* ptr; void assign(ref int* refPtr, return scope int* z) scope @safe { this.ptr = z; // allowed, first ref refPtr = z; // should not be allowed } } int* escape() @safe { int local; S3 escapeThis; int* escapeRef; escapeThis.assign(escapeRef, &local); return escapeRef; } /************************/ // https://issues.dlang.org/show_bug.cgi?id=22837 struct S4 { int* p; this(int dummy, return scope int* p) @safe { this.p = p; } } int* escape2() { int x; auto s4 = S4(0, &x); return s4.p; } /************************/ // https://issues.dlang.org/show_bug.cgi?id=22801 struct S5 { int* a; this(return ref int b) { a = &b; } int* c; void mem(return ref int d) scope { c = &d; } } S5 frerin() { int i; S5 s5c = S5(i); // should infer scope for s return s5c; // so this should error S5 s5m; s5m.mem(i); return s5m; } struct S6 { int** a; this(return ref int* b) { a = &b; } int** c; void mem(return ref int* d) scope { c = &d; } } S6 dis() { int* i = null; S6 s6c = S6(i); // should infer scope for s return s6c; // so this should error S6 s6m; s6m.mem(i); return s6m; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail159.d0000644000175000017500000000054315205374123020746 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail159.d(24): Error: static assert: `foo(S(1, 5), S(1, 4)) == 0` is false --- */ struct S { int i; int j = 3; int opEquals(S e2) { return 1; } } int foo(S s1, S s2) { return s1 == s2; } void main() { static assert(foo( S(1,5), S(1,5) ) == 1); static assert(foo( S(1,5), S(1,4) ) == 0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/betterc.d0000644000175000017500000000077315205374123021231 0ustar fabiofabio/* REQUIRED_ARGS: -betterC * TEST_OUTPUT: --- fail_compilation/betterc.d(12): Error: cannot use `throw` statements with `-fno-exceptions` fail_compilation/betterc.d(17): Error: cannot use try-catch statements with `-betterC` fail_compilation/betterc.d(29): Error: `TypeInfo` cannot be used with `-betterC` --- */ void test() { throw new Exception("msg"); } void test2() { try { test(); } catch (Exception e) { } } void test3() { int i; auto ti = typeid(i); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23626b.d0000644000175000017500000000125315205374123021253 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail23626b.d(26): Error: `fail23626b.AmbigOpApply.opApply` called with argument types `(int delegate(int i) pure nothrow @nogc @system)` matches multiple overloads after qualifier conversion: fail_compilation/fail23626b.d(12): `fail23626b.AmbigOpApply.opApply(int delegate(int) dg)` and: fail_compilation/fail23626b.d(17): `fail23626b.AmbigOpApply.opApply(int delegate(int) dg)` --- */ struct AmbigOpApply { int opApply(int delegate(int) dg) { return 0; } int opApply(int delegate(int) dg) @system { return 0; } } void ambigOpApply() @system { AmbigOpApply sa; foreach (int i; sa) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice8742.d0000644000175000017500000000041315205374123020655 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice8742.d(15): Error: class `ice8742.main.__anonclass1` is nested within `main`, but super class `D` is nested within `C` --- */ class C { class D { } } void main ( ) { auto c = new C; auto d = c.new class C.D { }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12636.d0000644000175000017500000000051415205374123021107 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail12636.d(13): Error: C++ class `fail12636.C` cannot implement D interface `fail12636.D` --- */ interface D { void foo(); } extern(C++) class C : D { extern(D) override void foo() { } } void main() { auto c = new C; c.foo(); // works D d = c; d.foo(); // segfault } ./ldc-1.42.0-src/tests/dmd/fail_compilation/deprecatedImports.d0000644000175000017500000000234215205374123023251 0ustar fabiofabio/* REQUIRED_ARGS: -de EXTRA_FILES: imports/deprecatedImporta.d imports/deprecatedImportb.d TEST_OUTPUT: ---- fail_compilation/deprecatedImports.d(19): Deprecation: alias `deprecatedImporta.foo` is deprecated - Please import deprecatedImportb directly! fail_compilation/deprecatedImports.d(21): Deprecation: alias `deprecatedImporta.bar` is deprecated - Please import deprecatedImportb directly! fail_compilation/deprecatedImports.d(23): Deprecation: alias `deprecatedImporta.AliasSeq` is deprecated - Please import deprecatedImportb directly! fail_compilation/deprecatedImports.d(27): Deprecation: alias `deprecatedImporta.S` is deprecated - Please import deprecatedImportb directly! fail_compilation/deprecatedImports.d(29): Deprecation: alias `deprecatedImporta.C` is deprecated - Please import deprecatedImportb directly! fail_compilation/deprecatedImports.d(31): Deprecation: alias `deprecatedImporta.I` is deprecated - Please import deprecatedImportb directly! fail_compilation/deprecatedImports.d(25): Deprecation: alias `deprecatedImporta.E` is deprecated - Please import deprecatedImportb directly! ---- */ import imports.deprecatedImporta; alias f = foo; alias b = bar!(int); alias Types = AliasSeq!(int); int x = E; S s; C c; I i; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9537.d0000644000175000017500000000062015205374123021033 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9537.d(26): Error: cannot take address of expression `foo(tuple(1, 2))` because it is not an lvalue --- */ struct Tuple(T...) { T field; alias field this; } Tuple!T tuple(T...)(T args) { return Tuple!T(args); } auto ref foo(T)(auto ref T t) { return t[0]; // t[0] is deduced to non-ref } void main() { int* p = &foo(tuple(1, 2)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9063.d0000644000175000017500000000023515205374123021027 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9063.d(9): Error: static assert: "msg" --- */ @property string bar() { return "msg"; } static assert(false, bar); ./ldc-1.42.0-src/tests/dmd/fail_compilation/scope_class.d0000644000175000017500000000044115205374123022067 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/scope_class.d(12): Error: functions cannot return `scope scope_class.C` --- */ scope class C { int i; } // Notice the use of `scope` here C increment(C c) { c.i++; return c; } void main() { scope C c = new C(); c.increment(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag12480.d0000644000175000017500000000032615205374123021076 0ustar fabiofabio// REQUIRED_ARGS: -m32 /* TEST_OUTPUT: --- fail_compilation/diag12480.d(12): Error: static assert: `2u == 3u` is false --- */ module diag12480; static immutable arr = ["a", "b"]; static assert(arr.length == 3); ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag15235.d0000644000175000017500000000034715205374123021102 0ustar fabiofabio/* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/diag15235.d(11): Error: too many registers memory operand --- */ void main() { asm { mov [EBX+EBX+EBX], EAX; // prints the same error message 20 times } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/verifyhookexist.d0000644000175000017500000000256115205374123023040 0ustar fabiofabio/* REQUIRED_ARGS: -checkaction=context EXTRA_SOURCES: extra-files/minimal/object.d */ /************************************************************/ /* TEST_OUTPUT: --- fail_compilation/verifyhookexist.d(21): Error: `object.__ArrayCast` not found. The current runtime does not support casting array of structs, or the runtime is corrupt. fail_compilation/verifyhookexist.d(28): Error: `object.__cmp` not found. The current runtime does not support comparing arrays, or the runtime is corrupt. fail_compilation/verifyhookexist.d(32): Error: `object._d_assert_fail` not found. The current runtime does not support generating assert messages, or the runtime is corrupt. fail_compilation/verifyhookexist.d(35): Error: `object.__switch` not found. The current runtime does not support switch cases on strings, or the runtime is corrupt. fail_compilation/verifyhookexist.d(40): Error: `object.__switch_error` not found. The current runtime does not support generating assert messages, or the runtime is corrupt. --- */ struct MyStruct { int a, b; } MyStruct[] castToMyStruct(int[] arr) { return cast(MyStruct[])arr; } void test() { int[] arrA, arrB; bool a = arrA[] == arrB[]; bool b = arrA < arrB; { int x = 1; int y = 1; assert(x == y); } switch ("") { default: break; } final switch (0) { case 1: break; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/no_object.d0000644000175000017500000000072515205374123021540 0ustar fabiofabio/* DFLAGS: LDC: just a different error msg DISABLED: LDC TEST_OUTPUT: --- Error: `object` not found. object.d may be incorrectly installed or corrupt. dmd might not be correctly installed. Run 'dmd -man' for installation instructions. config file: not found --- */ // Due to the empty D FLAGS test variable specified above, only the current // directory is in the import path. Therefore, compilation fails because the compiler // cannot locate object.d ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix19246.d0000644000175000017500000000103715205374123020767 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix19246.d(15): Error: `0b_` isn't a valid integer literal, use `0b0` instead fail_compilation/fix19246.d(16): Error: `0B_` isn't a valid integer literal, use `0B0` instead fail_compilation/fix19246.d(17): Error: `0b` isn't a valid integer literal, use `0b0` instead fail_compilation/fix19246.d(18): Error: `0B` isn't a valid integer literal, use `0B0` instead --- */ // https://issues.dlang.org/show_bug.cgi?id=19246 void foo() { auto a = 0b_; auto b = 0B_; auto c = 0b; auto d = 0B; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/dip22a.d0000644000175000017500000000146115205374123020655 0ustar fabiofabio/* EXTRA_FILES: imports/dip22a.d TEST_OUTPUT: --- fail_compilation/dip22a.d(18): Error: no property `bar` for `new Klass` of type `imports.dip22a.Klass` fail_compilation/imports/dip22a.d(3): class `Klass` defined here fail_compilation/dip22a.d(19): Error: no property `bar` for `Struct()` of type `imports.dip22a.Struct` fail_compilation/imports/dip22a.d(8): struct `Struct` defined here fail_compilation/dip22a.d(20): Error: undefined identifier `bar` in module `imports.dip22a` fail_compilation/dip22a.d(21): Error: no property `bar` for `Template!int` of type `void` fail_compilation/dip22a.d(22): Error: no property `bar` for `12` of type `int` --- */ import imports.dip22a; void test() { new Klass().bar(); Struct().bar(); imports.dip22a.bar(); Template!int.bar(); 12.bar(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/pragmainline.d0000644000175000017500000000032715205374123022242 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/pragmainline.d(8): Error: one boolean expression expected for `pragma(inline)`, not 3 --- */ pragma(inline, 1,2,3) void bar(); pragma(inline, "string") void baz(); // works now ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9414b.d0000644000175000017500000000632315205374123021175 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9414b.d(47): Error: variable `fail9414b.C.foo.__require.x` cannot modify parameter `x` in contract fail_compilation/fail9414b.d(34): Error: variable `fail9414b.C.foo.__require.x` cannot modify parameter `x` in contract fail_compilation/fail9414b.d(35): Error: variable `fail9414b.C.foo.__require.bar.y` cannot modify parameter `y` in contract fail_compilation/fail9414b.d(40): Error: variable `fail9414b.C.foo.__require.x` cannot modify parameter `x` in contract fail_compilation/fail9414b.d(41): Error: variable `fail9414b.C.foo.__require.bar.y` cannot modify parameter `y` in contract fail_compilation/fail9414b.d(42): Error: variable `fail9414b.C.foo.__require.bar.s` cannot modify result `s` in contract fail_compilation/fail9414b.d(52): Error: variable `fail9414b.C.foo.__require.x` cannot modify parameter `x` in contract fail_compilation/fail9414b.d(75): Error: variable `fail9414b.C.foo.__ensure.x` cannot modify result `x` in contract fail_compilation/fail9414b.d(76): Error: variable `fail9414b.C.foo.__ensure.r` cannot modify result `r` in contract fail_compilation/fail9414b.d(60): Error: variable `fail9414b.C.foo.__ensure.x` cannot modify result `x` in contract fail_compilation/fail9414b.d(61): Error: variable `fail9414b.C.foo.__ensure.r` cannot modify result `r` in contract fail_compilation/fail9414b.d(62): Error: variable `fail9414b.C.foo.__ensure.baz.y` cannot modify parameter `y` in contract fail_compilation/fail9414b.d(67): Error: variable `fail9414b.C.foo.__ensure.x` cannot modify result `x` in contract fail_compilation/fail9414b.d(68): Error: variable `fail9414b.C.foo.__ensure.r` cannot modify result `r` in contract fail_compilation/fail9414b.d(69): Error: variable `fail9414b.C.foo.__ensure.baz.y` cannot modify parameter `y` in contract fail_compilation/fail9414b.d(70): Error: variable `fail9414b.C.foo.__ensure.baz.s` cannot modify result `s` in contract fail_compilation/fail9414b.d(81): Error: variable `fail9414b.C.foo.__ensure.x` cannot modify result `x` in contract fail_compilation/fail9414b.d(82): Error: variable `fail9414b.C.foo.__ensure.r` cannot modify result `r` in contract --- */ class C { final int foo(int x) in { int a; int bar(int y) in { x = 10; // err y = 10; // err a = 1; // OK } out(s) { x = 10; // err y = 10; // err s = 10; // err a = 1; // OK } do { x = 10; // err y = 1; // OK a = 1; // OK return 2; } x = 10; // err } out(r) { int a; int baz(int y) in { x = 10; // err r = 10; // err y = 10; // err a = 1; // OK } out(s) { x = 10; // err r = 10; // err y = 10; // err s = 10; // err a = 1; // OK } do { x = 10; // err r = 10; // err y = 1; // OK a = 1; // OK return 2; } x = 10; // err r = 10; // err } do { return 1; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22780.d0000644000175000017500000000037615205374123021116 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22780 /* TEST_OUTPUT: --- fail_compilation/fail22780.d(12): Error: variable `fail22780.test10717.c` reference to `scope class` must be `scope` --- */ scope class C10717 { } void test10717() { C10717 c; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/spell9644.d0000644000175000017500000000244415205374123021244 0ustar fabiofabio// REQUIRED_ARGS: -o- // EXTRA_FILES: imports/spell9644a.d imports/spell9644b.d /* TEST_OUTPUT: --- fail_compilation/spell9644.d(26): Error: undefined identifier `b` fail_compilation/spell9644.d(27): Error: undefined identifier `xx` fail_compilation/spell9644.d(28): Error: undefined identifier `cb`, did you mean variable `ab`? fail_compilation/spell9644.d(29): Error: undefined identifier `bc`, did you mean variable `abc`? fail_compilation/spell9644.d(30): Error: undefined identifier `ccc` fail_compilation/spell9644.d(32): Error: undefined identifier `cor2`, did you mean variable `cor1`? fail_compilation/spell9644.d(33): Error: undefined identifier `pua`, did you mean variable `pub`? fail_compilation/spell9644.d(34): Error: undefined identifier `priw` --- */ import imports.spell9644a; int a; int ab; int abc; int cor1; int main() { cast(void)b; // max distance 0, no match cast(void)xx; // max distance 1, no match cast(void)cb; // max distance 1, match cast(void)bc; // max distance 1, match cast(void)ccc; // max distance 2, match cast(void)cor2; // max distance 1, match "cor1", but not cora from import (bug 13736) cast(void)pua; // max distance 1, match "pub" from import cast(void)priw; // max distance 1, match "priv" from import, but do not report (bug 5839) } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12932.d0000644000175000017500000000056115205374123021110 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail12932.d(11): Error: this array literal causes a GC allocation in `@nogc` function `foo` fail_compilation/fail12932.d(15): Error: this array literal causes a GC allocation in `@nogc` function `foo` --- */ int* foo() @nogc { foreach (ref e; [1,2,3]) { } foreach (ref e; [1,2,3]) { return &e; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail93.d0000644000175000017500000000050015205374123020654 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail93.d(14): Error: variable `i` is shadowing variable `fail93.main.i` fail_compilation/fail93.d(13): declared here --- */ // accepts-valid with DMD0.120. volatile as well as synchronized void main() { int i = 1; synchronized int i = 2; // should fail to compile } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test9150.d0000644000175000017500000000073515205374123021075 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=9150 // Mismatching static array length should be detected in foreach /* TEST_OUTPUT: --- fail_compilation/test9150.d(14): Error: mismatched array lengths 5 and 3 for assignment `row[] = __r$n$[__key$n$]` --- */ void main() { int[3][2] matrix = [ [1,11,111], [2,22,222] ]; foreach (int[5] row; matrix) //if int[3], there is no error. { foreach (x; row) {}//write(x, " "); //writeln(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail313.d0000644000175000017500000000121315205374123020731 0ustar fabiofabio/* EXTRA_FILES: imports/a313.d imports/b313.d imports/pkg313/package.d TEST_OUTPUT: --- fail_compilation/fail313.d(16): Error: undefined identifier `b313` in package `imports`, perhaps add `static import imports.b313;` fail_compilation/fail313.d(23): Error: undefined identifier `core` fail_compilation/fail313.d(28): Error: undefined identifier `pkg313` in package `imports`, perhaps add `static import imports.pkg313;` --- */ module test313; import imports.a313; void test1() { imports.b313.bug(); import imports.b313; imports.b313.bug(); } void test2() { core.stdc.stdio.printf(""); } void test3() { imports.pkg313.bug(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/aliasassign.d0000644000175000017500000000113615205374123022071 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/aliasassign.d(13): Error: `B` must have same parent `Swap!(int, string)` as alias `B` fail_compilation/aliasassign.d(14): Error: `A` must have same parent `Swap!(int, string)` as alias `A` fail_compilation/aliasassign.d(21): Error: template instance `aliasassign.Swap!(int, string)` error instantiating fail_compilation/aliasassign.d(21): while evaluating: `static assert(Swap!(int, string))` --- */ template Swap (alias A, alias B) { alias C = A; B = A; A = B; enum Swap = true; } alias A = int; alias B = string; static assert(Swap!(A, B)); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16193.d0000644000175000017500000000212615205374123021156 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test16193.d(39): Error: function `test16193.abc` is `@nogc` yet allocates closure for `abc()` with the GC fail_compilation/test16193.d(41): delegate `int(int i) => 0` closes over variable `x` fail_compilation/test16193.d(40): `x` declared here --- */ //fail_compilation/test16193.d(22): To enforce `@safe`, the compiler allocates a closure unless `opApply()` uses `scope` //fail_compilation/test16193.d(34): To enforce `@safe`, the compiler allocates a closure unless `opApply()` uses `scope` //fail_compilation/test16193.d(41): To enforce `@safe`, the compiler allocates a closure unless `opApply()` uses `scope` // https://issues.dlang.org/show_bug.cgi?id=16193 struct S { int opApply(int delegate(int) dg) @nogc; } void foo() { int x = 0; foreach(i; S.init) { x++; } } struct T { int opApply(scope int delegate(int) dg) @nogc; } void bar() @nogc { int x = 0; foreach(i; T.init) { x++; } } void abc() @nogc { int x = 0; foreach(i; S.init) { x++; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17502.d0000644000175000017500000000100015205374123021073 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17502.d(13): Error: function `fail17502.Foo.foo` `void` functions have no result fail_compilation/fail17502.d(13): Error: undefined identifier `res` fail_compilation/fail17502.d(17): Error: function `fail17502.Foo.bar` `void` functions have no result fail_compilation/fail17502.d(17): Error: undefined identifier `res` --- */ class Foo { void foo() out (res) { assert(res > 5); } do {} auto bar() out (res) { assert (res > 5); } do { return; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/previewin3.d0000644000175000017500000000104515205374123021665 0ustar fabiofabio/* REQUIRED_ARGS: -preview=in -preview=dip1000 TEST_OUTPUT: ---- fail_compilation/previewin3.d(2): Error: function `foo` is not callable using argument types `(int)` fail_compilation/previewin3.d(2): cannot pass argument `42` of type `int` to parameter `in WithDtor` fail_compilation/previewin3.d(8): `previewin3.foo(in WithDtor)` declared here ---- */ #line 1 void rvalueErrorMsg () { foo(42); } // Add a dtor to ensure things are passed by ref struct WithDtor { ~this() @safe pure nothrow @nogc {} } void foo(in WithDtor) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue21685_main.d0000644000175000017500000000067415205374123022343 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 -Ifail_compilation/imports TEST_OUTPUT: --- fail_compilation/issue21685_main.d(12): Error: constructor `issue21685.E.this` is not accessible from module `issue21685_main` fail_compilation/issue21685_main.d(19): Error: constructor `issue21685.E.this` is not accessible from module `issue21685_main` --- */ import issue21685; void main() { new E; } class F : E { this() { super(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10283.d0000644000175000017500000000045115205374123020730 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=10283 /* TEST_OUTPUT: --- fail_compilation/ice10283.d(14): Error: cannot implicitly convert expression `7` of type `int` to `string` --- */ S10283 blah(S10283 xxx) { return xxx; } S10283 repy = blah(S10283()); struct S10283 { string source = 7; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail97.d0000644000175000017500000000035315205374123020666 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail97.d(11): Error: pragma `lib` is missing a terminating `;` --- */ // https://issues.dlang.org/show_bug.cgi?id=151 import core.stdc.stdio; pragma(lib,"ws2_32.lib")//; class bla{} void main(){} ./ldc-1.42.0-src/tests/dmd/fail_compilation/bug16165.d0000644000175000017500000000130215205374123020746 0ustar fabiofabiovoid 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 `f` 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(1): `bug16165.f(int x, Object y)` declared here fail_compilation/bug16165.d(7): Error: function `f` 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` fail_compilation/bug16165.d(1): `bug16165.f(int x, Object y)` declared here --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail116.d0000644000175000017500000000064115205374123020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail116.d(11): Error: undefined identifier `x` fail_compilation/fail116.d(16): Error: template instance `square!1.2` does not match template declaration `square(_error_ x)` --- */ // https://issues.dlang.org/show_bug.cgi?id=405 // typeof in TemplateParameterList causes compiletime segmentfault template square(typeof(x) x) { const square = x * x; } const b = square!(1.2); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20696.d0000644000175000017500000000076215205374123021165 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test20696.d(106): Error: function `test20696.S!().S.test` cannot retrieve its `.mangleof` while inferring attributes fail_compilation/test20696.d(106): while evaluating `pragma(msg, test.mangleof)` fail_compilation/test20696.d(111): Error: template instance `test20696.S!()` error instantiating --- */ #line 100 // https://issues.dlang.org/show_bug.cgi?id=20696 struct S() { int test() { pragma(msg, test.mangleof); return 3; } } S!() s; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17421.d0000644000175000017500000000127215205374123021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17421.d(14): Error: argument to `__traits(getFunctionVariadicStyle, 1)` is not a function fail_compilation/fail17421.d(14): while evaluating: `static assert(__traits(getFunctionVariadicStyle, 1) == "none")` fail_compilation/fail17421.d(15): Error: argument to `__traits(getFunctionVariadicStyle, int*)` is not a function fail_compilation/fail17421.d(15): while evaluating: `static assert(__traits(getFunctionVariadicStyle, int*) == "none")` --- */ // https://issues.dlang.org/show_bug.cgi?id=17421 alias int* x; static assert(__traits(getFunctionVariadicStyle, 1) == "none"); static assert(__traits(getFunctionVariadicStyle, x) == "none"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag_template_alias.d0000644000175000017500000000066715205374123023553 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/diag_template_alias.d(1): Error: identifier expected for template `alias` parameter fail_compilation/diag_template_alias.d(1): Error: found `alias` when expecting `(` fail_compilation/diag_template_alias.d(1): Error: semicolon expected following function declaration, not `(` fail_compilation/diag_template_alias.d(1): Error: declaration expected, not `)` --- */ #line 1 void func1(alias alias)() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17722b.d0000644000175000017500000000046715205374123021261 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17722b.d(12): Error: static assert: `__traits(compiles, a1 || a2)` is false --- */ // https://issues.dlang.org/show_bug.cgi?id=17722 void fail17722b() { byte[16] a1, a2; static assert(__traits(compiles, a1 || a2)); // diagnostic was (__error) || (__error) } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test5412a.d0000644000175000017500000000044515205374123021231 0ustar fabiofabio/* EXTRA_FILES: imports/test5412a.d imports/test5412b.d TEST_OUTPUT: --- fail_compilation/test5412a.d(11): Error: import `test5412a.A` conflicts with import `test5412a.A` at fail_compilation/test5412a.d(10) --- */ module test5412a; import A = imports.test5412a; import A = imports.test5412b; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9773.d0000644000175000017500000000034615205374123021042 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9773.d(7): Error: cannot create default argument for `ref` / `out` parameter from expression `""` because it is not an lvalue --- */ void f(ref string a = "") { a = "crash and burn"; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/README.md0000644000175000017500000000143615205374123020710 0ustar fabiofabio# Tests for diagnostics on compilation failure Each D file will be compiled and the compilation is expected to fail with exit code 1. The diagnostic emitted must match the predefined diagnostic in the test file, otherwise the test will fail. ## Purpose The point of these files is to test that the compiler produces a correct diagnostic for each error message in the compiler's implementation. A further aim is that when the compiler does fail these tests, the test case should be crafted to make debugging the compiler as straightforward as practical. ## Remarks Every test in this directory is compiled with `-verrors=0` s.t. all error messages will be issued. Refer to [test/README.md](../README.md) for general information and the [test guidelines](../README.md#test-coding-practices). ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19181.d0000644000175000017500000000033115205374123021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19181.d(15): Error: undefined identifier `LanguageError` --- */ struct S { void opDispatch(string name, T)(T arg) { } } void main() { S s; s.foo(LanguageError); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21546.d0000644000175000017500000000347215205374123021161 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test21546.d(113): Error: cannot implicitly convert expression `pc` of type `const(int)* delegate() return` to `int* delegate() return` fail_compilation/test21546.d(114): Error: cannot implicitly convert expression `pc` of type `const(int)* delegate() return` to `immutable(int)* delegate() return` fail_compilation/test21546.d(115): Error: cannot implicitly convert expression `pi` of type `immutable(int)* delegate() return` to `int* delegate() return` fail_compilation/test21546.d(213): Error: cannot implicitly convert expression `dc` of type `const(int) delegate() return ref` to `int delegate() return ref` fail_compilation/test21546.d(214): Error: cannot implicitly convert expression `dc` of type `const(int) delegate() return ref` to `immutable(int) delegate() return ref` fail_compilation/test21546.d(215): Error: cannot implicitly convert expression `di` of type `immutable(int) delegate() return ref` to `int delegate() return ref` fail_compilation/test21546.d(305): Error: cannot implicitly convert expression `[dgi]` of type `immutable(int) delegate() return ref[]` to `int delegate() return ref[]` --- */ // https://issues.dlang.org/show_bug.cgi?id=21546 #line 100 alias Pm = int* delegate() return; alias Pc = const(int)* delegate() return; alias Pi = immutable(int)* delegate() return; void f() { Pm pm; Pc pc; Pi pi; pc = pm; pc = pi; pm = pc; pi = pc; pm = pi; } #line 200 alias DGm = ref int delegate() return; alias DGc = ref const(int) delegate() return; alias DGi = ref immutable(int) delegate() return; void g() { DGm dm; DGc dc; DGi di; dc = dm; dc = di; dm = dc; di = dc; dm = di; } #line 300 void h() { immutable int i = 0; DGi dgi = ref() => i; DGm[] dgms = [ dgi ]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/deprecations_preview_in.d0000644000175000017500000000047315205374123024505 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/deprecations_preview_in.d(1): Deprecation: using `in` parameters with `extern(C)` functions is deprecated fail_compilation/deprecations_preview_in.d(1): parameter `__anonymous_param` declared as `in` here --- */ #line 1 extern(C) void fun1(in char*); ./ldc-1.42.0-src/tests/dmd/fail_compilation/attributediagnostic_pure.d0000644000175000017500000000073615205374123024703 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/attributediagnostic_pure.d(19): Error: `pure` function `D main` cannot call impure function `attributediagnostic_pure.gc` fail_compilation/attributediagnostic_pure.d(14): and executing an `asm` statement without `pure` annotation makes it fail to infer `pure` --- */ // Issue 17374 - Improve inferred attribute error message // https://issues.dlang.org/show_bug.cgi?id=17374 auto gc() { asm {} } void main() pure { gc(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail179.d0000644000175000017500000000035615205374123020752 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail179.d(11): Error: variable `fail179.main.px` cannot be `final`, perhaps you meant `const`? --- */ void main() { int x = 3; final px = &x; *px = 4; auto ppx = &px; **ppx = 5; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3672.d0000644000175000017500000000145615205374123021035 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail3672.d(29): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/fail3672.d(29): Use `core.atomic.atomicOp!"+="(*p, 1)` instead fail_compilation/fail3672.d(33): Error: template `opOpAssign` is not callable using argument types `!("+")(int) shared` fail_compilation/fail3672.d(13): Candidate is: `opOpAssign(string op, T)(T rhs)` --- */ struct SF // should fail { void opOpAssign(string op, T)(T rhs) { } } struct SK // ok { void opOpAssign(string op, T)(T rhs) shared { } } void main() { shared int x; auto p = &x; *p += 1; // fail shared SF sf; auto sfp = &sf; *sfp += 1; // fail shared SK sk; auto skp = &sk; sk += 1; // ok *skp += 1; // ok } ./ldc-1.42.0-src/tests/dmd/fail_compilation/systemvariables_var_init.d0000644000175000017500000000225415205374123024705 0ustar fabiofabio/* REQUIRED_ARGS: -preview=systemVariables TEST_OUTPUT: --- fail_compilation/systemvariables_var_init.d(24): Error: access `@system` variable `ptrEnum` is not allowed in a `@safe` function fail_compilation/systemvariables_var_init.d(16): `ptrEnum` is inferred to be `@system` from its initializer here fail_compilation/systemvariables_var_init.d(25): Error: access `@system` variable `ptrConst` is not allowed in a `@safe` function fail_compilation/systemvariables_var_init.d(17): `ptrConst` is inferred to be `@system` from its initializer here fail_compilation/systemvariables_var_init.d(27): Error: access `@system` variable `ptrVar` is not allowed in a `@safe` function fail_compilation/systemvariables_var_init.d(19): `ptrVar` is inferred to be `@system` from its initializer here --- */ // https://issues.dlang.org/show_bug.cgi?id=24051 enum uint* ptrEnum = cast(uint*) 0xC00000; const uint* ptrConst = cast(uint*) 0xC00000; uint* ptrVarSafe = null; uint* ptrVar = cast(uint*) 0xC00000; @trusted uint* ptrTrusted = cast(uint*) 0xC00000; void varInitializers() @safe { *ptrEnum = 0; *ptrConst = 0; *ptrVarSafe = 0; *ptrVar = 0; *ptrTrusted = 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17380.d0000644000175000017500000000062415205374123021156 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test17380.d(12): Error: undefined identifier `ThisTypeDoesNotExistsAndCrahesTheCompiler` --- * https://issues.dlang.org/show_bug.cgi?id=17380 */ struct Int128 { Uint128 opCast() { return ThisTypeDoesNotExistsAndCrahesTheCompiler; } alias opCast this; } struct Uint128 { Int128 opCast() { return Int128.init; } alias opCast this; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail331.d0000644000175000017500000000031415205374123020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail331.d(10): Error: cannot use `typeof(return)` inside function `foo` with inferred return type --- */ auto foo() { typeof(return) result; return result; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14009.d0000644000175000017500000000037415205374123021107 0ustar fabiofabio/* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/fail14009.d(12): Error: end of instruction expected, not `:` --- */ void main() { asm { mov EAX, FS: 1 ? 2 : 3; // accepted mov EAX, FS: 1 ? 2 : : 3; // rejected } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice8630.d0000644000175000017500000000046215205374123020655 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice8630.d(9): Error: undefined identifier `v` fail_compilation/ice8630.d(10): Error: template instance `ice8630.foo!(int[])` error instantiating --- */ auto map(alias func, R)(R r) { return r; } typeof(v) foo(R)(R v) { return map!(p=>p)(v); } void main() { foo([1]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22138.d0000644000175000017500000000052315205374123021105 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fail22138.d(107): Error: returning scope variable `e` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=22138 #line 100 @safe int* test() { int*[] a; foreach (scope e; a) { return e; } return null; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag6796.d0000644000175000017500000000046515205374123021037 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag6796.d(11): Error: cannot implicitly convert expression `0` of type `int` to `int[]` fail_compilation/diag6796.d(11): Error: cannot implicitly convert expression `1` of type `int` to `int[]` --- */ void main() { enum int[][] array = [0, 1]; array[0] *= 10; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/must_use_reserved.d0000644000175000017500000000147215205374123023341 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/must_use_reserved.d(14): Error: `@mustuse` on `class` types is reserved for future use fail_compilation/must_use_reserved.d(15): Error: `@mustuse` on `interface` types is reserved for future use fail_compilation/must_use_reserved.d(16): Error: `@mustuse` on `enum` types is reserved for future use fail_compilation/must_use_reserved.d(17): Error: `@mustuse` on functions is reserved for future use fail_compilation/must_use_reserved.d(19): Error: `@mustuse` on `class` types is reserved for future use fail_compilation/must_use_reserved.d(20): Error: template instance `must_use_reserved.CT!int` error instantiating --- +/ import core.attribute; @mustuse class C {} @mustuse interface I {} @mustuse enum E { x } @mustuse int fun() { return 0; } @mustuse class CT(T) {} alias _ = CT!int; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice7782.d0000644000175000017500000000076515205374123020672 0ustar fabiofabio/* EXTRA_FILES: imports/ice7782algorithm.d imports/ice7782range.d TRANSFORM_OUTPUT: remove_lines("^import path") TEST_OUTPUT: ---- fail_compilation/ice7782.d(12): Error: unable to read module `ice7782math` fail_compilation/ice7782.d(12): Expected 'imports/ice7782range/imports/ice7782math.d' or 'imports/ice7782range/imports/ice7782math/package.d' in one of the following import paths: ---- */ import imports.ice7782algorithm; import imports.ice7782range. imports.ice7782math; void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail24213.d0000644000175000017500000000057115205374123021104 0ustar fabiofabio/+ REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fail24213.d(16): Error: assigning reference to local variable `n` to non-scope parameter `p` is not allowed in a `@safe` function --- +/ alias Dg = void delegate(int* p) @safe pure nothrow; void main() @safe { int* escaped; int n; Dg dg = delegate void (int* p) { escaped = p; }; dg(&n); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21215.d0000644000175000017500000000104715205374123021146 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test21215.d(13): Error: `y` is not a member of `S` fail_compilation/test21215.d(18): Error: `xhs` is not a member of `S`, did you mean variable `xsh`? fail_compilation/test21215.d(28): Error: `y` is not a member of `S` fail_compilation/test21215.d(32): Error: `yashu` is not a member of `S` --- */ struct S { int xsh; } void test() { auto s1 = S( y: 1 ); auto s2 = S( xhs: 1 ); auto s3 = S( xsh: 1 ); auto s4 = S( xsh: 1, y: 2 ); auto s5 = S( yashu: 2 ); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21259.d0000644000175000017500000000201715205374123021154 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21259 // REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/test21259.d(39): Deprecation: alias `test21259.Foo.width` is deprecated fail_compilation/test21259.d(40): Deprecation: alias `test21259.Foo2.width` is deprecated fail_compilation/test21259.d(41): Deprecation: variable `test21259.Foo3.bar` is deprecated fail_compilation/test21259.d(42): Deprecation: alias `test21259.Foo4.width` is deprecated --- */ struct Foo { int bar; deprecated alias width = bar; } struct Foo2 { deprecated int bar; deprecated alias width = bar; } struct Foo3 { deprecated int bar; } struct Foo4 { int bar; deprecated: alias width = bar; } void main() { Foo a = { width : 100}; Foo2 b = { width : 100}; Foo3 c = { bar : 100}; Foo4 d = { width : 100}; } // deprecations inside a deprecated scope shouldn't be triggered deprecated void test() { Foo a = { width : 100}; Foo2 b = { width : 100}; Foo3 c = { bar : 100}; Foo4 d = { width : 100}; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice4983.d0000644000175000017500000000027515205374123020666 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice4983.d(14): Error: circular reference to `ice4983.Foo.dg` --- */ struct Foo { void bar() { } void delegate() dg = &Foo.init.bar; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag19196.d0000644000175000017500000000050615205374123021111 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag19196.d(11): Error: unable to determine fields of `B` because of forward references fail_compilation/diag19196.d(15): Error: template instance `diag19196.Foo!(B)` error instantiating --- */ module diag19196; struct Foo(T) { alias F = typeof(T.tupleof); } struct B { Foo!B b; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice6538.d0000644000175000017500000000110415205374123020654 0ustar fabiofabio /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=9361 /* TEST_OUTPUT: --- fail_compilation/ice6538.d(23): Error: template instance `Sym!(super)` expression `super` is not a valid template value argument fail_compilation/ice6538.d(28): Error: template `foo` is not callable using argument types `!()()` fail_compilation/ice6538.d(23): Candidate is: `foo()()` --- */ template Sym(alias A) { enum Sym = true; } class C {} class D : C { void foo()() if (Sym!(super)) {} } void test9361b() { auto d = new D(); d.foo(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail129.d0000644000175000017500000000026215205374123020741 0ustar fabiofabioÄ ä; /* TEST_OUTPUT: --- fail_compilation/fail129.d: Error: module `fail129` source file must start with BOM or ASCII character, not \xC3 --- */ class Ä { } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9831.d0000644000175000017500000000050015205374123021016 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9831.d(13): Error: function `diag9831.main.__lambda_L13_C12(__T1)(x)` cannot access variable `c` in frame of function `D main` fail_compilation/diag9831.d(11): `c` declared here --- */ void main() { immutable int c; int function(int x) func; func = x => c; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19319b.d0000644000175000017500000000066215205374123021262 0ustar fabiofabio/* DFLAGS: REQUIRED_ARGS: -conf= -Ifail_compilation/extra-files/minimal TEST_OUTPUT: --- fail_compilation/fail19319b.d(16): Error: `7 ^^ x` requires `std.math` for `^^` operators fail_compilation/fail19319b.d(17): Error: `x ^^ 7` requires `std.math` for `^^` operators --- */ void test19319(int x) { static assert(!__traits(compiles, 7 ^^ x)); static assert(!__traits(compiles, x ^^= 7)); int i = 7 ^^ x; x ^^= 7; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/vector_cast.d0000644000175000017500000000070015205374123022103 0ustar fabiofabio/** REQUIRED_ARGS: -m64 TEST_OUTPUT: --- fail_compilation/vector_cast.d(11): Error: cannot cast expression `a` of type `int[3]` to `__vector(int[4])` fail_compilation/vector_cast.d(13): Error: cannot cast expression `a` of type `int[5]` to `__vector(int[4])` --- */ alias int4 = __vector(int[4]); int4 convtest3(int[3] a) { return cast(int4) a; } int4 convtest4(int[4] a) { return cast(int4) a; } int4 convtest5(int[5] a) { return cast(int4) a; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13120.d0000644000175000017500000000203115205374123021070 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail13120.d(13): Error: `pure` delegate `fail13120.g1.__foreachbody_L12_C5` cannot call impure function `fail13120.f1` fail_compilation/fail13120.d(13): Error: `@nogc` delegate `fail13120.g1.__foreachbody_L12_C5` cannot call non-@nogc function `fail13120.f1` --- */ void f1() {} void g1(char[] s) pure @nogc { foreach (dchar dc; s) f1(); } /* TEST_OUTPUT: --- fail_compilation/fail13120.d(35): Error: `pure` function `fail13120.h2` cannot call impure function `fail13120.g2!().g2` fail_compilation/fail13120.d(30): which calls `f2` fail_compilation/fail13120.d(35): Error: `@safe` function `fail13120.h2` cannot call `@system` function `fail13120.g2!().g2` fail_compilation/fail13120.d(27): `fail13120.g2!().g2` is declared here fail_compilation/fail13120.d(35): Error: `@nogc` function `fail13120.h2` cannot call non-@nogc function `fail13120.g2!().g2` --- */ void f2() {} void g2()(char[] s) { foreach (dchar dc; s) f2(); } void h2() @safe pure @nogc { g2(null); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14907.d0000644000175000017500000000144715205374123020745 0ustar fabiofabio/* 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 `f` is not callable using argument types `!()()` fail_compilation/ice14907.d(15): Candidate is: `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 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice20042.d0000644000175000017500000000140115205374123020716 0ustar fabiofabio/* DISABLED: freebsd32 openbsd32 linux32 osx32 win32 TEST_OUTPUT: --- fail_compilation/ice20042.d(18): Error: slice operation `cast(__vector(float[4]))[nanF, nanF, nanF, nanF] = [1.0F, 2.0F, 3.0F, 4.0F][0..4]` cannot be evaluated at compile time fail_compilation/ice20042.d(25): called from here: `Vec4(cast(__vector(float[4]))[nanF, nanF, nanF, nanF]).this([1.0F, 2.0F, 3.0F, 4.0F])` --- */ void write(T...)(T t){} struct Vec4 { __vector(float[4]) raw; this(const(float[4]) value...) inout pure @safe nothrow @nogc { __vector(float[4]) raw; raw[] = value[]; this.raw = raw; } } void main() { static immutable Vec4 v = Vec4( 1.0f, 2.0f, 3.0f, 4.0f ); static foreach(d; 0 .. 4) write(v.raw[d], " "); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14272.d0000644000175000017500000000046615205374123020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice14272.d(11): Error: circular initialization of variable `ice14272.A14272!1.A14272.tag` fail_compilation/ice14272.d(14): Error: template instance `ice14272.A14272!1` error instantiating --- */ struct A14272(int tag) { enum int tag = tag; } alias a14272 = A14272!1; ./ldc-1.42.0-src/tests/dmd/fail_compilation/nonvoid_return.d0000644000175000017500000000135315205374123022647 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/nonvoid_return.d(15): Error: cannot return non-void from `void` function fail_compilation/nonvoid_return.d(18): Error: cannot return non-void from `void` function fail_compilation/nonvoid_return.d(29): Error: cannot return non-void from `void` function fail_compilation/nonvoid_return.d(32): Error: undefined identifier `NONEXISTENT` --- */ void main() { return 10; } void fs() => "a"; class MyClass { } MyClass[char[]] myarray; void fn() { foreach (MyClass mc; myarray) return mc; } auto err() { NONEXISTENT++; } // Because `err` contains an error, it fails to infer void and gets an error return type // Don't print the 'cannot return non-void' error in this case void fe() => err; ./ldc-1.42.0-src/tests/dmd/fail_compilation/b3841.d0000644000175000017500000000774315205374123020346 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/b3841.d-mixin-45(45): Deprecation: `char += float` is performing truncating conversion fail_compilation/b3841.d(69): Error: template instance `b3841.f!("+=", char, float)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `int += float` is performing truncating conversion fail_compilation/b3841.d(70): Error: template instance `b3841.f!("+=", int, float)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `long += double` is performing truncating conversion fail_compilation/b3841.d(71): Error: template instance `b3841.f!("+=", long, double)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `char -= float` is performing truncating conversion fail_compilation/b3841.d(69): Error: template instance `b3841.f!("-=", char, float)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `int -= float` is performing truncating conversion fail_compilation/b3841.d(70): Error: template instance `b3841.f!("-=", int, float)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `long -= double` is performing truncating conversion fail_compilation/b3841.d(71): Error: template instance `b3841.f!("-=", long, double)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `char *= float` is performing truncating conversion fail_compilation/b3841.d(69): Error: template instance `b3841.f!("*=", char, float)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `int *= float` is performing truncating conversion fail_compilation/b3841.d(70): Error: template instance `b3841.f!("*=", int, float)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `long *= double` is performing truncating conversion fail_compilation/b3841.d(71): Error: template instance `b3841.f!("*=", long, double)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `char /= float` is performing truncating conversion fail_compilation/b3841.d(69): Error: template instance `b3841.f!("/=", char, float)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `int /= float` is performing truncating conversion fail_compilation/b3841.d(70): Error: template instance `b3841.f!("/=", int, float)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `long /= double` is performing truncating conversion fail_compilation/b3841.d(71): Error: template instance `b3841.f!("/=", long, double)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `char %= float` is performing truncating conversion fail_compilation/b3841.d(69): Error: template instance `b3841.f!("%=", char, float)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `int %= float` is performing truncating conversion fail_compilation/b3841.d(70): Error: template instance `b3841.f!("%=", int, float)` error instantiating fail_compilation/b3841.d-mixin-45(45): Deprecation: `long %= double` is performing truncating conversion fail_compilation/b3841.d(71): Error: template instance `b3841.f!("%=", long, double)` error instantiating --- */ void f(string op, LHS, RHS)() { // pragma(msg, LHS, " += ", RHS); LHS a; RHS b; mixin("a "~op~" b;"); } template Ops(T...) { alias Ops = T; } void main() { foreach (string op; Ops!("+=", "-=", "*=", "/=", "%=")) { // OK f!(op, int, int)(); f!(op, long, int)(); f!(op, long, short)(); f!(op, float, long)(); f!(op, double, float)(); // Should that really be OK ? f!(op, short, int)(); f!(op, float, double)(); // Not OK, truncating conversion. f!(op, char, float)(); f!(op, int, float)(); f!(op, long, double)(); } // OK f!("^^=", int, int)(); f!("^^=", long, int)(); f!("^^=", long, short)(); f!("^^=", float, long)(); f!("^^=", double, float)(); // Should that really be OK ? f!("^^=", float, double)(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17868.d0000644000175000017500000000124015205374123021164 0ustar fabiofabio/* DISABLED: LDC // differing output as LDC allows for a single optional integer argument (priority) TEST_OUTPUT: ---- fail_compilation/test17868.d(10): Error: pragma `crt_constructor` takes no argument fail_compilation/test17868.d(11): Error: pragma `crt_constructor` takes no argument fail_compilation/test17868.d(12): Error: pragma `crt_constructor` takes no argument fail_compilation/test17868.d(13): Error: pragma `crt_constructor` takes no argument ---- */ pragma(crt_constructor, ctfe()) pragma(crt_constructor, 1.5f) pragma(crt_constructor, "foobar") pragma(crt_constructor, S()) void foo() { } int ctfe() { __gshared int val; return val; } struct S {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail333.d0000644000175000017500000000017415205374123020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail333.d(8): Error: forward reference to `test` --- */ void test(typeof(test) p) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7603b.d0000644000175000017500000000026615205374123021173 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7603b.d(7): Error: cannot create default argument for `ref` / `out` parameter from constant `true` --- */ void test(out bool val = true) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail244.d0000644000175000017500000000304015205374123020734 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail244.d(27): Deprecation: variable `fail244.StructWithDeps.value` is deprecated fail_compilation/fail244.d(28): Deprecation: variable `fail244.StructWithDeps.value` is deprecated fail_compilation/fail244.d(29): Deprecation: variable `fail244.StructWithDeps.value` is deprecated fail_compilation/fail244.d(30): Deprecation: variable `fail244.StructWithDeps.value` is deprecated fail_compilation/fail244.d(32): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated fail_compilation/fail244.d(33): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated fail_compilation/fail244.d(34): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated fail_compilation/fail244.d(35): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated fail_compilation/fail244.d(36): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated fail_compilation/fail244.d(37): Deprecation: variable `fail244.StructWithDeps.staticValue` is deprecated --- */ //import std.stdio; struct StructWithDeps { deprecated int value; deprecated static int staticValue; void test(StructWithDeps obj) { obj.value = 666; this.value = 666; auto n1 = obj.value; auto n2 = this.value; obj.staticValue = 102; this.staticValue = 103; StructWithDeps.staticValue = 104; auto n3 = obj.staticValue; auto n4 = this.staticValue; auto n5 = StructWithDeps.staticValue; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12902.d0000644000175000017500000000067615205374123020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12902.d(20): Error: variable `ice12902.main.$` - type `void` is inferred from initializer `s.opDollar()`, and variables cannot be of type `void` fail_compilation/ice12902.d(20): Error: expression `s.opDollar()` is `void` and has no value --- */ struct S { void opDollar() { } void opIndex() { } void opIndexAssign() { } void opSliceAssign() { } } void main() { S s; s[] = s[$]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail209.d0000644000175000017500000000056115205374123020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail209.d(20): Error: incompatible types for `(a) -= (x)`: `float` and `fail209.X` --- */ // https://issues.dlang.org/show_bug.cgi?id=725 // expression.c:6516: virtual Expression* MinAssignExp::semantic(Scope*): Assertion `e2->type->isfloating()' failed class X { float a; } void main() { X x; float a; a -= x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail238_m64.d0000644000175000017500000000161615205374123021434 0ustar fabiofabio// REQUIRED_ARGS: -m64 /* TEST_OUTPUT: --- fail_compilation/fail238_m64.d(21): Error: cannot implicitly convert expression `"a"` of type `string` to `ulong` fail_compilation/fail238_m64.d(24): Error: cannot implicitly convert expression `X!()` of type `void` to `const(string)` fail_compilation/fail238_m64.d(29): Error: template instance `fail238_m64.A!"a"` error instantiating fail_compilation/fail238_m64.d(35): instantiated from here: `M!(q)` fail_compilation/fail238_m64.d(35): while evaluating `pragma(msg, M!(q))` --- */ // https://issues.dlang.org/show_bug.cgi?id=581 // Error message w/o line number in dot-instantiated template template X(){} template D(string str){} template A(string str) { static if (D!(str[str])) {} else const string A = .X!(); } template M(alias B) { const string M = A!("a"); } void main() { int q = 3; pragma(msg, M!(q)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/foreach_seq.d0000644000175000017500000000321515205374123022052 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/foreach_seq.d(25): Error: only one (element) or two (index, element) arguments allowed for sequence `foreach`, not 3 fail_compilation/foreach_seq.d(26): Error: invalid storage class `ref` for index `i` fail_compilation/foreach_seq.d(27): Error: foreach: index cannot be of non-integral type `void` fail_compilation/foreach_seq.d(28): Error: index type `bool` cannot cover index range 0..3 fail_compilation/foreach_seq.d(29): Error: `foreach` loop variable cannot be both `enum` and `alias` fail_compilation/foreach_seq.d(30): Error: constant value `1` cannot be `ref` fail_compilation/foreach_seq.d(31): Error: invalid storage class `enum` for index `i` fail_compilation/foreach_seq.d(33): Error: invalid storage class `ref` for element `e` fail_compilation/foreach_seq.d(34): Error: symbol `object` cannot be `ref` fail_compilation/foreach_seq.d(35): Error: cannot specify element type for symbol `e` fail_compilation/foreach_seq.d(36): Error: cannot specify element type for symbol `object` fail_compilation/foreach_seq.d(37): Error: invalid storage class `enum` for element `e` --- */ // test semantic errors on foreach parameters void main() { alias AliasSeq(A...) = A; alias seq = AliasSeq!(1, 2, 3); foreach (a, b, c; seq) {} foreach (ref i, e; seq) {} foreach (void i, e; seq) {} foreach (bool i, e; seq) {} foreach (enum alias e; seq) {} foreach (ref enum e; seq) {} foreach (ref enum i, e; seq) {} foreach (ref e; AliasSeq!int) {} foreach (ref e; AliasSeq!object) {} foreach (int e; AliasSeq!int) {} foreach (int e; AliasSeq!object) {} foreach (enum e; AliasSeq!int) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8559.d0000644000175000017500000000043215205374123021030 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8559.d(12): Error: `void` does not have a default initializer fail_compilation/diag8559.d(13): Error: `function` does not have a default initializer --- */ void foo(){} void main() { auto x = void.init; auto y = typeof(foo).init; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23591.d0000644000175000017500000000074515205374123021117 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23591 /* TEST_OUTPUT: --- fail_compilation/fail23591.d(13): Error: cannot implicitly convert expression `square(i) , null` of type `string` to `int` fail_compilation/fail23591.d(14): Error: cannot implicitly convert expression `assert(0) , null` of type `real function(char)` to `int` --- */ noreturn square(int x); int example(int i) { int x = cast(string)square(i); int y = cast(real function(char))assert(0); return x + y; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23279.d0000644000175000017500000000036115205374123021160 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23279 /* TEST_OUTPUT: --- fail_compilation/test23279.d(13): Error: undefined identifier `Sth` --- */ class Tester { enum a = __traits(hasMember, Tester, "setIt"); void setIt(Sth sth){} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/operator_undefined.d0000644000175000017500000000056415205374123023453 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/operator_undefined.d(20): Error: operator `-` is not defined for `Json` fail_compilation/operator_undefined.d(11): perhaps overload the operator with `auto opUnary(string op : "-")() {}` --- */ import std.stdio; struct Json { //int opUnary(string op : "-")(); } Json toJson(int); void main() { auto x = -2.toJson; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail199.d0000644000175000017500000000057215205374123020754 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail199.d(20): Deprecation: class `fail199.DepClass` is deprecated fail_compilation/fail199.d(20): Deprecation: class `fail199.DepClass` is deprecated --- */ //import std.stdio; deprecated class DepClass { void test() { //writefln("Accessing what's deprecated!"); } } class Derived : DepClass {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail200.d0000644000175000017500000000063015205374123020726 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail200.d(17): Deprecation: interface `fail200.DepClass` is deprecated fail_compilation/fail200.d(17): Deprecation: interface `fail200.DepClass` is deprecated --- */ //import std.stdio; deprecated interface DepClass { void test(); } class Derived : DepClass { void test() { //writefln("Accessing what's deprecated!"); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12236.d0000644000175000017500000000175415205374123021112 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail12236.d(16): Error: forward reference to inferred return type of function `f1` fail_compilation/fail12236.d(16): while evaluating `pragma(msg, f1.mangleof)` fail_compilation/fail12236.d(21): Error: forward reference to inferred return type of function `f2` fail_compilation/fail12236.d(21): while evaluating `pragma(msg, f2(T)(T).mangleof)` fail_compilation/fail12236.d(27): Error: template instance `fail12236.f2!int` error instantiating fail_compilation/fail12236.d(31): Error: forward reference to inferred return type of function `__lambda_L29_C5` fail_compilation/fail12236.d(31): while evaluating `pragma(msg, __lambda_L29_C5(__T1)(a).mangleof)` --- */ auto f1(int) { pragma(msg, f1.mangleof); // forward reference error } auto f2(T)(T) { pragma(msg, f2.mangleof); // error <- weird output: "v" } void main() { f1(1); f2(1); (a) { int x; pragma(msg, __traits(parent, x).mangleof); } (1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15672.d0000644000175000017500000000145415205374123021162 0ustar fabiofabio/* * TEST_OUTPUT: --- fail_compilation/test15672.d(17): Error: cast from `void[]` to `byte[]` is not allowed in a `@safe` function fail_compilation/test15672.d(17): `void` data may contain pointers and target element type is mutable fail_compilation/test15672.d(27): Error: cast from `void*` to `byte*` is not allowed in a `@safe` function fail_compilation/test15672.d(27): `void` data may contain pointers and target element type is mutable --- */ // https://issues.dlang.org/show_bug.cgi?id=15672 alias byte T; alias const(byte) CT; @safe T[] test1(void[] a) { return cast(T[])a; } @safe CT[] test2(void[] a) { return cast(CT[])a; } @safe T* test3(void* a) { return cast(T*)a; } @safe CT* test4(void* a) { return cast(CT*)a; } @safe T[] test5() { return cast(T[])[]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag12640.d0000644000175000017500000000057415205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag12640.d(14): Error: undefined identifier `asdf` fail_compilation/diag12640.d(23): Error: undefined identifier `asdf` --- */ void main() { switch (1) { case 0: asdf; break; default: } switch (1) { default: asdf; break; case 0: } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375i.d0000644000175000017500000000057315205374123021206 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375i.d(15): Error: else is dangling, add { } after condition at fail_compilation/fail4375i.d(10) --- */ void main() { if (true) switch (1) // o_O default: if (false) assert(115); else assert(116); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail35.d0000644000175000017500000000050315205374123020653 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail35.d(15): Error: variable `t` cannot be read at compile time --- */ // https://www.digitalmars.com/d/archives/digitalmars/D/bugs/2372.html // allegedly crashes, but cannot reproduce void main() { for (int t = 0; t < 33; t++) { size_t n = (bool[t]).sizeof; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/onemember_overloads.d0000644000175000017500000000274215205374123023626 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/onemember_overloads.d(29): Error: none of the overloads of `skipOver` are callable using argument types `()` fail_compilation/onemember_overloads.d(25): Candidates are: `onemember_overloads.skipOver(string)` fail_compilation/onemember_overloads.d(18): `skipOver(alias pred = (a, b) => a == b)` fail_compilation/onemember_overloads.d(20): - Containing: `skipOver(Haystack, Needles...)(ref Haystack haystack, Needles needles)` fail_compilation/onemember_overloads.d(21): - Containing: `skipOver(R)(ref R r1)` fail_compilation/onemember_overloads.d(22): - Containing: `skipOver(R, Es...)(ref R r, Es es)` fail_compilation/onemember_overloads.d(30): Error: template `t2` is not callable using argument types `!()()` fail_compilation/onemember_overloads.d(33): Candidate is: `t2(T)` fail_compilation/onemember_overloads.d(35): - Containing: `t2(string)` fail_compilation/onemember_overloads.d(36): - Containing: `t2(int[])` fail_compilation/onemember_overloads.d(37): - Containing: `t2(R)(R)` --- */ template skipOver(alias pred = (a, b) => a == b) { bool skipOver(Haystack, Needles...)(ref Haystack haystack, Needles needles) => true; bool skipOver(R)(ref R r1) => true; bool skipOver(R, Es...)(ref R r, Es es) => true; } void skipOver(string); void main() { skipOver(); t2(); } template t2(T) { bool t2(string); bool t2(int[]); bool t2(R)(R); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail25.d0000644000175000017500000000035515205374123020657 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail25.d(14): Error: accessing non-static variable `yuiop` requires an instance of `Qwert` --- */ class Qwert { int yuiop; static int asdfg() { return Qwert.yuiop + 105; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22035.d0000644000175000017500000000037515205374123021106 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22035 /* TEST_OUTPUT: --- fail_compilation/fail22035.d(10): Error: found `2` when expecting `:` fail_compilation/fail22035.d(10): Error: found `:` instead of statement --- */ int test22035() { case 1 2: } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21477.d0000644000175000017500000000050515205374123021156 0ustar fabiofabio/* REQUIRED_ARGS: -betterC DISABLED: LDC // no expression info in error msg TEST_OUTPUT: --- fail_compilation/test21477.d(103): Error: this array literal requires the GC and cannot be used with `-betterC` --- */ // https://issues.dlang.org/show_bug.cgi?id=21477 #line 100 int test() { int[] foo = [1]; return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail276.d0000644000175000017500000000077315205374123020753 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail276.d(19): Error: `this` has no effect fail_compilation/fail276.d(15): Error: cannot construct anonymous nested class because no implicit `this` reference to outer class is available --- */ class C { this() { auto i = new class() { auto k = new class() { void func() { this.outer.outer; } }; }; } int i; } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag6677.d0000644000175000017500000000222115205374123021025 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag6677.d(17): Error: static constructor cannot be `const` fail_compilation/diag6677.d(18): Error: static constructor cannot be `inout` fail_compilation/diag6677.d(19): Error: static constructor cannot be `immutable` fail_compilation/diag6677.d(20): Error: use `shared static this()` to declare a shared static constructor fail_compilation/diag6677.d(21): Error: use `shared static this()` to declare a shared static constructor fail_compilation/diag6677.d(23): Error: shared static constructor cannot be `const` fail_compilation/diag6677.d(24): Error: shared static constructor cannot be `inout` fail_compilation/diag6677.d(25): Error: shared static constructor cannot be `immutable` fail_compilation/diag6677.d(26): Error: redundant attribute `shared` fail_compilation/diag6677.d(27): Error: redundant attribute `shared` --- */ static this() const { } static this() inout { } static this() immutable { } static this() shared { } static this() const shared { } shared static this() const { } shared static this() inout { } shared static this() immutable { } shared static this() shared { } shared static this() const shared { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail134.d0000644000175000017500000000076615205374123020746 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail134.d(14): Error: template instance `foo!(f)` does not match template declaration `foo(T)` fail_compilation/fail134.d(14): `f` is not a type fail_compilation/fail134.d(15): Error: template instance `fail134.bar!(f)` error instantiating --- */ // https://issues.dlang.org/show_bug.cgi?id=651 // Assertion failure: 'global.errors' on line 2622 in file 'template.c' void f() {} template foo(T) {} template bar(T...) { alias foo!(T) buz; } alias bar!(f) a; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18385.d0000644000175000017500000000105615205374123021164 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/test18385.d(13): Error: function `test18385.foo` cannot overload `extern(C)` function at fail_compilation/test18385.d(12) --- */ extern (C): void foo(int) { } void foo(double) { } struct S { static void foo(int) {} static void foo(double) {} } void foo2(int) { } extern(D) void foo2(double) { } // OK as it has a different mangling void foo3(int) { } void foo3(double); // duplicate declarations are allowed void foo4(); void foo4() { } extern(D) void foo5(); extern(D) void foo5() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21093.d0000644000175000017500000000261615205374123021155 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21093 /* TEST_OUTPUT: --- fail_compilation/test21093.d(24): Error: function `test21093.LocalTime.hasDST` does not override any function fail_compilation/test21093.d(32): Error: class `test21093.LocalTime2` cannot implicitly generate a default constructor when base class `test21093.TimeZone2` is missing a default constructor fail_compilation/test21093.d(44): Error: function `test21093.LocalTime3.string` does not override any function fail_compilation/test21093.d(55): Error: cannot implicitly override base class method `test21093.TimeZone4.hasDST` with `test21093.LocalTime4.hasDST`; add `override` attribute --- */ void fromUnixTime(immutable TimeZone tz = LocalTime()) { } void fromUnixTime(immutable TimeZone2 tz = LocalTime2()) { } void fromUnixTime(immutable TimeZone3 tz = LocalTime3()) { } void fromUnixTime(immutable TimeZone4 tz = LocalTime4()) { } class TimeZone { } class LocalTime : TimeZone { static immutable(LocalTime) opCall() { } override hasDST() { } } class TimeZone2 { this(string) { } } class LocalTime2 : TimeZone2 { static immutable(LocalTime2) opCall() { } } class TimeZone3 { } class LocalTime3 : TimeZone3 { static immutable(LocalTime3) opCall() { } override string () { } } class TimeZone4 { bool hasDST(); } class LocalTime4 : TimeZone4 { static immutable(LocalTime4) opCall() { } bool hasDST() { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21246.d0000644000175000017500000000070715205374123021154 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21246 // EXTRA_FILES: imports/test21246.d /* TEST_OUTPUT: --- fail_compilation/test21246.d(16): Error: function `void test21246.C.set(Clock clock)` does not override any function, did you mean to override `void imports.test21246.B.set(imports.test21246.Clock clock)`? --- */ module test21246; import imports.test21246; class Clock { } class C : B { override void set (Clock clock) { } } void main () { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9004.d0000644000175000017500000000054015205374123021012 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9004.d(21): Error: template `bar` is not callable using argument types `!()(Foo!int, int)` fail_compilation/diag9004.d(14): Candidate is: `bar(FooT)(FooT foo, FooT.T x)` --- */ struct Foo(_T) { alias _T T; } void bar(FooT)(FooT foo, FooT.T x) { } void main() { Foo!int foo; bar(foo, 1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag11756.d0000644000175000017500000000132215205374123021100 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag11756.d(15): Error: cannot read uninitialized variable `cnt` in CTFE fail_compilation/diag11756.d(34): called from here: `foo.ptr2.opAssign(Ptr(& n))` fail_compilation/diag11756.d(39): called from here: `test()` fail_compilation/diag11756.d(39): while evaluating: `static assert(test())` --- */ struct Ptr { void opAssign(Ptr other) { (*cnt)--; // error cnt = other.cnt; (*cnt)++; } size_t *cnt; } union Foo { size_t *ptr1; Ptr ptr2; } bool test() { Foo foo; size_t cnt = 1; foo.ptr1 = &cnt; size_t n; foo.ptr2 = Ptr(&n); assert(cnt == 0); return true; } static assert(test()); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail334.d0000644000175000017500000000027615205374123020744 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail334.d(10): Error: properties can only have zero, one, or two parameter --- */ struct S { @property int foo(int a, int b, int c) { return 1; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/standalone_modctor.d0000644000175000017500000000116115205374123023450 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/standalone_modctor.d(11): Error: `@standalone` can only be used on shared static constructors fail_compilation/standalone_modctor.d(12): Error: a module constructor using `@standalone` must be `@system` or `@trusted` fail_compilation/standalone_modctor.d(13): Error: a module constructor using `@standalone` must be `@system` or `@trusted` --- */ import core.attribute : standalone; @standalone static this() {} @standalone shared static this() {} @standalone shared static this() @safe {} @standalone shared static this() @trusted {} @standalone shared static this() @system {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/diagin.d0000644000175000017500000000153415205374123021030 0ustar fabiofabio/* REQUIRED_ARGS: -preview=in TEST_OUTPUT: --- fail_compilation/diagin.d(15): Error: function `foo` is not callable using argument types `()` fail_compilation/diagin.d(15): too few arguments, expected 1, got 0 fail_compilation/diagin.d(20): `diagin.foo(in int)` declared here fail_compilation/diagin.d(17): Error: template `foo1` is not callable using argument types `!()(bool[])` fail_compilation/diagin.d(21): Candidate is: `foo1(T)(in T v, string)` --- */ void main () { foo(); bool[] lvalue; foo1(lvalue); } void foo(in int) {} void foo1(T)(in T v, string) {} // Ensure that `in` has a unique mangling static assert(foo.mangleof == `_D6diagin3fooFIiZv`); static assert(foo1!int.mangleof == `_D6diagin__T4foo1TiZQiFNaNbNiNfIiAyaZv`); static assert(foo1!char.mangleof == `_D6diagin__T4foo1TaZQiFNaNbNiNfIaAyaZv`); ./ldc-1.42.0-src/tests/dmd/fail_compilation/systemvariables_bool_union.d0000644000175000017500000000061515205374123025234 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/systemvariables_bool_union.d(21): Deprecation: accessing overlapped field `Box.b` with unsafe bit patterns will become `@system` in a future release --- */ // https://issues.dlang.org/show_bug.cgi?id=24477 bool schrodingersCat() @safe { union Box { bool b; ubyte y; } Box u; u.y = 2; return u.b; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/isreturnonstack.d0000644000175000017500000000054015205374123023027 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/isreturnonstack.d(11): Error: argument to `__traits(isReturnOnStack, int)` is not a function fail_compilation/isreturnonstack.d(12): Error: expected 1 arguments for `isReturnOnStack` but had 2 --- */ int test() { return 0; } enum b = __traits(isReturnOnStack, int); enum c = __traits(isReturnOnStack, test, int); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14096.d0000644000175000017500000000140315205374123020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice14096.d(29): Error: cannot access frame pointer of `ice14096.main.Baz!((i) => i).Baz` fail_compilation/ice14096.d(23): Error: template instance `ice14096.foo!(Tuple!(Baz!((i) => i))).foo.bar!(t)` error instantiating fail_compilation/ice14096.d(40): instantiated from here: `foo!(Tuple!(Baz!((i) => i)))` --- */ struct Tuple(Types...) { Types expand; alias expand this; alias field = expand; } Tuple!T tuple(T...)(T args) { return typeof(return)(args); } auto foo(T)(T t) { bar!t(); } auto bar(alias s)() { // default construction is not possible for: Tuple!(Baz!(i => i)) typeof(s) p; } struct Baz(alias f) { void g() {} } void main() { auto t = tuple(Baz!(i => i)()); foo(t); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9247.d0000644000175000017500000000036415205374123021027 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9247.d(11): Error: functions cannot return opaque type `S` by value fail_compilation/diag9247.d(12): Error: functions cannot return opaque type `S` by value --- */ struct S; S foo(); S function() bar; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18385b.d0000644000175000017500000000173615205374123021333 0ustar fabiofabio/* Previous implementation raised errors for overloads using alias declarations because they ignored the actual function name TEST_OUTPUT: --- fail_compilation/test18385b.d(13): Error: `test18385b.S.foo` called with argument types `(int)` matches multiple overloads exactly: fail_compilation/test18385b.d(8): `test18385b.S.foo(int s)` and: fail_compilation/test18385b.d(3): `test18385b.foo(int s)` fail_compilation/test18385b.d(102): Error: `test18385b.bar` called with argument types `(int)` matches multiple overloads exactly: fail_compilation/test18385b.d(2): `test18385b.bar(int s)` and: fail_compilation/test18385b.d(3): `test18385b.foo(int s)` --- */ #line 1 void bar(int s) {} void foo(int s) {} alias bar = foo; struct S { void foo(int s) {} alias foo = bar; void useEm() { foo(1); } } // False positive in mutex.d when building druntime class Mutex { this() {} this() shared {} this(Object obj) {} } #line 100 void main() { bar(0); new Mutex(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test14538.d0000644000175000017500000000054515205374123021162 0ustar fabiofabio /* TEST_OUTPUT: --- fail_compilation/test14538.d(18): Error: return value `x ? cast(uint)this.fCells[x].code : 32u` of type `uint` does not match return type `Cell`, and cannot be implicitly converted --- */ struct Cell { dchar code; alias code this; } struct Row { Cell[] fCells; Cell opIndex(size_t x) { return x ? fCells[x] : ' '; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag_ptr_conversion.d0000644000175000017500000000107415205374123023632 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag_ptr_conversion.d(15): Error: cannot implicitly convert `const(int)*` to `int*` fail_compilation/diag_ptr_conversion.d(15): Note: Converting const to mutable requires an explicit cast (`cast(int*)`). fail_compilation/diag_ptr_conversion.d(16): Error: cannot implicitly convert `int*` to `float*` fail_compilation/diag_ptr_conversion.d(16): Note: Pointer types point to different base types (`int` vs `float`) --- */ void testPointerConversions() { int* p; const(int)* cp = p; p = cp; float* f = p; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/retscope6.d0000644000175000017500000001602315205374123021506 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 */ /* TEST_OUTPUT: --- fail_compilation/retscope6.d(6007): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function --- */ #line 6000 // https://issues.dlang.org/show_bug.cgi?id=17795 int* test() @safe { int i; int*[][] arr = new int*[][](1); arr[0] ~= &i; return arr[0][0]; } /* TEST_OUTPUT: --- fail_compilation/retscope6.d(7034): Error: assigning address of variable `i` to `s` with longer lifetime is not allowed in a `@safe` function fail_compilation/retscope6.d(7035): Error: assigning address of variable `i` to `s` with longer lifetime is not allowed in a `@safe` function fail_compilation/retscope6.d(7025): Error: assigning scope variable `__param_2` to `ref` variable `t` with longer lifetime is not allowed in a `@safe` function fail_compilation/retscope6.d(7037): Error: template instance `retscope6.S.emplace4!(int*)` error instantiating fail_compilation/retscope6.d(7037): Error: assigning address of variable `i` to `s` with longer lifetime is not allowed in a `@safe` function --- */ #line 7000 alias T = int*; struct S { T payload; static void emplace(Args...)(ref S s, Args args) @safe { s.payload = args[0]; } void emplace2(Args...)(Args args) @safe { payload = args[0]; } static void emplace3(Args...)(S s, Args args) @safe { s.payload = args[0]; } static void emplace4(Args...)(scope ref S s, scope out S t, scope Args args) @safe { s.payload = args[0]; t.payload = args[0]; } } void foo() @safe { S s; int i; s.emplace(s, &i); s.emplace2(&i); s.emplace3(s, &i); s.emplace4(s, s, &i); } /* TEST_OUTPUT: --- fail_compilation/retscope6.d(8016): Error: assigning address of variable `i` to `p` with longer lifetime is not allowed in a `@safe` function fail_compilation/retscope6.d(8031): Error: assigning reference to local variable `i` to non-scope parameter `p` calling `betty` is not allowed in a `@safe` function fail_compilation/retscope6.d(8031): Error: assigning reference to local variable `j` to non-scope parameter `q` calling `betty` is not allowed in a `@safe` function fail_compilation/retscope6.d(8023): which is not `scope` because of `p = q` fail_compilation/retscope6.d(8048): Error: assigning reference to local variable `i` to non-scope parameter `p` calling `archie` is not allowed in a `@safe` function fail_compilation/retscope6.d(8039): which is not `scope` because of `r = p` fail_compilation/retscope6.d(8048): Error: assigning reference to local variable `j` to non-scope parameter `q` calling `archie` is not allowed in a `@safe` function fail_compilation/retscope6.d(8038): which is not `scope` because of `p = q` --- */ // https://issues.dlang.org/show_bug.cgi?id=19035 #line 8000 @safe { void escape(int*); /**********************/ void frank()(ref scope int* p, int* s) { p = s; // should error here } void testfrankly() { int* p; int i; frank(p, &i); } /**********************/ void betty()(int* p, int* q) { p = q; escape(p); } void testbetty() { int i; int j; betty(&i, &j); // should error on i and j } /**********************/ void archie()(int* p, int* q, int* r) { p = q; r = p; escape(q); } void testarchie() { int i; int j; int k; archie(&i, &j, &k); // should error on j } } /* TEST_OUTPUT: --- fail_compilation/retscope6.d(9023): Error: escaping a reference to local variable `i` by returning `fred(& i)` is not allowed in a `@safe` function --- */ #line 9000 @safe { alias T9 = S9!(); struct S9() { this(int* q) { this.p = q; } int* p; } auto fred(int* r) { return T9(r); } T9 testfred() { int i; auto j = fred(&i); // ok return fred(&i); // error } /* TEST_OUTPUT: --- fail_compilation/retscope6.d(10003): Error: assigning scope variable `values` to non-scope parameter `values` calling `escape` is not allowed in a `@safe` function --- */ #line 10000 void variadicCaller(int[] values...) { escape(values); } void escape(int[] values) {} /* TEST_OUTPUT: --- fail_compilation/retscope6.d(11004): Error: assigning address of variable `buffer` to `secret` with longer lifetime is not allowed in a `@safe` function --- */ #line 11000 void hmac(scope ubyte[] secret) { ubyte[10] buffer; secret = buffer[]; } } /* TEST_OUTPUT: --- fail_compilation/retscope6.d(12011): Error: escaping a reference to local variable `x` by returning `escape_m_20150(& x)` is not allowed in a `@safe` function fail_compilation/retscope6.d(12022): Error: escaping a reference to local variable `x` by returning `escape_c_20150(& x)` is not allowed in a `@safe` function --- */ #line 12000 // https://issues.dlang.org/show_bug.cgi?id=20150 int* escape_m_20150(int* r) @safe pure nothrow { return r; } int* f_m_20150() @safe nothrow { int x = 42; return escape_m_20150(&x); } const(int)* escape_c_20150(const int* r) @safe pure nothrow { return r; } const(int)* f_c_20150() @safe nothrow { int x = 42; return escape_c_20150(&x); } /* TEST_OUTPUT: --- fail_compilation/retscope6.d(13010): Error: assigning reference to local variable `str` to non-scope parameter `x` calling `f_throw` is not allowed in a `@safe` function --- */ #line 13000 // https://issues.dlang.org/show_bug.cgi?id=22221 void f_throw(string x) @safe pure { throw new Exception(x); } void escape_throw_20150() @safe { immutable(char)[4] str; f_throw(str[]); } /* TEST_OUTPUT: --- fail_compilation/retscope6.d(14019): Error: assigning scope variable `scopePtr` to non-scope parameter `x` calling `noInfer23021` is not allowed in a `@safe` function fail_compilation/retscope6.d(14009): which is not `scope` because of `*escapeHole = cast(const(int)*)x` fail_compilation/retscope6.d(14022): Error: returning scope variable `scopePtr` is not allowed in a `@safe` function --- */ #line 14000 // https://issues.dlang.org/show_bug.cgi?id=23021 ref int infer23021(ref int* x) @safe pure nothrow { return *x; } ref int noInfer23021(ref int* x, const(int)** escapeHole = null) @safe pure nothrow { *escapeHole = x; return *x; } ref int escape23021() @safe { scope int* scopePtr; int* nonScopePtr = null; // don't infer scope cast(void) noInfer23021(scopePtr); // error // ensure we infer return scope return infer23021(scopePtr); // error // ensure we do not infer return ref return infer23021(nonScopePtr); // no error } /******************************/ /* TEST_OUTPUT: --- fail_compilation/retscope6.d(14050): Error: assigning scope variable `z` to non-scope parameter `y` calling `f23294` is not allowed in a `@safe` function fail_compilation/retscope6.d(14044): which is not `scope` because of `x = y` --- */ // https://issues.dlang.org/show_bug.cgi?id=23294 @safe: int g23294; auto f23294(int* x, int* y) { x = y; g23294++; // make sure it's not inferring scope from pure } void escape23294(scope int* z) { f23294(z, z); // passes } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14446.d0000644000175000017500000000040615205374123020735 0ustar fabiofabio// REQUIRED_ARGS: -o- // EXTRA_SOURCES: extra-files/a14446.d /* TEST_OUTPUT: --- fail_compilation/extra-files/a14446.d(5): Error: module `x14446` from file fail_compilation/ice14446.d must be imported with 'import x14446;' --- */ module x14446; struct CDB {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12764.d0000644000175000017500000000051015205374123021105 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=12764 /* TEST_OUTPUT: --- fail_compilation/fail12764.d(20): Error: field `s` must be initialized in constructor --- */ struct S { @disable this(); this(string) { } int f; } class C { this(int) { s.f = 1; // circumvents default ctor! } S s; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11542.d0000644000175000017500000000336315205374123021107 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/fail11542.d(15): Error: `object.Exception` is thrown but not caught fail_compilation/fail11542.d(12): Error: function `fail11542.test_success1` may throw but is marked as `nothrow` fail_compilation/fail11542.d(25): Error: `object.Exception` is thrown but not caught fail_compilation/fail11542.d(22): Error: function `fail11542.test_success3` may throw but is marked as `nothrow` --- */ void test_success1() nothrow { scope(success) {} throw new Exception(""); // error } void test_success2() nothrow { scope(success) {} throw new Error(""); // no error } void test_success3() nothrow { scope(success) assert(0); throw new Exception(""); // error } /* TEST_OUTPUT: --- fail_compilation/fail11542.d(38): Error: `object.Exception` is thrown but not caught fail_compilation/fail11542.d(35): Error: function `fail11542.test_failure1` may throw but is marked as `nothrow` --- */ void test_failure1() nothrow { scope(failure) {} throw new Exception(""); // error } void test_failure2() nothrow { scope(failure) {} throw new Error(""); // no error } void est_failure3() nothrow { scope(failure) assert(0); throw new Exception(""); // no error } /* TEST_OUTPUT: --- fail_compilation/fail11542.d(61): Error: `object.Exception` is thrown but not caught fail_compilation/fail11542.d(58): Error: function `fail11542.test_exit1` may throw but is marked as `nothrow` --- */ void test_exit1() nothrow { scope(exit) {} throw new Exception(""); // error } void test_exit2() nothrow { scope(exit) {} throw new Error(""); // no error } void test_exit3() nothrow { scope(exit) assert(0); throw new Exception(""); // no error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20775.d0000644000175000017500000000061015205374123021107 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail20775.d(19): Error: cannot pass types that need destruction as variadic arguments fail_compilation/fail20775.d(20): Error: cannot pass types that need destruction as variadic arguments --- */ extern void variadic(...); struct S20775 { int field; ~this() { } } void test() { auto v = S20775(0); variadic(v, S20775(1)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4923.d0000644000175000017500000000102715205374123021027 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4923.d(5): Error: immutable variable `bar` initialization is not allowed in `static this` fail_compilation/fail4923.d(5): Use `shared static this` instead. fail_compilation/fail4923.d(6): Deprecation: const variable `baz` initialization is not allowed in `static this` fail_compilation/fail4923.d(6): Use `shared static this` instead. --- */ #line 1 immutable int bar; const int baz; // https://issues.dlang.org/show_bug.cgi?id=24056 static this() { bar = 42; baz = 43; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20919.d0000644000175000017500000000044515205374123021161 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test20919.d(12): Error: `__traits(getAttributes, int a)` does not give a valid type --- */ // https://issues.dlang.org/show_bug.cgi?id=20919 void foo(int a) {} static if (is(typeof(foo) params == __parameters)) { __traits(getAttributes, params) a; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/emptyModulePattern.d0000644000175000017500000000041515205374123023434 0ustar fabiofabio/* REQUIRED_ARGS: -i= LDC: treated like (and not distinguishable from) `-i` DISABLED: LDC TEST_OUTPUT: --- Error: invalid option '-i=', module patterns cannot be empty run `dmd` to print the compiler manual run `dmd -man` to open browser on manual --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21740a.i0000644000175000017500000000022115205374123021244 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail21740a.i(7): Error: `=`, `;` or `,` expected to end declaration instead of `)` --- */ int a\U000000aa); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail253.d0000644000175000017500000000105315205374123020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail253.d(13): Error: variable `fail253.main.x` - `inout` variables can only be declared inside `inout` functions fail_compilation/fail253.d(16): Error: cannot modify `inout` expression `x` fail_compilation/fail253.d(19): Error: variable `fail253.main.err11` - `inout` variables can only be declared inside `inout` functions --- */ void main() { foreach (i; 0 .. 2) { foreach (inout char x; "hola") { //printf("%c", x); x = '?'; } } inout(int)* err11; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11748.d0000644000175000017500000000037215205374123021114 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11748.d(12): Error: expression `my_function(0)` is `void` and has no value --- */ void main() { enum my_template(alias T) = T.stringof; void my_function(int i) { } my_template!(my_function(0)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail143.d0000644000175000017500000000101415205374123020731 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail143.d(23): Error: calling non-static function `next` requires an instance of type `Quux` fail_compilation/fail143.d(30): Error: template instance `fail143.Foo!int` error instantiating --- */ class Quux { uint x; final uint next() { return x; } } template Foo(T) { void bar() { int r = Quux.next; } } int main(char[][] args) { auto prng = new Quux(); alias Foo!(int).bar baz; int x = prng.next; baz(); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20616.d0000644000175000017500000000110015205374123021074 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail20616.d(16): Error: undefined identifier `$` fail_compilation/fail20616.d(13): perhaps define `opDollar` for `X` fail_compilation/fail20616.d(18): Error: undefined identifier `$` fail_compilation/fail20616.d(13): perhaps define `opDollar` for `X` --- */ module fail20616; void g() { struct X { auto opSlice(size_t a, size_t b) { return ""; } } auto x = X()[0 .. $]; auto b = X(); auto c = b[0 .. $ - 1]; auto v = [1, 2, 3]; auto d = v[$.. $]; } int main() { g(); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail121.d0000644000175000017500000000100415205374123020724 0ustar fabiofabio// PERMUTE_ARGS: -d -dw // segfault on DMD0.150, never failed if use typeid() instead. /* TEST_OUTPUT: --- fail_compilation/fail121.d(24): Error: no property `typeinfo` for `list[1]` of type `fail121.myobject` fail_compilation/fail121.d(12): struct `myobject` defined here fail_compilation/fail121.d(24): Error: no property `typeinfo` for `i` of type `int` --- */ struct myobject { TypeInfo objecttype; void* offset; } myobject[] list; void foo() { int i; list[1].typeinfo = i.typeinfo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9562.d0000644000175000017500000000116315205374123021034 0ustar fabiofabio/* REQUIRED_ARGS: -o- TEST_OUTPUT: --- fail_compilation/fail9562.d(16): Error: `int[]` is not an expression fail_compilation/fail9562.d(17): Error: no property `reverse` for type `int[]` fail_compilation/fail9562.d(18): Error: no property `sort` for type `int[]`, perhaps `import std.algorithm;` is needed? fail_compilation/fail9562.d(19): Error: no property `dup` for type `int[]` fail_compilation/fail9562.d(20): Error: no property `idup` for type `int[]` --- */ void main() { alias A = int[]; auto len = A.length; auto rev = A.reverse; auto sort = A.sort; auto dup = A.dup; auto idup = A.idup; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag3672.d0000644000175000017500000001064715205374123021030 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/diag3672.d(8): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(8): Use `core.atomic.atomicOp!"+="(x, 1)` instead fail_compilation/diag3672.d(9): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(9): Use `core.atomic.atomicOp!"+="(x, 1)` instead fail_compilation/diag3672.d(10): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(10): Use `core.atomic.atomicOp!"-="(x, 1)` instead fail_compilation/diag3672.d(11): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(11): Use `core.atomic.atomicOp!"-="(x, 1)` instead fail_compilation/diag3672.d(12): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(12): Use `core.atomic.atomicOp!"+="(x, 1)` instead fail_compilation/diag3672.d(13): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(13): Use `core.atomic.atomicOp!"+="(x, 2)` instead fail_compilation/diag3672.d(14): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(14): Use `core.atomic.atomicOp!"-="(x, 3)` instead fail_compilation/diag3672.d(15): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(15): Use `core.atomic.atomicOp!"|="(x, y)` instead fail_compilation/diag3672.d(16): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(16): Use `core.atomic.atomicOp!"*="(x, y)` instead fail_compilation/diag3672.d(17): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(17): Use `core.atomic.atomicOp!"/="(x, y)` instead fail_compilation/diag3672.d(18): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(18): Use `core.atomic.atomicOp!"%="(x, y)` instead fail_compilation/diag3672.d(19): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(19): Use `core.atomic.atomicOp!"&="(x, y)` instead fail_compilation/diag3672.d(20): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(20): Use `core.atomic.atomicOp!"^="(x, y)` instead fail_compilation/diag3672.d(21): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(21): Use `core.atomic.atomicOp!"<<="(x, y)` instead fail_compilation/diag3672.d(22): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(22): Use `core.atomic.atomicOp!">>="(x, y)` instead fail_compilation/diag3672.d(23): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(23): Use `core.atomic.atomicOp!">>>="(x, y)` instead fail_compilation/diag3672.d(24): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(24): Use `core.atomic.atomicOp!"^^="(x, y)` instead fail_compilation/diag3672.d(25): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(25): Use `core.atomic.atomicOp!"+="(ptr, 1)` instead fail_compilation/diag3672.d(26): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(26): Use `core.atomic.atomicOp!"+="(ptr, 1)` instead fail_compilation/diag3672.d(27): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(27): Use `core.atomic.atomicOp!"-="(ptr, 1)` instead fail_compilation/diag3672.d(28): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672.d(28): Use `core.atomic.atomicOp!"-="(ptr, 1)` instead --- */ #line 1 shared int x; shared int y; shared int* ptr; shared static this() { ptr = new int; } // silence null-dereference errors void main() { ++x; x++; --x; x--; x += 1; x += 2; x -= 3; x |= y; x *= y; x /= y; x %= y; x &= y; x ^= y; x <<= y; x >>= y; x >>>= y; x ^^= y; ++ptr; ptr++; --ptr; ptr--; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail263.d0000644000175000017500000000076115205374123020744 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/fail263.d(20): Error: function `f` is not callable using argument types `(const(byte)*)` fail_compilation/fail263.d(20): cannot pass argument `cast(const(byte)*)A` of type `const(byte)*` to parameter `byte* p` fail_compilation/fail263.d(14): `fail263.f(byte* p)` declared here ---- */ // https://issues.dlang.org/show_bug.cgi?id=2766 // DMD hangs with 0%cpu const byte[] A = [ cast(byte)0 ]; void f(byte* p) { } void func() { f(A.ptr); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19319a.d0000644000175000017500000000075015205374123021257 0ustar fabiofabio/* DFLAGS: REQUIRED_ARGS: -conf= -Ifail_compilation/extra-files/minimal TEST_OUTPUT: --- fail_compilation/fail19319a.d(16): Error: `7 ^^ g19319` requires `std.math` for `^^` operators fail_compilation/fail19319a.d(17): Error: `g19319 ^^ 7` requires `std.math` for `^^` operators --- */ __gshared int g19319 = 0; static assert(!__traits(compiles, 7 ^^ g19319)); static assert(!__traits(compiles, g19319 ^^= 7)); __gshared int e19319 = 7 ^^ g19319; __gshared int a19319 = g19319 ^^= 7;; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_circular.d0000644000175000017500000001254215205374123022375 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail_circular.d(16): Error: circular reference to variable `fail_circular.a1` fail_compilation/fail_circular.d(17): Error: circular reference to variable `fail_circular.a2` fail_compilation/fail_circular.d(19): Error: circular reference to variable `fail_circular.b1` fail_compilation/fail_circular.d(20): Error: circular reference to variable `fail_circular.b2` fail_compilation/fail_circular.d(22): Error: circular reference to variable `fail_circular.c1` fail_compilation/fail_circular.d(23): Error: circular reference to variable `fail_circular.c2` fail_compilation/fail_circular.d(25): Error: circular initialization of variable `fail_circular.d1` fail_compilation/fail_circular.d(26): Error: circular initialization of variable `fail_circular.d2` fail_compilation/fail_circular.d(28): Error: circular initialization of variable `fail_circular.e1` fail_compilation/fail_circular.d(29): Error: circular initialization of variable `fail_circular.e2` --- */ auto a1 = a1; // semantic error (cannot determine expression type) auto a2 = .a2; // semantic error const b1 = b1; // semantic error const b2 = .b2; // semantic error enum c1 = c1; // semantic error enum c2 = .c2; // semantic error const int d1 = d1; // CTFE error (expression type is determined to int) const int d2 = .d2; // CTFE error enum int e1 = e1; // CTFE error enum int e2 = .e2; // CTFE error /* TEST_OUTPUT: --- fail_compilation/fail_circular.d(47): Error: circular reference to variable `fail_circular.a1a` fail_compilation/fail_circular.d(49): Error: circular reference to variable `fail_circular.a2a` fail_compilation/fail_circular.d(52): Error: circular reference to variable `fail_circular.b1a` fail_compilation/fail_circular.d(54): Error: circular reference to variable `fail_circular.b2a` fail_compilation/fail_circular.d(57): Error: circular reference to variable `fail_circular.c1a` fail_compilation/fail_circular.d(59): Error: circular reference to variable `fail_circular.c2a` fail_compilation/fail_circular.d(62): Error: circular initialization of variable `fail_circular.d1a` fail_compilation/fail_circular.d(64): Error: circular initialization of variable `fail_circular.d2a` fail_compilation/fail_circular.d(67): Error: circular initialization of variable `fail_circular.e1a` fail_compilation/fail_circular.d(69): Error: circular initialization of variable `fail_circular.e2a` --- */ auto a1a = a1b; auto a1b = a1a; // semantic error auto a2a = a2b; auto a2b = .a2a; // semantic error const b1a = b1b; const b1b = b1a; // semantic error const b2a = b2b; const b2b = .b2a; // semantic error enum c1a = c1b; enum c1b = c1a; // semantic error enum c2a = c2b; enum c2b = .c2a; // semantic error const int d1a = d1b; const int d1b = d1a; // CTFE error const int d2a = d2b; const int d2b = .d2a; // CTFE error enum int e1a = e1b; enum int e1b = e1a; // CTFE error enum int e2a = e2b; enum int e2b = .e2a; // CTFE error /* TEST_OUTPUT: --- fail_compilation/fail_circular.d(84): Error: circular reference to variable `fail_circular.S1.a1` fail_compilation/fail_circular.d(88): Error: circular reference to variable `fail_circular.S2.b1` fail_compilation/fail_circular.d(92): Error: circular reference to variable `fail_circular.S3.c1` fail_compilation/fail_circular.d(97): Error: circular reference to variable `fail_circular.S4.a1a` fail_compilation/fail_circular.d(102): Error: circular reference to variable `fail_circular.S5.b1a` fail_compilation/fail_circular.d(107): Error: circular reference to variable `fail_circular.S6.c1a` --- */ struct S1 { static a1 = S1.a1; // semantic error } struct S2 { static const b1 = S2.b1; // semantic error } struct S3 { enum c1 = S3.c1; // semantic error } struct S4 { static a1a = S4.a1b; static a1b = S4.a1a; // semantic error } struct S5 { static const b1a = S5.b1b; static const b1b = S5.b1a; // semantic error } struct S6 { enum c1a = S6.c1b; enum c1b = S6.c1a; // semantic error } /* TEST_OUTPUT: --- fail_compilation/fail_circular.d(126): Error: circular reference to variable `fail_circular.C.a1` fail_compilation/fail_circular.d(128): Error: circular reference to variable `fail_circular.C.b1` fail_compilation/fail_circular.d(130): Error: circular reference to variable `fail_circular.C.c1` fail_compilation/fail_circular.d(133): Error: circular reference to variable `fail_circular.C.a1a` fail_compilation/fail_circular.d(132): Error: type of variable `fail_circular.C.a1b` has errors fail_compilation/fail_circular.d(136): Error: circular reference to variable `fail_circular.C.b1a` fail_compilation/fail_circular.d(135): Error: type of variable `fail_circular.C.b1b` has errors fail_compilation/fail_circular.d(139): Error: circular reference to variable `fail_circular.C.c1a` fail_compilation/fail_circular.d(138): Error: type of variable `fail_circular.C.c1b` has errors --- */ class C { static a1 = C.a1; // semantic error static const b1 = C.b1; // semantic error enum c1 = C.c1; // semantic error static a1a = C.a1b; static a1b = C.a1a; // semantic error static const b1a = C.b1b; static const b1b = C.b1a; // semantic error enum c1a = C.c1b; enum c1b = C.c1a; // semantic error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9357.d0000644000175000017500000000153115205374123021026 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9357.d(14): Error: cannot implicitly convert expression `1.0` of type `double` to `int` fail_compilation/diag9357.d(15): Error: cannot implicitly convert expression `10.0` of type `double` to `int` fail_compilation/diag9357.d(16): Error: cannot implicitly convert expression `11.0` of type `double` to `int` fail_compilation/diag9357.d(17): Error: cannot implicitly convert expression `99.0` of type `double` to `int` fail_compilation/diag9357.d(18): Error: cannot implicitly convert expression `1.04858e+06L` of type `real` to `int` fail_compilation/diag9357.d(19): Error: cannot implicitly convert expression `1.04858e+06L` of type `real` to `int` --- */ void main() { { int x = 1.0; } { int x = 10.0; } { int x = 11.0; } { int x = 99.0; } { int x = 1048575.0L; } { int x = 1048576.0L; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13577.d0000644000175000017500000000105615205374123021116 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=13577 /* TEST_OUTPUT: --- fail_compilation/fail13577.d(27): Error: cannot implicitly convert tuple element of type `int[]` to variable `x` of type `immutable(int[])` --- */ struct Tuple(Types...) { Types items; alias items this; } struct Range(T) { T[] arr; alias ElemType = Tuple!(int, T); ElemType front() { return typeof(return)(0, arr[0]); } bool empty() { return false; } void popFront() {} } void main() { foreach (immutable i, immutable x; Range!(int[])()) {} // Error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/placenew.d0000644000175000017500000000312415205374123021370 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/placenew.d(23): Error: PlacementExpression `3` is an rvalue, but must be an lvalue fail_compilation/placenew.d(28): Error: undefined identifier `x` fail_compilation/placenew.d(36): Error: `new ( i )` PlacementExpression cannot be evaluated at compile time fail_compilation/placenew.d(39): called from here: `xxx()` fail_compilation/placenew.d(39): while evaluating: `static assert(xxx() == 1)` fail_compilation/placenew.d(48): Error: new placement size 24 must be >= object size 40 fail_compilation/placenew.d(54): Error: placement new cannot be used with associative arrays fail_compilation/placenew.d(67): Error: new placement size 4 must be >= class object size $?:32=16|64=24$ fail_compilation/placenew.d(77): Error: `@safe` function `test7` cannot use placement `new` is not allowed in a `@safe` function --- */ void test0() { int i; int* pi = new (i) int; } void test1() { int* pi = new (3) int; } void test2() { int* px = new (x) int; } void test3() { int xxx() { int i; int* pi = new (i) int(1); return 1; } static assert(xxx() == 1); } struct S { int[6] a; } struct T { int[10] a; } void test4() { S s; new (s) T(); } void test5() { T p; auto aa = new(p) int[int*]; } /*************************************************/ class C6 { int i, j; } int test6() { int k; C6 c = new(k) C6; return c.j; } /*************************************************/ @safe void test7() { int i; int* p = new(i) int; } /*************************************************/ ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7524a.d0000644000175000017500000000022215205374123021164 0ustar fabiofabio/* REQUIRED_ARGS: -o- TEST_OUTPUT: ---- fail_compilation/fail7524a.d(9): Error: invalid filename for `#line` directive ---- */ #line 47 __DATE__ ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail133.d0000644000175000017500000000044215205374123020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail133.d(13): Error: function `D main` circular dependency. Functions cannot be interpreted while being compiled fail_compilation/fail133.d(15): called from here: `main()` --- */ template t(int t) { } int main() { return t!(main() + 8); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15925.d0000644000175000017500000000051115205374123021154 0ustar fabiofabio/* EXTRA_FILES: imports/imp15925.d TEST_OUTPUT: --- fail_compilation/test15925.d(18): Error: undefined identifier `X` fail_compilation/test15925.d(18): while evaluating: `static assert(X == 1)` --- */ mixin template Import() { import imports.imp15925; } class Foo { mixin Import!(); static assert(X == 1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail156.d0000644000175000017500000000224615205374123020745 0ustar fabiofabio// REQUIRED_ARGS: -d /* TEST_OUTPUT: --- fail_compilation/fail156.d(35): Error: overlapping initialization for field `x` and `y` fail_compilation/fail156.d(35): `struct` initializers that contain anonymous unions must initialize only the first member of a `union`. All subsequent non-overlapping fields are default initialized fail_compilation/fail156.d(42): Error: overlapping initialization for field `x` and `y` fail_compilation/fail156.d(42): `struct` initializers that contain anonymous unions must initialize only the first member of a `union`. All subsequent non-overlapping fields are default initialized --- */ alias int myint; struct S { int i; union { int x = 2; int y; } int j = 3; myint k = 4; } void main() { S s = S( 1, 5 ); assert(s.i == 1); assert(s.x == 5); assert(s.y == 5); assert(s.j == 3); assert(s.k == 4); static S t = S( 1, 6, 6 ); assert(t.i == 1); assert(t.x == 6); assert(t.y == 6); assert(t.j == 3); assert(t.k == 4); S u = S( 1, 5, 6 ); assert(u.i == 1); assert(u.x == 5); assert(u.y == 5); assert(u.j == 3); assert(u.k == 4); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test14064.d0000644000175000017500000000105115205374123021145 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test14064.d(11): Error: `private` is a keyword, not an `@` attribute fail_compilation/test14064.d(12): Error: `deprecated` is a keyword, not an `@` attribute fail_compilation/test14064.d(13): Error: `pure` is a keyword, not an `@` attribute fail_compilation/test14064.d(14): Error: `nothrow` is a keyword, not an `@` attribute fail_compilation/test14064.d(15): Error: `in` is a keyword, not an `@` attribute --- */ @private int v; @deprecated void foo(); int goo() @pure; @nothrow unittest {}; void zoom(@in int x); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21849.d0000644000175000017500000000207215205374123021116 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21849 // REQUIRED_ARGS: -verrors=context -vcolumns /* TEST_OUTPUT: --- fail_compilation/fail21849.d(21,17): Error: cannot implicitly convert expression `1` of type `int` to `string` string ß = 1; ^ fail_compilation/fail21849.d(25,42): Error: cannot implicitly convert expression `cast(ushort)65535u` of type `ushort` to `byte` string s = "ß☺-oneline"; byte S = ushort.max; ^ fail_compilation/fail21849.d(30,10): Error: undefined identifier `undefined_identifier` ß-utf"; undefined_identifier; ^ fail_compilation/fail21849.d(35,15): Error: `s[0..9]` has no effect ☺-smiley"; s[0 .. 9]; ^ --- */ void fail21849a() { string ß = 1; } void fail21849b() { string s = "ß☺-oneline"; byte S = ushort.max; } void fail21849c() { string s = " ß-utf"; undefined_identifier; } // Test correct context with line directive present // https://github.com/dlang/dmd/issues/20929 #line 32 void fail21849d() { string s = " ☺-smiley"; s[0 .. 9]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag3672a.d0000644000175000017500000000211315205374123021156 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/diag3672a.d(17): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672a.d(17): Use `core.atomic.atomicOp!"+="(ns.x, 1)` instead fail_compilation/diag3672a.d(19): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672a.d(19): Use `core.atomic.atomicOp!"+="(s.sx, 1)` instead --- */ class NS { shared int x; } shared class S { int sx; } void main() { NS ns = new NS; ns.x++; S s = new S; s.sx++; } /* TEST_OUTPUT: --- fail_compilation/diag3672a.d(35): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672a.d(35): Use `core.atomic.atomicOp!"+="(s.var, 1)` instead fail_compilation/diag3672a.d(36): Error: read-modify-write operations are not allowed for `shared` variables fail_compilation/diag3672a.d(36): Use `core.atomic.atomicOp!"-="(s.var, 2)` instead --- */ void test13003() { struct S { int var; } shared S s; s.var++; s.var -= 2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23073.d0000644000175000017500000000117415205374123021153 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test23073.d(28): Error: assigning scope variable `c` to non-scope parameter `c` calling `assignNext` is not allowed in a `@safe` function fail_compilation/test23073.d(22): which is not `scope` because of `c.next = c` --- */ // https://issues.dlang.org/show_bug.cgi?id=23073 // scope inference from pure doesn't consider self-assignment @safe: class C { C next; } void assignNext(C c) pure nothrow @nogc { c.next = c; } C escape() @nogc { scope C c = new C(); assignNext(c); return c.next; } void main() { C dangling = escape(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag15209.d0000644000175000017500000000075015205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag15209.d(18): Error: accessing non-static variable `x` requires an instance of `C1` fail_compilation/diag15209.d(21): Error: accessing non-static variable `x` requires an instance of `S2` --- */ class C1 { int x; } struct S1 { alias y = C1.x; } struct S2 { int x; } class C2 { alias y = S2.x; } void main() { S1 s1; s1.y = 10; // invalid field variable access auto c2 = new C2(); c2.y = 10; // invalid field variable access } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18994.d0000644000175000017500000000045715205374123021132 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail18994.d(19): Error: struct `fail18994.Type1` is not copyable because it has a disabled postblit --- */ struct Type2 { int opApply(int delegate(ref Type1)) { return 0; } } struct Type1 { @disable this(this); } void test() { foreach(b; Type2()) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail239.d0000644000175000017500000000020715205374123020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail239.d(8): Error: type `F` is not an expression --- */ class F { int x; } alias typeof(F).x b; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11926.d0000644000175000017500000000034615205374123020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11926.d(11): Error: no identifier for declarator `const(a)` fail_compilation/ice11926.d(12): Error: no identifier for declarator `const(b)` --- */ enum { const a = 1, const b = 2 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11925.d0000644000175000017500000000103415205374123020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11925.d(23): Error: cannot `goto` into `try` block fail_compilation/ice11925.d(31): Error: cannot `goto` into `try` block --- */ void test11925a() { try { try { L1: {} } finally { } } finally { } goto L1; } void test11925b() { switch (1) { case 1: goto L1; break; default: break; } try { L1: { } } finally { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11849b.d0000644000175000017500000000060515205374123021104 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11849b.d(11): Error: circular reference to enum base type `DWORD1` fail_compilation/ice11849b.d(11): Error: `DWORD1` is used as a type fail_compilation/ice11849b.d(16): Error: circular reference to enum base type `typeof(DWORD2)` --- */ enum REG_DWORD = 1; enum : DWORD1 { DWORD1 = REG_DWORD } enum : typeof(DWORD2) { DWORD2 = REG_DWORD } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20551.d0000644000175000017500000000104315205374123021100 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail20551.d(15): Error: taking address of lazy parameter `e` is not allowed in a `@safe` function fail_compilation/fail20551.d(26): Error: template instance `fail20551.LazyStore!int.LazyStore.opAssign!int` error instantiating --- */ struct LazyStore(T) { T delegate() @safe dg; void opAssign(E)(lazy E e) @safe { dg = cast(typeof(dg)) &e; } T test() @safe{ return dg(); } } static LazyStore!int f; void main(string[] args) @safe { int x = 1; f = x + x + 20 + x * 20; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b17285.d0000644000175000017500000000061615205374123020425 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/b17285.d(15): Error: type `ONE` has no value fail_compilation/b17285.d(15): perhaps use `ONE.init` fail_compilation/b17285.d(15): Error: type `TWO` has no value fail_compilation/b17285.d(15): Error: cannot implicitly convert expression `ONE` of type `b17285.ONE` to `int` --- */ class ONE {} enum TWO; void foo() { foreach(key; [ONE, TWO, 1]) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375v.d0000644000175000017500000000043215205374123021215 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375v.d(12): Error: else is dangling, add { } after condition at fail_compilation/fail4375v.d(10) --- */ version (A) version (B) struct G3 {} else struct G4 {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/safer.d0000644000175000017500000000046115205374123020673 0ustar fabiofabio/* REQUIRED_ARGS: -preview=safer TEST_OUTPUT: --- fail_compilation/safer.d(10): Error: `void` initializing a pointer is not allowed in a function with default safety with `-preview=safer` --- */ void test1() { int* p = void; } void foo3() { } void test2() { foo3(); // should not be an error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20638.d0000644000175000017500000000037315205374123021113 0ustar fabiofabio/* EXTRA_FILES: imports/fail20638b.d TEST_OUTPUT: --- fail_compilation/fail20638.d(13): Error: undefined identifier `foo` in module `imports.fail20638b` --- */ module fail20638; import imports.fail20638b; void main() { imports.fail20638b.foo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16116.d0000644000175000017500000000042215205374123021146 0ustar fabiofabio/* REQUIRED_ARGS: -m64 TEST_OUTPUT: --- fail_compilation/test16116.d(14): Error: incompatible types for `(v) * (i)`: `__vector(short[8])` and `int` --- */ // https://issues.dlang.org/show_bug.cgi?id=16116 void foo() { __vector(short[8]) v; int i; v = v * i; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23886.i0000644000175000017500000000070515205374123021173 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23886.i(103): Error: "string" expected after `#ident` fail_compilation/test23886.i(103): Error: no type for declarator before `#` fail_compilation/test23886.i(104): Error: "string" expected after `#ident` fail_compilation/test23886.i(105): Error: "string" expected after `#ident` --- */ // https://issues.dlang.org/show_bug.cgi?id=23886 #line 100 #ident "abc" #ident 7 #ident "def" x #ident void test() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failescape.d0000644000175000017500000000016715205374123021672 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/failescape.d(8): Error: character '\' is not a valid token --- */ string x = \n; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag11078.d0000644000175000017500000000070215205374123021076 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag11078.d(19): Error: none of the overloads of `value` are callable using argument types `(double)` fail_compilation/diag11078.d(12): Candidates are: `diag11078.S1.value()` fail_compilation/diag11078.d(13): `diag11078.S1.value(int n)` --- */ struct S1 { @property int value() { return 1; } @property void value(int n) { } } void main() { S1 s1; s1.value = 1.0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail1900.d0000644000175000017500000000244415205374123021023 0ustar fabiofabio/* EXTRA_FILES: imports/fail1900a.d imports/fail1900b.d TEST_OUTPUT: --- fail_compilation/fail1900.d(27): Error: template `fail1900.Mix1a!().Foo` matches more than one template declaration: fail_compilation/fail1900.d(14): `Foo(ubyte x)` and: fail_compilation/fail1900.d(15): `Foo(byte x)` --- */ template Mix1a() { template Foo(ubyte x) {} template Foo(byte x) {} } template Mix1b() { template Foo(int x) {} } mixin Mix1a; mixin Mix1b; void test1900a() { alias x = Foo!1; } /* TEST_OUTPUT: --- fail_compilation/fail1900.d(44): Error: `Bar` matches conflicting symbols: fail_compilation/imports/fail1900b.d(2): template `imports.fail1900b.Bar(short n)` fail_compilation/imports/fail1900a.d(2): template `imports.fail1900a.Bar(int n)` --- */ import imports.fail1900a; import imports.fail1900b; void test1900b() { enum x = Bar!1; } /* TEST_OUTPUT: --- fail_compilation/fail1900.d(70): Error: `Baz` matches conflicting symbols: fail_compilation/fail1900.d(62): template `fail1900.Mix2b!().Baz(int x)` fail_compilation/fail1900.d(58): template `fail1900.Mix2a!().Baz(byte x)` --- */ template Mix2a() { template Baz(byte x) {} } template Mix2b() { template Baz(int x) {} } mixin Mix2a; mixin Mix2b; void test1900c() { alias x = Baz!1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20163.d0000644000175000017500000000035515205374123021104 0ustar fabiofabio// REQUIRED_ARGS: -de // EXTRA_FILES: imports/fail20164.d /* TEST_OUTPUT: --- fail_compilation/fail20163.d-mixin-11(11): Deprecation: module `imports.fail20164` is deprecated --- */ module fail20163; mixin("import imports.fail20164;"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15535.d0000644000175000017500000000046115205374123021111 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail15535.d(17): Error: `goto default` not allowed in `final switch` statement --- */ void test() { int i; switch (i) { case 0: final switch (i) { case 1: goto default; } default: break; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/imphint.d0000644000175000017500000001321315205374123021242 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/imphint.d(60): Error: `printf` is not defined, perhaps `import core.stdc.stdio;` is needed? fail_compilation/imphint.d(61): Error: `writeln` is not defined, perhaps `import std.stdio;` is needed? fail_compilation/imphint.d(62): Error: `sin` is not defined, perhaps `import std.math;` is needed? fail_compilation/imphint.d(63): Error: `cos` is not defined, perhaps `import std.math;` is needed? fail_compilation/imphint.d(64): Error: `sqrt` is not defined, perhaps `import std.math;` is needed? fail_compilation/imphint.d(65): Error: `fabs` is not defined, perhaps `import std.math;` is needed? fail_compilation/imphint.d(68): Error: `AliasSeq` is not defined, perhaps `import std.meta;` is needed? fail_compilation/imphint.d(69): Error: `appender` is not defined, perhaps `import std.array;` is needed? fail_compilation/imphint.d(70): Error: `array` is not defined, perhaps `import std.array;` is needed? fail_compilation/imphint.d(71): Error: `calloc` is not defined, perhaps `import core.stdc.stdlib;` is needed? fail_compilation/imphint.d(72): Error: `chdir` is not defined, perhaps `import std.file;` is needed? fail_compilation/imphint.d(73): Error: `dirEntries` is not defined, perhaps `import std.file;` is needed? fail_compilation/imphint.d(74): Error: `drop` is not defined, perhaps `import std.range;` is needed? fail_compilation/imphint.d(75): Error: `each` is not defined, perhaps `import std.algorithm;` is needed? fail_compilation/imphint.d(76): Error: `empty` is not defined, perhaps `import std.range;` is needed? fail_compilation/imphint.d(77): Error: `enumerate` is not defined, perhaps `import std.range;` is needed? fail_compilation/imphint.d(78): Error: `endsWith` is not defined, perhaps `import std.algorithm;` is needed? fail_compilation/imphint.d(79): Error: `enforce` is not defined, perhaps `import std.exception;` is needed? fail_compilation/imphint.d(80): Error: `equal` is not defined, perhaps `import std.algorithm;` is needed? fail_compilation/imphint.d(81): Error: `exists` is not defined, perhaps `import std.file;` is needed? fail_compilation/imphint.d(82): Error: `filter` is not defined, perhaps `import std.algorithm;` is needed? fail_compilation/imphint.d(83): Error: `format` is not defined, perhaps `import std.format;` is needed? fail_compilation/imphint.d(84): Error: `free` is not defined, perhaps `import core.stdc.stdlib;` is needed? fail_compilation/imphint.d(85): Error: `front` is not defined, perhaps `import std.range;` is needed? fail_compilation/imphint.d(86): Error: `iota` is not defined, perhaps `import std.range;` is needed? fail_compilation/imphint.d(87): Error: `isDir` is not defined, perhaps `import std.file;` is needed? fail_compilation/imphint.d(88): Error: `isFile` is not defined, perhaps `import std.file;` is needed? fail_compilation/imphint.d(89): Error: `join` is not defined, perhaps `import std.array;` is needed? fail_compilation/imphint.d(90): Error: `joiner` is not defined, perhaps `import std.algorithm;` is needed? fail_compilation/imphint.d(91): Error: `malloc` is not defined, perhaps `import core.stdc.stdlib;` is needed? fail_compilation/imphint.d(92): Error: `map` is not defined, perhaps `import std.algorithm;` is needed? fail_compilation/imphint.d(93): Error: `max` is not defined, perhaps `import std.algorithm;` is needed? fail_compilation/imphint.d(94): Error: `min` is not defined, perhaps `import std.algorithm;` is needed? fail_compilation/imphint.d(95): Error: `mkdir` is not defined, perhaps `import std.file;` is needed? fail_compilation/imphint.d(96): Error: `popFront` is not defined, perhaps `import std.range;` is needed? fail_compilation/imphint.d(97): Error: `realloc` is not defined, perhaps `import core.stdc.stdlib;` is needed? fail_compilation/imphint.d(98): Error: `replace` is not defined, perhaps `import std.array;` is needed? fail_compilation/imphint.d(99): Error: `rmdir` is not defined, perhaps `import std.file;` is needed? fail_compilation/imphint.d(100): Error: `sort` is not defined, perhaps `import std.algorithm;` is needed? fail_compilation/imphint.d(101): Error: `split` is not defined, perhaps `import std.array;` is needed? fail_compilation/imphint.d(102): Error: `startsWith` is not defined, perhaps `import std.algorithm;` is needed? fail_compilation/imphint.d(103): Error: `take` is not defined, perhaps `import std.range;` is needed? fail_compilation/imphint.d(104): Error: `text` is not defined, perhaps `import std.conv;` is needed? fail_compilation/imphint.d(105): Error: `to` is not defined, perhaps `import std.conv;` is needed? fail_compilation/imphint.d(107): Error: `InterpolationHeader` is not defined, perhaps `import core.interpolation;` ? fail_compilation/imphint.d(108): Error: template `heresy` is not callable using argument types `!()(InterpolationHeader, InterpolationFooter)` fail_compilation/imphint.d(107): Candidate is: `heresy(Args...)(InterpolationHeader header, Args args, InterpolationFooter footer)` --- */ void foo() { printf("hello world\n"); writeln("hello world\n"); sin(3.6); cos(1.2); sqrt(2.0); fabs(-3); AliasSeq(); appender(); array(); calloc(); chdir(); dirEntries(); drop(); each(); empty(); enumerate(); endsWith(); enforce(); equal(); exists(); filter(); format(); free(); front(); iota(); isDir(); isFile(); join(); joiner(); malloc(); map(); max(); min(); mkdir(); popFront(); realloc(); replace(); rmdir(); sort(); split(); startsWith(); take(); text(); to(); void heresy(Args...)(InterpolationHeader header, Args args, InterpolationFooter footer) {} heresy(i""); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10082.d0000644000175000017500000000041615205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10082.d(24): Error: cannot infer type from overloaded function symbol `&foo` --- */ mixin template T() { int foo() { return 0; } } class A { mixin T; mixin T; } void main() { auto x = &A.foo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21247.d0000644000175000017500000000102615205374123021150 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test21247.d(13): Error: anonymous union can only be a part of an aggregate, not function `hang_dmd` fail_compilation/test21247.d(17): Error: undefined identifier `u` fail_compilation/test21247.d(18): Error: undefined identifier `b` fail_compilation/test21247.d(20): called from here: `hang_dmd(0u)` --- */ // https://github.com/dlang/dmd/issues/21247 ubyte[4] hang_dmd(uint a) { union { uint u = void; ubyte[4] b; } u = a; return b; } enum T = hang_dmd(0); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail145.d0000644000175000017500000000103015205374123020731 0ustar fabiofabio/* REQUIRED_ARGS: -checkaction=context TEST_OUTPUT: --- fail_compilation/fail145.d(14): Error: `assert(i && (i < 0))` failed fail_compilation/fail145.d(27): called from here: `bar(7)` --- */ //import core.stdc.stdio : printf; int bar(int i) { assert(i && i < 0); foreach_reverse (k, v; "hello") { i <<= 1; if (k == 2) break; i += v; } return i; } void main() { static b = bar(7); auto c = bar(7); //printf("b = %d, %d\n", b, c); assert(b && b == 674); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail86.d0000644000175000017500000000025215205374123020662 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail86.d(12): Error: alias `Foo` recursive alias declaration --- */ template Foo(TYPE) {} void main() { alias Foo!(int) Foo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag24812.d0000644000175000017500000000021515205374123021075 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag24812.d(7): Error: enum `diag24812.Foo` enum `Foo` must have at least one member --- */ enum Foo {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail258.d0000644000175000017500000000057115205374123020747 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail258.d(101): Error: delimiter cannot be whitespace fail_compilation/fail258.d(101): Error: delimited string must end in `"` fail_compilation/fail258.d(101): Error: declaration expected, not `"X"` fail_compilation/fail258.d(104): Error: unterminated string constant starting at fail_compilation/fail258.d(104) --- */ #line 100 q" X X" ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11751.d0000644000175000017500000000046215205374123021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11751.d(10): Error: missing exponent fail_compilation/fail11751.d(10): Error: semicolon expected following auto declaration, not `ABC` fail_compilation/fail11751.d(10): Error: variable name expected after type `ABC`, not `;` --- */ auto x = 0x1.FFFFFFFFFFFFFpABC; ./ldc-1.42.0-src/tests/dmd/fail_compilation/b15909.d0000644000175000017500000000032115205374123020417 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/b15909.d(12): Error: duplicate `case 'a'` in `switch` statement --- */ void main() { switch ('a') { case 'a': case 'a': break; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6611.d0000644000175000017500000000027615205374123021030 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail6611.d(11): Error: cannot post-increment array slice `x[]`, use pre-increment instead --- */ void main() { auto x = new int[](10); x[]++; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10534.d0000644000175000017500000000324015205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10534.d(24): Error: illegal operator `+` for `a` of type `int delegate()` fail_compilation/fail10534.d(24): Error: illegal operator `+` for `b` of type `int delegate()` fail_compilation/fail10534.d(25): Error: illegal operator `-` for `a` of type `int delegate()` fail_compilation/fail10534.d(25): Error: illegal operator `-` for `b` of type `int delegate()` fail_compilation/fail10534.d(26): Error: illegal operator `/` for `a` of type `int delegate()` fail_compilation/fail10534.d(27): Error: illegal operator `*` for `a` of type `int delegate()` fail_compilation/fail10534.d(32): Error: illegal operator `+` for `a` of type `int function()` fail_compilation/fail10534.d(32): Error: illegal operator `+` for `b` of type `int function()` fail_compilation/fail10534.d(33): Error: illegal operator `-` for `a` of type `int function()` fail_compilation/fail10534.d(33): Error: illegal operator `-` for `b` of type `int function()` fail_compilation/fail10534.d(34): Error: illegal operator `/` for `a` of type `int function()` fail_compilation/fail10534.d(35): Error: illegal operator `*` for `a` of type `int function()` --- */ void main() { { int delegate() a = ()=>5; int delegate() b = ()=>5; auto c1 = a + b; // passes (and will crash if c1() called) auto c2 = a - b; // passes (and will crash if c2() called) auto c3 = a / b; // a & b not of arithmetic type auto c4 = a * b; // a & b not of arithmetic type } { int function() a = ()=>5; int function() b = ()=>5; auto c1 = a + b; auto c2 = a - b; auto c3 = a / b; auto c4 = a * b; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20.d0000644000175000017500000000064115205374123020650 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail20.d(17): Error: no operator `<` for type `FOO` fail_compilation/fail20.d(11): perhaps overload it with `int opCmp(FOO other) const {}` --- */ // ICE(cod3) DMD0.080 struct FOO{} void main() { FOO one; FOO two; if (one < two){} // This should tell me that there // is no opCmp() defined instead // of crashing. } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11922.d0000644000175000017500000000042015205374123020725 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11922.d(11): Error: undefined identifier `a` fail_compilation/ice11922.d(17): Error: template instance `ice11922.S.f!int` error instantiating --- */ struct S { auto f(B)(B) { return a; } } void main() { S s; s.f(5); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/staticarrayoverflow.d0000644000175000017500000000233415205374123023706 0ustar fabiofabio/* DISABLED: LDC // no hardcoded limit for static array size REQUIRED_ARGS: -m64 TEST_OUTPUT: --- fail_compilation/staticarrayoverflow.d(23): Error: static array `S[cast(size_t)1879048192]` size overflowed to 7516192768000 fail_compilation/staticarrayoverflow.d(23): Error: variable `staticarrayoverflow.y` size overflow fail_compilation/staticarrayoverflow.d(25): Error: static array `S[cast(size_t)8070450532247928832]` size overflowed to 8070450532247928832 fail_compilation/staticarrayoverflow.d(25): Error: variable `staticarrayoverflow.a` size overflow fail_compilation/staticarrayoverflow.d(26): Error: static array `S[0][18446744073709551615LU]` size overflowed to 18446744073709551615 fail_compilation/staticarrayoverflow.d(26): Error: variable `staticarrayoverflow.b` size overflow fail_compilation/staticarrayoverflow.d(27): Error: static array `S[0][cast(size_t)4294967295]` size overflowed to 4294967295 fail_compilation/staticarrayoverflow.d(27): Error: variable `staticarrayoverflow.c` size overflow --- */ version (LDC) { /* don't attempt to compile, OOM error can take a while */ } else: struct S { int[1000] x; } S[0x7000_0000] y; S[0x100_0000/(4*1000 - 1)] z; S[0x7000_0000_0000_0000] a; S[0][-1] b; S[0][uint.max] c; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20965.d0000644000175000017500000000107115205374123021112 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20965 // REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail20965.d(17): Deprecation: `struct S` implicitly-generated postblit hides copy constructor. fail_compilation/fail20965.d(17): The field postblit will have priority over the copy constructor. fail_compilation/fail20965.d(17): To change this, the postblit should be disabled for `struct S` --- */ struct C { this(this) {} } struct S { C c; @disable this(ref typeof(this)); } void main() { S s1; auto s2 = s1; // problem } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail40.d0000644000175000017500000000026215205374123020651 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail40.d(11): Error: variable `yuiop` cannot be read at compile time --- */ struct Qwert { int[20] yuiop; int* asdfg = yuiop.ptr; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/static_import.d0000644000175000017500000000024415205374123022453 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/static_import.d(8): Error: static import `core` cannot have an import bind list --- */ static import core.stdc.stdio : p = q; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9759.d0000644000175000017500000000062715205374123020675 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9759.d(25): Error: mutable method `ice9759.Json.opAssign` is not callable using a `const` object fail_compilation/ice9759.d(17): Consider adding `const` or `inout` here --- */ struct Json { union { Json[] m_array; Json[string] m_object; } void opAssign(Json v) { } } void bug() { const(Json) r; r = r.init; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11919.d0000644000175000017500000000107215205374123020737 0ustar fabiofabio/* EXTRA_FILES: imports/a11919.d TEST_OUTPUT: --- fail_compilation/ice11919.d(18): Error: initializer must be an expression, not `foo` fail_compilation/imports/a11919.d(4): Error: template instance `a11919.doBar!(Foo).doBar.zoo!(t)` error instantiating fail_compilation/imports/a11919.d(11): instantiated from here: `doBar!(Foo)` fail_compilation/ice11919.d(26): instantiated from here: `doBar!(Bar)` --- */ import imports.a11919; enum foo; class Foo { @foo bool _foo; } class Bar : Foo {} void main() { auto bar = new Bar(); bar.doBar; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17969.d0000644000175000017500000000072315205374123021127 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17969.d(10): Error: no property `sum` for type `fail17969.__lambda_L10_C1!(int[]).__lambda_L10_C1.MapResult2!((b) => b)` fail_compilation/fail17969.d(16): struct `MapResult2` defined here --- * https://issues.dlang.org/show_bug.cgi?id=17969 */ alias fun = a => MapResult2!(b => b).sum; int[] e; static assert(!is(typeof(fun(e)) == void)); void foo() { fun(e); } struct MapResult2(alias fun) { int[] _input; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/traits_initSymbol.d0000644000175000017500000000343515205374123023316 0ustar fabiofabio/******************************************** TEST_OUTPUT: --- fail_compilation/traits_initSymbol.d(105): Error: struct / class type expected as argument to __traits(initSymbol) instead of `int` fail_compilation/traits_initSymbol.d(106): Error: struct / class type expected as argument to __traits(initSymbol) instead of `S[2]` fail_compilation/traits_initSymbol.d(107): Error: struct / class type expected as argument to __traits(initSymbol) instead of `123` --- */ #line 100 struct S { int i = 4; } void test1() { const void[] initInt = __traits(initSymbol, int); const void[] initArray = __traits(initSymbol, S[2]); const void[] initValue = __traits(initSymbol, 123); } /******************************************** TEST_OUTPUT: --- fail_compilation/traits_initSymbol.d(203): Error: cannot determine the address of the initializer symbol during CTFE fail_compilation/traits_initSymbol.d(203): called from here: `(*function () pure nothrow @nogc @safe => S)()` --- */ #line 200 void test2() { enum initLen = (() => __traits(initSymbol, S))(); } /******************************************** TEST_OUTPUT: --- fail_compilation/traits_initSymbol.d(305): Error: struct / class type expected as argument to __traits(initSymbol) instead of `traits_initSymbol.Interface` --- */ #line 300 interface Interface {} void test3() { const void[] initInterface = __traits(initSymbol, Interface); } /******************************************** TEST_OUTPUT: --- fail_compilation/traits_initSymbol.d(404): Error: expected 1 arguments for `initSymbol` but had 0 fail_compilation/traits_initSymbol.d(405): Error: expected 1 arguments for `initSymbol` but had 2 --- */ #line 400 void test4() { const void[] tmp = __traits(initSymbol); const void[] tmo = __traits(initSymbol, Interface, S); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23789.c0000644000175000017500000000056515205374123021173 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23789.c(101): Error: __decspec(align(3)) must be an integer positive power of 2 and be <= 8,192 fail_compilation/test23789.c(103): Error: alignment value expected, not `"a"` --- */ // https://issues.dlang.org/show_bug.cgi?id=23789 #line 100 struct __declspec(align(3)) S { int a; }; struct __declspec(align("a")) T { int a; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag11759.d0000644000175000017500000000023215205374123021102 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag11759.d(8): Error: lower case integer suffix 'l' is not allowed. Please use 'L' instead --- */ ulong x = 123ul; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail320.d0000644000175000017500000000100715205374123020730 0ustar fabiofabio/* EXTRA_FILES: imports/fail320a.d imports/fail320b.d TEST_OUTPUT: --- fail_compilation/fail320.d(16): Error: no overload matches for `foo("")` fail_compilation/fail320.d(16): Candidates are: fail_compilation/imports/fail320b.d(1): foo(T)(string) fail_compilation/imports/fail320b.d(2): foo(alias a)() fail_compilation/imports/fail320a.d(1): foo(int) fail_compilation/imports/fail320a.d(2): foo(bool) --- */ import imports.fail320a; import imports.fail320b; void main() { foo(""); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/constraints_defs.d0000755000175000017500000000413715205374123023152 0ustar fabiofabio/* EXTRA_FILES: imports/constraints.d TEST_OUTPUT: --- fail_compilation/constraints_defs.d(49): Error: template instance `constraints_defs.main.def!(int, 0, (a) => a)` does not match template declaration `def(T, int i = 5, alias R)()` with `T = int, i = 0, R = (a) => a` must satisfy the following constraint: ` N!T` fail_compilation/constraints_defs.d(50): Error: template instance `imports.constraints.defa!int` does not match template declaration `defa(T, U = int)()` with `T = int` must satisfy the following constraint: ` N!T` fail_compilation/constraints_defs.d(51): Error: template instance `imports.constraints.defv!()` does not match template declaration `defv(T = bool, int i = 5, Ts...)()` with `Ts = ()` must satisfy the following constraint: ` N!T` fail_compilation/constraints_defs.d(52): Error: template instance `imports.constraints.defv!int` does not match template declaration `defv(T = bool, int i = 5, Ts...)()` with `T = int, Ts = ()` must satisfy the following constraint: ` N!T` fail_compilation/constraints_defs.d(53): Error: template instance `imports.constraints.defv!(int, 0)` does not match template declaration `defv(T = bool, int i = 5, Ts...)()` with `T = int, i = 0, Ts = ()` must satisfy the following constraint: ` N!T` fail_compilation/constraints_defs.d(54): Error: template instance `imports.constraints.defv!(int, 0, bool)` does not match template declaration `defv(T = bool, int i = 5, Ts...)()` with `T = int, i = 0, Ts = (bool)` must satisfy the following constraint: ` N!T` fail_compilation/constraints_defs.d(55): Error: template instance `imports.constraints.defv!(int, 0, bool, float)` does not match template declaration `defv(T = bool, int i = 5, Ts...)()` with `T = int, i = 0, Ts = (bool, float)` must satisfy the following constraint: ` N!T` --- */ void main() { import imports.constraints; def!(int, 0, a => a)(); defa!(int)(); defv!()(); defv!(int)(); defv!(int, 0)(); defv!(int, 0, bool)(); defv!(int, 0, bool, float)(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag12829.d0000644000175000017500000000177215205374123021113 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag12829.d(15): Error: function `diag12829.test1` is `@nogc` yet allocates closure for `test1()` with the GC fail_compilation/diag12829.d(18): delegate `() { int y = x; }` closes over variable `x` fail_compilation/diag12829.d(17): `x` declared here fail_compilation/diag12829.d(22): function `bar` closes over variable `x` fail_compilation/diag12829.d(17): `x` declared here fail_compilation/diag12829.d(29): Error: function `diag12829.test2` is `@nogc` yet allocates closure for `test2()` with the GC fail_compilation/diag12829.d(34): function `foo` closes over variable `x` fail_compilation/diag12829.d(31): `x` declared here --- */ auto test1() @nogc { int x; void delegate() @nogc foo = () { int y = x; }; void bar() { int y = x; } auto dg = &bar; } auto test2() @nogc { int x; struct S { void foo() { int y = x; } } return S(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/covariant_override.d0000644000175000017500000000231415205374123023457 0ustar fabiofabio/++ https://issues.dlang.org/show_bug.cgi?id=21538 TEST_OUTPUT: --- fail_compilation/covariant_override.d(23): Error: function `@safe void covariant_override.CI.f(void delegate() @safe dg)` does not override any function, did you mean to override `@safe void covariant_override.I.f(void delegate() @system dg)`? fail_compilation/covariant_override.d(34): Error: function `@safe void covariant_override.CA.f(void delegate() @safe dg)` does not override any function, did you mean to override `@safe void covariant_override.A.f(void delegate() @system dg)`? fail_compilation/covariant_override.d(20): Error: class `covariant_override.CI` interface function `void f(void delegate() @system dg) @safe` is not implemented --- ++/ static assert(!is(void delegate() @system : void delegate() @safe)); static assert( is(void delegate() @safe : void delegate() @system)); interface I { void f(void delegate() @system dg) @safe; } class CI : I { // this overrride should not be legal override void f(void delegate() @safe dg) @safe { } } abstract class A { void f(void delegate() @system dg) @safe; } class CA : A { // this overrride should not be legal override void f(void delegate() @safe dg) @safe { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18228.d0000644000175000017500000000062715205374123021117 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail18228.d(12): Error: undefined identifier `this`, did you mean `typeof(this)`? fail_compilation/fail18228.d(13): Error: undefined identifier `this`, did you mean `typeof(this)`? fail_compilation/fail18228.d(14): Error: undefined identifier `super`, did you mean `typeof(super)`? --- */ class C { this(this a) {} this(int a, this b) {} this(super a) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/staticforeach1.d0000644000175000017500000000027615205374123022477 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/staticforeach1.d(10): Error: must use labeled `break` within `static foreach` --- */ void main(){ for(;;){ static foreach(i;0..1){ break; } } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail153.d0000644000175000017500000000026615205374123020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail153.d(10): Error: class `fail153.Bar` cannot inherit from class `Foo` because it is `final` --- */ final class Foo { } class Bar : Foo { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21830.d0000644000175000017500000000137415205374123021110 0ustar fabiofabio/* REQUIRED_ARGS: -de -unittest TEST_OUTPUT: --- fail_compilation/fail21830.d(24): Deprecation: struct `fail21830.OldS21830` is deprecated - Deprecated type fail_compilation/fail21830.d(24): Deprecation: template `fail21830.test21830(T)(T t) if (is(T == OldS21830))` is deprecated - Deprecated template fail_compilation/fail21830.d(24): Deprecation: struct `fail21830.OldS21830` is deprecated - Deprecated type --- */ #line 1 deprecated("Deprecated type") struct OldS21830 { } struct NewS21830 { } static if (1) { auto test21830(T)(T t) if (is(T == NewS21830)) { return T.init; } } deprecated("Deprecated template") auto test21830(T)(T t) if (is(T == OldS21830)) { return T.init; } unittest { auto b = test21830(OldS21830()); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24159.d0000644000175000017500000000044015205374123021154 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24159 // REQUIRED_ARGS: -betterC /* TEST_OUTPUT: --- fail_compilation/test24159.d(13): Error: appending to array in `x ~= 3` requires the GC which is not available with -betterC --- */ extern(C) void main() { int[] x = null; x ~= 3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22680.d0000644000175000017500000000047215205374123021156 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test22680.d(104): Error: assigning scope variable `this` to global variable `c` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=22680 #line 100 C c; class C { ~this() @safe { c = this; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16228.d0000644000175000017500000000104415205374123021153 0ustar fabiofabio/* REQUIRED_ARGS: TEST_OUTPUT: --- fail_compilation/test16228.d(23): Error: function `test16228.S.bar` `static` member has no `this` to which `return` can apply --- */ // https://issues.dlang.org/show_bug.cgi?id=16228 int* wrap ( return ref int input ) { return &input; } struct S { int x; int foo() return { return 3; } static ref int bar() return { return x; } } // https://issues.dlang.org/show_bug.cgi?id=18963 T Identity(T)(return T t) { return t; } void bar(int i, void* p) { Identity(p); Identity(i); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10212.d0000644000175000017500000000064415205374123020724 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10212.d(13): Error: expected return type of `int`, not `int function() pure nothrow @nogc @safe`: fail_compilation/ice10212.d(13): Return type of `int` inferred here. --- */ int delegate() foo() { // returns "int function() pure nothrow @safe function() pure nothrow @safe" // and it mismatches to "int delegate()" return () => () { return 1; }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/udatypes.d0000644000175000017500000000027115205374123021430 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/udatypes.d(8): Error: user-defined attributes not allowed for `alias` declarations --- */ alias c_typedef = extern(C) @(1) void* function(size_t); ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8697.d0000644000175000017500000000045015205374123021033 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8697.d(11): Error: no property `Invalid` for type `diag8697.Base` fail_compilation/diag8697.d(9): class `Base` defined here --- */ interface InterBase : InterRoot { } class Base : InterBase { } void test(Base.Invalid) { } interface InterRoot { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice2843.d0000644000175000017500000000126515205374123020657 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice2843.d(22): Error: incompatible types for `(1) is (typeid(int))`: `int` and `object.TypeInfo` --- */ // https://issues.dlang.org/show_bug.cgi?id=2843 // ICE(constfold.c) with is-expression with invalid dot-expression in is-expression involving typeid expression /* 2843 Assertion failure: '0' on line 863 in file 'constfold.c' PATCH: constfold.c, line 861: OLD: }else assert(0); NEW: }else if (e1->isConst() && e2->isConst()) { // Comparing a SymExp with a literal, eg typeid(int) is 7.1; cmp=0; // An error has already occurred. Prevent an ICE. }else assert(0); */ bool b = 1 is typeid(int); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13123.d0000644000175000017500000000056115205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail13123.d(9): Error: `fail13123.test`: `in` contract may throw but function is marked as `nothrow` fail_compilation/fail13123.d(9): Error: `fail13123.test`: `out` contract may throw but function is marked as `nothrow` --- */ void test() nothrow in { throw new Exception(null); } out { throw new Exception(null); } do { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failexpression3.d0000644000175000017500000003506415205374123022720 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte += float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte -= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte *= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte /= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte %= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte += double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte -= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte *= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte /= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte %= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte += real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte -= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte *= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte /= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `byte %= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte += float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte -= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte *= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte /= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte %= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte += double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte -= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte *= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte /= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte %= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte += real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte -= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte *= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte /= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ubyte %= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short += float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short -= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short *= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short /= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short %= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short += double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short -= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short *= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short /= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short %= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short += real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short -= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short *= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short /= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `short %= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort += float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort -= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort *= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort /= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort %= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort += double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort -= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort *= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort /= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort %= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort += real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort -= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort *= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort /= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ushort %= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int += float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int -= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int *= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int /= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int %= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int += double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int -= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int *= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int /= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int %= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int += real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int -= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int *= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int /= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `int %= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint += float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint -= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint *= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint /= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint %= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint += double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint -= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint *= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint /= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint %= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint += real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint -= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint *= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint /= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `uint %= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long += float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long -= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long *= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long /= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long %= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long += double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long -= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long *= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long /= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long %= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long += real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long -= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long *= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long /= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `long %= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong += float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong -= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong *= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong /= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong %= float` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong += double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong -= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong *= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong /= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong %= double` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong += real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong -= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong *= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong /= real` is performing truncating conversion fail_compilation/failexpression3.d-mixin-139(139): Deprecation: `ulong %= real` is performing truncating conversion fail_compilation/failexpression3.d(149): Error: template instance `failexpression3.X!(integral, floating, arith)` error instantiating fail_compilation/failexpression3.d(154): instantiated from here: `OpAssignCases!(TestOpAssignAuto)` --- */ template TT(T...) { alias T TT; } void TestOpAssignAuto(Tx, Ux, ops)() { foreach(T; Tx.x) foreach(U; Ux.x) foreach(op; ops.x) { T a = cast(T)1; U b = cast(U)1; mixin("auto r = a " ~ op ~ " cast(U)1;"); } } struct integral { alias TT!(byte, ubyte, short, ushort, int, uint, long, ulong) x; } struct floating { alias TT!(float, double, real) x; } struct arith { alias TT!("+=", "-=", "*=", "/=", "%=") x; } void OpAssignCases(alias X)() { X!(integral, floating, arith)(); } void main() { OpAssignCases!TestOpAssignAuto(); // https://issues.dlang.org/show_bug.cgi?id=5181 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test19661.d0000644000175000017500000000104415205374123021157 0ustar fabiofabio/* EXTRA_FILES: imports/imp19661.d TEST_OUTPUT: --- fail_compilation/test19661.d(12): Error: variables cannot be initialized with an expression of type `void` fail_compilation/test19661.d(12): only `= void;` is allowed, which prevents default initialization --- */ module ice19661; immutable bool testModule = testFunctionMembers!(); void testFunctionMembers()() { import imports.imp19661 : isFunction; foreach(member; __traits(allMembers, ice19661)) { bool b = isFunction!(__traits(getMember, ice19661, member)); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag16499.d0000644000175000017500000000116315205374123021114 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag16499.d(24): Error: operator `in` is not defined for type `A` fail_compilation/diag16499.d(11): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int rhs) {}` fail_compilation/diag16499.d(26): Error: operator `in` is not defined for type `B` fail_compilation/diag16499.d(12): perhaps overload the operator with `auto opBinaryRight(string op : "in")(double rhs) {}` --- */ struct A {} struct B { void* opBinaryRight(string op)(int b) if (op == "in") { return null; } } void main() { A foo; B bar; 2 in foo; 2 in bar; // OK 1.0 in bar; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test4838.d0000644000175000017500000000206315205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test4838.d(13): Error: `const`/`immutable`/`shared`/`inout`/`return` attributes are only valid for non-static member functions fail_compilation/test4838.d(14): Error: `const`/`immutable`/`shared`/`inout`/`return` attributes are only valid for non-static member functions fail_compilation/test4838.d(15): Error: `const`/`immutable`/`shared`/`inout`/`return` attributes are only valid for non-static member functions fail_compilation/test4838.d(16): Error: `const`/`immutable`/`shared`/`inout`/`return` attributes are only valid for non-static member functions fail_compilation/test4838.d(17): Error: `const`/`immutable`/`shared`/`inout`/`return` attributes are only valid for non-static member functions fail_compilation/test4838.d(18): Error: `const`/`immutable`/`shared`/`inout`/`return` attributes are only valid for non-static member functions --- */ void function() const fpc; void function() immutable fpi; void function() shared fps; void function() shared const fpsc; void function() inout fpw; void function() shared inout fpsw; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test19646.d0000644000175000017500000000103615205374123021163 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test19646.d(12): Error: cast from `const(int)*` to `int*` can't initialize `@safe` variable `y` fail_compilation/test19646.d(12): Source type is incompatible with target type containing a pointer fail_compilation/test19646.d(18): Error: `@safe` variable `z` cannot be initialized by calling `@system` function `f` --- https://issues.dlang.org/show_bug.cgi?id=19646 */ @safe: const x = 42; int* y = cast(int*)&x; @system: @system int* f() { return cast(int*) 0xDEADBEEF; }; @safe int* z = f(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18892.d0000644000175000017500000000077315205374123021130 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail18892.d(22): Error: no property `foo` for `a` of type `fail18892.MT` fail_compilation/fail18892.d(13): struct `MT` defined here fail_compilation/fail18892.d(23): Error: no property `foo` for `MT` of type `fail18892.MT` fail_compilation/fail18892.d(13): struct `MT` defined here --- */ // https://issues.dlang.org/show_bug.cgi?id=18892 struct MT { int _payload; alias _payload this; } void main() { MT a; a.foo = 3; MT.foo = 3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375m.d0000644000175000017500000000054615205374123021212 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375m.d(14): Error: else is dangling, add { } after condition at fail_compilation/fail4375m.d(11) --- */ void main() { do if (true) if (true) assert(76); else assert(77); while (false); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19098.d0000644000175000017500000000042115205374123021115 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19098.d(18): Error: cannot modify struct instance `a` of type `A` because it contains `const` or `immutable` members --- */ struct A { const int a; this(int) {} } void main() { A a = A(2); A b = A(3); a = b; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9451.d0000644000175000017500000000131315205374123021017 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9451.d(27): Error: cannot create instance of abstract class `C2` fail_compilation/diag9451.d(21): class `C2` is declared here fail_compilation/diag9451.d(15): function `void f1()` is not implemented fail_compilation/diag9451.d(16): function `void f2(int)` is not implemented fail_compilation/diag9451.d(17): function `void f2(float) const` is not implemented fail_compilation/diag9451.d(18): function `int f2(float) pure` is not implemented --- */ class C1 { abstract void f1(); abstract void f2(int); abstract void f2(float) const; abstract int f2(float) pure; } class C2 : C1 { } void main() { auto c2 = new C2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail351.d0000644000175000017500000000065215205374123020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail351.d(14): Error: expression `this.num[index]` of type `immutable(uint)` is not implicitly convertible to return type `ref uint` --- */ // https://issues.dlang.org/show_bug.cgi?id=2780 struct Immutable { immutable uint[2] num; ref uint opIndex(size_t index) immutable return { return num[index]; } } void main() { immutable Immutable foo; //foo[0]++; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14130.d0000644000175000017500000000054115205374123020723 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice14130.d(10): Error: undefined identifier `Undef` fail_compilation/ice14130.d(14): Error: template `foo` is not callable using argument types `!()(int)` fail_compilation/ice14130.d(10): Candidate is: `foo(R, F = Undef)(R r, F s = 0)` --- */ F foo(R, F = Undef)(R r, F s = 0) {} void main() { 0.foo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/parseStc.d0000644000175000017500000000204615205374123021360 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/parseStc.d(12): Error: missing closing `)` after `if (x` fail_compilation/parseStc.d(12): Error: use `{ }` for an empty statement, not `;` fail_compilation/parseStc.d(12): Error: found `)` when expecting `;` following expression fail_compilation/parseStc.d(12): expression: `1` fail_compilation/parseStc.d(13): Error: redundant attribute `const` --- */ void test1() { if (x; 1) {} if (const const auto x = 1) {} } /* TEST_OUTPUT: --- fail_compilation/parseStc.d(26): Error: redundant attribute `const` fail_compilation/parseStc.d(27): Error: redundant attribute `const` fail_compilation/parseStc.d(28): Error: conflicting attribute `immutable` --- */ void test2() { const const x = 1; foreach (const const x; [1,2,3]) {} foreach (const immutable x; [1,2,3]) {} } /* TEST_OUTPUT: --- fail_compilation/parseStc.d(38): Error: redundant attribute `const` fail_compilation/parseStc.d(39): Error: redundant attribute `const` --- */ struct S3 { const const test3() {} } void test4(const const int x) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/alignedext.i0000644000175000017500000000056215205374123021726 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/alignedext.i(10): Error: __decspec(align(123)) must be an integer positive power of 2 and be <= 8,192 fail_compilation/alignedext.i(11): Error: __decspec(align(16384)) must be an integer positive power of 2 and be <= 8,192 --- */ typedef struct __declspec(align(123)) S { int a; } S; struct __declspec(align(16384)) T { int a; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix22253.c0000644000175000017500000000126615205374123020762 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix22253.c(106): Error: `ptr` is not a member of `char[10]` fail_compilation/fix22253.c(107): Error: `length` is not a member of `char[10]` fail_compilation/fix22253.c(108): Error: `dup` is not a member of `char[10]` fail_compilation/fix22253.c(109): Error: `init` is not a member of `char` fail_compilation/fix22253.c(113): Error: `tupleof` is not a member of `S` --- */ // https://issues.dlang.org/show_bug.cgi?id=22253 #line 100 void foo(int, int); void test() { char a[10]; char *p = a.ptr; unsigned i = a.length; char *q = a.dup.ptr; p = p->init; struct S { int a, b; }; struct S s; s.a = s.b; foo(s.tupleof); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/pull12941.d0000644000175000017500000000233615205374123021153 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/pull12941.d(110): Error: `pull12941.foo` called with argument types `(int*)` matches multiple overloads exactly: fail_compilation/pull12941.d(101): `pull12941.foo(return ref scope int* p)` and: fail_compilation/pull12941.d(102): `pull12941.foo(return out scope int* p)` fail_compilation/pull12941.d(111): Error: function `bar` is not callable using argument types `(int)` fail_compilation/pull12941.d(111): cannot pass argument `1` of type `int` to parameter `return scope int* p` fail_compilation/pull12941.d(104): `pull12941.bar(return scope int* p)` declared here fail_compilation/pull12941.d(112): Error: function `abc` is not callable using argument types `(int)` fail_compilation/pull12941.d(112): cannot pass rvalue argument `1` of type `int` to parameter `return ref int* p` fail_compilation/pull12941.d(105): `pull12941.abc(return ref int* p)` declared here --- */ /*********************************/ // Tests for https://github.com/dlang/dmd/pull/12941 #line 100 int* foo(return ref scope int* p); int* foo(return out scope int* p); int* bar(return scope int* p); int* abc(return ref int* p); void test() { int* p; foo(p); bar(1); abc(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/aliasassign1.d0000644000175000017500000000153515205374123022155 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/aliasassign1.d(106): Error: A was read, so cannot reassign fail_compilation/aliasassign1.d(110): Error: template instance `aliasassign1.staticMap!(Unqual, int, const(uint))` error instantiating fail_compilation/aliasassign1.d(112): Error: static assert: `is(TK == AliasSeq!(int, uint))` is false --- */ template AliasSeq(T...) { alias AliasSeq = T; } template Unqual(T) { static if (is(T U == const U)) alias Unqual = U; else static if (is(T U == immutable U)) alias Unqual = U; else alias Unqual = T; } #line 100 template staticMap(alias F, T...) { alias A = AliasSeq!(); alias B = A; static foreach (t; T) A = AliasSeq!(A, F!t); // what's tested alias staticMap = A; } alias TK = staticMap!(Unqual, int, const uint); //pragma(msg, TK); static assert(is(TK == AliasSeq!(int, uint))); ./ldc-1.42.0-src/tests/dmd/fail_compilation/json3.d0000644000175000017500000000034115205374123020624 0ustar fabiofabio/* REQUIRED_ARGS: -Xifoo LDC: just a different error msg DISABLED: LDC TEST_OUTPUT: --- Error: unrecognized switch '-Xifoo' run `dmd` to print the compiler manual run `dmd -man` to open browser on manual --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice8499.d0000644000175000017500000000035715205374123020675 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice8499.d(18): Error: undefined identifier `i` --- */ struct Variant { @property T get(T)() { struct X {} // necessary } } void main() { (Variant()).get!(typeof(() => i)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice19755.d0000644000175000017500000000071015205374123020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice19755.d(12): Error: no property `x` for `self` of type `ice19755.Thunk!int*` fail_compilation/ice19755.d(8): struct `Thunk` defined here fail_compilation/ice19755.d(17): Error: template instance `ice19755.Thunk!int` error instantiating --- */ struct Thunk(Dummy) { void opAssign(int dlg) {} auto get() inout { Thunk* self; self.x = 0; } alias get this; } alias T = Thunk!int; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag19022.d0000644000175000017500000000051615205374123021076 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag19022.d(16): Error: immutable field `b` initialized multiple times fail_compilation/diag19022.d(15): Previous initialization is here. --- */ // https://issues.dlang.org/show_bug.cgi?id=19022 struct Foo { immutable int b; this(int a) { b = 2; b = 2; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13787.d0000644000175000017500000000042715205374123021113 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/diag13787.d(12): Error: cannot slice function pointer `& main` fail_compilation/diag13787.d(13): Error: cannot index function pointer `& main` --- */ void main() { auto a = (&main)[0..1]; auto x = (&main)[0]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11503d.d0000644000175000017500000000117715205374123021251 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11503d.d(26): Error: cannot implicitly convert expression `filename(d)` of type `const(char)[]` to `string` fail_compilation/fail11503d.d(27): Error: cannot implicitly convert expression `filename2(& d)` of type `const(char)[]` to `string` --- */ struct Data2 { char buffer; } @property const(char)[] filename(const return ref Data2 d) pure nothrow { return (&d.buffer)[0 .. 1]; } @property const(char)[] filename2(const Data2* d) pure nothrow { return (&d.buffer)[0 .. 1]; } void main() { Data2 d; string f = d.filename; string g = (&d).filename2; d.buffer = 'a'; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11510.d0000644000175000017500000000137215205374123021100 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11510.d(25): Error: reinterpretation through overlapped field `y` is not allowed in CTFE fail_compilation/fail11510.d(29): called from here: `test11510a()` fail_compilation/fail11510.d(36): Error: reinterpretation through overlapped field `y` is not allowed in CTFE fail_compilation/fail11510.d(40): called from here: `test11510b()` --- */ struct S11510 { union { size_t x; int* y; // pointer field } } bool test11510a() { S11510 s; s.y = [1,2,3].ptr; auto x = s.x; // reinterpretation return true; } enum a = test11510a(); bool test11510b() { S11510 s; s.x = 10; auto y = s.y; // reinterpretation return true; } enum b = test11510b(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail111.d0000644000175000017500000000051615205374123020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail111.d(12): Error: cannot have array of `int(int)` --- */ // https://issues.dlang.org/show_bug.cgi?id=289 // Compiler allows (and crashes on) dynamic arrays of typedefs of "immediate"-function types alias int ft(int); ft[] x; // is allowed void test() { x.length = 2; // crashes DMD } ./ldc-1.42.0-src/tests/dmd/fail_compilation/throwexp.d0000644000175000017500000000042515205374123021453 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/throwexp.d(11): Error: to be thrown `ret()` must be non-null fail_compilation/throwexp.d(12): Error: to be thrown `null` must be non-null --- +/ auto ret() { return Exception.init; } enum y = throw ret(); enum x = throw Exception.init; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail16001.d0000644000175000017500000000065215205374123021100 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail16001.d(10): Deprecation: using `(args) => { ... }` to create a delegate that returns a delegate is error-prone. fail_compilation/fail16001.d(10): Use `(args) { ... }` for a multi-statement function literal or use `(args) => () { }` if you intended for the lambda to return a delegate. --- */ void main() { auto fail = () => {}; auto ok = () => () {}; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21832.d0000644000175000017500000000067215205374123021112 0ustar fabiofabio// REQUIRED_ARGS: -de // EXTRA_FILES: imports/imp21832.d /* TEST_OUTPUT: --- fail_compilation/fail21832.d(4): Deprecation: function `imports.imp21832.fun` is deprecated fail_compilation/fail21832.d(10): Deprecation: template `imports.imp21832.tpl()(char a)` is deprecated --- */ #line 1 int test21832a() { import imports.imp21832 : fun; return fun('a'); } int test21832b() { import imports.imp21832 : tpl; return tpl('a'); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7424b.d0000644000175000017500000000030415205374123021165 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7424b.d(10): Error: template `this.g()()` has no value --- */ struct S7424b { @property int g()() { return 0; } void test() const { int f = g; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12174.d0000644000175000017500000000175715205374123020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12174.d(12): Error: no property `sum` for `[1, 2, 3]` of type `int[]` fail_compilation/ice12174.d(20): Error: CTFE failed because of previous errors in `this` fail_compilation/ice12174.d(13): called from here: `filter([1, 2, 3])` --- */ void main() { enum foo3 = (int n) => [1,2,3].sum; enum bar3 = [1,2,3].filter!(n => n % foo3(n) == 0); } template filter(alias pred) { auto filter(Range)(Range rs) { return FilterResult!(pred, Range)(rs); } } private struct FilterResult(alias pred, R) { R _input; this(R r) { _input = r; while (_input.length && !pred(_input[0])) { _input = _input[1..$]; } } @property bool empty() { return _input.length == 0; } @property auto ref front() { return _input[0]; } void popFront() { do { _input = _input[1..$]; } while (_input.length && !pred(_input[0])); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22023.d0000644000175000017500000000041115205374123021136 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test22023.d(102): Error: typesafe variadic function parameter `a` of type `int[]` cannot be marked `return` --- */ // issues.dlang.org/show_bug.cgi?id=22023 #line 100 @safe: ref int f(return int[] a ...) { return a[2]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/widechars.d0000644000175000017500000000023515205374123021543 0ustar fabiofabio /* DISABLED: win32 win64 TEST_OUTPUT: --- fail_compilation/widechars.d(10): Error: undefined identifier `wchar_t`, did you mean `dchar`? --- */ wchar_t x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20461.d0000644000175000017500000000057015205374123021104 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fail20461.d(106): Error: assigningreference to local variable `buffer` to non-scope parameter calling `assert()` is not allowed in a `@safe` function --- */ #line 100 // https://issues.dlang.org/show_bug.cgi?id=20461 void test() @safe { char[10] buffer = "0123456789"; assert(false, buffer[]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail308.d0000644000175000017500000000051615205374123020742 0ustar fabiofabio// REQUIRED_ARGS: -unittest /* TEST_OUTPUT: --- fail_compilation/fail308.d(18): Error: template instance `object.RTInfo!(TestType)` recursive expansion --- */ void main() { MinHeap!(int) foo = new MinHeap!(int)(); } class MinHeap(NodeType) { unittest { struct TestType {} MinHeap!(TestType) foo; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22084.d0000644000175000017500000000055115205374123021106 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22084 /* TEST_OUTPUT: --- fail_compilation/fail22084.d(22): Error: cannot pass types that need destruction as variadic arguments --- */ import core.stdc.stdarg; extern(C++) void testVariadic(int a, ...) { } struct Destructor { ~this() { } } void test() { auto a0 = Destructor(); testVariadic(1, a0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17908a.d0000644000175000017500000000036115205374123021323 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test17908a.d(10): Error: function `test17908a.foo` cannot be used because it is annotated with `@disable` --- */ @disable void foo(); @disable void foo(int) {} alias g = foo; void main() { g(10); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail280.d0000644000175000017500000000054115205374123020737 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=2920 // recursive templates blow compiler stack // template_17_A. /* TEST_OUTPUT: --- fail_compilation/fail280.d(13): Error: template instance `fail280.t!500` recursive expansion exceeded allowed nesting limit --- */ template t(int i) { const int x = t!(i + 1).x; } void main() { int i = t!(0).x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10.d0000644000175000017500000000033315205374123020645 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10.d(18): Error: mixin `Foo!y` cannot resolve forward reference --- */ template Foo(alias b) { int a() { return b; } } void test() { mixin Foo!(y) y; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24694.d0000644000175000017500000000061415205374123021163 0ustar fabiofabio/** REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test24694.d(25): Error: assigning reference to local variable `x` to non-scope `b.c.p` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=24694 class C { int* p; } struct S { C c; } int* escape() @safe { int x = 0; S b = S(new C()); b.c.p = &x; return b.c.p; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/testTypeof.c0000644000175000017500000000057115205374123021742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/testTypeof.c(10): Error: `typeof` operator expects an expression or type name in parentheses fail_compilation/testTypeof.c(10): Error: identifier or `(` expected fail_compilation/testTypeof.c(10): Error: expected identifier for declarator fail_compilation/testTypeof.c(10): Error: expected identifier for declaration --- */ typeof(1;2) x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375s.d0000644000175000017500000000060215205374123021211 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375s.d(16): Error: else is dangling, add { } after condition at fail_compilation/fail4375s.d(10) --- */ void main() { if (true) try assert(106); catch(Exception e) if (true) assert(107); else assert(108); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/typeerrors.d0000644000175000017500000000451715205374123022017 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/typeerrors.d(37): Error: sequence index `4` out of bounds `[0 .. 4]` fail_compilation/typeerrors.d(39): Error: variable `x` cannot be read at compile time fail_compilation/typeerrors.d(40): Error: cannot have array of `void()` fail_compilation/typeerrors.d(41): Error: cannot have array of scope `typeerrors.C` fail_compilation/typeerrors.d(42): Error: cannot have array of scope `typeerrors.C` fail_compilation/typeerrors.d(45): Error: `int[5]` is not an expression fail_compilation/typeerrors.d(47): Error: variable `x` is used as a type fail_compilation/typeerrors.d(38): variable `x` is declared here fail_compilation/typeerrors.d(48): Error: cannot have associative array key of `void()` fail_compilation/typeerrors.d(49): Error: cannot have associative array key of `void` fail_compilation/typeerrors.d(50): Error: cannot have array of scope `typeerrors.C` fail_compilation/typeerrors.d(51): Error: cannot have associative array of `void` fail_compilation/typeerrors.d(52): Error: cannot have associative array of `void()` fail_compilation/typeerrors.d(54): Error: cannot have parameter of type `void` fail_compilation/typeerrors.d(56): Error: slice `[1..5]` is out of range of [0..4] fail_compilation/typeerrors.d(57): Error: slice `[2..1]` is out of range of [0..4] fail_compilation/typeerrors.d(59): Error: variable `typeerrors.foo.globalC` globals, statics, fields, manifest constants, ref and out parameters cannot be `scope` fail_compilation/typeerrors.d(59): Error: variable `typeerrors.foo.globalC` reference to `scope class` must be `scope` fail_compilation/typeerrors.d(60): Error: variable `typeerrors.foo.manifestC` globals, statics, fields, manifest constants, ref and out parameters cannot be `scope` fail_compilation/typeerrors.d(60): Error: variable `typeerrors.foo.manifestC` reference to `scope class` must be `scope` --- */ template tuple(T...) { alias T tuple; } void bar(); scope class C { } void foo() { alias T = tuple!(1,2,int,7); T[4] a; int x; T[x] b; typeof(bar)[5] c; C[6] d; C[] e; alias int[5] AI; auto f = AI.ptr; int[x*] g; int[typeof(bar)] h; int[void] i; C[int] j; void[int] k; typeof(bar)[int] l; void abc(void) { } alias T2 = T[1 .. 5]; alias T3 = T[2 .. 1]; static C globalC; enum C manifestC = new C(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13563.d0000644000175000017500000000070515205374123020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13563.d(23): Error: undefined identifier `z` in module `ice13563` --- */ struct Payload { void opIndex(K)(K i) {} void opIndexAssign(T, N)(T value, N i) {} } struct Value { Payload payload; alias payload this; } void main() { Value v; v["name"] = .z(); // ICE //v["name"] = z(); // OK //v.opIndex("name") = .z(); // OK //v.payload["name"] = .z(); // OK } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22709.d0000644000175000017500000000122215205374123021152 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test22709.d(15): Error: assigning address of variable `local` to `arr` with longer lifetime is not allowed in a `@safe` function fail_compilation/test22709.d(20): Error: assigning address of variable `local` to `arr` with longer lifetime is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=22709 @safe: void escape(ref ubyte[] arr, ref ubyte[64] local) { arr = local[]; } void escape1(ref ubyte[64] local, ref ubyte[] arr) { arr = local[]; } ubyte[] getArr() { ubyte[64] blob; ubyte[] arr; escape(arr, blob[]); return arr; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/dip22b.d0000644000175000017500000000033515205374123020655 0ustar fabiofabio/* EXTRA_FILES: imports/dip22b.d imports/dip22c.d TEST_OUTPUT: --- fail_compilation/dip22b.d(12): Error: undefined identifier `Foo`, did you mean variable `foo`? --- */ module pkg.dip22; import imports.dip22b; Foo foo; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22749.d0000644000175000017500000000035015205374123021113 0ustar fabiofabio// EXTRA_FILES: imports/imp22749.c /* TEST_OUTPUT: --- fail_compilation/fail22749.d(12): Error: cannot take address of bitfield `s.field` --- */ import imports.imp22749; void test22749() { S22749 s; void* ptr = &s.field; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail287.d0000644000175000017500000000043515205374123020750 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail287.d(14): Error: had 300 cases which is more than 257 cases in case range --- */ void main() { int i = 2; switch (i) { case 1: .. case 300: i = 5; break; } if (i != 5) assert(0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail340.d0000644000175000017500000000071115205374123020733 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail340.d(18): Error: variable `fail340.w` of type struct `const(CopyTest)` uses `this(this)`, which is not allowed in static initialization fail_compilation/fail340.d(19): while evaluating: `static assert(w.x == 55.0)` --- */ struct CopyTest { double x; this(double a) { x = a * 10.0;} this(this) { x += 2.0; } } const CopyTest z = CopyTest(5.3); const CopyTest w = z; static assert(w.x == 55.0); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14185.d0000644000175000017500000000045115205374123020735 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice14185.d(12): Error: cannot implicitly convert expression `this` of type `Mutexed` to `Mutexed*` --- */ struct Mutexed { auto acquire () { return Lock (this); } alias acquire this; struct Lock { Mutexed* source; } } void main () { Mutexed x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22118.d0000644000175000017500000000067315205374123021111 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22118 /* TEST_OUTPUT: --- fail_compilation/fail22118.d(33): Error: cannot modify `this.v.a` in `const` function --- */ struct NeedsInit { int n; @disable this(); } union U { NeedsInit a; } struct V { NeedsInit a; } struct S { U u; V v; this(const NeedsInit arg) const { u.a = arg; // this should compile v.a = arg; // this should not } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18597.d0000644000175000017500000000125415205374123021171 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test18597.d(24): Error: modifying misaligned pointers through field `Unaligned.p` is not allowed in a `@safe` function fail_compilation/test18597.d(25): Error: field `Unaligned.p` assigning to misaligned pointers is not allowed in a `@safe` function fail_compilation/test18597.d(26): Error: field `Unaligned.p` assigning to misaligned pointers is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=18597 @safe: align(1) struct Unaligned { align(1): ubyte filler; int* p; } void test() { Unaligned u; u.p = new int; Unaligned v = Unaligned(0, new int); Unaligned w = { p : new int }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15550.d0000644000175000017500000000105115205374123021102 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail15550.d(25): Error: partial template instance `foo!int` has no type fail_compilation/fail15550.d(26): Error: partial template instance `opDispatch!"_isMatrix"` has no type fail_compilation/fail15550.d(27): Error: partial template instance `baz!"_isMatrix"` has no type --- */ T foo(T, T2)(T2) { } struct Vector { void opDispatch(string, U)(U) { } void baz(string, U)(U) { } } alias T1 = typeof(foo!int); alias T2 = typeof(Vector._isMatrix); alias T3 = typeof(Vector.baz!"_isMatrix"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test9701b.d0000644000175000017500000000065215205374123021237 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/test9701b.d(20): Deprecation: enum member `test9701b.Enum.e0` is deprecated fail_compilation/test9701b.d(21): Deprecation: enum member `test9701b.Enum.e1` is deprecated - message --- */ // https://issues.dlang.org/show_bug.cgi?id=9701 enum Enum { deprecated e0, deprecated("message") e1, } void main() { auto value = Enum.e0; auto value2 = Enum.e1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23109.d0000644000175000017500000000132315205374123021103 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23109 /* EXTRA_FILES: imports/test23109a.d imports/test23109b.d imports/test23109c.d EXTRA_SOURCES: extra-files/test23109/object.d TEST_OUTPUT: --- Error: no property `getHash` for `typeid(const(Ensure[]))` of type `object.TypeInfo_Const` fail_compilation/extra-files/test23109/object.d(7): class `TypeInfo_Const` defined here Error: no property `getHash` for `typeid(const(Ensure[1]))` of type `object.TypeInfo_Const` fail_compilation/extra-files/test23109/object.d(7): class `TypeInfo_Const` defined here fail_compilation/imports/test23109a.d(10): Error: template instance `imports.test23109a.Array!(Ensure)` error instantiating --- */ import imports.test23109a; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_pretty_errors.d0000644000175000017500000000245115205374123023512 0ustar fabiofabio/* REQUIRED_ARGS: -verrors=context TEST_OUTPUT: --- fail_compilation/fail_pretty_errors.d(29): Error: undefined identifier `a` a = 1; ^ fail_compilation/fail_pretty_errors.d-mixin-34(34): Error: undefined identifier `b` b = 1; ^ fail_compilation/fail_pretty_errors.d(39): Error: cannot implicitly convert expression `5` of type `int` to `string` string x = 5; ^ fail_compilation/fail_pretty_errors.d(44): Error: mixin `fail_pretty_errors.testMixin2.mixinTemplate!()` error instantiating mixin mixinTemplate; ^ fail_compilation/fail_pretty_errors.d(50): Error: invalid array operation `"" + ""` (possible missing []) auto x = ""+""; ^ fail_compilation/fail_pretty_errors.d(50): did you mean to concatenate (`"" ~ ""`) instead ? fail_compilation/fail_pretty_errors.d(53): Error: cannot implicitly convert expression `1111` of type `int` to `byte` byte ɑ = 1111; ^ --- */ void foo() { a = 1; } void testMixin1() { mixin("b = 1;"); } mixin template mixinTemplate() { string x = 5; } void testMixin2() { mixin mixinTemplate; } void f() { // check supplemental error doesn't show context auto x = ""+""; // Check correct spacing with the presence of unicode characters and tabs byte ɑ = 1111; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b12504.d0000644000175000017500000000560315205374123020413 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/b12504.d(26): Error: cannot implicitly convert expression `257$?:32=u|64=LU$` of type `$?:32=uint|64=ulong$` to `ubyte` fail_compilation/b12504.d(27): Error: index type `ubyte` cannot cover index range 0..257 fail_compilation/b12504.d(31): Error: cannot implicitly convert expression `129$?:32=u|64=LU$` of type `$?:32=uint|64=ulong$` to `byte` fail_compilation/b12504.d(32): Error: index type `byte` cannot cover index range 0..129 fail_compilation/b12504.d(36): Error: cannot implicitly convert expression `65537$?:32=u|64=LU$` of type `$?:32=uint|64=ulong$` to `ushort` fail_compilation/b12504.d(37): Error: index type `ushort` cannot cover index range 0..65537 fail_compilation/b12504.d(41): Error: cannot implicitly convert expression `32769$?:32=u|64=LU$` of type `$?:32=uint|64=ulong$` to `short` fail_compilation/b12504.d(42): Error: index type `short` cannot cover index range 0..32769 fail_compilation/b12504.d(46): Error: cannot implicitly convert expression `257$?:32=u|64=LU$` of type `$?:32=uint|64=ulong$` to `ubyte` fail_compilation/b12504.d(47): Error: index type `ubyte` cannot cover index range 0..257 fail_compilation/b12504.d(51): Error: cannot implicitly convert expression `129$?:32=u|64=LU$` of type `$?:32=uint|64=ulong$` to `byte` fail_compilation/b12504.d(52): Error: index type `byte` cannot cover index range 0..129 fail_compilation/b12504.d(56): Error: cannot implicitly convert expression `65537$?:32=u|64=LU$` of type `$?:32=uint|64=ulong$` to `ushort` fail_compilation/b12504.d(57): Error: index type `ushort` cannot cover index range 0..65537 fail_compilation/b12504.d(61): Error: cannot implicitly convert expression `32769$?:32=u|64=LU$` of type `$?:32=uint|64=ulong$` to `short` fail_compilation/b12504.d(62): Error: index type `short` cannot cover index range 0..32769 --- */ void main() { { int[0xFF + 2] sta; foreach (ubyte i; 0 .. sta.length) {} foreach (ubyte i, x; sta) {} } { int[0x7F + 2] sta; foreach (byte i; 0 .. sta.length) {} foreach (byte i, x; sta) {} } { int[0xFFFF + 2] sta; foreach (ushort i; 0 .. sta.length) {} foreach (ushort i, x; sta) {} } { int[0x7FFF + 2] sta; foreach (short i; 0 .. sta.length) {} foreach (short i, x; sta) {} } { immutable int[0xFF + 2] sta; static foreach (ubyte i; 0 .. sta.length) {} static foreach (ubyte i, x; sta) {} } { immutable int[0x7F + 2] sta; static foreach (byte i; 0 .. sta.length) {} static foreach (byte i, x; sta) {} } { immutable int[0xFFFF + 2] sta; static foreach (ushort i; 0 .. sta.length) {} static foreach (ushort i, x; sta) {} } { immutable int[0x7FFF + 2] sta; static foreach (short i; 0 .. sta.length) {} static foreach (short i, x; sta) {} } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21204.d0000644000175000017500000000052215205374123021141 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21204 /* TEST_OUTPUT: --- fail_compilation/test21204.d(22): Error: generating an `inout` copy constructor for `struct test21204.B` failed, therefore instances of it are uncopyable --- */ struct A { this(ref A other) {} } struct B { A a; } void example() { B b1; B b2 = b1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21930.d0000644000175000017500000000110715205374123021147 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21930 /* TEST_OUTPUT: --- fail_compilation/test21930.d(21): Error: variable `string` is used as a type fail_compilation/test21930.d(15): variable `string` is declared here fail_compilation/test21930.d(26): Error: constructor `test21930.R.this(string)` is not callable using argument types `()` --- */ alias AliasSeq(T...) = T; alias TP(alias name) = AliasSeq!name; int string; // 'string' declared as a variable alias a = TP!(main); class R { this(string) { } // so constructor have errors } @system main() { new R; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag4596.d0000644000175000017500000000116315205374123021027 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag4596.d(15): Error: cannot modify expression `this` because it is not an lvalue fail_compilation/diag4596.d(16): Error: conditional expression `1 ? this : this` is not a modifiable lvalue fail_compilation/diag4596.d(18): Error: cannot modify expression `super` because it is not an lvalue fail_compilation/diag4596.d(19): Error: conditional expression `1 ? super : super` is not a modifiable lvalue --- */ class NoGo4596 { void fun() { this = new NoGo4596; (1?this:this) = new NoGo4596; super = new Object; (1?super:super) = new Object; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail316.d0000644000175000017500000000047215205374123020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail316.d(17): Error: mixin `fail316.foo.BadImpl!(uint, Mix1)` cannot resolve forward reference --- */ template BadImpl(T, alias thename) { void a_bad_idea(T t) { thename.a_bad_idea(t); } } class foo { mixin BadImpl!(uint,Mix1) Mix1; } int main() { return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16495.d0000644000175000017500000000055715205374123021171 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test16495.d(12): Error: undefined identifier `q` fail_compilation/test16495.d(17): Error: expected 1 arguments for `fullyQualifiedName` but had 0 --- */ // https://issues.dlang.org/show_bug.cgi?id=16495 void test1() { auto m = __traits(fullyQualifiedName, q); } void test2() { auto n = __traits(fullyQualifiedName); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/mixinexpr.d0000644000175000017500000000074315205374123021621 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/mixinexpr.d-mixin-10(10): Error: unexpected token `;` after function expression fail_compilation/mixinexpr.d-mixin-10(10): while parsing string mixin expression `(int i) => true;` fail_compilation/mixinexpr.d-mixin-11(11): Error: unexpected token `j` after identifier expression fail_compilation/mixinexpr.d-mixin-11(11): while parsing string mixin expression `i j` --- */ enum e = mixin("(int i) => true;"); enum f = mixin("i j"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24745.d0000644000175000017500000000035115205374123021156 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24745 /* TEST_OUTPUT: --- fail_compilation/test24745.d(12): Error: incorrect syntax for associative array, expected `[]`, found `{}` --- */ void main() { int[int] f = {1: 1, 2: 2}; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail27.d0000644000175000017500000000163415205374123020662 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail27.d(15): Error: cannot implicitly convert expression `-32769` of type `int` to `short` fail_compilation/fail27.d(16): Error: cannot implicitly convert expression `-129` of type `int` to `byte` fail_compilation/fail27.d(17): Error: cannot implicitly convert expression `-1` of type `int` to `char` fail_compilation/fail27.d(18): Error: cannot implicitly convert expression `65536` of type `int` to `wchar` fail_compilation/fail27.d(19): Error: cannot implicitly convert expression `-1` of type `int` to `wchar` fail_compilation/fail27.d(21): Error: cannot implicitly convert expression `-1` of type `int` to `dchar` --- */ void main() { short a = -32769; // short.min-1 byte b = -129; // byte.min-1 char c = -1; // char.min-1 wchar D = 65536; // wchar.max+1 wchar d = -1; // wchar.min-1 dchar E = 1114111; // dchar.max+1 dchar e = -1; // dchar.min-1 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag16271.d0000644000175000017500000000024515205374123021100 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag16271.d(10): Error: found `x` when expecting function literal following `ref` --- */ void main() { auto fun = ref x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice15922.d0000644000175000017500000000214315205374123020735 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice15922.d(23): Error: function `ice15922.ValidSparseDataStore!int.ValidSparseDataStore.correctedInsert!false.correctedInsert` has no `return` statement, but is expected to return a value of type `int` fail_compilation/ice15922.d(21): Error: template instance `ice15922.ValidSparseDataStore!int.ValidSparseDataStore.correctedInsert!false` error instantiating fail_compilation/ice15922.d(26): instantiated from here: `ValidSparseDataStore!int` fail_compilation/ice15922.d(14): Error: calling non-static function `insert` requires an instance of type `ValidSparseDataStore` fail_compilation/ice15922.d(26): Error: template instance `ice15922.StorageAttributes!(ValidSparseDataStore!int)` error instantiating --- */ template StorageAttributes(Store) { enum hasInsertMethod = Store.insert; enum hasFullSlice = Store.init[]; } struct ValidSparseDataStore(DataT) { DataT insert() { correctedInsert!(false); } DataT correctedInsert(bool CorrectParents)() {} auto opSlice() inout {} } alias BasicCubeT = StorageAttributes!(ValidSparseDataStore!int); ./ldc-1.42.0-src/tests/dmd/fail_compilation/impchint.i0000644000175000017500000000446115205374123021417 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/impchint.i(33): Error: `bool` is not defined, perhaps `#include ` ? fail_compilation/impchint.i(33): Error: `true` is not defined, perhaps `#include ` is needed? fail_compilation/impchint.i(34): Error: `nullptr_t` is not defined, perhaps `#include ` ? fail_compilation/impchint.i(35): Error: `int8_t` is not defined, perhaps `#include ` ? fail_compilation/impchint.i(35): Error: `INT8_MAX` is not defined, perhaps `#include ` is needed? fail_compilation/impchint.i(36): Error: `uint32_t` is not defined, perhaps `#include ` ? fail_compilation/impchint.i(36): Error: `UINT32_MAX` is not defined, perhaps `#include ` is needed? fail_compilation/impchint.i(37): Error: `wchar_t` is not defined, perhaps `#include ` ? fail_compilation/impchint.i(37): Error: `WCHAR_MIN` is not defined, perhaps `#include ` is needed? fail_compilation/impchint.i(38): Error: `FILE` is not defined, perhaps `#include ` is needed? fail_compilation/impchint.i(38): Error: undefined identifier `f` fail_compilation/impchint.i(39): Error: `fpos_t` is not defined, perhaps `#include ` ? fail_compilation/impchint.i(39): Error: `EOF` is not defined, perhaps `#include ` is needed? fail_compilation/impchint.i(40): Error: `EXIT_SUCCESS` is not defined, perhaps `#include ` is needed? fail_compilation/impchint.i(41): Error: `va_list` is not defined, perhaps `#include ` ? fail_compilation/impchint.i(43): Error: `exit` is not defined, perhaps `#include ` is needed? fail_compilation/impchint.i(44): Error: `getchar` is not defined, perhaps `#include ` is needed? fail_compilation/impchint.i(45): Error: `offsetof` is not defined, perhaps `#include ` is needed? fail_compilation/impchint.i(46): Error: `strcat` is not defined, perhaps `#include ` is needed? fail_compilation/impchint.i(48): Error: `false` is not defined, perhaps `#include ` is needed? --- */ int test(void) { bool a = true; nullptr_t b; int8_t c = INT8_MAX; uint32_t d = UINT32_MAX; wchar_t e = WCHAR_MIN; FILE *f = NULL; fpos_t g = EOF; int h = EXIT_SUCCESS; va_list i; exit(); getchar(); offsetof(); strcat(); return false; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7424g.d0000644000175000017500000000030515205374123021173 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7424g.d(10): Error: template `this.g()()` has no value --- */ struct S7424g { @property int g()() { return 0; } void test() shared { int f = g; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice8100.d0000644000175000017500000000064515205374123020650 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice8100.d(11): Error: no property `Q` for type `ice8100.Bar!bool` fail_compilation/ice8100.d(12): class `Bar` defined here fail_compilation/ice8100.d(12): Error: template instance `ice8100.Foo!(Bar!bool)` error instantiating fail_compilation/ice8100.d(13): instantiated from here: `Bar!bool` --- */ class Foo(T1) { T1.Q r; } class Bar(T2) : Foo!(Bar!T2) {} Bar!bool b; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18736.d0000644000175000017500000000060515205374123021163 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test18736.d(21): Error: constructor calls not allowed in loops or after labels --- */ // https://issues.dlang.org/show_bug.cgi?id=18736 class A { this(char c) { } this(int i) { switch (i) { case 1: break; case 2: .. case 4: break; default: break; } this('c'); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19911b.d0000644000175000017500000000040715205374123021255 0ustar fabiofabio/* DFLAGS: EXTRA_SOURCES: extra-files/minimal/object.d TEST_OUTPUT: --- fail_compilation/fail19911b.d(10): Error: function `fail19911b.fun` `object.TypeInfo_Tuple` could not be found, but is implicitly used in D-style variadic functions --- */ void fun(...) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19912e.d0000644000175000017500000000032315205374123021256 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19912e.d(7): Error: function `fail19912e.object` conflicts with import `fail19912e.object` at fail_compilation/fail19912e.d --- */ void object() { } void fun(string) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17307.d0000644000175000017500000000037215205374123021155 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test17307.d(9): Error: anonymous struct can only be a part of an aggregate, not module `test17307` --- * https://issues.dlang.org/show_bug.cgi?id=17307 */ struct { enum bitsPerWord = size_t; } void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12749.d0000644000175000017500000000276715205374123021130 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail12749.d(19): Error: immutable field `inum` initialization is not allowed in foreach loop fail_compilation/fail12749.d(20): Error: const field `cnum` initialization is not allowed in foreach loop fail_compilation/fail12749.d(25): Error: immutable field `inum` initialization is not allowed in nested function `set` fail_compilation/fail12749.d(26): Error: const field `cnum` initialization is not allowed in nested function `set` --- */ struct S { immutable int inum; const int cnum; this(int i) { foreach (n; Aggr()) { inum = i; cnum = i; } void set(int i) { inum = i; cnum = i; } } } /* TEST_OUTPUT: --- fail_compilation/fail12749.d(48): Error: immutable variable `inum` initialization is not allowed in foreach loop fail_compilation/fail12749.d(49): Error: const variable `cnum` initialization is not allowed in foreach loop fail_compilation/fail12749.d(54): Error: immutable variable `inum` initialization is not allowed in nested function `set` fail_compilation/fail12749.d(55): Error: const variable `cnum` initialization is not allowed in nested function `set` --- */ immutable int inum; const int cnum; static this() { int i = 10; foreach (n; Aggr()) { inum = i; cnum = i; } void set(int i) { inum = i; cnum = i; } } struct Aggr { int opApply(int delegate(int) dg) { return dg(1); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test19608.d0000644000175000017500000000045615205374123021166 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19608 /* TEST_OUTPUT: --- fail_compilation/test19608.d(15): Error: cannot pass function `*& f` as a function argument --- */ import core.stdc.stdarg; void f(int) {} void g(...) {} void h() { g(&f); // OK, function address g(*&f); // ICE -> Error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14642.d0000644000175000017500000000127015205374123020733 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice14642.d(48): Error: undefined identifier `errorValue` fail_compilation/ice14642.d(52): error on member `ice14642.Z.v` fail_compilation/ice14642.d(24): Error: template instance `ice14642.X.NA!()` error instantiating --- */ alias TypeTuple(T...) = T; struct X { static struct NA() { X x; void check() { x.func(); } } alias na = NA!(); auto func() { Y* p; p.func(); } } struct Y { mixin Mix; } template Mix() { void func() { auto z = Z(null); } } struct Type(size_t v) {} enum errVal = errorValue; struct Z { Type!errVal v; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/retscope3.d0000644000175000017500000000415215205374123021503 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 */ /* TEST_OUTPUT: --- fail_compilation/retscope3.d(2008): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function fail_compilation/retscope3.d(2017): Error: escaping a reference to local variable `i` by copying `S2000(& i)` into allocated memory is not allowed in a `@safe` function --- */ #line 2000 // https://issues.dlang.org/show_bug.cgi?id=17790 @safe: int* bar1() { int i; int*[] arr = [ &i ]; return arr[0]; } struct S2000 { int* p; } S2000 bar2() { int i; S2000[] arr = [ S2000(&i) ]; return arr[0]; } void bar3(string[] u...) @safe pure nothrow @nogc { foreach (str; u) { } } void bar4() { static struct S { int* p; } S[2][10] pairs; foreach (ref pair; pairs) { } } /**********************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope3.d(4003): Error: escaping a reference to parameter `u` by copying `u[]` into allocated memory is not allowed in a `@safe` function fail_compilation/retscope3.d(4016): Error: storing reference to outer local variable `i` into allocated memory causes it to escape fail_compilation/retscope3.d(4025): Deprecation: slice of static array temporary returned by `makeSA()` assigned to longer lived variable `a` fail_compilation/retscope3.d(4025): Error: escaping reference to stack allocated value returned by `makeSA()` into allocated memory fail_compilation/retscope3.d(4032): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function --- */ #line 4000 void bar4000(int[1] u...) @safe { int[][] n = [u[]]; } void bar4001() @safe { static int i; int*[] n = [&i]; } ref int bar4002(return ref int i) @safe { void nested() { int*[] n = [&i]; } return i; } int[3] makeSA() @safe; void bar4003() @safe { int[][] a = [makeSA()[]]; } // https://github.com/dlang/dmd/issues/20901 int* f20901() @safe { int i = 3; auto x = &[&i][0]; // Should error, i is escaped into allocated memory return *x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3882.d0000644000175000017500000000147715205374123021043 0ustar fabiofabio/* PERMUTE_ARGS: -debug TEST_OUTPUT: --- fail_compilation/fail3882.d(32): Error: `@mustuse` on functions is reserved for future use fail_compilation/fail3882.d(33): Error: `@mustuse` on functions is reserved for future use --- */ import core.attribute; /******************************************/ // https://issues.dlang.org/show_bug.cgi?id=3882 @mustuse @safe pure nothrow T strictlyPure(T)(T x) { return x*x; } void main() { int x = 3; strictlyPure(x); // https://issues.dlang.org/show_bug.cgi?id=12649 auto fp = &strictlyPure!int; fp(x); } /******************************************/ // bugfix in TypeFunction::purityLevel @mustuse nothrow pure int f1(immutable(int)[] a) { return 0; } @mustuse nothrow pure int f2(immutable(int)* p) { return 0; } void test_bug() { f1([]); f2(null); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/checkimports2.d0000644000175000017500000000170715205374123022354 0ustar fabiofabio// EXTRA_FILES: imports/imp1.d imports/imp2.d /* TEST_OUTPUT: --- fail_compilation/checkimports2.d(27): Error: no property `X` for type `checkimports2.B` fail_compilation/imports/imp2.d(3): did you mean `imports.imp2.X`? fail_compilation/checkimports2.d(27): while evaluating: `static assert((B).X == 0)` fail_compilation/checkimports2.d(28): Error: no property `Y` for type `checkimports2.B` fail_compilation/imports/imp2.d(4): did you mean `imports.imp2.Y`? fail_compilation/checkimports2.d(28): while evaluating: `static assert((B).Y == 2)` --- */ import imports.imp1; enum X = 0; class B { import imports.imp2; static assert(X == 0); // imp2.X --> .X int[Y] aa; // imp2.Y } class C : B { static assert(B.X == 0); // imp2.X --> error static assert(B.Y == 2); // imp2.Y --> error static assert(X == 0); // imp2.X --> .X static assert(Y == 1); // imp2.Y --> imp1.Y } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3150.d0000644000175000017500000000030515205374123021014 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail3150.d(10): Error: cannot cast expression `[1, 2]` of type `int[]` to `ulong` --- */ void main() { ulong u = cast(ulong)[1,2]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/e15876_5.d0000644000175000017500000000110315205374123020650 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/e15876_5.d(17): Error: basic type expected, not `End of File` fail_compilation/e15876_5.d(17): Error: semicolon expected to close `alias` declaration, not `End of File` fail_compilation/e15876_5.d(17): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/e15876_5.d(16): unmatched `{` fail_compilation/e15876_5.d(17): Error: found `End of File` when expecting `]` fail_compilation/e15876_5.d(17): Error: variable name expected after type `p[() { alias ; } ]`, not `End of File` --- */ p[{alias ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix21042.d0000644000175000017500000000055015205374123020751 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix21042.d(14): Error: template `gun` is not callable using argument types `!()(int)` fail_compilation/fix21042.d(14): no parameter named `x` fail_compilation/fix21042.d(10): Candidate is: `gun(T)(T a)` --- */ void gun(T)(T a) {} void main() { gun(x: 1); // (no explanation) --> (no parameter named `x`) } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fob2.d0000644000175000017500000000667015205374123020433 0ustar fabiofabio/* Testing Ownership/Borrowing system REQUIRED_ARGS: -preview=dip1021 */ int* malloc(); void free(int*); /* TEST_OUTPUT: --- fail_compilation/fob2.d(110): Error: variable `fob2.foo1.b1` has undefined state and cannot be read fail_compilation/fob2.d(103): Error: variable `fob2.foo1.p` is not disposed of before return --- */ #line 100 @live int foo1(int i) { int* p = malloc(); scope const(int)* b1, b2; if (i) b1 = p; else b2 = p; *p = 3; return *b1; } /* TEST_OUTPUT: --- fail_compilation/fob2.d(203): Error: more than one mutable reference of `p` in arguments to `fob2.foo2()` --- */ //fail_compilation/fob2.d(203): Error: variable `fob2.zoo2.p` is passed as Owner more than once //fail_compilation/fob2.d(202): Error: variable `fob2.zoo2.p` is left dangling at return #line 200 @live void zoo2() { int* p = malloc(); foo2(p, p + 1); } @live void foo2( scope int* p, scope int* q ); /* TEST_OUTPUT: --- fail_compilation/fob2.d(303): Error: variable `fob2.foo3.b` is not disposed of before return --- */ #line 300 @live void foo3() { scope int* b = malloc(); } /* TEST_OUTPUT: --- fail_compilation/fob2.d(427): Error: variable `fob2.test43.p` is both Owner and Undefined fail_compilation/fob2.d(429): Error: variable `fob2.test43.p` has undefined state and cannot be read fail_compilation/fob2.d(429): Error: variable `fob2.test43.p` is not Owner, cannot consume its value fail_compilation/fob2.d(432): Error: variable `fob2.test43.p` has undefined state and cannot be read fail_compilation/fob2.d(432): Error: variable `fob2.test43.p` is not Owner, cannot consume its value --- */ #line 400 bool f(); @live void test41(int* p, int i) { for (; f(); ++i) { --i; free(p); p = null; } free(p); } @live void test42(int* p, int i) { for (; f(); ++i) { --i; } free(p); } @live void test43(int* p, int i) { for (; f(); ++i) { free(p); --i; } free(p); } /* TEST_OUTPUT: --- fail_compilation/fob2.d(506): Error: variable `fob2.test51.p` has undefined state and cannot be read fail_compilation/fob2.d(515): Error: variable `fob2.test52.p` has undefined state and cannot be read --- */ // https://issues.dlang.org/show_bug.cgi?id=20747 #line 500 @live test51() { int x; scope p = &x; x = 3; *p = 4; } @live void test52() @safe { int x = 5; auto p = &x; auto q = &x; *p = 3; } @live void test53() { scope int x; scope int y; y = x; x = 3; y = 4; } /* TEST_OUTPUT: --- fail_compilation/fob2.d(603): Error: variable `fob2.test6.p` is not disposed of before return fail_compilation/fob2.d(612): Error: more than one mutable reference of `p` in arguments to `fob2.foo6b()` --- */ #line 600 @live extern (C) void foo6(int, scope ...); @live void test6(int* p) { foo6(1, p); } @live extern (C) void foo6b(int, scope const ...); @live int* test6b(return int* p) { foo6b(1, p, p); return p; } /* TEST_OUTPUT: --- fail_compilation/fob2.d(705): Error: variable `fob2.test7.p` is not Owner, cannot consume its value --- */ #line 700 void free7(int*); @live void test7(scope int* p) { free7(p); } /* TEST_OUTPUT: --- fail_compilation/fob2.d(807): Error: variable `fob2.test8.p` assigning to Owner without disposing of owned value --- */ #line 800 int* malloc8(); void free8(int*); @live void test8() { int* p = malloc8(); p = malloc8(); // error here free8(p); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/attributediagnostic_nothrow.d0000644000175000017500000000273615205374123025432 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/attributediagnostic_nothrow.d(19): Error: function `attributediagnostic_nothrow.layer1` is not `nothrow` fail_compilation/attributediagnostic_nothrow.d(20): which calls `layer0` fail_compilation/attributediagnostic_nothrow.d(21): which calls `gc` fail_compilation/attributediagnostic_nothrow.d(25): and executing an `asm` statement without a `nothrow` annotation makes it fail to infer `nothrow` fail_compilation/attributediagnostic_nothrow.d(19): Error: function `attributediagnostic_nothrow.layer2` may throw but is marked as `nothrow` fail_compilation/attributediagnostic_nothrow.d(41): Error: function `attributediagnostic_nothrow.gc1` is not `nothrow` fail_compilation/attributediagnostic_nothrow.d(30): and `object.Exception` being thrown but not caught makes it fail to infer `nothrow` fail_compilation/attributediagnostic_nothrow.d(42): Error: function `attributediagnostic_nothrow.gc2` is not `nothrow` fail_compilation/attributediagnostic_nothrow.d(39): Error: function `D main` may throw but is marked as `nothrow` --- */ // Issue 17374 - Improve inferred attribute error message // https://issues.dlang.org/show_bug.cgi?id=17374 auto layer2() nothrow { layer1(); } auto layer1() { layer0(); } auto layer0() { gc(); } auto gc() { asm {} } auto gc1() { throw new Exception("msg"); } auto fgc = function void() {throw new Exception("msg");}; auto gc2() { fgc(); } void main() nothrow { gc1(); gc2(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail5908.d0000644000175000017500000000066115205374123021036 0ustar fabiofabio/* DISABLED: LDC // error message is generated by dmd backend after constant propagation REQUIRED_ARGS: -O TEST_OUTPUT: --- fail_compilation/fail5908.d(16): Error: divide by zero fail_compilation/fail5908.d(17): Error: divide by zero --- */ // This bug is caught by the dmd optimizer - other backends might not catch it or give a different message int main() { int a = 1; int b = 0; return (a % b) + (a / b); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failcstuff4.c0000644000175000017500000000147415205374123022011 0ustar fabiofabio// check importAll analysis of C files /* TEST_OUTPUT: --- fail_compilation/failcstuff4.c(100): Error: can only `*` a pointer, not a `int` fail_compilation/failcstuff4.c(157): Error: variable `failcstuff4.T22106.f1` - no definition of struct `S22106_t` fail_compilation/failcstuff4.c(157): see https://dlang.org/spec/struct.html#opaque_struct_unions fail_compilation/failcstuff4.c(157): perhaps declare a variable with pointer type `S22106_t*` instead --- */ /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22103 #line 100 int test22103(int array[*4]); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22106 #line 150 typedef struct S22106 { int field; } S22106_t; struct T22106 { struct S22106_t f1; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19076.d0000644000175000017500000000050615205374123021115 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19076.d(12): Error: no property `V` for type `fail19076.I` fail_compilation/fail19076.d(11): interface `I` defined here fail_compilation/fail19076.d(12): Error: `(I).V` cannot be resolved --- */ interface P { } interface I : P { } auto F = __traits(getVirtualMethods, I, "V"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/auto_ref_inout.d0000644000175000017500000000056415205374123022621 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/auto_ref_inout.d(12): Error: template `f` is not callable using argument types `!()(int)` fail_compilation/auto_ref_inout.d(10): Candidate is: `f(T)(auto ref inout T a, auto ref inout T b)` --- */ // https://issues.dlang.org/show_bug.cgi?id=24707 auto ref inout(T) f(T)(auto ref inout T a, auto ref inout T b); enum e = f(5); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21243.d0000644000175000017500000000163115205374123021102 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/fail21243.d(12): Error: found `(` when expecting `ref` and function literal following `auto` fail_compilation/fail21243.d(12): Error: semicolon expected following auto declaration, not `int` fail_compilation/fail21243.d(12): Error: semicolon needed to end declaration of `x` instead of `)` fail_compilation/fail21243.d(12): Error: declaration expected, not `)` fail_compilation/fail21243.d(13): Error: `auto` can only be used as part of `auto ref` for function literal return values fail_compilation/fail21243.d(14): Error: `auto` can only be used as part of `auto ref` for function literal return values fail_compilation/fail21243.d(15): Error: `auto` can only be used as part of `auto ref` for function literal return values --- +/ auto a = auto (int x) => x; auto b = function auto (int x) { return x; }; alias c = auto (int x) => x; alias d = function auto (int x) { return x; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10984.d0000644000175000017500000000044615205374123021110 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10984.d(12): Error: `static` function `diag10984.f.n` cannot access variable `x` in frame of function `diag10984.f` fail_compilation/diag10984.d(11): `x` declared here --- */ void f() { int x; static void n() { x++; } } void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14055.d0000644000175000017500000000046115205374123020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice14055.d(16): Error: uninitialized variable `foo` cannot be returned from CTFE --- */ struct S { static returnsFoo() { uint[1] foo = void; return foo; } static enum fooEnum = returnsFoo(); static uint[1] fooArray = fooEnum[]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail80_m64.d0000644000175000017500000000122115205374123021337 0ustar fabiofabio// REQUIRED_ARGS: -m64 /* TEST_OUTPUT: --- fail_compilation/fail80_m64.d(28): Error: cannot implicitly convert expression `"progress_rem"` of type `string` to `ulong` fail_compilation/fail80_m64.d(29): Error: cannot implicitly convert expression `"redo"` of type `string` to `ulong` --- */ module paintshop; class Image{} class ResourceManager { Image getImage(char[] name) { return null; } } class Test { static Image[] images; static void initIcons() { images["progress_rem"] = ResourceManager.getImage("progress_rem.gif"); // delete_obj_dis images["redo"] = ResourceManager.getImage("redo.gif"); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19759.d0000644000175000017500000000051615205374123021126 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19759 /* TEST_OUTPUT: --- fail_compilation/fail19759.d(8): Error: function `fail19759` cannot have parameter of type `float[4]` because its linkage is `extern(C++)` fail_compilation/fail19759.d(8): perhaps use a `float*` type instead --- */ extern(C++) bool fail19759(float[4] col); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix22342.c0000644000175000017500000000027215205374123020755 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix22342.c(103): Error: named parameter required before `...` --- */ #line 100 // https://issues.dlang.org/show_bug.cgi?id=22342 void func(...); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail208.d0000644000175000017500000000053415205374123020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail208.d(18): Error: `return` expression expected fail_compilation/fail208.d(21): called from here: `MakeA()` --- */ // https://issues.dlang.org/show_bug.cgi?id=1593 // ICE compiler crash empty return statement in function struct A { } A MakeA() { return ; } static const A aInstance = MakeA(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_casting1.d0000644000175000017500000003544215205374123022306 0ustar fabiofabio// REQUIRED_SRGS: -o- // references alias P = int*; P p; alias FP = int function(); FP fp; alias DG = int delegate(); DG dg; alias DA = int[]; DA da; alias AA = int[int]; AA aa; class C {} C c; alias N = typeof(null); N n; // values alias SA = int[1]; SA sa; struct S {} S s; int i; double f; /* TEST_OUTPUT: --- fail_compilation/fail_casting1.d(39): Error: cannot cast expression `p` of type `int*` to `int[1]` fail_compilation/fail_casting1.d(40): Error: cannot cast expression `fp` of type `int function()` to `int[1]` fail_compilation/fail_casting1.d(41): Error: cannot cast expression `dg` of type `int delegate()` to `int[1]` fail_compilation/fail_casting1.d(42): Error: cannot cast expression `da` of type `int[]` to `int[1]` fail_compilation/fail_casting1.d(43): Error: cannot cast expression `aa` of type `int[int]` to `int[1]` fail_compilation/fail_casting1.d(44): Error: cannot cast expression `c` of type `fail_casting1.C` to `int[1]` fail_compilation/fail_casting1.d(45): Error: cannot cast expression `n` of type `typeof(null)` to `int[1]` fail_compilation/fail_casting1.d(49): Error: cannot cast expression `sa` of type `int[1]` to `int delegate()` fail_compilation/fail_casting1.d(51): Error: cannot cast expression `sa` of type `int[1]` to `double[]` since sizes don't line up fail_compilation/fail_casting1.d(52): Error: cannot cast expression `sa` of type `int[1]` to `int[int]` fail_compilation/fail_casting1.d(53): Error: cannot cast expression `sa` of type `int[1]` to `fail_casting1.C` fail_compilation/fail_casting1.d(54): Error: cannot cast expression `sa` of type `int[1]` to `typeof(null)` --- */ void test1() { { auto x = cast(SA) p; } // Reject (Bugzilla 14596) { auto x = cast(SA)fp; } // Reject (Bugzilla 14596) (FP is Tpointer) { auto x = cast(SA)dg; } // Reject (from e2ir) { auto x = cast(SA)da; } // Reject (from e2ir) { auto x = cast(SA)aa; } // Reject (from e2ir) { auto x = cast(SA) c; } // Reject (Bugzilla 10646) { auto x = cast(SA) n; } // Reject (Bugzilla 8179) { auto x = cast( P)sa; } // Accept (equivalent with: cast(int*)sa.ptr;) { auto x = cast(double*)sa; } // Accept (equivalent with: cast(double*)sa.ptr;) { auto x = cast(FP)sa; } // Accept (equivalent with: cast(FP)sa.ptr;) { auto x = cast(DG)sa; } // Reject (from e2ir) { auto x = cast(DA)sa; } // Accept (equivalent with: cast(int[])sa[];) { auto x = cast(double[])sa; } // Reject (from e2ir) { auto x = cast(AA)sa; } // Reject (from e2ir) { auto x = cast( C)sa; } // Reject (Bugzilla 10646) { auto x = cast( N)sa; } // Reject (Bugzilla 8179) } /* TEST_OUTPUT: --- fail_compilation/fail_casting1.d(78): Error: cannot cast expression `p` of type `int*` to `S` fail_compilation/fail_casting1.d(79): Error: cannot cast expression `fp` of type `int function()` to `S` fail_compilation/fail_casting1.d(80): Error: cannot cast expression `dg` of type `int delegate()` to `S` fail_compilation/fail_casting1.d(81): Error: cannot cast expression `da` of type `int[]` to `S` fail_compilation/fail_casting1.d(82): Error: cannot cast expression `aa` of type `int[int]` to `S` fail_compilation/fail_casting1.d(83): Error: cannot cast expression `c` of type `fail_casting1.C` to `S` fail_compilation/fail_casting1.d(84): Error: cannot cast expression `n` of type `typeof(null)` to `S` fail_compilation/fail_casting1.d(85): Error: cannot cast expression `s` of type `S` to `int*` fail_compilation/fail_casting1.d(86): Error: cannot cast expression `s` of type `S` to `int function()` fail_compilation/fail_casting1.d(87): Error: cannot cast expression `s` of type `S` to `int delegate()` fail_compilation/fail_casting1.d(88): Error: cannot cast expression `s` of type `S` to `int[]` fail_compilation/fail_casting1.d(89): Error: cannot cast expression `s` of type `S` to `int[int]` fail_compilation/fail_casting1.d(90): Error: cannot cast expression `s` of type `S` to `fail_casting1.C` fail_compilation/fail_casting1.d(91): Error: cannot cast expression `s` of type `S` to `typeof(null)` --- */ void test2() { { auto x = cast( S) p; } // Reject (Bugzilla 13959) { auto x = cast( S)fp; } // Reject (Bugzilla 13959) (FP is Tpointer) { auto x = cast( S)dg; } // Reject (from e2ir) { auto x = cast( S)da; } // Reject (from e2ir) { auto x = cast( S)aa; } // Reject (from e2ir) { auto x = cast( S) c; } // Reject (from e2ir) { auto x = cast( S) n; } // Reject (Bugzilla 9904) { auto x = cast( P) s; } // Reject (Bugzilla 13959) { auto x = cast(FP) s; } // Reject (Bugzilla 13959) (FP is Tpointer) { auto x = cast(DG) s; } // Reject (from e2ir) { auto x = cast(DA) s; } // Reject (from e2ir) { auto x = cast(AA) s; } // Reject (from e2ir) { auto x = cast( C) s; } // Reject (from e2ir) { auto x = cast( N) s; } // Reject (Bugzilla 9904) } /* TEST_OUTPUT: --- fail_compilation/fail_casting1.d(125): Error: cannot cast expression `p` of type `int*` to `int delegate()` fail_compilation/fail_casting1.d(126): Error: cannot cast expression `p` of type `int*` to `int[]` fail_compilation/fail_casting1.d(129): Error: cannot cast expression `p` of type `int*` to `typeof(null)` fail_compilation/fail_casting1.d(133): Error: cannot cast expression `fp` of type `int function()` to `int delegate()` fail_compilation/fail_casting1.d(134): Error: cannot cast expression `fp` of type `int function()` to `int[]` fail_compilation/fail_casting1.d(137): Error: cannot cast expression `fp` of type `int function()` to `typeof(null)` fail_compilation/fail_casting1.d(139): Deprecation: casting from int delegate() to int* is deprecated fail_compilation/fail_casting1.d(140): Deprecation: casting from int delegate() to int function() is deprecated fail_compilation/fail_casting1.d(142): Error: cannot cast expression `dg` of type `int delegate()` to `int[]` fail_compilation/fail_casting1.d(143): Error: cannot cast expression `dg` of type `int delegate()` to `int[int]` fail_compilation/fail_casting1.d(144): Error: cannot cast expression `dg` of type `int delegate()` to `fail_casting1.C` fail_compilation/fail_casting1.d(145): Error: cannot cast expression `dg` of type `int delegate()` to `typeof(null)` fail_compilation/fail_casting1.d(157): Error: cannot cast expression `da` of type `int[]` to `int delegate()` fail_compilation/fail_casting1.d(159): Error: cannot cast expression `da` of type `int[]` to `int[int]` fail_compilation/fail_casting1.d(160): Error: cannot cast expression `da` of type `int[]` to `fail_casting1.C` fail_compilation/fail_casting1.d(161): Error: cannot cast expression `da` of type `int[]` to `typeof(null)` fail_compilation/fail_casting1.d(165): Error: cannot cast expression `aa` of type `int[int]` to `int delegate()` fail_compilation/fail_casting1.d(166): Error: cannot cast expression `aa` of type `int[int]` to `int[]` fail_compilation/fail_casting1.d(169): Error: cannot cast expression `aa` of type `int[int]` to `typeof(null)` fail_compilation/fail_casting1.d(173): Error: cannot cast expression `c` of type `fail_casting1.C` to `int delegate()` fail_compilation/fail_casting1.d(174): Error: cannot cast expression `c` of type `fail_casting1.C` to `int[]` fail_compilation/fail_casting1.d(177): Error: cannot cast expression `c` of type `fail_casting1.C` to `typeof(null)` --- */ void test3() // between reference types { { auto x = cast( P) p; } // Accept { auto x = cast(FP) p; } // Accept (FP is Tpointer) { auto x = cast(DG) p; } // Reject (from e2ir) { auto x = cast(DA) p; } // Reject (Bugzilla 14596) { auto x = cast(AA) p; } // Accept (because of size match) { auto x = cast( C) p; } // Accept (because of size match) { auto x = cast( N) p; } // Reject (Bugzilla 14629) { auto x = cast( P)fp; } // Accept (FP is Tpointer) { auto x = cast(FP)fp; } // Accept { auto x = cast(DG)fp; } // Reject (from e2ir) { auto x = cast(DA)fp; } // Reject (Bugzilla 14596) { auto x = cast(AA)fp; } // Accept (because of size match) { auto x = cast( C)fp; } // Accept (because of size match) { auto x = cast( N)fp; } // Reject (Bugzilla 14629) { auto x = cast( P)dg; } // Deprecated (equivalent with: cast( P)dg.ptr;) { auto x = cast(FP)dg; } // Deprecated (equivalent with: cast(FP)dg.ptr;) { auto x = cast(DG)dg; } // Accept { auto x = cast(DA)dg; } // Reject (from e2ir) { auto x = cast(AA)dg; } // Reject (from e2ir) { auto x = cast( C)dg; } // Reject (from e2ir) { auto x = cast( N)dg; } // Reject (Bugzilla 14629) { auto x = cast( P) n; } // Accept { auto x = cast(FP) n; } // Accept { auto x = cast(DG) n; } // Accept { auto x = cast(DA) n; } // Accept { auto x = cast(AA) n; } // Accept { auto x = cast( C) n; } // Accept { auto x = cast( N) n; } // Accept { auto x = cast( P)da; } // Accept (equivalent with: cast(P)da.ptr;) { auto x = cast(FP)da; } // Accept (FP is Tpointer) { auto x = cast(DG)da; } // Reject (from e2ir) { auto x = cast(DA)da; } // Accept { auto x = cast(AA)da; } // Reject (from e2ir) { auto x = cast( C)da; } // Reject (Bugzilla 10646) { auto x = cast( N)da; } // Reject (Bugzilla 14629) { auto x = cast( P)aa; } // Accept (because of size match) { auto x = cast(FP)aa; } // Accept (FP is Tpointer) { auto x = cast(DG)aa; } // Reject (from e2ir) { auto x = cast(DA)aa; } // Reject (from e2ir) { auto x = cast(AA)aa; } // Accept { auto x = cast( C)aa; } // Accept (because of size match) { auto x = cast( N)aa; } // Reject (Bugzilla 14629) { auto x = cast( P) c; } // Accept { auto x = cast(FP) c; } // Accept (FP is Tpointer) { auto x = cast(DG) c; } // Reject (from e2ir) { auto x = cast(DA) c; } // Reject (Bugzilla 10646) { auto x = cast(AA) c; } // Accept (because of size match) { auto x = cast( C) c; } // Accept { auto x = cast( N) c; } // Reject (Bugzilla 14629) } /* TEST_OUTPUT: --- fail_compilation/fail_casting1.d(206): Error: cannot cast expression `0` of type `int` to `int delegate()` fail_compilation/fail_casting1.d(207): Error: cannot cast expression `0` of type `int` to `int[]` fail_compilation/fail_casting1.d(208): Error: cannot cast expression `0` of type `int` to `int[1]` fail_compilation/fail_casting1.d(209): Error: cannot cast expression `0` of type `int` to `int[int]` fail_compilation/fail_casting1.d(210): Error: cannot cast expression `0` of type `int` to `fail_casting1.C` fail_compilation/fail_casting1.d(211): Error: cannot cast expression `0` of type `int` to `typeof(null)` fail_compilation/fail_casting1.d(215): Error: cannot cast expression `i` of type `int` to `int delegate()` fail_compilation/fail_casting1.d(216): Error: cannot cast expression `i` of type `int` to `int[]` fail_compilation/fail_casting1.d(217): Error: cannot cast expression `i` of type `int` to `int[1]` fail_compilation/fail_casting1.d(218): Error: cannot cast expression `i` of type `int` to `int[int]` fail_compilation/fail_casting1.d(219): Error: cannot cast expression `i` of type `int` to `fail_casting1.C` fail_compilation/fail_casting1.d(220): Error: cannot cast expression `i` of type `int` to `typeof(null)` fail_compilation/fail_casting1.d(224): Error: cannot cast expression `dg` of type `int delegate()` to `int` fail_compilation/fail_casting1.d(225): Error: cannot cast expression `da` of type `int[]` to `int` fail_compilation/fail_casting1.d(226): Error: cannot cast expression `sa` of type `int[1]` to `int` fail_compilation/fail_casting1.d(227): Error: cannot cast expression `aa` of type `int[int]` to `int` fail_compilation/fail_casting1.d(228): Error: cannot cast expression `c` of type `fail_casting1.C` to `int` --- */ void test4() { { auto x = cast( P) 0; } // Accept { auto x = cast(FP) 0; } // Accept { auto x = cast(DG) 0; } // Reject (from constfold) { auto x = cast(DA) 0; } // Reject (Bugzilla 11484) { auto x = cast(SA) 0; } // Reject (Bugzilla 11484) { auto x = cast(AA) 0; } // Reject (from constfold) { auto x = cast( C) 0; } // Reject (Bugzilla 11485) { auto x = cast( N) 0; } // Reject (from constfold) { auto x = cast( P) i; } // Accept { auto x = cast(FP) i; } // Accept { auto x = cast(DG) i; } // Reject (from e2ir) { auto x = cast(DA) i; } // Reject (Bugzilla 11484) { auto x = cast(SA) i; } // Reject (Bugzilla 11484) { auto x = cast(AA) i; } // Reject (from e2ir) { auto x = cast( C) i; } // Reject (Bugzilla 11485) { auto x = cast( N) i; } // Reject (from e2ir) { auto x = cast(int) p; } // Accept { auto x = cast(int)fp; } // Accept { auto x = cast(int)dg; } // Reject (from e2ir) { auto x = cast(int)da; } // Reject (Bugzilla 11484) { auto x = cast(int)sa; } // Reject (Bugzilla 11484) { auto x = cast(int)aa; } // Reject (from e2ir) { auto x = cast(int) c; } // Reject (Bugzilla 7472) { auto x = cast(int) n; } // Accept } /* TEST_OUTPUT: --- fail_compilation/fail_casting1.d(249): Error: cannot cast expression `0` of type `int` to `int[1]` fail_compilation/fail_casting1.d(250): Error: cannot cast expression `0` of type `int` to `S` fail_compilation/fail_casting1.d(251): Error: cannot cast expression `i` of type `int` to `int[1]` fail_compilation/fail_casting1.d(252): Error: cannot cast expression `i` of type `int` to `S` fail_compilation/fail_casting1.d(253): Error: cannot cast expression `f` of type `double` to `int[1]` fail_compilation/fail_casting1.d(254): Error: cannot cast expression `f` of type `double` to `S` fail_compilation/fail_casting1.d(255): Error: cannot cast expression `sa` of type `int[1]` to `int` fail_compilation/fail_casting1.d(256): Error: cannot cast expression `s` of type `S` to `int` fail_compilation/fail_casting1.d(257): Error: cannot cast expression `sa` of type `int[1]` to `double` fail_compilation/fail_casting1.d(258): Error: cannot cast expression `s` of type `S` to `double` --- */ void test5() { { auto x = cast(SA) 0; } // Reject (Bugzilla 14154) { auto x = cast( S) 0; } // Reject (Bugzilla 14154) { auto x = cast(SA) i; } // Reject (Bugzilla 14154) { auto x = cast( S) i; } // Reject (Bugzilla 14154) { auto x = cast(SA) f; } // Reject (Bugzilla 14154) { auto x = cast( S) f; } // Reject (Bugzilla 14154) { auto x = cast(int)sa; } // Reject (Bugzilla 14154) { auto x = cast(int) s; } // Reject (Bugzilla 14154) { auto x = cast(double)sa; } // Reject (Bugzilla 14154) { auto x = cast(double) s; } // Reject (Bugzilla 14154) } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bool_cast.d0000644000175000017500000000206215205374123021537 0ustar fabiofabio/* REQUIRED_ARGS: -de -preview=dip1000 TEST_OUTPUT: --- fail_compilation/bool_cast.d(17): Deprecation: cast from `ubyte[]` to `bool[]` will become `@system` in a future release fail_compilation/bool_cast.d(17): Source element may have bytes which are not 0 or 1 fail_compilation/bool_cast.d(22): Deprecation: cast from `int*` to `bool*` will become `@system` in a future release fail_compilation/bool_cast.d(22): Source element may have bytes which are not 0 or 1 fail_compilation/bool_cast.d(24): Deprecation: cast from `bool*` to `byte*` will become `@system` in a future release fail_compilation/bool_cast.d(24): Target element could be assigned a byte which is not 0 or 1 --- */ void main() @safe { ubyte[] a = [2, 4]; auto b = cast(bool[]) a; // reinterprets a's data auto c = cast(bool[]) [2, 4]; // OK, literal cast applies to each element auto d = cast(const(byte)[]) b; // OK, result's elements are const int i = 2; auto p = cast(bool*) &i; bool v; auto bp = cast(byte*) &v; *bp = 2; // v is now invalid } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22054.d0000644000175000017500000000113215205374123021077 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22054 /* TEST_OUTPUT: --- fail_compilation/fail22054.d(21): Error: no property `what` for type `fail22054.exception` fail_compilation/fail22054.d(16): `class fail22054.exception` is opaque and has no members. fail_compilation/fail22054.d(22): Error: no property `what` for type `fail22054.exception2` fail_compilation/fail22054.d(17): `struct fail22054.exception2` is opaque and has no members. --- */ class exception; struct exception2; void main () { assert(exception.what() == "Hello"); assert(exception2.what() == "Hello"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10273.d0000644000175000017500000000107715205374123020734 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=10273 // ICE in CTFE /* TEST_OUTPUT: --- fail_compilation/ice10273.d(14): Error: cannot implicitly convert expression `3.45` of type `double` to `int` fail_compilation/ice10273.d(13): Error: CTFE failed because of previous errors in `Bug10273.init` fail_compilation/ice10273.d(22): called from here: `bug10273()` fail_compilation/ice10273.d(22): while evaluating: `static assert(bug10273())` --- */ struct Bug10273 { int val = 3.45; } int bug10273() { Bug10273 p; return 1; } static assert(bug10273()); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4374.d0000644000175000017500000000023115205374123021023 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4374.d(11): Error: terminating `;` required after do-while statement --- */ void main() { do {} while(0) } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11136.d0000644000175000017500000000034315205374123020726 0ustar fabiofabio// EXTRA_SOURCES: imports/bar11136.d /* TEST_OUTPUT: --- fail_compilation/imports/bar11136.d(1): Error: package name 'ice11136' conflicts with usage as a module name in file fail_compilation/ice11136.d --- */ module ice11136; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12727.d0000644000175000017500000000153615205374123020742 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/ice12727.d(16): Error: template instance `IndexTuple!(1, 0)` recursive template expansion fail_compilation/ice12727.d(16): Error: alias `ice12727.IndexTuple!(1, 0).IndexTuple` recursive alias declaration fail_compilation/ice12727.d(23): Error: template instance `ice12727.IndexTuple!(1, 0)` error instantiating fail_compilation/ice12727.d(27): instantiated from here: `Matrix!(float, 3)` fail_compilation/ice12727.d(28): instantiated from here: `Vector!(float, 3)` ---- */ template IndexTuple(int e, int s = 0, T...) { static if (s == e) alias IndexTuple = T; else alias IndexTuple = IndexTuple!(e); } struct Matrix(T, int N = M) { pure decomposeLUP() { foreach (j; IndexTuple!(1)) {} } } alias Vector(T, int M) = Matrix!(T, M); alias Vector3 = Vector!(float, 3); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22202.d0000644000175000017500000000115515205374123021077 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22202 /* TEST_OUTPUT: --- fail_compilation/fail22202.d(22): Error: function `fun` is not callable using argument types `(SystemCopy)` fail_compilation/fail22202.d(22): `inout ref inout(SystemCopy)(ref inout(SystemCopy) other)` copy constructor cannot be called from a `pure @safe nogc` context fail_compilation/fail22202.d(17): `fail22202.fun(SystemCopy __param_0)` declared here --- */ struct SystemCopy { this(ref inout SystemCopy other) inout {} } void fun(SystemCopy) @safe pure @nogc {} void main() @safe pure @nogc { SystemCopy s; fun(s); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail8009.d0000644000175000017500000000050315205374123021024 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail8009.d(9): Error: template `filter` is not callable using argument types `!()(void)` fail_compilation/fail8009.d(8): Candidate is: `filter(R)(scope bool delegate(ref BAD!R) func)` --- */ void filter(R)(scope bool delegate(ref BAD!R) func) { } void main() { filter(r => r); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9254a.d0000644000175000017500000000146115205374123021021 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9254a.d(15): Error: using the result of a comma expression is not allowed fail_compilation/ice9254a.d(15): Error: using the result of a comma expression is not allowed fail_compilation/ice9254a.d(15): Error: using the result of a comma expression is not allowed fail_compilation/ice9254a.d(15): Error: using the result of a comma expression is not allowed fail_compilation/ice9254a.d(15): Error: using the result of a comma expression is not allowed fail_compilation/ice9254a.d(15): Error: invalid `foreach` aggregate `false` of type `bool` --- */ void main() { foreach (divisor; !(2, 3, 4, 8, 7, 9)) { // ice in ForeachRangeStatement::blockExit() foreach (v; 0..uint.max) {} // ice in WhileStatement::blockExit() while (1) {} } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail2962.d0000644000175000017500000000154315205374123021033 0ustar fabiofabio// EXTRA_SOURCES: imports/fail2962a.d // comment 6 /* TEST_OUTPUT: --- fail_compilation/fail2962.d(14): Error: variable `y` cannot be read at compile time fail_compilation/fail2962.d(14): while looking for match for `baz6!(int, y)` fail_compilation/fail2962.d(22): Error: template instance `fail2962.bar6!int` error instantiating --- */ T bar6(T)(T y) { return baz6!(T, y)(); } T baz6(T, T z)() { return z * z; } void test6() { assert(bar6(4) != 0); } // comment 4 /* TEST_OUTPUT: --- fail_compilation/fail2962.d(36): Error: variable `x` cannot be read at compile time fail_compilation/fail2962.d(36): while looking for match for `baz4!(int, x)` fail_compilation/imports/fail2962a.d(6): Error: template instance `fail2962.bar4!int` error instantiating --- */ T bar4(T)(T x) { return baz4!(T, x)(); } T baz4(T, T x)() { return x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/class2.d0000644000175000017500000000032115205374123020755 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/class2.d(11): Error: class `class2.C` identity assignment operator overload is illegal --- */ class C { // Templated identity opAssign void opAssign(T)(T rhs){} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12730a.d0000644000175000017500000000036415205374123021246 0ustar fabiofabio/* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/fail12730a.d(13): Error: expected integer operand(s) for `-` --- */ // https://issues.dlang.org/show_bug.cgi?id=12730 void test() { asm { lea ECX, [EBX - EAX]; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6652.d0000644000175000017500000000132215205374123021026 0ustar fabiofabio// PERMUTE_ARGS: -w -dw -de -d /******************************************/ // https://issues.dlang.org/show_bug.cgi?id=6652 /* TEST_OUTPUT: --- fail_compilation/fail6652.d(20): Error: cannot modify `const` expression `i` fail_compilation/fail6652.d(25): Error: cannot modify `const` expression `i` fail_compilation/fail6652.d(30): Error: cannot modify `const` expression `i` fail_compilation/fail6652.d(35): Error: cannot modify `const` expression `i` --- */ void main() { foreach (const i; 0..2) { ++i; } foreach (ref const i; 0..2) { ++i; } foreach (const i, e; [1,2,3,4,5]) { ++i; } foreach (ref const i, e; [1,2,3,4,5]) { ++i; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail285.d0000644000175000017500000000035315205374123020745 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail285.d(19): Error: with symbol `fail285.S.x` is shadowing local symbol `fail285.main.x` --- */ struct S { int x; } void main() { int x; S s; with (s) { x++; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue23947.d0000644000175000017500000000045215205374123021334 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23947 /* TEST_OUTPUT: --- fail_compilation/issue23947.d(10): Error: function `imports.issue23947a.Class.handle` of type `void(X x)` is not accessible from module `issue23947` --- */ import imports.issue23947a; void main() { Class.init.handle(X.init); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/parseStc2.d0000644000175000017500000000466415205374123021452 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/parseStc2.d(11): Error: conflicting attribute `const` fail_compilation/parseStc2.d(12): Error: conflicting attribute `@system` fail_compilation/parseStc2.d(13): Error: conflicting attribute `@safe` fail_compilation/parseStc2.d(14): Error: conflicting attribute `@trusted` fail_compilation/parseStc2.d(15): Error: conflicting attribute `__gshared` --- */ immutable const void f4() {} @safe @system void f4() {} @trusted @safe void f4() {} @system @trusted void f4() {} shared __gshared f4() {} /* TEST_OUTPUT: --- fail_compilation/parseStc2.d(26): Error: redundant attribute `static` fail_compilation/parseStc2.d(27): Error: redundant attribute `pure` fail_compilation/parseStc2.d(28): Error: redundant attribute `@property` fail_compilation/parseStc2.d(29): Error: redundant attribute `@safe` --- */ static static void f1() {} pure nothrow pure void f2() {} @property extern(C) @property void f3() {} deprecated("") @safe @safe void f4() {} @(1) @(1) void f5() {} // OK /* TEST_OUTPUT: --- fail_compilation/parseStc2.d(39): Error: redundant linkage `extern (C)` fail_compilation/parseStc2.d(40): Error: conflicting linkage `extern (C)` and `extern (C++)` --- */ extern(C) extern(C) void f6() {} extern(C) extern(C++) void f7() {} extern(C++, foo) extern(C++, bar) void f8() {} // OK /* TEST_OUTPUT: --- fail_compilation/parseStc2.d(50): Error: redundant visibility attribute `public` fail_compilation/parseStc2.d(51): Error: conflicting visibility attribute `public` and `private` --- */ public public void f9() {} public private void f10() {} /* TEST_OUTPUT: --- fail_compilation/parseStc2.d(63): Error: redundant alignment attribute `align(default)` fail_compilation/parseStc2.d(64): Error: redundant alignment attribute `align(1)` fail_compilation/parseStc2.d(65): Error: redundant alignment attribute `align(1)` fail_compilation/parseStc2.d(66): Error: redundant alignment attribute `align(default)` fail_compilation/parseStc2.d(67): Error: redundant alignment attribute `align(2)` --- */ align align void f11() {} align(1) align(1) void f12() {} align align(1) void f13() {} align(1) align void f14() {} align(1) align(2) void f15() {} /* TEST_OUTPUT: --- fail_compilation/parseStc2.d(76): Error: redundant linkage `extern (System)` fail_compilation/parseStc2.d(77): Error: conflicting linkage `extern (System)` and `extern (C++)` --- */ extern(System) extern(System) void f16() {} extern(System) extern(C++) void f17() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/funcpostattr.d0000644000175000017500000000116515205374123022331 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/funcpostattr.d(11): Error: `deprecated` token is not allowed in postfix position fail_compilation/funcpostattr.d(11): Error: `extern` token is not allowed in postfix position fail_compilation/funcpostattr.d(15): Error: `static` token is not allowed in postfix position fail_compilation/funcpostattr.d(15): Error: `ref` token is not allowed in postfix position fail_compilation/funcpostattr.d(20): Error: `override` token is not allowed in postfix position --- */ void foo() deprecated extern; void main() { int i; int foo() static ref => i; } class C { void foo() override {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/must_use_template.d0000644000175000017500000000043315205374123023331 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/must_use_template.d(15): Error: ignored value of `@mustuse` type `must_use_template.S!int`; prepend a `cast(void)` if intentional --- +/ import core.attribute; @mustuse struct S(T) {} S!int fun() { return S!int(); } void test() { fun(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3581a.d0000644000175000017500000000033115205374123021164 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail3581a.d(9): Error: function `fail3581a.B.f` cannot override a non-virtual function --- */ class A { void f() {} } class B : A { static override void f() {}; } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15306.d0000644000175000017500000000136015205374123021150 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test15306.d(15): Error: `immutable` delegate `test15306.main.__dgliteral_L15_C16` cannot access mutable data `i` fail_compilation/test15306.d(19): Error: `shared` delegate `test15306.main.__dgliteral_L19_C16` cannot access non-shared data `p` --- */ // https://issues.dlang.org/show_bug.cgi?id=15306 void main() { // immutable cannot access mutable int i = 42; auto dg1 = delegate void() immutable { auto inner = i; }; // shared cannot access unshared int* p = &i; auto dg2 = delegate int() shared { return *p; }; assert(dg2() == i); // unshared can access shared shared j = 43; shared int* q = &j; auto dg3 = delegate int() { return *q; }; assert(dg2() == j); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13225.d0000644000175000017500000000056715205374123020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13225.d(12): Error: mixin `ice13225.S.M!(function (S __param_0) pure nothrow @nogc @safe => 0)` does not match template declaration `M(T)` fail_compilation/ice13225.d(16): Error: undefined identifier `undefined` --- */ mixin template M(T) {} struct S { mixin M!((typeof(this)) => 0); } struct T { mixin M!(() => undefined); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail56.d0000644000175000017500000000114315205374123020657 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail56.d(21): Error: mixin `dstress.nocompile.bug_20050330_A.main.Blah!(5, a).Blah!(5, a)` recursive mixin instantiation fail_compilation/fail56.d(26): Error: mixin `dstress.nocompile.bug_20050330_A.main.Blah!(5, a)` error instantiating --- */ // $HeadURL$ // $Date$ // $Author$ // @author@ Regan Heath // @date@ 2005-03-30 // @uri@ news:opsof4hwgy23k2f5@nrage.netwin.co.nz // __DSTRESS_ELINE__ 14 module dstress.nocompile.bug_20050330_A; template Blah(int a, alias B){ mixin Blah!(a, B) Foo; } int main(){ int a; mixin Blah!(5,a); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail318_b.d0000644000175000017500000000025315205374123021242 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail318_b.d(8): Error: function `D main` must return `int`, `void` or `noreturn`, not `string` --- */ auto main() { return ""; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/cpp_abi_tag2.d0000644000175000017500000000143615205374123022110 0ustar fabiofabio/* DISABLED: win32 win64 REQUIRED_ARGS: -extern-std=c++11 TEST_OUTPUT: --- fail_compilation/cpp_abi_tag2.d(102): Error: constructor `core.attribute.gnuAbiTag.this(string[] tags...)` is not callable using argument types `(string, wstring, dstring)` fail_compilation/cpp_abi_tag2.d(102): cannot pass argument `"b"w` of type `wstring` to parameter `string[] tags...` fail_compilation/cpp_abi_tag2.d(105): Error: constructor `core.attribute.gnuAbiTag.this(string[] tags...)` is not callable using argument types `(string, int, double)` fail_compilation/cpp_abi_tag2.d(105): cannot pass argument `2` of type `int` to parameter `string[] tags...` --- */ #line 100 import core.attribute; @gnuAbiTag("a", "b"w, "c"d) extern(C++) struct C {} @gnuAbiTag("a", 2, 3.3) extern(C++) struct E {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10099.d0000644000175000017500000000031515205374123021100 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10099.d(15): Error: variable `diag10099.main.s` - default construction is disabled for type `S` --- */ struct S { @disable this(); } void main() { S s; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20626.d0000644000175000017500000000053615205374123021155 0ustar fabiofabio/* REQUIRED_ARGS: -check=invariant=off TEST_OUTPUT: ---- fail_compilation/test20626.d(2): Error: expression `__unittest_L1_C1` has no type _error_ const void() ---- https://issues.dlang.org/show_bug.cgi?id=20626 */ #line 1 unittest {} pragma(msg, typeof(__unittest_L1_C1)); struct S { invariant {} } pragma(msg, typeof(S.init.__invariant1)); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20448.d0000644000175000017500000000054015205374123021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail20448.d(16): Error: returning `p.x` escapes a reference to parameter `p` fail_compilation/fail20448.d(22): Error: template instance `fail20448.member!"x"` error instantiating --- */ struct S { int x, y; } ref int member(string mem)(S p) { return p.x; } void main() { S p; p.member!"x" = 2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14554.d0000644000175000017500000000164115205374123021112 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/fail14554.d(28): Error: `fail14554.issue14554_1.foo` called with argument types `(int)` matches multiple overloads exactly: fail_compilation/fail14554.d(17): `fail14554.issue14554_1.foo!bool.foo(int j)` and: fail_compilation/fail14554.d(18): `fail14554.issue14554_1.foo!bool.foo(int j)` fail_compilation/fail14554.d(29): Error: `fail14554.issue14554_2.foo` called with argument types `(int)` matches multiple overloads exactly: fail_compilation/fail14554.d(22): `fail14554.issue14554_2.foo!bool.foo(int j)` and: fail_compilation/fail14554.d(23): `fail14554.issue14554_2.foo!bool.foo(int j)` --- */ struct issue14554_1 { void foo(T)(int j) {} static void foo(T)(int j) {} } struct issue14554_2 { static void foo(T)(int j) {} void foo(T)(int j) {} } void test14554() { issue14554_1.foo!bool(1); issue14554_2.foo!bool(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21429.d0000644000175000017500000000071115205374123021152 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test21429.d(20): Error: no property `z` for `s` of type `test21429.S` fail_compilation/test21429.d(13): struct `S` defined here --- */ //make sure this fails properly after fixing bug 21429.d template mixinOpDispatch(string id){ string opDispatch(string s)() if(s == id){ return id; } } struct S { mixin mixinOpDispatch!"x"; mixin mixinOpDispatch!"y"; } void main(){ S s; auto fail = s.z; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3.d0000644000175000017500000000135015205374123020567 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail3.d(42): Error: operator `+` is not defined for type `vec2` fail_compilation/fail3.d(13): perhaps overload the operator with `auto opBinary(string op : "+")(vec2 rhs) {}` --- */ // DMD 0.79 linux: Internal error: ../ztc/cgcod.c 1459 template vector(T) { struct vec2 { T x, y; } // not struct member vec2 opAdd(vec2 a, vec2 b) { vec2 r; r.x = a.x + b.x; r.y = a.y + b.y; return r; } vec2 make2(T x, T y) { vec2 a; a.x = x; a.y = y; return a; } } alias vector!(float).vec2 vec2f; int main() { vec2f a, b; b.x = 3; a = a + b; //printf("%f\n", a.x); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag_cstyle.d0000644000175000017500000000137515205374123022067 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag_cstyle.d(13): Error: instead of C-style syntax, use D-style `int function(int) fp1` fail_compilation/diag_cstyle.d(14): Error: instead of C-style syntax, use D-style `int function(int)* fp3` fail_compilation/diag_cstyle.d(16): Error: instead of C-style syntax, use D-style `int function(int) FP` fail_compilation/diag_cstyle.d(18): Error: instead of C-style syntax, use D-style `int function() fp` fail_compilation/diag_cstyle.d(18): Error: instead of C-style syntax, use D-style `int[] arr` fail_compilation/diag_cstyle.d(20): Error: instead of C-style syntax, use D-style `string[] result` --- */ int (*fp1)(int); int (*(*fp3))(int); alias int(*FP)(int); void foo(int(*fp)(), int arr[]) {} string result[]() = "abc"; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375h.d0000644000175000017500000000065415205374123021205 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375h.d(15): Error: else is dangling, add { } after condition at fail_compilation/fail4375h.d(12) --- */ void main() { switch (4) { default: if (true) // disallowed if (false) assert(48); else assert(49); break; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail2740.d0000644000175000017500000000041715205374123021024 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail2740.d(17): Error: class `fail2740.Foo` ambiguous virtual function `foo` --- */ interface IFoo { int foo(); } mixin template MFoo(int N) { int foo() { return N; } } class Foo : IFoo { mixin MFoo!(1) t1; mixin MFoo!(2) t2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail221.d0000644000175000017500000000026215205374123020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail221.d(11): Error: expression `cast(void)0` is `void` and has no value --- */ void main() { void[] data; data ~= cast(void) 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21693.d0000644000175000017500000000104515205374123021112 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail21693.d(15): Error: function `fail` is not callable using argument types `(uint)` fail_compilation/fail21693.d(15): cannot pass rvalue argument `__rvalue(s.x)` of type `uint` to parameter `ref uint` fail_compilation/fail21693.d(11): `fail21693.fail(ref uint)` declared here fail_compilation/fail21693.d(16): Error: rvalue `__rvalue(s.x)` cannot be assigned to `ref x` --- */ struct S { uint x; } void fail(ref uint); void test21693(S s) { fail(__rvalue(s.x)); ref x = __rvalue(s.x); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23773.d0000644000175000017500000000040015205374123021105 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23773 /* TEST_OUTPUT: --- fail_compilation/fail23773.d(14): Error: assignment cannot be used as a condition, perhaps `==` was meant? --- */ void main() { int i; int[] arr; assert(arr.length = i); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b19691.d0000644000175000017500000000050415205374123020424 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/b19691.d(12): Error: forward reference to template `this` --- */ // https://issues.dlang.org/show_bug.cgi?id=19691 module b19691; struct S1 { this(T...)(T) { S2(42, ""); } } struct S2 { this(int a, string) {} this(int a, S1 s = null) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failattr.d0000644000175000017500000000277215205374123021410 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/failattr.d(103): Error: variable `failattr.C2901.v1` cannot be `synchronized` fail_compilation/failattr.d(104): Error: variable `failattr.C2901.v2` cannot be `override` fail_compilation/failattr.d(105): Error: variable `failattr.C2901.v3` cannot be `abstract` fail_compilation/failattr.d(106): Error: variable `failattr.C2901.v4` cannot be `final`, perhaps you meant `const`? fail_compilation/failattr.d(118): Error: variable `failattr.C2901.v13` cannot be `final abstract synchronized override` fail_compilation/failattr.d(120): Error: variable `failattr.C2901.v14` cannot be `final`, perhaps you meant `const`? fail_compilation/failattr.d(123): Error: undefined identifier `ERROR` --- */ #line 100 class C2901 { synchronized int v1; // error override int v2; // error abstract int v3; // error final int v4; // error synchronized { int v5; } // no error override { int v6; } // no error abstract { int v7; } // no error final { int v8; } // no error synchronized: int v9; // no error override: int v10; // no error abstract: int v11; // no error final: int v12; // no error synchronized override abstract final int v13; // one line error static final int v14; // error, even if static is applied at the same time } enum B23122 { @ERROR e } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix350a.d0000644000175000017500000000054515205374123020755 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix350a.d(12): Error: comma expected separating field initializers fail_compilation/fix350a.d(12): Error: comma expected separating field initializers --- */ struct S1 { int a, b, c; static immutable S1 C1 = { 1 2 3 }; // no commas here, compiles static immutable S1 C2 = { 1, 2, 3 }; // compiles as well } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17492.d0000644000175000017500000000123715205374123021117 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/fail17492.d(20): Error: function `fail17492.C.testE()` conflicts with previous declaration at fail_compilation/fail17492.d(13) fail_compilation/fail17492.d(37): Error: function `fail17492.S.testE()` conflicts with previous declaration at fail_compilation/fail17492.d(30) --- https://issues.dlang.org/show_bug.cgi?id=17492 */ class C { void testE() { class I { } } void testE() { class I { } } } class S { void testE() { struct I { } } void testE() { struct I { } } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22075.d0000644000175000017500000000147415205374123021113 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22075 /* TEST_OUTPUT: --- fail_compilation/fail22075.d(25): Error: AA key type `S` should have `extern (D) size_t toHash() const nothrow @safe` if `opEquals` defined fail_compilation/fail22075.d(26): Error: AA key type `S` should have `extern (D) size_t toHash() const nothrow @safe` if `opEquals` defined --- */ struct HasAliasThis { int a; alias a this; } struct LacksAliasThis { int a; } struct S(T) { private T a; bool opEquals(const S rhs) const @nogc nothrow @safe { return rhs is this; } } int[S!HasAliasThis] aa1; // Compiles but should not. int[S!LacksAliasThis] aa2; // Correctly fails to compile with "Error: AA key // type `S` should have `extern (D) size_t toHash() const nothrow @safe` // if `opEquals` defined"". void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23715.i0000644000175000017500000000036115205374123021160 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23715.i(11): Error: `_Thread_local` in block scope must be accompanied with `static` or `extern` --- */ // https://issues.dlang.org/show_bug.cgi?id=23715 void test2() { _Thread_local int tli; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14844.d0000644000175000017500000000104515205374123020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice14844.d(21): Error: in expression `__traits(allMembers, opDispatch)` template `opDispatch(string name)` has no members fail_compilation/ice14844.d(21): `opDispatch(string name)` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation --- */ struct Typedef { template opDispatch(string name) { static if (true) { } } } void runUnitTestsImpl() { foreach (x; __traits(allMembers, Typedef.opDispatch)) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag20059.d0000644000175000017500000000045015205374123021075 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag20059.d(15): Error: expected return type of `string`, not `string[]`: fail_compilation/diag20059.d(13): Return type of `string` inferred here. --- */ auto fail() { string ret; if (true) return ret; else return [ret]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failob2.d0000644000175000017500000000320315205374123021106 0ustar fabiofabio// REQUIRED_ARGS: -preview=dip1021 /* TEST_OUTPUT: --- fail_compilation/failob2.d(105): Error: variable `failob2.foo1!int.foo1.p` has undefined state and cannot be read fail_compilation/failob2.d(105): Error: variable `failob2.foo1!int.foo1.p` is returned but is Undefined fail_compilation/failob2.d(124): Error: template instance `failob2.foo1!int` error instantiating fail_compilation/failob2.d(111): Error: variable `failob2.foo2!int.foo2.p` has undefined state and cannot be read fail_compilation/failob2.d(111): Error: variable `failob2.foo2!int.foo2.p` is returned but is Undefined fail_compilation/failob2.d(125): Error: template instance `failob2.foo2!int` error instantiating fail_compilation/failob2.d(119): Error: variable `failob2.foo3!int.foo3.p` has undefined state and cannot be read fail_compilation/failob2.d(119): Error: variable `failob2.foo3!int.foo3.p` is returned but is Undefined fail_compilation/failob2.d(126): Error: template instance `failob2.foo3!int` error instantiating --- */ #line 100 @live T* foo1(T)() { T* p = void; return p; } template foo2(T) { @live T* foo2() { T* p = void; return p; } } @live template foo3(T) { T* foo3() { T* p = void; return p; } } void test1() { foo1!int(); foo2!int(); foo3!int(); } /* TEST_OUTPUT: --- fail_compilation/failob2.d(205): Error: variable `failob2.foo4!int.foo4.p` is not disposed of before return fail_compilation/failob2.d(209): Error: template instance `failob2.foo4!int` error instantiating --- */ #line 200 void* alloc(size_t); @live void foo4(T)() { auto p = alloc(4); } void test2() { foo4!int(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag14145.d0000644000175000017500000000136515205374123021102 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag14145.d(14): Error: no property `i` for `_` of type `diag14145.main.Capture!(i)` fail_compilation/diag14145.d(33): Error: expression `*this.ptr` of type `shared(int)` is not implicitly convertible to return type `ref int` fail_compilation/diag14145.d(14): Error: template instance `diag14145.main.Capture!(i).Capture.opDispatch!"i"` error instantiating --- */ int main() { int i; auto _ = capture!i; _.i; _.opDispatch!"i"; return 0; } auto capture(alias c)() { return Capture!c(c); } struct Capture(alias c) { shared typeof(c)* ptr; this(ref typeof(c) _c) { ptr = cast(shared)&c; } ref shared typeof(c) opDispatch(string s)() { return *ptr; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail36.d0000644000175000017500000000053515205374123020661 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail36.d(13): Error: template `t(int L)` does not have property `a` fail_compilation/fail36.d(18): Error: mixin `fail36.func.t!10` error instantiating --- */ template t(int L) { int a; // void foo(int b = t!(L).a) {} // correct void foo(int b = t.a) {} // wrong } void func() { mixin t!(10); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail115.d0000644000175000017500000000045715205374123020742 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=402 // compiler crash with mixin and forward reference /* TEST_OUTPUT: --- fail_compilation/fail115.d(17): Error: mixin `Foo!y` cannot resolve forward reference --- */ template Foo(alias b) { int a() { return b; } } void main() { mixin Foo!(y) y; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/aliasassign2.d0000644000175000017500000000176715205374123022165 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/aliasassign2.d(16): Error: `alias aa1 = aa1;` cannot alias itself, use a qualified name to create an overload set fail_compilation/aliasassign2.d(19): Error: template instance `aliasassign2.Tp1!()` error instantiating fail_compilation/aliasassign2.d(24): Error: undefined identifier `unknown` fail_compilation/aliasassign2.d(26): Error: template instance `aliasassign2.Tp2!()` error instantiating fail_compilation/aliasassign2.d(31): Error: template instance `AliasSeqX!(aa3, 1)` template `AliasSeqX` is not defined, did you mean AliasSeq(T...)? fail_compilation/aliasassign2.d(33): Error: template instance `aliasassign2.Tp3!()` error instantiating --- */ alias AliasSeq(T...) = T; template Tp1() { alias aa1 = aa1; aa1 = AliasSeq!(aa1, float); } alias a1 = Tp1!(); template Tp2() { alias aa2 = AliasSeq!(); aa2 = AliasSeq!(aa2, unknown); } alias a2 = Tp2!(); template Tp3() { alias aa3 = AliasSeq!(); aa3 = AliasSeqX!(aa3, 1); } alias a3 = Tp3!(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/nogc2.d0000644000175000017500000000623115205374123020604 0ustar fabiofabio// REQUIRED_ARGS: -o- /***************** CatExp *******************/ /* TEST_OUTPUT: --- fail_compilation/nogc2.d(20): Error: concatenating with operator `~` causes a GC allocation in `@nogc` function `testCat` fail_compilation/nogc2.d(21): Error: concatenating with operator `~` causes a GC allocation in `@nogc` function `testCat` fail_compilation/nogc2.d(22): Error: concatenating with operator `~` causes a GC allocation in `@nogc` function `testCat` fail_compilation/nogc2.d(24): Error: concatenating with operator `~` causes a GC allocation in `@nogc` function `testCat` fail_compilation/nogc2.d(25): Error: concatenating with operator `~` causes a GC allocation in `@nogc` function `testCat` fail_compilation/nogc2.d(26): Error: concatenating with operator `~` causes a GC allocation in `@nogc` function `testCat` fail_compilation/nogc2.d(27): Error: concatenating with operator `~` causes a GC allocation in `@nogc` function `testCat` fail_compilation/nogc2.d(28): Error: concatenating with operator `~` causes a GC allocation in `@nogc` function `testCat` --- */ @nogc void testCat(int[] a, string s) { int[] a1 = a ~ a; int[] a2 = a ~ 1; int[] a3 = 1 ~ a; string s1 = s ~ s; string s2 = s ~ "a"; string s3 = "a" ~ s; string s4 = s ~ 'c'; string s5 = 'c' ~ s; string s6 = "a" ~ "b"; // no error string s7 = "a" ~ 'c'; // no error string s8 = 'c' ~ "b"; // no error } /***************** CatAssignExp *******************/ /* TEST_OUTPUT: --- fail_compilation/nogc2.d(47): Error: appending to this array with operator `~=` causes a GC allocation in `@nogc` function `testCatAssign` fail_compilation/nogc2.d(49): Error: appending to this array with operator `~=` causes a GC allocation in `@nogc` function `testCatAssign` fail_compilation/nogc2.d(50): Error: appending to this array with operator `~=` causes a GC allocation in `@nogc` function `testCatAssign` --- */ @nogc void testCatAssign(int[] a, string s) { a ~= 1; s ~= "a"; s ~= 'c'; } /***************** ArrayLiteralExp *******************/ @nogc int* barA(); /* TEST_OUTPUT: --- fail_compilation/nogc2.d(69): Error: this array literal causes a GC allocation in `@nogc` function `testArray` fail_compilation/nogc2.d(70): Error: this array literal causes a GC allocation in `@nogc` function `testArray` --- */ @nogc void testArray() { enum arrLiteral = [null, null]; int* p; auto a = [p, p, barA()]; a = arrLiteral; } /***************** AssocArrayLiteralExp *******************/ /* TEST_OUTPUT: --- fail_compilation/nogc2.d(86): Error: this associative array literal causes a GC allocation in `@nogc` function `testAssocArray` fail_compilation/nogc2.d(87): Error: this associative array literal causes a GC allocation in `@nogc` function `testAssocArray` --- */ @nogc void testAssocArray() { enum aaLiteral = [10: 100]; auto aa = [1:1, 2:3, 4:5]; aa = aaLiteral; } /***************** IndexExp *******************/ /* TEST_OUTPUT: --- fail_compilation/nogc2.d(100): Error: assigning this associative array element causes a GC allocation in `@nogc` function `testIndex` --- */ @nogc void testIndex(int[int] aa) { aa[1] = 0; int n = aa[1]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/objc_class3.d0000644000175000017500000000074415205374123021764 0ustar fabiofabio// EXTRA_OBJC_SOURCES: /* TEST_OUTPUT: --- fail_compilation/objc_class3.d(15): Error: function `objc_class3.A.test!int.test` template cannot have an Objective-C selector attached fail_compilation/objc_class3.d(21): Error: template instance `objc_class3.A.test!int` error instantiating --- */ import core.attribute : selector; extern (Objective-C) extern class A { void test(T)(T a) @selector("test:"); // selector defined for template } void test() { A a; a.test(3); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/aa_assign.d0000644000175000017500000000041215205374123021514 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation\aa_assign.d(11): Error: associative arrays can only be assigned values with immutable keys, not `char[]` --- */ void test_mutable_key() { int[char[]] aa; char[] str = "123".dup; aa[str] = 3; assert(str in aa); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17423.d0000644000175000017500000000117315205374123021154 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test17423.d(27): Error: assigning reference to local `this` to non-scope parameter `dlg` calling `opApply` is not allowed in a `@safe` function fail_compilation/test17423.d(16): which is not `scope` because of `this.myDlg = dlg` --- */ // https://issues.dlang.org/show_bug.cgi?id=17423 struct Bar { int delegate(int) @safe myDlg; auto opApply(int delegate(int) @safe dlg) @safe { myDlg = dlg; return 0; } } struct Foo { Bar o; int i = 3; this(int x) @safe { foreach(_; o) { i = 0; } i = x; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15044.d0000644000175000017500000000171715205374123021111 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail15044.d(30): Error: generated function `fail15044.V.opAssign` cannot be used because it is annotated with `@disable` --- */ struct S { void opAssign(S) {} } struct V { // `s` has opAssign, so struct V needs to generate member-wise opAssign. // But S.opAssign is not callable on const object, so V.opAssign should be // @disable. const S s; // Here, the initializer of x is evaluated in V.semantic2. But // V.opAssign.semantic3 is not yet invoked, so its attribute should be // lazily inferred in functionSemantic even though it's non-instantiated function. enum int x = () { // Here, the initializer of x is evaluated in V.semantic2, and // V.opAssign.semantic3 is not yet invoked in this time. // Therefore its @disable attribute needs to be inferred by // functionSemantic, even though it's non-instantiated function. V v; v = v; }(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9346.d0000644000175000017500000000064715205374123021042 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9346.d(26): Error: struct `fail9346.S` is not copyable because it has a disabled postblit fail_compilation/fail9346.d(27): Error: struct `fail9346.S` is not copyable because it has a disabled postblit --- */ struct S { @disable this(this); } struct SS1 { S s; } struct SS2 { S s; this(this){} } void main() { S s; SS1 ss1 = SS1(s); SS2 ss2 = SS2(s); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag7050b.d0000644000175000017500000000030715205374123021154 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag7050b.d(12): Error: `pure` function `diag7050b.f.g` cannot call impure function `diag7050b.f` --- */ void f() { pure void g() { f(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12436.d0000644000175000017500000000412315205374123021105 0ustar fabiofabioalias void FuncType(); struct Opaque; template Tuple(T...) { alias T Tuple; } alias Tuple!(int, int) TupleType; /******************************************/ // return type /* TEST_OUTPUT: --- fail_compilation/fail12436.d(18): Error: functions cannot return a function fail_compilation/fail12436.d(19): Error: functions cannot return a sequence (use `std.typecons.Tuple`) --- */ FuncType test1(); TupleType test2(); /* TEST_OUTPUT: --- fail_compilation/fail12436.d(28): Error: functions cannot return opaque type `Opaque` by value fail_compilation/fail12436.d(29): Error: functions cannot return opaque type `Opaque[1]` by value --- */ Opaque ret12436a(); // error Opaque[1] ret12436b(); // error Opaque* ret12436c(); // no error Opaque[] ret12436d(); // no error Opaque[]* ret12436e(); // no error ref Opaque ret12436f(); // no error ref Opaque[1] ret12436g(); // no error /******************************************/ // parameter type /* TEST_OUTPUT: --- fail_compilation/fail12436.d(46): Error: cannot have parameter of function type `void()` --- */ void test3(FuncType) {} /* TEST_OUTPUT: --- fail_compilation/fail12436.d(55): Error: cannot have parameter of opaque type `Opaque` by value fail_compilation/fail12436.d(56): Error: cannot have parameter of opaque type `Opaque[1]` by value --- */ void param12436a(Opaque); // error void param12436b(Opaque[1]); // error void param12436c(Opaque*); // no error void param12436d(Opaque[]); // no error void param12436e(Opaque[]*); // no error void param12436f(ref Opaque); // no error void param12436g(ref Opaque[1]); // no error void param12436h(out Opaque); // no error void param12436i(out Opaque[1]); // no error /* TEST_OUTPUT: --- fail_compilation/fail12436.d(75): Error: cannot have parameter of opaque type `A14906` by value fail_compilation/fail12436.d(76): Error: cannot have parameter of opaque type `A14906[3]` by value fail_compilation/fail12436.d(77): Error: cannot have parameter of opaque type `A14906[3][3]` by value --- */ enum A14906; void f14906a(A14906) {} void f14906b(A14906[3]) {} void f14906c(A14906[3][3]) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice15002.d0000644000175000017500000000034615205374123020725 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice15002.d(10): Error: array index 5 is out of bounds `x[0 .. 3]` fail_compilation/ice15002.d(10): Error: array index 5 is out of bounds `x[0 .. 3]` --- */ int[][3] x = []; int* p = &x[5][0]; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20365.d0000644000175000017500000000125515205374123021110 0ustar fabiofabio/* REQUIRED_ARGS: -preview=bitfields TEST_OUTPUT: --- fail_compilation/fail20365.d(16): Error: bitfield `a.x` cannot be assigned to `ref x` fail_compilation/fail20365.d(23): Error: function `f` is not callable using argument types `(int)` fail_compilation/fail20365.d(23): cannot pass bitfield argument `a.y` to parameter `ref int` fail_compilation/fail20365.d(19): `fail20365.f(ref int)` declared here fail_compilation/fail20365.d(28): Error: cannot `ref` return bitfield `a.y` --- */ struct A { int x : 16, y : 16; } void ref_assign(A a) { ref int x = a.x; } void f(ref int); void ref_param(A a) { f(a.y); } ref int ref_return(ref A a) { return a.y; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail299.d0000644000175000017500000000032615205374123020752 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail299.d(14): Error: initializer provided for struct `Foo` with no fields --- */ struct Foo {} void foo (Foo b, void delegate ()) {} void main () { foo(Foo(1), (){}); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bug19569.d0000644000175000017500000000653615205374123020777 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/bug19569.d(70): Error: `bug19569.test0` called with argument types `()` matches multiple overloads exactly: fail_compilation/bug19569.d(56): `bug19569.test0()` and: fail_compilation/bug19569.d(57): `bug19569.test0()` fail_compilation/bug19569.d(71): Error: `bug19569.test1` called with argument types `()` matches multiple overloads exactly: fail_compilation/bug19569.d(59): `bug19569.test1()` and: fail_compilation/bug19569.d(60): `bug19569.test1()` fail_compilation/bug19569.d(72): Error: `bug19569.test2` called with argument types `()` matches multiple overloads exactly: fail_compilation/bug19569.d(62): `bug19569.test2!().test2()` and: fail_compilation/bug19569.d(63): `bug19569.test2!().test2()` fail_compilation/bug19569.d(73): Error: `bug19569.test3` called with argument types `()` matches multiple overloads exactly: fail_compilation/bug19569.d(65): `bug19569.test3!().test3()` and: fail_compilation/bug19569.d(66): `bug19569.test3!().test3()` fail_compilation/bug19569.d(78): Error: `bug19569.test0` called with argument types `()` matches multiple overloads exactly: fail_compilation/bug19569.d(56): `bug19569.test0()` and: fail_compilation/bug19569.d(57): `bug19569.test0()` fail_compilation/bug19569.d(79): Error: `bug19569.test1` called with argument types `()` matches multiple overloads exactly: fail_compilation/bug19569.d(59): `bug19569.test1()` and: fail_compilation/bug19569.d(60): `bug19569.test1()` fail_compilation/bug19569.d(80): Error: `bug19569.test2` called with argument types `()` matches multiple overloads exactly: fail_compilation/bug19569.d(62): `bug19569.test2!().test2()` and: fail_compilation/bug19569.d(63): `bug19569.test2!().test2()` fail_compilation/bug19569.d(81): Error: `bug19569.test3` called with argument types `()` matches multiple overloads exactly: fail_compilation/bug19569.d(65): `bug19569.test3!().test3()` and: fail_compilation/bug19569.d(66): `bug19569.test3!().test3()` fail_compilation/bug19569.d(86): Error: `bug19569.test0` called with argument types `()` matches multiple overloads exactly: fail_compilation/bug19569.d(56): `bug19569.test0()` and: fail_compilation/bug19569.d(57): `bug19569.test0()` fail_compilation/bug19569.d(87): Error: `bug19569.test1` called with argument types `()` matches multiple overloads exactly: fail_compilation/bug19569.d(59): `bug19569.test1()` and: fail_compilation/bug19569.d(60): `bug19569.test1()` fail_compilation/bug19569.d(88): Error: `bug19569.test2` called with argument types `()` matches multiple overloads exactly: fail_compilation/bug19569.d(62): `bug19569.test2!().test2()` and: fail_compilation/bug19569.d(63): `bug19569.test2!().test2()` fail_compilation/bug19569.d(89): Error: `bug19569.test3` called with argument types `()` matches multiple overloads exactly: fail_compilation/bug19569.d(65): `bug19569.test3!().test3()` and: fail_compilation/bug19569.d(66): `bug19569.test3!().test3()` --- */ void test0(); void test0() nothrow; void test1(); void test1() @nogc; void test2()(); void test2()() nothrow; void test3()(); void test3()() @nogc; void attr0() { test0(); test1(); test2(); test3(); } void attr1() @nogc { test0(); test1(); test2(); test3(); } void attr3() nothrow @nogc { test0(); test1(); test2(); test3(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice18803a.d0000644000175000017500000000041415205374123021076 0ustar fabiofabio/* EXTRA_FILES: ice18803b.d TEST_OUTPUT: --- fail_compilation/ice18803b.d(9): Error: (expression) expected following `static if` fail_compilation/ice18803b.d(9): Error: declaration expected following attribute, not end of file --- */ void main() { import ice18803b; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/retref2.d0000644000175000017500000000102215205374123021136 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/retref2.d(18): Error: function `ref int retref2.D.foo(return ref int)` does not override any function, did you mean to override `ref int retref2.C.foo(ref int)`? fail_compilation/retref2.d(19): Error: function `ref int retref2.D.bar() scope return` does not override any function, did you mean to override `ref int retref2.C.bar()`? --- */ class C { ref int foo(ref int); ref int bar(); } class D : C { override ref int foo(return ref int); override ref int bar() return; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/mangle1.d0000644000175000017500000000025415205374123021117 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/mangle1.d(8): Error: `pragma(mangle)` can only apply to a single declaration --- */ pragma(mangle, "_stuff_") __gshared { int x, y; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag16977.d0000644000175000017500000000251215205374123021114 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag16977.d(25): Error: undefined identifier `undefined`, did you mean function `undefinedId`? fail_compilation/diag16977.d(26): Error: cannot implicitly convert expression `"\x01string"` of type `string` to `int` fail_compilation/diag16977.d(27): Error: template `templ` is not callable using argument types `!()(int)` fail_compilation/diag16977.d(20): Candidate is: `templ(S)(S s)` with `S = int` must satisfy the following constraint: ` false` fail_compilation/diag16977.d(28): Error: cannot implicitly convert expression `5` of type `int` to `string` fail_compilation/diag16977.d(30): Error: template instance `diag16977.test.funcTemplate!string` error instantiating --- */ // when copying the expression of a default argument, location information is // replaced by the location of the caller to improve debug information // verify error messages are displayed for the original location only string templ(S)(S s) if(false) { return null; } void test() { // local functions to defer evaluation into semantic3 pass void undefinedId(int x, int y = undefined) {} void badOp(int x, int y = 1 ~ "string") {} void lazyTemplate(int x, lazy int y = 4.templ) {} void funcTemplate(T)(T y = 5) {} funcTemplate!string(); undefinedId(1); badOp(2); lazyTemplate(3); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail279.d0000644000175000017500000001504315205374123020752 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail279.d(14): Error: mixin `fail279.Template!0.Template!1.Template!2.Template!3.Template!4.Template!5.Template!6.Template!7.Template!8.Template!9.Template!10.Template!11.Template!12.Template!13.Template!14.Template!15.Template!16.Template!17.Template!18.Template!19.Template!20.Template!21.Template!22.Template!23.Template!24.Template!25.Template!26.Template!27.Template!28.Template!29.Template!30.Template!31.Template!32.Template!33.Template!34.Template!35.Template!36.Template!37.Template!38.Template!39.Template!40.Template!41.Template!42.Template!43.Template!44.Template!45.Template!46.Template!47.Template!48.Template!49.Template!50.Template!51.Template!52.Template!53.Template!54.Template!55.Template!56.Template!57.Template!58.Template!59.Template!60.Template!61.Template!62.Template!63.Template!64.Template!65.Template!66.Template!67.Template!68.Template!69.Template!70.Template!71.Template!72.Template!73.Template!74.Template!75.Template!76.Template!77.Template!78.Template!79.Template!80.Template!81.Template!82.Template!83.Template!84.Template!85.Template!86.Template!87.Template!88.Template!89.Template!90.Template!91.Template!92.Template!93.Template!94.Template!95.Template!96.Template!97.Template!98.Template!99.Template!100.Template!101.Template!102.Template!103.Template!104.Template!105.Template!106.Template!107.Template!108.Template!109.Template!110.Template!111.Template!112.Template!113.Template!114.Template!115.Template!116.Template!117.Template!118.Template!119.Template!120.Template!121.Template!122.Template!123.Template!124.Template!125.Template!126.Template!127.Template!128.Template!129.Template!130.Template!131.Template!132.Template!133.Template!134.Template!135.Template!136.Template!137.Template!138.Template!139.Template!140.Template!141.Template!142.Template!143.Template!144.Template!145.Template!146.Template!147.Template!148.Template!149.Template!150.Template!151.Template!152.Template!153.Template!154.Template!155.Template!156.Template!157.Template!158.Template!159.Template!160.Template!161.Template!162.Template!163.Template!164.Template!165.Template!166.Template!167.Template!168.Template!169.Template!170.Template!171.Template!172.Template!173.Template!174.Template!175.Template!176.Template!177.Template!178.Template!179.Template!180.Template!181.Template!182.Template!183.Template!184.Template!185.Template!186.Template!187.Template!188.Template!189.Template!190.Template!191.Template!192.Template!193.Template!194.Template!195.Template!196.Template!197.Template!198.Template!199.Template!200.Template!201.Template!202.Template!203.Template!204.Template!205.Template!206.Template!207.Template!208.Template!209.Template!210.Template!211.Template!212.Template!213.Template!214.Template!215.Template!216.Template!217.Template!218.Template!219.Template!220.Template!221.Template!222.Template!223.Template!224.Template!225.Template!226.Template!227.Template!228.Template!229.Template!230.Template!231.Template!232.Template!233.Template!234.Template!235.Template!236.Template!237.Template!238.Template!239.Template!240.Template!241.Template!242.Template!243.Template!244.Template!245.Template!246.Template!247.Template!248.Template!249.Template!250.Template!251.Template!252.Template!253.Template!254.Template!255.Template!256.Template!257.Template!258.Template!259.Template!260.Template!261.Template!262.Template!263.Template!264.Template!265.Template!266.Template!267.Template!268.Template!269.Template!270.Template!271.Template!272.Template!273.Template!274.Template!275.Template!276.Template!277.Template!278.Template!279.Template!280.Template!281.Template!282.Template!283.Template!284.Template!285.Template!286.Template!287.Template!288.Template!289.Template!290.Template!291.Template!292.Template!293.Template!294.Template!295.Template!296.Template!297.Template!298.Template!299.Template!300.Template!301.Template!302.Template!303.Template!304.Template!305.Template!306.Template!307.Template!308.Template!309.Template!310.Template!311.Template!312.Template!313.Template!314.Template!315.Template!316.Template!317.Template!318.Template!319.Template!320.Template!321.Template!322.Template!323.Template!324.Template!325.Template!326.Template!327.Template!328.Template!329.Template!330.Template!331.Template!332.Template!333.Template!334.Template!335.Template!336.Template!337.Template!338.Template!339.Template!340.Template!341.Template!342.Template!343.Template!344.Template!345.Template!346.Template!347.Template!348.Template!349.Template!350.Template!351.Template!352.Template!353.Template!354.Template!355.Template!356.Template!357.Template!358.Template!359.Template!360.Template!361.Template!362.Template!363.Template!364.Template!365.Template!366.Template!367.Template!368.Template!369.Template!370.Template!371.Template!372.Template!373.Template!374.Template!375.Template!376.Template!377.Template!378.Template!379.Template!380.Template!381.Template!382.Template!383.Template!384.Template!385.Template!386.Template!387.Template!388.Template!389.Template!390.Template!391.Template!392.Template!393.Template!394.Template!395.Template!396.Template!397.Template!398.Template!399.Template!400.Template!401.Template!402.Template!403.Template!404.Template!405.Template!406.Template!407.Template!408.Template!409.Template!410.Template!411.Template!412.Template!413.Template!414.Template!415.Template!416.Template!417.Template!418.Template!419.Template!420.Template!421.Template!422.Template!423.Template!424.Template!425.Template!426.Template!427.Template!428.Template!429.Template!430.Template!431.Template!432.Template!433.Template!434.Template!435.Template!436.Template!437.Template!438.Template!439.Template!440.Template!441.Template!442.Template!443.Template!444.Template!445.Template!446.Template!447.Template!448.Template!449.Template!450.Template!451.Template!452.Template!453.Template!454.Template!455.Template!456.Template!457.Template!458.Template!459.Template!460.Template!461.Template!462.Template!463.Template!464.Template!465.Template!466.Template!467.Template!468.Template!469.Template!470.Template!471.Template!472.Template!473.Template!474.Template!475.Template!476.Template!477.Template!478.Template!479.Template!480.Template!481.Template!482.Template!483.Template!484.Template!485.Template!486.Template!487.Template!488.Template!489.Template!490.Template!491.Template!492.Template!493.Template!494.Template!495.Template!496.Template!497.Template!498.Template!499.Template!500` recursive expansion --- */ // https://issues.dlang.org/show_bug.cgi?id=2920 // recursive templates blow compiler stack // template_16 template Template(int i) { mixin Template!(i + 1); } mixin Template!(0); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14304.d0000644000175000017500000000413715205374123021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail14304.d(26): Error: reinterpreting cast from `const(S14304)*` to `S14304*` is not supported in CTFE fail_compilation/fail14304.d(58): called from here: `sle14304.modify()` fail_compilation/fail14304.d(35): Error: cannot modify read-only constant `[1:1, 2:2]` fail_compilation/fail14304.d(61): called from here: `modify14304(aae14304)` fail_compilation/fail14304.d(41): Error: cannot modify read-only constant `[1, 2, 3]` fail_compilation/fail14304.d(64): called from here: `modify14304(cast(const(int)[])index14304)` fail_compilation/fail14304.d(46): Error: array cast from `immutable(double[])` to `double[]` is not supported at compile time fail_compilation/fail14304.d(67): called from here: `modify14304(cast(const(double)[])slice14304)` fail_compilation/fail14304.d(53): Error: cannot modify read-only string literal `"abc"` fail_compilation/fail14304.d(70): called from here: `modify14304(cast(const(char)[])str14304)` --- */ struct S14304 { int x; int modify() const { assert(x == 1); // This force modification must not affect to ghe s14304 value. (cast(S14304*)&this).x = 10; assert(x == 10); return x; } } int modify14304(immutable int[int] aa) { auto p = cast(int*)&aa[1]; *p = 10; return aa[1]; } int modify14304(const(int)[] arr) { auto a = cast(int[])arr; a[0] = 10; return arr[0]; } int modify14304(const(double)[] arr) { auto a = cast(double[])arr; a[] = 3.14; return cast(int)arr[0]; } int modify14304(const(char)[] str) { auto s = cast(char[])str; s[0] = 'z'; return str[0]; } static immutable sle14304 = immutable S14304(1); static immutable v14304 = sle14304.modify(); static immutable aae14304 = [1:1, 2:2]; static immutable w14304 = modify14304(aae14304); static immutable index14304 = [1, 2, 3]; static immutable x14304 = modify14304(index14304); static immutable slice14304 = [1.414, 1.732, 2]; static immutable y14304 = modify14304(slice14304); static immutable str14304 = "abc"; static immutable z14304 = modify14304(str14304); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11726.d0000644000175000017500000000032415205374123020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11726.d(16): Error: undefined identifier `x` --- */ struct S { auto opDispatch(string fn, Args...)(Args args) { } } void main() { S().reserve(x.foo()); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20771.d0000644000175000017500000000064715205374123021115 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail20771.d(19): Error: cannot pass types with postblits or copy constructors as variadic arguments fail_compilation/fail20771.d(20): Error: cannot pass types with postblits or copy constructors as variadic arguments --- */ extern void variadic(...); struct S20771 { int field; this(this) { } } void test() { auto v = S20771(0); variadic(v, S20771(1)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test19112.d0000644000175000017500000000062515205374123021152 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test19112.d(13): Error: cannot implicitly convert expression `[123, 456]` of type `int[]` to `int[1]` fail_compilation/test19112.d(15): Error: cannot implicitly convert expression `a` of type `int[]` to `int[1]` --- */ // https://issues.dlang.org/show_bug.cgi?id=19112 void main() { int[int[1]] aa; int* p = [123, 456] in aa; int[] a; p = a in aa; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23439.d0000644000175000017500000000060415205374123021112 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23439 // PERMUTE_ARGS: -lowmem /* TEST_OUTPUT: --- fail_compilation/fail23439.d(14): Error: variable `fail23439.ice23439` is a thread-local class and cannot have a static initializer fail_compilation/fail23439.d(14): use `static this()` to initialize instead --- */ class C23439 { noreturn f23439; } static ice23439 = new C23439(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12574.d0000644000175000017500000000210015205374123020726 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12574.d(40): Error: sequence index `2` out of bounds `[0 .. 2]` fail_compilation/ice12574.d(53): Error: template instance `ice12574.reduce!("a", "a").reduce!(Tuple!(int, int, int))` error instantiating --- */ struct Tuple(T...) { alias Types = T; T field; alias field this; } Tuple!A tuple(A...)(A args) { return typeof(return)(args); } template binaryFun(alias fun) { static if (is(typeof(fun) : string)) { auto binaryFun(ElementType1, ElementType2)(auto ref ElementType1 __a, auto ref ElementType2 __b) { mixin("alias "~"a"~" = __a ;"); mixin("alias "~"b"~" = __b ;"); return mixin(fun); } } else { alias binaryFun = fun; } } template reduce(fun...) { auto reduce(Seed)(Seed result) { foreach (i, Unused; Seed.Types) { result[i] = binaryFun!(fun[i])(1, 1); // here } return result; } } int foo(int value) { return value; } void main() { reduce!("a", "a")(tuple(1, 1, 1)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag18574.d0000644000175000017500000000120315205374123021103 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag18574.d(16): Error: `diag18574.Test`: multiple class inheritance is not supported. Use multiple interface inheritance and/or composition. fail_compilation/diag18574.d(16): `diag18574.Bar` has no fields, consider making it an `interface` fail_compilation/diag18574.d(16): `diag18574.Baz` has fields, consider making it a member of `diag18574.Test` fail_compilation/diag18574.d(16): Error: `diag18574.Test`: base type must be `interface`, not `int` --- */ // https://issues.dlang.org/show_bug.cgi?id=18574 class Foo {} class Bar {} class Baz { int a; } class Test : Foo, Bar, Baz, int {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail359.d0000644000175000017500000000020615205374123020744 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail359.d(7): Error: invalid filename for `#line` directive --- */ #line 5 _BOOM void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail155.d0000644000175000017500000000066015205374123020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail155.d(20): Error: overlapping initialization for field `x` and `y` fail_compilation/fail155.d(20): `struct` initializers that contain anonymous unions must initialize only the first member of a `union`. All subsequent non-overlapping fields are default initialized --- */ struct S { int i; union { int x; int y; } int j; } S s = S( 1, 2, 3, 4 ); ./ldc-1.42.0-src/tests/dmd/fail_compilation/depmsg15814.d0000644000175000017500000000035215205374123021454 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/depmsg15814.d(9): Deprecation: function `depmsg15814.get15814` is deprecated - bug15814 --- */ deprecated("bug15814") int get15814() { return 0; } enum val15814 = get15814(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15704.d0000644000175000017500000000157615205374123021163 0ustar fabiofabio/* * TEST_OUTPUT: --- fail_compilation/test15704.d(19): Error: copying `void[]` to `void[]` is not allowed in a `@safe` function fail_compilation/test15704.d(20): Error: copying `const(void)[]` to `void[]` is not allowed in a `@safe` function fail_compilation/test15704.d(21): Deprecation: copying `int[]` to `void[]` will become `@system` in a future release fail_compilation/test15704.d(22): Error: cannot implicitly convert expression `cast(byte)0` of type `byte` to `void[]` fail_compilation/test15704.d(22): Error: cannot copy `byte` to `void[]` --- */ // https://issues.dlang.org/show_bug.cgi?id=15704 void main() @safe { Object[] objs = [ new Object() ]; void[] arr1 = objs; void[] arr2 = [ 123, 345, 567 ]; arr1[] = arr2[]; // overwrites pointers with arbitrary ints arr1[] = new const(void)[3]; arr1[] = [5]; arr1[] = byte(); // filling not allowed } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test14238.d0000644000175000017500000000143415205374123021155 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test14238.d(22): Error: scope parameter `fn` may not be returned fail_compilation/test14238.d(25): Error: function `test14238.bar` is `@nogc` yet allocates closure for `bar()` with the GC fail_compilation/test14238.d(27): function `baz` closes over variable `x` fail_compilation/test14238.d(26): `x` declared here --- */ // https://issues.dlang.org/show_bug.cgi?id=14238 @safe: alias Fn = ref int delegate() return @nogc; ref int call(return scope Fn fn) @nogc { return fn(); // Ok } ref int foo2(scope Fn fn) { return fn(); // Error } ref int bar() @nogc { int x; ref int baz() { return x; } if (x == 0) return call(&baz); else return (&baz)(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice15317.d0000644000175000017500000000025215205374123020732 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/ice15317.d(11): Error: undefined identifier `fun` --- */ void main() { alias f = fun; auto x1 = &f; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag_in_array.d0000644000175000017500000000127715205374123022371 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/diag_in_array.d(17): Error: incompatible types for `(3) in (a)`: `int` and `int[4]` fail_compilation/diag_in_array.d(17): `in` is only allowed on associative arrays fail_compilation/diag_in_array.d(17): perhaps use `std.algorithm.find(3, a[])` instead fail_compilation/diag_in_array.d(19): Error: incompatible types for `("s") in (b)`: `string` and `string[]` fail_compilation/diag_in_array.d(19): `in` is only allowed on associative arrays fail_compilation/diag_in_array.d(19): perhaps use `std.algorithm.find("s", b)` instead --- */ void main() { int[4] a; string[] b; if (3 in a) return; auto c = "s" in b; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bug5096.d0000644000175000017500000000027115205374123020673 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/bug5096.d(13): Error: unmatched closing brace --- */ void foo(int x) in { assert(x > 0); } do { x++; } } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8684.d0000644000175000017500000000056015205374123021031 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8684.d(12): Error: found `;` when expecting `)` fail_compilation/diag8684.d(13): Error: semicolon needed to end declaration of `x`, instead of `for` fail_compilation/diag8684.d(12): `x` declared here --- */ int foo(int n, int m) { int x = foo( 5, m; for (int q=0; q<10; ++q){ ++q; } return 2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21928.d0000644000175000017500000000040015205374123021105 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail21928.d(18): Error: this array literal causes a GC allocation in `@nogc` function `main` --- */ @nogc: struct Shape { immutable size_t[] dims = []; } void main() { auto s = Shape(2 ~ Shape.init.dims); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failcstuff5.c0000644000175000017500000000131615205374123022005 0ustar fabiofabio// check semantic analysis of C files /* TEST_OUTPUT: --- fail_compilation/failcstuff5.c(404): Error: undefined identifier `p1` fail_compilation/failcstuff5.c(404): Error: undefined identifier `p2` fail_compilation/failcstuff5.c(458): Error: cannot take address of bitfield `s.field` --- */ /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22584 #line 400 long test22584(long p1, long p2); long test22584(long, long) { return p1 + p2; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22749 #line 450 struct S22749 { int field : 1; }; void test22749(void) { struct S22749 s; void *ptr = &s.field; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17570.d0000644000175000017500000000067015205374123021114 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17570.d(12): Error: cannot use function constraints for non-template functions. Use `static if` instead fail_compilation/fail17570.d(13): Error: declaration expected, not `{` fail_compilation/fail17570.d(15): Error: `}` expected following members in `struct` declaration fail_compilation/fail17570.d(11): struct `S` starts here --- */ struct S(T) { void func() if(isIntegral!T) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/safe_pointer_index.d0000644000175000017500000000033415205374123023437 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/safe_pointer_index.d(11): Error: indexing pointer `x` is not allowed in a `@safe` function --- */ @safe void f(int* x) { int y = x[0]; // allowed, same as *x int z = x[1]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix22104.c0000644000175000017500000000063715205374123020756 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix22104.c(103): Error: variable `fix22104.test1.array1` - incomplete array type must have initializer fail_compilation/fix22104.c(108): Error: variable `fix22104.test2.array2` - incomplete array type must have initializer --- */ // https://issues.dlang.org/show_bug.cgi?id=22104 #line 100 void test1() { static int array1[][4]; } void test2() { int array2[][4]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail282.d0000644000175000017500000000060515205374123020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail282.d(13): Error: template instance `fail282.Template!500` recursive expansion exceeded allowed nesting limit --- */ // https://issues.dlang.org/show_bug.cgi?id=2920 // recursive templates blow compiler stack // template_class_09. template Template(int i) { class Class : Template!(i + 1).Class { } } alias Template!(0).Class Class0; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18644.d0000644000175000017500000000133215205374123021157 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test18644.d(15): Error: escaping a `scope` value returned from nested function `foo` into allocated memory is not allowed in a `@safe` function fail_compilation/test18644.d(16): Error: escaping local variable through nested function `foo` is not allowed in a `@safe` function fail_compilation/test18644.d(22): Error: escaping local variable through nested function `foo` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=18644 @safe int* test1() { int i; int* foo() { return &i; } int*[] b = [foo()]; return foo(); } @safe ref int test2() { int i; ref int foo() { return i; } return foo(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18093.d0000644000175000017500000000177315205374123021122 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail18093.d(19): Error: function `void fail18093.GenericTransitiveVisitor!(ASTCodegen).GenericTransitiveVisitor.ParseVisitMethods!(ASTCodegen).visit()` does not override any function, did you mean to override `extern (C++) void fail18093.ParseTimeVisitor!(ASTCodegen).ParseTimeVisitor.visit()`? fail_compilation/fail18093.d(24): Error: mixin `fail18093.GenericTransitiveVisitor!(ASTCodegen).GenericTransitiveVisitor.ParseVisitMethods!(ASTCodegen)` error instantiating fail_compilation/fail18093.d(27): Error: template instance `fail18093.GenericTransitiveVisitor!(ASTCodegen)` error instantiating --- * https://issues.dlang.org/show_bug.cgi?id=18093 */ struct ASTCodegen {} extern (C++) class ParseTimeVisitor(AST) { void visit() {} } template ParseVisitMethods(AST) { override void visit() {} } class GenericTransitiveVisitor(AST) : ParseTimeVisitor!AST { mixin ParseVisitMethods!AST; } alias SemanticTimeTransitiveVisitor = GenericTransitiveVisitor!ASTCodegen; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail123.d0000644000175000017500000000051715205374123020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail123.d(11): Error: undefined identifier `type` fail_compilation/fail123.d(17): Error: enum `fail123.foo2` base type must not be `void` --- */ // https://issues.dlang.org/show_bug.cgi?id=355 // ICE from enum : nonexistent type enum foo : type { blah1, blah2 } enum foo2 : void { a, b } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19038.d0000644000175000017500000000176315205374123021121 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19038.d(21): Error: cannot implicitly convert expression `a` of type `string[][]` to `const(string)[][]` fail_compilation/fail19038.d(23): Error: cannot modify `const` expression `c[0]` --- * Credit: yshui * https://github.com/dlang/dmd/pull/8413#issuecomment-401104961 * https://issues.dlang.org/show_bug.cgi?id=19038 */ void test() { /* string[][] is not implicitly converible to const(string)[][], * and there is good reason why: * * https://stackoverflow.com/questions/5055655/double-pointer-const-correctness-warnings-in-c */ string[][] a = [["Lord"]]; const(string)[][] b = a; // assume this works (and it should not) const(string)[] c = ["Sauron"]; c[0] = "Mordor"; // invalid, because c[0] is const(string) b[0] = c; // valid, b[0] is const(string)[] // But now, a[0] has become c a[0][0] = "Nazgul"; // valid, because a[0][0] is string // But this also changes c[0], which shouldn't be possible } ./ldc-1.42.0-src/tests/dmd/fail_compilation/cdeprecated.i0000644000175000017500000000140015205374123022035 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/cdeprecated.i(18): Deprecation: function `cdeprecated.mars` is deprecated fail_compilation/cdeprecated.i(19): Deprecation: function `cdeprecated.jupiter` is deprecated - jumping jupiter fail_compilation/cdeprecated.i(20): Deprecation: function `cdeprecated.saturn` is deprecated fail_compilation/cdeprecated.i(21): Deprecation: function `cdeprecated.neptune` is deprecated - spinning neptune --- */ __declspec(deprecated) int mars(); __declspec(deprecated("jumping jupiter")) int jupiter(); __attribute__((deprecated)) extern int saturn(); __attribute__((deprecated("spinning neptune"))) extern int neptune(); int test() { return mars() + jupiter() + saturn() + neptune(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail16600.d0000644000175000017500000000104215205374123021077 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail16600.d(22): Error: `fail16600.S.__ctor` called with argument types `(string) const` matches multiple overloads exactly: fail_compilation/fail16600.d(16): `fail16600.S.this(string __param_0)` and: fail_compilation/fail16600.d(17): `fail16600.S.this(string __param_0) immutable` --- */ // https://issues.dlang.org/show_bug.cgi?id=16600 struct S { int i; this(string) { i = 1; } this(string) immutable { i = 2; } } void main() { auto a = const(S)("abc"); assert(a.i == 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9880.d0000644000175000017500000000047515205374123021035 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9880.d(12): Error: template instance `diag9880.foo!string` does not match template declaration `foo(T)(int)` with `T = string` must satisfy the following constraint: ` is(T == int)` --- */ void foo(T)(int) if (is(T == int)) {} void main() { alias f = foo!string; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail37_m32.d0000644000175000017500000000042515205374123021341 0ustar fabiofabio// REQUIRED_ARGS: -m32 /* TEST_OUTPUT: --- fail_compilation/fail37_m32.d(9): Error: `cast(float)4u / cast(float)8u - cast(float)2147483647` is not of integral type, it is a `float` --- */ ulong[cast(uint)((cast(float)int.sizeof/ulong.sizeof)-int.max>>2)+int.max>>2] hexarray; ./ldc-1.42.0-src/tests/dmd/fail_compilation/debugCaseDeclaration.d0000644000175000017500000000121015205374123023614 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=21739 REQUIRED_ARGS: -debug TEST_OUTPUT: --- fail_compilation/debugCaseDeclaration.d(22): Error: undefined identifier `x` fail_compilation/debugCaseDeclaration.d(33): Error: undefined identifier `y` --- */ void main() { int i, k; switch (i) { case 0: int x; break; case 1: x = 1; break; case 2: int y; break; debug { case 3: k = 1; // Valid y = 1; // Invalid but accepted break; } default: } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9254c.d0000644000175000017500000000150215205374123021017 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9254c.d(15): Error: using the result of a comma expression is not allowed fail_compilation/ice9254c.d(15): Error: using the result of a comma expression is not allowed fail_compilation/ice9254c.d(15): Error: using the result of a comma expression is not allowed fail_compilation/ice9254c.d(15): Error: using the result of a comma expression is not allowed fail_compilation/ice9254c.d(15): Error: using the result of a comma expression is not allowed fail_compilation/ice9254c.d(15): Error: invalid `foreach` aggregate `false` of type `bool` --- */ void main() { foreach(divisor; !(2, 3, 4, 8, 7, 9)) { assert(0); // ice in ForeachRangeStatement::comeFrom() foreach (v; 0..uint.max) {} // ice in WhileStatement::comeFrom() while (1) {} } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bug9631.d0000644000175000017500000000562415205374123020701 0ustar fabiofabio/* 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: no operator `==` for type `S` fail_compilation/bug9631.d(30): perhaps overload it with `bool opEquals(S other) const {}` --- */ 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(55): Error: cannot cast expression `x` of type `bug9631.S` to `bug9631.tem!().S` because of different sizes fail_compilation/bug9631.d(58): Error: cannot cast expression `ta` of type `bug9631.tem!().S[1]` to `bug9631.S[1]` because of different sizes fail_compilation/bug9631.d(59): Error: cannot cast expression `sa` of type `S[1]` to `S[]` since sizes don't line up --- */ void test3() { S x; auto y = cast(tem!().S)x; tem!().S[1] ta; S[1] sa = cast(S[1])ta; auto t2 = cast(tem!().S[])sa; } /* TEST_OUTPUT: --- fail_compilation/bug9631.d(80): Error: function `f` is not callable using argument types `(int, S)` fail_compilation/bug9631.d(80): cannot pass argument `y` of type `bug9631.tem!().S` to parameter `bug9631.S s` fail_compilation/bug9631.d(79): `bug9631.arg.f(int i, S s)` declared here fail_compilation/bug9631.d(81): Error: function literal `(S s) { }` is not callable using argument types `(S)` fail_compilation/bug9631.d(81): cannot pass argument `x` of type `bug9631.S` to parameter `bug9631.tem!().S s` fail_compilation/bug9631.d(87): Error: constructor `bug9631.arg.A.this(S __param_0)` is not callable using argument types `(S)` fail_compilation/bug9631.d(87): cannot pass argument `S(0)` of type `bug9631.tem!().S` to parameter `bug9631.S __param_0` --- */ 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(108): Error: function `ft` is not callable using argument types `(S)` fail_compilation/bug9631.d(108): cannot pass argument `x` of type `bug9631.S` to parameter `bug9631.tem!().S __param_0` fail_compilation/bug9631.d(107): `bug9631.targ.ft!().ft(S __param_0)` declared here fail_compilation/bug9631.d(109): Error: template `ft` is not callable using argument types `!()(S)` fail_compilation/bug9631.d(107): Candidate is: `ft()(tem!().S)` fail_compilation/bug9631.d(111): Error: template `ft2` is not callable using argument types `!()(S, int)` fail_compilation/bug9631.d(110): Candidate is: `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); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11038.d0000644000175000017500000000042515205374123021103 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=11038 /* TEST_OUTPUT: --- fail_compilation/fail11038.d(16): Error: `printf` is not defined, perhaps `import core.stdc.stdio;` is needed? --- */ static { import core.stdc.stdio; } void main() { printf("foo"); // compiles } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test13667.d0000644000175000017500000000437615205374123021172 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test13667.d(112): Error: cannot cast expression `this` of type `const(Array1!int)` to `Array1!int*` fail_compilation/test13667.d(116): Error: template instance `test13667.Array1!int` error instantiating fail_compilation/test13667.d(121): Error: cannot cast expression `this` of type `const(Array2!int)` to `B*` fail_compilation/test13667.d(125): Error: template instance `test13667.Array2!int` error instantiating fail_compilation/test13667.d(136): Error: cannot cast expression `this` of type `const(Array3!int)` to `C*` fail_compilation/test13667.d(140): Error: template instance `test13667.Array3!int` error instantiating fail_compilation/test13667.d(151): Error: cannot cast expression `this` of type `const(Array4!int)` to `D*` fail_compilation/test13667.d(155): Error: template instance `test13667.Array4!int` error instantiating fail_compilation/test13667.d(172): Error: cannot cast expression `this` of type `const(Array5!int)` to `F*` fail_compilation/test13667.d(176): Error: template instance `test13667.Array5!int` error instantiating --- */ // https://issues.dlang.org/show_bug.cgi?id=13667 #line 100 // 0, no error but also crashed before struct Array0(T) { Array0!(T) impConv() const { return cast(typeof(return))this; } alias impConv this; } alias AI0 = Array0!int; // 1 struct Array1(T) { Array1!(T) impConv() const { return *cast(typeof(return)*)this; } alias impConv this; } alias AI1 = Array1!int; // 2 struct Array2(T) { B impConv() const { return cast(B*)this; } alias impConv this; } alias AI2 = Array2!int; struct B { AI2 get() { return AI2(); } alias get this; } // 3 struct Array3(T) { C impConv() const { return cast(C*)this; } alias impConv this; } alias AI3 = Array3!int; struct C { C get() { return C(); } alias get this; } // 4 struct Array4(T) { D impConv() const { return cast(D*)this; } alias impConv this; } alias AI4 = Array4!int; struct D { E get() { return E(); } alias get this; } struct E { AI4 ai; alias ai this; } // 5: test enum based on struct, needed to use base type (toBasetype()) struct Array5(T) { F impConv() const { return cast(F*)this; } alias impConv this; } alias AI5 = Array5!int; enum F : AI5 { f = AI5() } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10805.d0000644000175000017500000000107415205374123021076 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10805.d(12): Error: delimited string must end in `FOO"` fail_compilation/diag10805.d(14): Error: unterminated string constant starting at fail_compilation/diag10805.d(14) fail_compilation/diag10805.d(14): Error: implicit string concatenation is error-prone and disallowed in D fail_compilation/diag10805.d(14): Use the explicit syntax instead (concatenating literals is `@nogc`): "" ~ "" fail_compilation/diag10805.d(15): Error: semicolon expected following auto declaration, not `End of File` --- */ enum s = q"FOO FOO "; ./ldc-1.42.0-src/tests/dmd/fail_compilation/b19685.d0000644000175000017500000000041615205374123020431 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/b19685.d(6): Error: overlapping default initialization for field `b` and `a` --- */ struct S { union { struct { int a = 123; } struct { int b = 456; } } } void main() { S s; assert(s.b == 123); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22852.c0000644000175000017500000000120215205374123021102 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22852 /* TEST_OUTPUT: --- fail_compilation/fail22852.c(11): Error: `=`, `;` or `,` expected to end declaration instead of `"string"` fail_compilation/fail22852.c(12): Error: character '`' is not a valid token fail_compilation/fail22852.c(12): Error: character '`' is not a valid token fail_compilation/fail22852.c(13): Error: expression expected, not `x"ff ff"` fail_compilation/fail22852.c(14): Error: `=`, `;` or `,` expected to end declaration instead of `{` --- */ const char *rstring = r"string"; const char *wstring = `string`; const char *hstring = x"ffff"; const char *qstring = q{string}; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix17349.d0000644000175000017500000000120515205374123020766 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix17349.d(35): Error: cannot implicitly override base class method `fix17349.E.foo` with `fix17349.F.foo`; add `override` attribute --- */ // https://issues.dlang.org/show_bug.cgi?id=17349 struct S { } class C { void bar(); void foo(void* p); void abc(Object); void def(S); } class D : C { override void bar() const; override void foo(const void*); override void abc(const Object); override void def(const S); } alias fp_t = void function(int*); @safe void abc(const int*); fp_t fp = &abc; class E { void foo(void*); } class F : E { void foo(const void*); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13336a.d0000644000175000017500000000075715205374123021257 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail13336a.d(28): Error: cannot modify expression `choose(true)` because it is not an lvalue --- */ class Animal {} class Cat : Animal {} class Dog : Animal {} Animal animal; Cat cat; auto ref choose(bool f) { if (f) return cat; else return animal; } void main() { //pragma(msg, typeof(&choose)); static assert(is(typeof(&choose) == Animal function(bool) nothrow @nogc @safe)); // pass choose(true) = new Dog(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail8179b.d0000644000175000017500000000034015205374123021175 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/fail8179b.d(10): Error: cannot cast expression `[1, 2]` of type `int[]` to `int[2][1]` --- */ void foo(int[2][1]) {} void main() { foo(cast(int[2][1])[1, 2]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23037.c0000644000175000017500000000312215205374123021145 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23037.c(101): Error: type-specifier missing for declaration of `a` fail_compilation/test23037.c(102): Error: type-specifier omitted for declaration of `b` fail_compilation/test23037.c(103): Error: type-specifier is missing fail_compilation/test23037.c(104): Error: type-specifier is missing fail_compilation/test23037.c(105): Error: type-specifier is missing fail_compilation/test23037.c(106): Error: type-specifier is missing fail_compilation/test23037.c(201): Error: no type-specifier for parameter fail_compilation/test23037.c(202): Error: no type-specifier for struct member fail_compilation/test23037.c(203): Error: type-specifier omitted before declaration of `x` fail_compilation/test23037.c(204): Error: type-specifier omitted for parameter `x` fail_compilation/test23037.c(205): Error: type-specifier omitted before bit field declaration of `x` fail_compilation/test23037.c(206): Error: expected identifier for declarator fail_compilation/test23037.c(206): Error: expected identifier for declaration fail_compilation/test23037.c(207): Error: no type-specifier for declarator fail_compilation/test23037.c(207): Error: expected identifier for declarator fail_compilation/test23037.c(207): Error: expected identifier for declaration --- */ /* https://issues.dlang.org/show_bug.cgi?id=23037 */ #line 100 const a; const b = 1; int c = sizeof(const); int d = (const)0; int *e = (const*)0; enum E : const { ee=1, }; #line 200 void fn1(const); struct { const : 1; } s1; struct { const x; } s2; void fn2(const x) {} struct { const x : 1; } s3; const fn3(); const arr[1]; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ccast.d0000644000175000017500000000116215205374123020667 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ccast.d(12): Error: C style cast illegal, use `cast(byte)i` fail_compilation/ccast.d(25): Error: C style cast illegal, use `cast(foo)5` fail_compilation/ccast.d(27): Error: C style cast illegal, use `cast(void*)5` fail_compilation/ccast.d(30): Error: C style cast illegal, use `cast(void*)5` --- */ int i; byte b = (byte)i; void bar(int x); void main() { (&bar)(5); // ok auto foo = &bar; (foo = foo)(5); // ok (*foo)(5); // ok (foo)(5); // ok (bar)(5); // ok (foo)5; (void*)5; (void*)(5); // semantic implicit cast error (void*) 5; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6029.d0000644000175000017500000000050415205374123021025 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail6029.d(10): Error: alias this is not reachable as `A` already converts to `A` --- */ struct A { static A a; alias a this; } void foo(A a) { } void main() { // foo(A); // Error: type A is not an expression int s = A; // Error: type A has no value + stack overflow } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17586.d0000644000175000017500000000037315205374123021167 0ustar fabiofabio/* REQUIRED_ARGS: -o- -de TEST_OUTPUT: --- fail_compilation/test17586.d(13): Deprecation: `test17586.D.foo` is overriding the deprecated method `test17586.C.foo` --- */ class C{ deprecated void foo(){} } class D : C{ override void foo(){} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17927.d0000644000175000017500000000141615205374123021121 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 * TEST_OUTPUT: --- fail_compilation/fail17927.d(13): Error: scope parameter `this` may not be returned fail_compilation/fail17927.d(15): Error: scope parameter `this` may not be returned fail_compilation/fail17927.d(21): Error: scope parameter `ptr` may not be returned fail_compilation/fail17927.d(23): Error: scope parameter `ptr` may not be returned --- */ // https://issues.dlang.org/show_bug.cgi?id=17927 struct String { const(char)* mem1() const scope @safe { return ptr; } // https://issues.dlang.org/show_bug.cgi?id=22027 inout(char)* mem2() inout scope @safe { return ptr; } char* ptr; } const(char)* foo1(scope const(char)* ptr) @safe { return ptr; } inout(char)* foo2(scope inout(char)* ptr) @safe { return ptr; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7903.d0000644000175000017500000000112215205374123021024 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7903.d(21): Error: variable `fail7903.F1.x` Field members of a `synchronized` class cannot be `public` fail_compilation/fail7903.d(22): Error: variable `fail7903.F1.y` Field members of a `synchronized` class cannot be `export` fail_compilation/fail7903.d(27): Error: variable `fail7903.F2.x` Field members of a `synchronized` class cannot be `public` --- */ synchronized class K1 { public struct S { } } synchronized class K2 { struct S { } } synchronized class F1 { public int x; export int y; } synchronized class F2 { int x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15177.d0000644000175000017500000000131115205374123021152 0ustar fabiofabio// REQUIRED_ARGS: -o- // COMPILED_IMPORTS: imports/test15117a.d /* TEST_OUTPUT: --- fail_compilation/test15177.d-mixin-19(19): Error: `imports.test15117a.object` is not visible from module `test15177` fail_compilation/test15177.d(28): Error: template instance `test15177.RunApiTest!()` error instantiating --- */ import users = imports.test15117a; void RunApiTest(T...)() { foreach (name; __traits(allMembers, users)) { // 3. list the name of TyepInfoStructDeclaration, // but it's just internal symbol and invisible. mixin("alias func = users . " ~ name ~ ";"); } } void main() { // 1. run semantic3 of users.test_usr_1 users.test_usr_1(); RunApiTest!(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12841.d0000644000175000017500000000112415205374123020730 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12841.d(23): Error: cannot take address of expression `taskPool().amap(Args...)(Args args)` because it is not an lvalue fail_compilation/ice12841.d(24): Error: cannot take address of template `amap(Args...)(Args args)`, perhaps instantiate it first --- */ @property TaskPool taskPool() @trusted { return new TaskPool; } final class TaskPool { template amap(functions...) { auto amap(Args...)(Args args) { } } } void main() { auto dg = &(taskPool.amap!"a.result()"); auto fp = &(TaskPool.amap!"a.result()"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9414d.d0000644000175000017500000000606715205374123021204 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9414d.d(47): Error: variable `fail9414d.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414d.d(34): Error: variable `fail9414d.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414d.d(35): Error: variable `fail9414d.C.foo.bar.y` cannot modify parameter `y` in contract fail_compilation/fail9414d.d(40): Error: variable `fail9414d.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414d.d(41): Error: variable `fail9414d.C.foo.bar.y` cannot modify parameter `y` in contract fail_compilation/fail9414d.d(42): Error: variable `fail9414d.C.foo.bar.s` cannot modify result `s` in contract fail_compilation/fail9414d.d(52): Error: variable `fail9414d.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414d.d(75): Error: variable `fail9414d.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414d.d(76): Error: variable `fail9414d.C.foo.r` cannot modify result `r` in contract fail_compilation/fail9414d.d(60): Error: variable `fail9414d.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414d.d(61): Error: variable `fail9414d.C.foo.r` cannot modify result `r` in contract fail_compilation/fail9414d.d(62): Error: variable `fail9414d.C.foo.baz.y` cannot modify parameter `y` in contract fail_compilation/fail9414d.d(67): Error: variable `fail9414d.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414d.d(68): Error: variable `fail9414d.C.foo.r` cannot modify result `r` in contract fail_compilation/fail9414d.d(69): Error: variable `fail9414d.C.foo.baz.y` cannot modify parameter `y` in contract fail_compilation/fail9414d.d(70): Error: variable `fail9414d.C.foo.baz.s` cannot modify result `s` in contract fail_compilation/fail9414d.d(81): Error: variable `fail9414d.C.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9414d.d(82): Error: variable `fail9414d.C.foo.r` cannot modify result `r` in contract --- */ class C { static int foo(int x) in { int a; int bar(int y) in { x = 10; // err y = 10; // err a = 1; // OK } out(s) { x = 10; // err y = 10; // err s = 10; // err a = 1; // OK } do { x = 10; // err y = 1; // OK a = 1; // OK return 2; } x = 10; // err } out(r) { int a; int baz(int y) in { x = 10; // err r = 10; // err y = 10; // err a = 1; // OK } out(s) { x = 10; // err r = 10; // err y = 10; // err s = 10; // err a = 1; // OK } do { x = 10; // err r = 10; // err y = 1; // OK a = 1; // OK return 2; } x = 10; // err r = 10; // err } do { return 1; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail100.d0000644000175000017500000000125215205374123020726 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail100.d(24): Error: return value `f` of type `Class[]` does not match return type `I[]`, and cannot be implicitly converted --- */ // https://issues.dlang.org/show_bug.cgi?id=85 // Array of classes doesn't function as array of interfaces interface I { I[] foo(); uint x(); } class Class : I { I[] foo() { // changing this to I[] f = new Class[1] fixes the bug Class[] f = new Class[1]; //I[] f = new Class[1]; f[0] = new Class; return f; } uint x() { return 0; } } void main() { Class c = new Class(); assert(c.x == 0); assert(c.foo[0].x == 0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail183.d0000644000175000017500000000245415205374123020746 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail183.d(17): Error: attribute `const` is redundant with previously-applied `in` fail_compilation/fail183.d(18): Error: attribute `scope` cannot be applied with `in`, use `-preview=in` instead fail_compilation/fail183.d(19): Error: attribute `const` is redundant with previously-applied `in` fail_compilation/fail183.d(19): Error: attribute `scope` cannot be applied with `in`, use `-preview=in` instead fail_compilation/fail183.d(20): Error: attribute `scope` cannot be applied with `in`, use `-preview=in` instead fail_compilation/fail183.d(20): Error: attribute `const` is redundant with previously-applied `in` fail_compilation/fail183.d(22): Error: attribute `in` cannot be added after `const`: remove `const` fail_compilation/fail183.d(23): Error: attribute `in` cannot be added after `scope`: remove `scope` and use `-preview=in` fail_compilation/fail183.d(24): Error: attribute `in` cannot be added after `const`: remove `const` fail_compilation/fail183.d(25): Error: attribute `in` cannot be added after `const`: remove `const` --- */ void f1(in const int x) {} void f2(in scope int x) {} void f3(in const scope int x) {} void f4(in scope const int x) {} void f5(const in int x) {} void f6(scope in int x) {} void f7(const scope in int x) {} void f8(scope const in int x) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix20318.d0000644000175000017500000000230415205374123020755 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix20318.d(16): Error: cannot implicitly convert expression `c` of type `const(Bar)` to `Bar` because struct `Bar` contains pointers or references fail_compilation/fix20318.d(20): Error: cannot implicitly convert expression `complex_c` of type `const(ComplexBar)` to `ComplexBar` because struct `ComplexBar` contains pointers or references --- */ void main() { // This should work - struct without pointers const Foo a; Foo b = a; // This is okay // This should fail with improved diagnostic message const Bar c; Bar d = c; // Error with improved diagnostic message // Test with a more complex struct with nested pointers const ComplexBar complex_c; ComplexBar complex_d = complex_c; // Give improved error message } struct Foo { int value; } struct Bar { void* ptr; } // Simple struct without pointers struct Simple { int value; } // Struct with a pointer struct WithPointer { int* ptr; } // Complex struct that contains another struct with pointers struct ComplexBar { Simple simple; // This is fine int data; // This is fine WithPointer nested; // This field prevents implicit conversion } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21912.d0000644000175000017500000000327215205374123021154 0ustar fabiofabio/* PERMUTE_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test21912.d(28): Error: function `test21912.escapeParam` is `@nogc` yet allocates closure for `escapeParam()` with the GC fail_compilation/test21912.d(30): delegate `() => i` closes over variable `i` fail_compilation/test21912.d(28): `i` declared here fail_compilation/test21912.d(33): Error: function `test21912.escapeAssign` is `@nogc` yet allocates closure for `escapeAssign()` with the GC fail_compilation/test21912.d(35): delegate `() => i` closes over variable `i` fail_compilation/test21912.d(33): `i` declared here fail_compilation/test21912.d(44): Error: function `test21912.escapeAssignRef` is `@nogc` yet allocates closure for `escapeAssignRef()` with the GC fail_compilation/test21912.d(46): delegate `() => i` closes over variable `i` fail_compilation/test21912.d(44): `i` declared here fail_compilation/test21912.d(55): Error: function `test21912.escapeParamInferred` is `@nogc` yet allocates closure for `escapeParamInferred()` with the GC fail_compilation/test21912.d(57): delegate `() => i` closes over variable `i` fail_compilation/test21912.d(55): `i` declared here --- */ @nogc: alias Dg = @nogc int delegate(); Dg identity(return scope Dg dg) { return dg; } Dg escapeParam(int i) { return identity(() => i); } Dg escapeAssign(int i, return scope Dg dg) { dg = () => i; return dg; } ref Dg identityR(return ref scope Dg dg) { return dg; } ref Dg escapeAssignRef(int i, return ref scope Dg dg) { dg = () => i; return dg; } auto identityInferred(Dg dg) { return dg; } Dg escapeParamInferred(int i) { return identityInferred(() => i); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice22516.d0000644000175000017500000000036415205374123020735 0ustar fabiofabio/++ https://issues.dlang.org/show_bug.cgi?id=22516 TEST_OUTPUT: --- fail_compilation/ice22516.d(18): Error: undefined identifier `X` --- +/ struct Data { void function() eval; } struct Builtins { X x; Data myData = { (){} }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12850.d0000644000175000017500000000036315205374123020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12850.d(12): Error: cannot implicitly convert expression `0` of type `int` to `string` --- */ alias TypeTuple(TL...) = TL; void main() { int[string] arr; alias staticZip = TypeTuple!(arr[0]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail336.d0000644000175000017500000000065315205374123020745 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail336.d(17): Error: Cannot use struct initializer syntax for struct `S` because it has a constructor fail_compilation/fail336.d(17): Use `S( arguments )` instead of `{ initializers }` --- */ // https://issues.dlang.org/show_bug.cgi?id=3476 // C-style initializer for structs must be disallowed for structs with a constructor struct S { int a; this(int) {} } S s = { 1 }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/staticforeach3.d0000644000175000017500000000035115205374123022473 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/staticforeach3.d(7): Error: variable `staticforeach3.__anonymous.i` conflicts with variable `staticforeach3.__anonymous.i` at fail_compilation/staticforeach3.d(7) --- */ static foreach(i,i;[0]){} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test6883.d0000644000175000017500000000111015205374123021073 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test6883.d(15): Error: array index 5 is out of bounds `x[0 .. 5]` fail_compilation/test6883.d(17): Error: array index 7 is out of bounds `x[0 .. 5]` fail_compilation/test6883.d(21): Error: array index 5 is out of bounds `x[0 .. 5]` fail_compilation/test6883.d(23): Error: array index 7 is out of bounds `x[0 .. 5]` --- */ void main() { { int[5] x; x[x.length] = 1; enum size_t n = 2; x[x.length + n] = 2; } { int[5] x; x[$] = 1; enum size_t n = 2; x[$ + n] = 2; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail46.d0000644000175000017500000000044415205374123020661 0ustar fabiofabio// PERMUTE_ARGS: -inline /* TEST_OUTPUT: --- fail_compilation/fail46.d(19): Error: calling non-static function `bug` requires an instance of type `MyStruct` --- */ struct MyStruct { int bug() { return 3; } } int main() { assert(MyStruct.bug() == 3); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10259.d0000644000175000017500000000112215205374123020727 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10259.d(11): Error: circular reference to `ice10259.D.d` fail_compilation/ice10259.d(11): called from here: `(*function () pure nothrow @safe => x)()` --- */ class D { int x; D d = { auto x = new D(); return x; }(); } enum x = new D; /* TEST_OUTPUT: --- fail_compilation/ice10259.d(25): Error: circular reference to `ice10259.D2.d` fail_compilation/ice10259.d(25): called from here: `(*function () pure nothrow @safe => x)()` --- */ class D2 { int x; D2 d = function { auto x = new D2(); return x; }(); } enum x2 = new D2; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10666.d0000644000175000017500000000056515205374123021116 0ustar fabiofabio// REQUIRED_ARGS: -c /* TEST_OUTPUT: --- fail_compilation/fail10666.d(16): Error: variable `fail10666.foo10666.s1` has scoped destruction, cannot build closure --- */ struct S10666 { int val; ~this() {} } void foo10666(S10666 s1) { auto f1 = (){ return () => s1.val; }(); // NG S10666 s2; auto f2 = (){ return () => s2.val; }(); // (should be NG) } ./ldc-1.42.0-src/tests/dmd/fail_compilation/template_decl.d0000644000175000017500000000033715205374123022377 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/template_decl.d(8): Error: `{` expected after template parameter list, not `(` fail_compilation/template_decl.d(8): Error: declaration expected, not `)` --- */ template b(alias d)() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17.d0000644000175000017500000000050015205374123020650 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17.d(11): Error: undefined identifier `B` fail_compilation/fail17.d(11): Error: mixin `fail17.A!int.A.B!(T, A!T)` is not defined fail_compilation/fail17.d(14): Error: template instance `fail17.A!int` error instantiating --- */ struct A(T) { mixin B!(T, A!(T)); } A!(int) x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16095.d0000644000175000017500000000135015205374123021155 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test16095.d(18): Error: `shared` method `test16095.C.ping` is not callable using a non-shared `a` fail_compilation/test16095.d(28): Error: `shared` method `test16095.S.ping` is not callable using a non-shared `*a` fail_compilation/test16095.d(41): Error: mutable method `test16095.Foo.flip` is not callable using a `immutable` `foo` --- */ // https://issues.dlang.org/show_bug.cgi?id=16095 class C { void ping() shared; } void test1(C a) { (&a.ping)(); // error } struct S { void ping() shared; } void test2(S* a) { (&a.ping)(); // error } struct Foo { bool flag; void flip() { flag = true; } } void test3() { immutable Foo foo; (&foo.flip)(); // error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail291.d0000644000175000017500000000023715205374123020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail291.d(9): Error: variable `fail291.X` cannot be declared to be a function --- */ auto a() { return 0; } typeof(a) X; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23719.c0000644000175000017500000000050315205374123021154 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23719.c(15): Error: since `abc` is a pointer, use `abc->b` instead of `abc.b` --- */ // https://issues.dlang.org/show_bug.cgi?id=23719 struct S { int a, b; }; struct S *abc = &(struct S){ 1, 2 }; int main() { int j = abc.b; if (j != 2) return 1; return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/init1.c0000644000175000017500000000171715205374123020623 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/init1.c(100): Error: array initializer has 4 elements, but array length is 3 fail_compilation/init1.c(103): Error: `.identifier` expected for C struct field initializer `{[0]=3}` fail_compilation/init1.c(104): Error: only 1 designated initializer allowed for C struct field of type `int` fail_compilation/init1.c(106): Error: `[ constant-expression ]` expected for C array element initializer `{.a=3}` fail_compilation/init1.c(107): Error: only 1 designator currently allowed for C array element initializer `{[0][1]=3}` fail_compilation/init1.c(110): Error: overlapping initialization for field `a` and `b` fail_compilation/init1.c(113): Error: struct `init1.S6` unknown size --- */ #line 100 int a1[3] = { 1,2,3,4 }; typedef struct S1 { int a; } S1; S1 s1 = { [0] = 3 }; S1 s2 = { .a[0] = 3 }; int a3[2] = { .a = 3 }; int a4[2] = { [0][1] = 3 }; union U { int a, b; }; union U u = { 1, 2 }; struct S6; struct S6 a6[2] = { 1, 2 }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20245.d0000644000175000017500000000537015205374123021153 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test20245.d(21): Error: assigning reference to local variable `x` to non-scope parameter `ptr` calling `escape` is not allowed in a `@safe` function fail_compilation/test20245.d(22): Error: escaping a reference to parameter `x` by copying `&x` into allocated memory is not allowed in a `@safe` function fail_compilation/test20245.d(23): Error: returning scope variable `a` is not allowed in a `@safe` function fail_compilation/test20245.d(27): Error: taking address of `scope` variable `x` with pointers is not allowed in a `@safe` function fail_compilation/test20245.d(33): Error: assigning reference to local variable `x` to non-scope parameter `ptr` calling `escape` is not allowed in a `@safe` function fail_compilation/test20245.d(34): Error: escaping a reference to parameter `x` by copying `&x` into allocated memory is not allowed in a `@safe` function fail_compilation/test20245.d(50): Error: assigning reference to local variable `price` to non-scope `this.minPrice` is not allowed in a `@safe` function fail_compilation/test20245.d(69): Error: reference to local variable `this.content[]` calling non-scope member function `Exception.this()` is not allowed in a `@safe` function fail_compilation/test20245.d(89): Error: assigning reference to local variable `this` to non-scope parameter `content` calling `listUp` is not allowed in a `@safe` function fail_compilation/test20245.d(82): which is not `scope` because of `charPtr = content` --- */ // https://issues.dlang.org/show_bug.cgi?id=20245 @safe int* foo(ref int x) { int* a = &x; escape(&x); auto b = [&x]; return a; } @safe int** foo(ref scope int* x) { int** a = &x; return a; } @safe int* foo(return ref int x) { int* a = &x; escape(&x); auto b = [&x]; return a; } int* gPtr; @safe void escape(int* ptr) { gPtr = ptr; } // https://issues.dlang.org/show_bug.cgi?id=21212 class MinPointerRecorder { int* minPrice; void update(ref int price) @safe { minPrice = &price; // Should not compile. } } void main() @safe { auto r = new MinPointerRecorder; () { int mp = 42; r.update(mp); } (); () { ulong[1000] stomp = 13; } (); auto x = *r.minPrice; // "13" } // https://issues.dlang.org/show_bug.cgi?id=22782 struct DontDoThis { immutable char[12] content; @safe this(char ch) { content[] = ch; throw new Exception(content[]); } } void main1() @safe { DontDoThis('a'); } // https://issues.dlang.org/show_bug.cgi?id=22783 const(char)* charPtr; // argument is not, or should not be scope auto listUp(const(char)* content) {charPtr = content;} struct DontDoThis2 { char content; @safe escape() { listUp(&content); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23181.d0000644000175000017500000000110715205374123021103 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=23181 TEST_OUTPUT: --- $p:/core/lifetime.d$($n$): Error: struct `fail23181.fail23181.NoPostblit` is not copyable because it has a disabled postblit $p:/core/internal/array/construction.d$($n$): Error: template instance `core.lifetime.copyEmplace!(NoPostblit, NoPostblit)` error instantiating fail_compilation/fail23181.d(15): instantiated from here: `_d_arraysetctor!(NoPostblit[], NoPostblit)` --- */ void fail23181() { struct NoPostblit { @disable this(this); } NoPostblit[4] noblit23181 = NoPostblit(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/no_Throwable.d0000644000175000017500000000073215205374123022217 0ustar fabiofabio/* DFLAGS: REQUIRED_ARGS: -c EXTRA_SOURCES: extra-files/minimal/object.d TEST_OUTPUT: --- fail_compilation/no_Throwable.d(14): Error: cannot use `throw` statements because `object.Throwable` was not declared fail_compilation/no_Throwable.d(19): Error: cannot use try-catch statements because `object.Throwable` was not declared --- */ void test() { throw new Exception("msg"); } void test2() { try { test(); } catch (Exception e) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail91.d0000644000175000017500000000022015205374123020651 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail91.d(12): Error: struct `fail91.S` unknown size --- */ struct S; void main() { S* s = new S(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24036.d0000644000175000017500000000076415205374123021157 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=24036 Issue 24036 - assert message in CTFE becomes `['m', 'e', 's', 's', 'a', 'g', 'e'][0..7]` if produced using std.format.format TEST_OUTPUT: --- fail_compilation/test24036.d(19): Error: message fail_compilation/test24036.d(21): called from here: `(*function () pure nothrow @safe => 42)()` --- */ auto format() { return ['m', 'e', 's', 's', 'a', 'g', 'e'][0 .. 7]; } immutable ctfeThing = () { assert(0, format()); return 42; }(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10968.d0000644000175000017500000000633715205374123021126 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10968.d(43): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.this(this)` fail_compilation/fail10968.d(43): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.this(this)` fail_compilation/fail10968.d(31): `fail10968.SA.this(this)` is declared here fail_compilation/fail10968.d(44): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.this(this)` fail_compilation/fail10968.d(44): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.this(this)` fail_compilation/fail10968.d(31): `fail10968.SA.this(this)` is declared here fail_compilation/fail10968.d(45): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.this(this)` fail_compilation/fail10968.d(45): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.this(this)` fail_compilation/fail10968.d(31): `fail10968.SA.this(this)` is declared here fail_compilation/fail10968.d(48): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.this(this)` fail_compilation/fail10968.d(48): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.this(this)` fail_compilation/fail10968.d(31): `fail10968.SA.this(this)` is declared here fail_compilation/fail10968.d(49): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.this(this)` fail_compilation/fail10968.d(49): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.this(this)` fail_compilation/fail10968.d(31): `fail10968.SA.this(this)` is declared here fail_compilation/fail10968.d(50): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.this(this)` fail_compilation/fail10968.d(50): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.this(this)` fail_compilation/fail10968.d(31): `fail10968.SA.this(this)` is declared here --- */ #line 29 struct SA { this(this) { throw new Exception("BOOM!"); } } void bar() pure @safe { SA ss; SA[1] sa; // TOKassign ss = ss; sa = ss; sa = sa; // TOKconstruct SA ss2 = ss; SA[1] sa2 = ss; SA[1] sa3 = sa; } /* TEST_OUTPUT: --- fail_compilation/fail10968.d(76): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit fail_compilation/fail10968.d(77): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit fail_compilation/fail10968.d(78): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit fail_compilation/fail10968.d(81): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit fail_compilation/fail10968.d(82): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit fail_compilation/fail10968.d(83): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit --- */ struct SD { this(this) @disable; } void baz() { SD ss; SD[1] sa; // TOKassign ss = ss; sa = ss; sa = sa; // TOKconstruct SD ss2 = ss; SD[1] sa2 = ss; SD[1] sa3 = sa; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail24301.d0000644000175000017500000000067315205374123021105 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/fail24301.d(19): Error: function `fun` is not callable using argument types `(S)` fail_compilation/fail24301.d(19): `ref S(ref S)` copy constructor cannot be used because it is annotated with `@disable` fail_compilation/fail24301.d(14): `fail24301.fun(S __param_0)` declared here --- +/ struct S { @disable this(ref S); } @safe void fun(S) {} @safe void main() { S s; fun(s); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix350b.d0000644000175000017500000000111115205374123020744 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix350b.d(15): Error: comma expected separating field initializers fail_compilation/fix350b.d(15): Error: comma expected separating field initializers fail_compilation/fix350b.d(16): Error: comma expected separating field initializers --- */ int foo() { return 3; } struct S2 { int a, b, c; static immutable S2 C1 = { foo() 2 3 }; // compiles (and works) static immutable S2 C2 = { foo() 2, 3 }; // compiles (and works) //static immutable S2 C3 = { 2 foo() 3 }; // does not compile: comma expected separating field initializers } ./ldc-1.42.0-src/tests/dmd/fail_compilation/compgoto.i0000644000175000017500000000054315205374123021430 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/compgoto.i(105): Error: unary `&&` computed goto extension is not supported fail_compilation/compgoto.i(106): Error: `goto *` computed goto extension is not supported --- */ // https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html #line 100 void test() { void *ptr; foo: ptr = &&foo; goto *ptr; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17451.d0000644000175000017500000000205115205374123021151 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test17451.d(22): Error: undefined identifier `allocator` fail_compilation/test17451.d(23): Error: `false` has no effect fail_compilation/test17451.d(30): Error: variable `test17451.HashMap!(ThreadSlot).HashMap.__lambda_L30_C20.v` - size of type `ThreadSlot` is invalid fail_compilation/test17451.d(44): Error: template instance `test17451.HashMap!(ThreadSlot)` error instantiating --- */ // https://issues.dlang.org/show_bug.cgi?id=17451 interface ManualEvent {} interface EventDriver { ManualEvent createManualEvent() ; } struct ArraySet(Key) { ~this() { try allocator; catch (Exception e) false; // should never happen } } struct HashMap(TValue) { alias Value = TValue; static if ({ Value v; }) {} } struct Task {} class Libevent2Driver : EventDriver { Libevent2ManualEvent createManualEvent() {} } struct ThreadSlot { ArraySet!Task tasks; } class Libevent2ManualEvent : ManualEvent { HashMap!ThreadSlot m_waiters; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/casttuple.d0000644000175000017500000000131315205374123021574 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/casttuple.d(104): Error: cannot cast `__tup1_field_0` of type `int` to type sequence `(string)` fail_compilation/casttuple.d(107): Error: cannot cast `AliasSeq!(__tup2_field_0, __tup2_field_1)` of type `(int, int)` to type sequence `(string, string)` fail_compilation/casttuple.d(111): Error: cannot cast `AliasSeq!(foo, 123)` of type `(int, int)` to type sequence `(string, string)` --- */ alias tuple(T...) = T; #line 100 void nomatch() { tuple!int tup1; auto x = cast(tuple!string) tup1; tuple!(int, int) tup2; auto y = cast(tuple!(string, string)) tup2; int foo; alias tup3 = tuple!(foo, 123); auto z = cast(tuple!(string, string)) tup3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15361.d0000644000175000017500000000042015205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail15361.d(9): Error: unexpected `(` after `errorize`, inside `is` expression fail_compilation/fail15361.d(9): try enclosing the contents of `is` with a `typeof` expression --- */ enum isErrorizable(T) = is(errorize(T.init)); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20383.d0000644000175000017500000000043115205374123021147 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test20383.d(11): Error: invalid array operation `cast(int[])data[] & [42]` (possible missing []) --- */ // https://issues.dlang.org/show_bug.cgi?id=20383 ubyte[1] ice(ubyte[1] data) { ubyte[1] result = data[] & [42]; return result; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21319.d0000644000175000017500000000030615205374123021150 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21319 /* TEST_OUTPUT: --- fail_compilation/test21319.d(11): Error: circular reference to `test21319.C.c` --- */ class C { immutable C c = new C(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bitfields2.c0000644000175000017500000000071215205374123021620 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/bitfields2.c(103): Error: bitfield type `float` is not an integer type fail_compilation/bitfields2.c(104): Error: bitfield width `3.0` is not an integer constant fail_compilation/bitfields2.c(105): Error: bitfield `c` has zero width fail_compilation/bitfields2.c(106): Error: width `60` of bitfield `d` does not fit in type `int` --- */ #line 100 struct S { float a:3; int b:3.0; int c:0; int d:60; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13424.d0000644000175000017500000000072615205374123021110 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail13424.d(12): Error: delegate `(dchar) { }` cannot be struct members fail_compilation/fail13424.d(17): Error: delegate `(dchar) { }` cannot be union members fail_compilation/fail13424.d(22): Error: delegate `(dchar) { }` cannot be class members --- */ struct S { void delegate(dchar) onChar = (dchar) {}; } union U { void delegate(dchar) onChar = (dchar) {}; } class C { void delegate(dchar) onChar = (dchar) {}; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b19523.d0000644000175000017500000000100215205374123020410 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/b19523.d(13): Error: undefined identifier `SomeStruct` fail_compilation/b19523.d(14): Error: function `foo` is not callable using argument types `(_error_)` fail_compilation/b19523.d(14): cannot pass argument `__error` of type `_error_` to parameter `int delegate() arg` fail_compilation/b19523.d(19): `b19523.foo(int delegate() arg)` declared here ---- */ module b19523; void bar () { SomeStruct s; foo({ return s; }); } void foo (int delegate() arg) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12235.d0000644000175000017500000000075715205374123020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12235.d(14): Error: forward reference to inferred return type of function `__lambda_L12_C5` fail_compilation/ice12235.d(15): Error: forward reference to inferred return type of function `__lambda_L12_C5` fail_compilation/ice12235.d(15): while evaluating `pragma(msg, __lambda_L12_C5.mangleof)` --- */ void main() { (){ int x; enum s = __traits(parent, x).mangleof; pragma(msg, __traits(parent, x).mangleof); }(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13434_m64.d0000644000175000017500000000036115205374123021572 0ustar fabiofabio// REQUIRED_ARGS: -m64 /* TEST_OUTPUT: --- fail_compilation/fail13434_m64.d(13): Error: cannot implicitly convert expression `()` of type `()` to `ulong` --- */ alias tuple(A...) = A; void main() { float[] arr; arr[tuple!()] = 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test13698.d0000644000175000017500000000053215205374123021164 0ustar fabiofabio // REQUIRED_ARGS: -m64 // https://issues.dlang.org/show_bug.cgi?id=13698 /* DISABLED: LDC // unsupported __simd syntax TEST_OUTPUT: --- fail_compilation/test13698.d(16): Error: constant expression expected, not `cast(void)b` --- */ import core.simd; void main() { float4 a; ubyte b = 0; a = __simd(XMM.SHUFPS, a, b); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail16575.d0000644000175000017500000001075215205374123021122 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16575 /* REQUIRED_ARGS: -m64 TEST_OUTPUT: --- fail_compilation/fail16575.d(10): Error: function `immNull` cannot have parameter of type `immutable(typeof(null))*` because its linkage is `extern(C++)` fail_compilation/fail16575.d(11): Error: function `shaNull` cannot have parameter of type `shared(typeof(null))*` because its linkage is `extern(C++)` fail_compilation/fail16575.d(20): Error: function `immNoReturn` cannot have parameter of type `immutable(noreturn)*` because its linkage is `extern(C++)` fail_compilation/fail16575.d(21): Error: function `shaNoReturn` cannot have parameter of type `shared(noreturn)*` because its linkage is `extern(C++)` fail_compilation/fail16575.d(30): Error: function `immBasic` cannot have parameter of type `immutable(int)*` because its linkage is `extern(C++)` fail_compilation/fail16575.d(31): Error: function `shaBasic` cannot have parameter of type `shared(int)*` because its linkage is `extern(C++)` fail_compilation/fail16575.d(40): Error: function `immVector` cannot have parameter of type `immutable(__vector(long[2]))*` because its linkage is `extern(C++)` fail_compilation/fail16575.d(41): Error: function `shaVector` cannot have parameter of type `shared(__vector(long[2]))*` because its linkage is `extern(C++)` fail_compilation/fail16575.d(50): Error: function `immSArray` cannot have parameter of type `immutable(long[2])` because its linkage is `extern(C++)` fail_compilation/fail16575.d(50): perhaps use a `long*` type instead fail_compilation/fail16575.d(51): Error: function `shaSArray` cannot have parameter of type `shared(long[2])` because its linkage is `extern(C++)` fail_compilation/fail16575.d(51): perhaps use a `long*` type instead fail_compilation/fail16575.d(60): Error: function `immPointer` cannot have parameter of type `immutable(int*)` because its linkage is `extern(C++)` fail_compilation/fail16575.d(61): Error: function `shaPointer` cannot have parameter of type `shared(int*)` because its linkage is `extern(C++)` fail_compilation/fail16575.d(71): Error: function `immStruct` cannot have parameter of type `immutable(SPP)*` because its linkage is `extern(C++)` fail_compilation/fail16575.d(72): Error: function `shaStruct` cannot have parameter of type `shared(SPP)*` because its linkage is `extern(C++)` fail_compilation/fail16575.d(81): Error: function `immClass` cannot have parameter of type `immutable(CPP)` because its linkage is `extern(C++)` fail_compilation/fail16575.d(82): Error: function `shaClass` cannot have parameter of type `shared(CPP)` because its linkage is `extern(C++)` fail_compilation/fail16575.d(91): Error: function `immEnum` cannot have parameter of type `immutable(EPP)*` because its linkage is `extern(C++)` fail_compilation/fail16575.d(92): Error: function `shaEnum` cannot have parameter of type `shared(EPP)*` because its linkage is `extern(C++)` fail_compilation/fail16575.d(100): Error: function `typeDArray` cannot have parameter of type `int[]` because its linkage is `extern(C++)` fail_compilation/fail16575.d(101): Error: function `typeAArray` cannot have parameter of type `int[int]` because its linkage is `extern(C++)` fail_compilation/fail16575.d(102): Error: function `typeDelegate` cannot have parameter of type `extern (C++) int delegate()` because its linkage is `extern(C++)` --- */ #line 10 extern(C++) void immNull(immutable(typeof(null))* a) {} extern(C++) void shaNull(shared(typeof(null))* a) {} #line 20 extern(C++) void immNoReturn(immutable(typeof(*null))* a) {} extern(C++) void shaNoReturn(shared(typeof(*null))* a) {} #line 30 extern(C++) void immBasic(immutable(int)* a) {} extern(C++) void shaBasic(shared(int)* a) {} #line 40 extern(C++) void immVector(immutable(__vector(long[2]))* a) {} extern(C++) void shaVector(shared(__vector(long[2]))* a) {} #line 50 extern(C++) void immSArray(immutable(long[2]) a) {} extern(C++) void shaSArray(shared(long[2]) a) {} #line 60 extern(C++) void immPointer(immutable(int*) a) {} extern(C++) void shaPointer(shared(int*) a) {} #line 70 extern(C++) struct SPP {} extern(C++) void immStruct(immutable(SPP)* a) {} extern(C++) void shaStruct(shared(SPP)* a) {} #line 80 extern(C++) class CPP {} extern(C++) void immClass(immutable CPP a) {} extern(C++) void shaClass(shared CPP a) {} #line 90 extern(C++) enum EPP {a} extern(C++) void immEnum(immutable(EPP)* a) {} extern(C++) void shaEnum(shared(EPP)* a) {} # line 100 extern(C++) void typeDArray(int[] a) {} extern(C++) void typeAArray(int[int] a) {} extern(C++) void typeDelegate(int delegate() a) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11513a.d0000644000175000017500000000037615205374123021074 0ustar fabiofabio/* EXTRA_FILES: imports/ice11513x.d TEST_OUTPUT: --- fail_compilation/imports/ice11513x.d(1): Error: package name 'ice11513a' conflicts with usage as a module name in file fail_compilation/ice11513a.d --- */ module ice11513a; import imports.ice11513x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9290.d0000644000175000017500000000053115205374123021030 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9290.d(15): Error: slice `s1[]` is not mutable, struct `S` has immutable members fail_compilation/fail9290.d(16): Error: array `s1` is not mutable, struct `S` has immutable members --- */ struct S { immutable int i; } void main() { S[1] s1 = S(1); S[1] s2 = S(2); s1 = S(3); s1 = s2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail256.d0000644000175000017500000000024115205374123020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail256.d(8): Error: incompatible types for `("foo"d) ~ ("bar"c)`: `dstring` and `string` --- */ auto s = "foo"d ~ "bar"c; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail161.d0000644000175000017500000000045415205374123020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail161.d(15): Error: template instance `MetaString!"2 == 1"` does not match template declaration `MetaString(String)` --- */ template MetaString(String) { alias String Value; } void main() { alias MetaString!("2 == 1") S; assert(mixin(S.Value)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail94.d0000644000175000017500000000136615205374123020670 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail94.d(28): Error: cannot implicitly override base class method `fail94.A.clone` with `fail94.B.clone`; add `override` attribute --- */ interface I { int foo(); } class IA : I { int foo() { return 1; } } class A { I i; I clone() { return i; } } class B : A { IA ia; IA clone() out (result) { printf("B.clone()\n"); } do { return ia; } } void main() { IA ia = new IA; assert(ia.foo() == 1); I i = ia; assert(i.foo() == 1); A a = new A; a.i = i; assert(a.clone().foo() == 1); B b = new B; b.ia = ia; assert(b.clone().foo() == 1); a = b; assert(a.clone().foo() == 1); bar(&b.clone); } void bar(IA delegate() dg) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17491.d0000644000175000017500000000304515205374123021115 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17491.d(22): Error: cannot modify expression `(S17491).init` because it is not an lvalue fail_compilation/fail17491.d(23): Error: cannot take address of expression `S17491(0)` because it is not an lvalue fail_compilation/fail17491.d(25): Error: cannot modify expression `S17491(0).field` because it is not an lvalue fail_compilation/fail17491.d(26): Error: cannot take address of expression `S17491(0).field` because it is not an lvalue fail_compilation/fail17491.d(31): Error: cannot modify expression `S17491(0)` because it is not an lvalue fail_compilation/fail17491.d(32): Error: cannot take address of expression `S17491(0)` because it is not an lvalue fail_compilation/fail17491.d(34): Error: cannot modify expression `S17491(0).field` because it is not an lvalue fail_compilation/fail17491.d(35): Error: cannot take address of expression `S17491(0).field` because it is not an lvalue --- */ // https://issues.dlang.org/show_bug.cgi?id=17491 struct S17491 { int field; static int var; } void test17491() { S17491.init = S17491(42); // NG *&S17491.init = S17491(42); // NG S17491.init.field = 42; // NG *&S17491.init.field = 42; // NG S17491.init.var = 42; // OK *&S17491.init.var = 42; // OK S17491(0) = S17491(42); // NG *&S17491(0) = S17491(42); // NG S17491(0).field = 42; // NG *&S17491(0).field = 42; // NG S17491(0).var = 42; // OK *&S17491(0).var = 42; // OK } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail207.d0000644000175000017500000000043315205374123020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail207.d(11): Error: found end of file instead of initializer fail_compilation/fail207.d(11): Error: semicolon needed to end declaration of `x`, instead of `End of File` fail_compilation/fail207.d(10): `x` declared here --- */ int x = { ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21317.d0000644000175000017500000000140115205374123021143 0ustar fabiofabiomodule dmd.compiler.test.fail_compilation.test21317; /* TEST_OUTPUT: --- fail_compilation/test21317.d(16): Error: `writeln` is not defined, perhaps `import std.stdio;` ? fail_compilation/test21317.d(21): Error: undefined identifier `Zero`, did you mean variable `zero`? fail_compilation/test21317.d(25): Error: undefined identifier `NULL`, did you mean `null`? fail_compilation/test21317.d(31): Error: undefined identifier `this`, did you mean `typeof(this)`? fail_compilation/test21317.d(38): Error: undefined identifier `unknown` --- */ // Weird formatting is intended to check the loc int[ writeln ] arr1; int zero = 0; int [ Zero ] arr2; int [ NULL ] arr3; struct S4 { enum E4 : this { fail, } } int [ unknown ] arr5; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11.d0000644000175000017500000000041015205374123020642 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11.d(12): Error: `int*` has no effect --- */ // https://forum.dlang.org/thread/c738o9$1p7i$1@digitaldaemon.com void main() { TFoo!(int).t; // should produce a "no identifier" error. } template TFoo(T) { alias T* t; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/lexer5.d0000644000175000017500000000074115205374123021000 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/lexer5.d(11): Error: number `1e-100f` is not representable as a `float` fail_compilation/lexer5.d(11): https://dlang.org/spec/lex.html#floatliteral fail_compilation/lexer5.d(12): Error: number `1e-10024` is not representable as a `double` fail_compilation/lexer5.d(12): `real` literals can be written using the `L` suffix. https://dlang.org/spec/lex.html#floatliteral --- */ static float f = 1e-100f; static float f2 = 1e-10024; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23022.d0000644000175000017500000000046415205374123021146 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test23022.d(14): Error: returning `p` escapes a reference to variadic parameter `p` --- */ // https://issues.dlang.org/show_bug.cgi?id=23022 // Typesafe variadic parameter should not infer return auto ir(string[] p...) { return p; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue24534.d0000644000175000017500000000113215205374123021321 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/issue24534.d(12): Error: `goto` skips declaration of variable `issue24534.f1.y1` fail_compilation/issue24534.d(13): declared here fail_compilation/issue24534.d(20): Error: `goto` skips declaration of variable `issue24534.f2.y2` fail_compilation/issue24534.d(22): declared here --- */ void f1(){ //always failed with error about skipping a declaration int x1; goto Label1; int y1; Label1: int z1; } void f2(){ //compiled fine before this bug was fixed int x2; goto Label2; Dummy2: int y2; Label2: int z2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/generic.c0000644000175000017500000000227615205374123021214 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/generic.c(103): Error: generic association type `float` can only appear once fail_compilation/generic.c(108): Error: no compatible generic association type for controlling expression type `long` fail_compilation/generic.c(110): Error: undefined identifier `T` fail_compilation/generic.c(112): Error: undefined identifier `E` --- */ int test1() { return _Generic(1, int:5, long long:6); } _Static_assert(test1() == 5, "in"); int test2() { return _Generic(1, default:5, long long:6); } _Static_assert(test2() == 5, "in"); int test3() { return _Generic(1, long: 5, int: 4, long long: 6); } _Static_assert(test3() == 4 + (sizeof(long) == 4), "in"); int test4() { return _Generic(1.0, long double: 5, double: 4); } // LDC: adapted assertion - DMD maps 64-bit C `long double` to D `double` // for LDC, C `long double` always corresponds to D `real` _Static_assert(test4() == 4 /*+ (sizeof(long double) == 8)*/, "in"); #line 100 void test() { int e1 = _Generic(1, int: 4, float: 5, float: 6); int e2 = _Generic(1LL, int:5); int e4 = _Generic(1, T:5); int e5 = _Generic(1, int:E); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23826.d0000644000175000017500000000053115205374123021111 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23826 // REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail23826.d(23): Deprecation: alias `fail23826.S.value` is deprecated --- */ alias Alias(alias A) = A; class S { deprecated alias value = Alias!5; } enum identity(alias A) = A; void main() { auto a = identity!(S.value); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_arrayop3c.d0000644000175000017500000000104115205374123022464 0ustar fabiofabio/* REQUIRED_ARGS: -o- TEST_OUTPUT: ---- $p:core/internal/array/operations.d$($n$): Error: static assert: "Binary op `*=` not supported for types `int*` and `int*`." $p:core/internal/array/operations.d$($n$): instantiated from here: `typeCheck!(true, int*, int*, "*=")` $p:object.d$($n$): instantiated from here: `arrayOp!(int*[], int*[], "*=")` fail_compilation/fail_arrayop3c.d(15): instantiated from here: `_arrayOp!(int*[], int*[], "*=")` ---- */ void test11376() { int*[] pa1; int*[] pa2; pa1[] *= pa2[]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8787.d0000644000175000017500000000031615205374123021034 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8787.d(10): Error: function `diag8787.I.f` function body only allowed in `final` functions in interface `I` --- */ interface I { void f() { } } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10254.d0000644000175000017500000000154415205374123021105 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10254.d(20): Error: `pure` function `fail10254.foo` cannot call impure constructor `fail10254.C.this` fail_compilation/fail10254.d(20): Error: `@safe` function `fail10254.foo` cannot call `@system` constructor `fail10254.C.this` fail_compilation/fail10254.d(15): `fail10254.C.this` is declared here fail_compilation/fail10254.d(21): Error: `pure` function `fail10254.foo` cannot call impure constructor `fail10254.S.this` fail_compilation/fail10254.d(21): Error: `@safe` function `fail10254.foo` cannot call `@system` constructor `fail10254.S.this` fail_compilation/fail10254.d(16): `fail10254.S.this` is declared here --- */ int a; class C { this() { a = 2; } } struct S { this(int) { a = 2; } } void foo() pure @safe { auto c = new C; // This line should be a compilation error. auto s = new S(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/vararg2.d0000644000175000017500000000141115205374123021133 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/vararg2.d(106): Error: function `foo` is not callable using argument types `(double)` fail_compilation/vararg2.d(106): cannot pass argument `1.0` of type `double` to parameter `int x` fail_compilation/vararg2.d(101): `vararg2.foo(int x, const return ...)` declared here fail_compilation/vararg2.d(111): Error: function `bar` is not callable using argument types `(double)` fail_compilation/vararg2.d(111): cannot pass argument `1.0` of type `double` to parameter `int x` fail_compilation/vararg2.d(102): `vararg2.bar(int x, scope shared ...)` declared here ---- */ #line 100 int* foo(int x, return const ...); int* bar(int x, scope shared ...); void test1() { foo(1.0); } void test2() { bar(1.0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22899.c0000644000175000017500000000062115205374123021165 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test22899.c(105): Error: expression expected, not `)` fail_compilation/test22899.c(105): Error: found `;` when expecting `)` fail_compilation/test22899.c(106): Error: found `}` when expecting `;` following statement --- */ // https://issues.dlang.org/show_bug.cgi?id=22904 #line 100 typedef int mytype_t; void fn() { int x; x = sizeof( (mytype_t) ); }} ./ldc-1.42.0-src/tests/dmd/fail_compilation/attrpure.i0000644000175000017500000000034215205374123021444 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/attrpure.i(11): Error: `pure` function `attrpure.pureAsSnow` cannot call impure function `attrpure.impure` --- */ void impure(); __attribute__((pure)) void pureAsSnow() { impure(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/traits.d0000644000175000017500000001467015205374123021110 0ustar fabiofabio/************************************************************/ /* TEST_OUTPUT: --- fail_compilation/traits.d(100): Error: `getTargetInfo` key `"not_a_target_info"` not supported by this implementation fail_compilation/traits.d(101): Error: string expected as argument of __traits `getTargetInfo` instead of `100` fail_compilation/traits.d(102): Error: expected 1 arguments for `getTargetInfo` but had 2 fail_compilation/traits.d(103): Error: expected 1 arguments for `getTargetInfo` but had 0 fail_compilation/traits.d(200): Error: undefined identifier `imports.nonexistent` fail_compilation/traits.d(201): Error: undefined identifier `imports.nonexistent` fail_compilation/traits.d(202): Error: expected 1 arguments for `isPackage` but had 0 fail_compilation/traits.d(203): Error: expected 1 arguments for `isModule` but had 0 fail_compilation/traits.d(300): Error: in expression `__traits(allMembers, float)` `float` can't have members fail_compilation/traits.d(300): `float` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation fail_compilation/traits.d(306): Error: in expression `__traits(allMembers, TemplatedStruct)` struct `TemplatedStruct(T)` has no members fail_compilation/traits.d(306): `TemplatedStruct(T)` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation fail_compilation/traits.d(309): Error: in expression `__traits(derivedMembers, float)` `float` can't have members fail_compilation/traits.d(309): `float` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation fail_compilation/traits.d(316): Error: in expression `__traits(derivedMembers, TemplatedStruct)` struct `TemplatedStruct(T)` has no members fail_compilation/traits.d(316): `TemplatedStruct(T)` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation fail_compilation/traits.d(404): Error: function `traits.func1` circular reference in `__traits(GetCppNamespaces,...)` fail_compilation/traits.d(413): Error: function `traits.foo1.func1` circular reference in `__traits(GetCppNamespaces,...)` --- */ #line 100 enum A1 = __traits(getTargetInfo, "not_a_target_info"); enum B1 = __traits(getTargetInfo, 100); enum C1 = __traits(getTargetInfo, "cppRuntimeLibrary", "bits"); enum D1 = __traits(getTargetInfo); #line 200 enum A2 = __traits(isPackage, imports.nonexistent); enum B2 = __traits(isModule, imports.nonexistent); enum C2 = __traits(isPackage); enum D2 = __traits(isModule); interface Interface {} struct TemplatedStruct(T) {} struct Struct {} union Union {} class Class {} #line 300 enum AM0 = __traits(allMembers, float); // compile error enum AM1 = __traits(allMembers, Struct); // no error enum AM2 = __traits(allMembers, Union); // no error enum AM3 = __traits(allMembers, Class); // no error enum AM4 = __traits(allMembers, Interface); // no error enum AM5 = __traits(allMembers, TemplatedStruct!float); // no error enum AM6 = __traits(allMembers, TemplatedStruct); // compile error enum AM7 = __traits(allMembers, mixin(__MODULE__)); // no error enum DM0 = __traits(derivedMembers, float); // compile error enum DM1 = __traits(derivedMembers, Struct); // no error enum DM2 = __traits(derivedMembers, Struct); // no error enum DM3 = __traits(derivedMembers, Union); // no error enum DM4 = __traits(derivedMembers, Class); // no error enum DM5 = __traits(derivedMembers, Interface); // no error enum DM6 = __traits(derivedMembers, TemplatedStruct!float); // no error enum DM7 = __traits(derivedMembers, TemplatedStruct); // compile error enum DM8 = __traits(derivedMembers, mixin(__MODULE__)); // no error #line 400 extern(C++, "bar") extern(C++, __traits(getCppNamespaces, func1)) void func () {} extern(C++, "foo") extern(C++, __traits(getCppNamespaces, func2)) void func1 () {} extern(C++, "foobar") extern(C++, __traits(getCppNamespaces, func)) void func2 () {} extern(C++, bar1) extern(C++, __traits(getCppNamespaces, foo1.func1)) void func () {} extern(C++, foo1) extern(C++, __traits(getCppNamespaces, foobar1.func2)) void func1 () {} extern(C++, foobar1) extern(C++, __traits(getCppNamespaces, bar1.func)) void func2 () {} /******************************************** https://issues.dlang.org/show_bug.cgi?id=21918 TEST_OUTPUT: --- fail_compilation/traits.d(501): Error: undefined identifier `T` fail_compilation/traits.d(502): while evaluating `pragma(msg, __traits(getParameterStorageClasses, yip, 0))` --- */ #line 500 auto yip(int f) {return T[];} pragma(msg, __traits(getParameterStorageClasses, yip, 0)); /******************************************** TEST_OUTPUT: --- fail_compilation/traits.d(602): Error: expected 1 arguments for `hasCopyConstructor` but had 0 fail_compilation/traits.d(602): while evaluating `pragma(msg, __traits(hasCopyConstructor))` fail_compilation/traits.d(603): Error: type expected as second argument of __traits `hasCopyConstructor` instead of `S()` fail_compilation/traits.d(603): while evaluating `pragma(msg, __traits(hasCopyConstructor, S()))` fail_compilation/traits.d(604): Error: expected 1 arguments for `hasPostblit` but had 0 fail_compilation/traits.d(604): while evaluating `pragma(msg, __traits(hasPostblit))` fail_compilation/traits.d(605): Error: type expected as second argument of __traits `hasPostblit` instead of `S()` fail_compilation/traits.d(605): while evaluating `pragma(msg, __traits(hasPostblit, S()))` --- */ #line 600 struct S { this (ref S rhs) {} } pragma(msg, __traits(hasCopyConstructor)); pragma(msg, __traits(hasCopyConstructor, S())); pragma(msg, __traits(hasPostblit)); pragma(msg, __traits(hasPostblit, S())); /******************************************** https://issues.dlang.org/show_bug.cgi?id=23178 TEST_OUTPUT: --- fail_compilation/traits.d(701): Error: alias `traits.a` cannot alias an expression `true` fail_compilation/traits.d(702): Error: alias `traits.b` cannot alias an expression `false` fail_compilation/traits.d(703): Error: alias `traits.c` cannot alias an expression `"Object"` fail_compilation/traits.d(704): while evaluating `pragma(msg, a)` --- */ #line 700 alias a = __traits(compiles, 1); alias b = __traits(isIntegral, 1.1); alias c = __traits(identifier, Object); pragma(msg, a, b, c); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail329.d0000644000175000017500000000163515205374123020750 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail329.d(28): Error: variable `fail329.A.foo.__ensure.result` cannot modify result `result` in contract --- */ //import core.stdc.stdio; /*******************************************/ class A { int x = 7; int foo(int i) in { //printf("A.foo.in %d\n", i); assert(i == 2); assert(x == 7); //printf("A.foo.in pass\n"); } out (result) { assert(result & 1); assert(x == 7); result++; } do { return i; } } class B : A { override int foo(int i) in { float f; //printf("B.foo.in %d\n", i); assert(i == 4); assert(x == 7); f = f + i; } out (result) { assert(result < 8); assert(x == 7); } do { return i - 1; } } void test1() { auto b = new B(); b.foo(2); b.foo(4); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail193.d0000644000175000017500000000036215205374123020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail193.d(14): Error: cannot infer type from overloaded function symbol `& foo` --- */ void foo() { } void foo(int) { } void main() { //void function(int) fp = &foo; auto fp = &foo; fp(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/no_TypeInfo.d0000644000175000017500000000037615205374123022031 0ustar fabiofabio/* DFLAGS: REQUIRED_ARGS: -c EXTRA_SOURCES: extra-files/minimal/object.d TEST_OUTPUT: --- fail_compilation/no_TypeInfo.d(14): Error: `object.TypeInfo` could not be found, but is implicitly used --- */ void test() { int i; auto ti = typeid(i); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test1021.d0000644000175000017500000000626215205374123021063 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1021 */ @safe: /* TEST_OUTPUT: --- fail_compilation/test1021.d(1009): Error: more than one mutable reference of `p` in arguments to `test1021.fooa()` fail_compilation/test1021.d(1010): Error: mutable and const references of `p` in arguments to `test1021.foob()` fail_compilation/test1021.d(1011): Error: mutable and const references of `p` in arguments to `test1021.fooc()` fail_compilation/test1021.d(1013): Error: more than one mutable reference of `p` in arguments to `test1021.fooe()` --- */ #line 1000 void fooa(int*, int*); void foob(const(int)*, int*); void fooc(int*, const(int)*); void food(const(int)*, const(int)*); void fooe(int*, ...); void test1(int* p) { fooa(p, p); // error foob(p, p); // error fooc(p, p); // error food(p, p); // ok fooe(p, p); // error } /***********************************/ /* TEST_OUTPUT: --- fail_compilation/test1021.d(2010): Error: more than one mutable reference to `i` in arguments to `test1021.fopa()` fail_compilation/test1021.d(2011): Error: mutable and const references to `i` in arguments to `test1021.fopb()` fail_compilation/test1021.d(2012): Error: mutable and const references to `i` in arguments to `test1021.fopc()` fail_compilation/test1021.d(2014): Error: more than one mutable reference to `i` in arguments to `test1021.fope()` --- */ #line 2000 void fopa(ref int, scope int*); void fopb(ref int, scope const int*); void fopc(ref const int, scope int*); void fopd(ref const int, scope const int*); inout(int) fope(ref inout int, scope int*); void test2() { int i; @trusted int* toPtr(ref int i) { return &i; } fopa(i, toPtr(i)); // error fopb(i, toPtr(i)); // error fopc(i, toPtr(i)); // error fopd(i, toPtr(i)); // ok fope(i, toPtr(i)); // error } /***********************************/ /* TEST_OUTPUT: --- fail_compilation/test1021.d(3015): Error: more than one mutable reference to `s` in arguments to `test1021.S.method()` fail_compilation/test1021.d(3019): Error: more than one mutable reference of `c` in arguments to `test1021.C.method()` --- */ #line 3000 struct S { void method(ref S s); } class C { void method(C c); } void test3() { S s; S* ps; s.method(s); // error ps.method(s); // ok C c; c.method(c); // error } /***********************************/ /* TEST_OUTPUT: --- fail_compilation/test1021.d(4008): Error: more than one mutable reference to `i` in arguments to `test1021.test4.nested()` --- */ #line 4000 void test4() { int i, k; int nested(ref int j) { return i + j; } nested(i); // error nested(k); // ok } /***********************************/ /* TEST_OUTPUT: --- fail_compilation/test1021.d(5012): Error: more than one mutable reference of `s` in arguments to `test1021.foo5()` --- */ #line 5000 struct S5 { int i; int* p; } void foo5(S5, S5); void test5() { S5 s; foo5(s, s); } alias A5 = void delegate() const; void foo5(A5, A5); void test5a() { A5 a; foo5(a, a); } alias B5 = void function(); void foo5(B5, B5); void test5b() { B5 b; foo5(b, b); } struct S5c { void function() fp; } void foo5(S5c, S5c); void test5c() { S5c s; foo5(s, s); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/noreturn.d0000644000175000017500000000536715205374123021461 0ustar fabiofabio/* REQUIRED_ARGS: -w -o- TEST_OUTPUT: --- fail_compilation\noreturn.d(38): Error: Accessed expression of type `noreturn` fail_compilation\noreturn.d(42): called from here: `assign()` fail_compilation\noreturn.d(49): Error: Accessed expression of type `noreturn` fail_compilation\noreturn.d(49): called from here: `foo(n)` fail_compilation\noreturn.d(53): called from here: `calling()` fail_compilation\noreturn.d(59): Error: Accessed expression of type `noreturn` fail_compilation\noreturn.d(62): called from here: `nested()` fail_compilation\noreturn.d(68): Error: Accessed expression of type `noreturn` fail_compilation\noreturn.d(78): called from here: `casting(0)` fail_compilation\noreturn.d(69): Error: Accessed expression of type `noreturn` fail_compilation\noreturn.d(79): called from here: `casting(1)` fail_compilation\noreturn.d(72): Error: Accessed expression of type `noreturn` fail_compilation\noreturn.d(80): called from here: `casting(2)` fail_compilation/noreturn.d(120): Error: uncaught CTFE exception `object.Exception("")` --- https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1034.md */ alias noreturn = typeof(*null); int pass() { noreturn n; noreturn m; return 0; } enum forcePass = pass(); int assign() { noreturn n; noreturn m = n; return 0; } enum forceAss = assign(); void foo(const noreturn) {} int calling() { noreturn n; foo(n); return 0; } enum forceCall = calling(); int nested() { int[4] arr; noreturn n; return arr[n ? n : n]; } enum forceNested = nested(); noreturn casting(int i) { final switch (i) { case 0: return cast(noreturn) i; case 1: return cast(typeof(assert(0))) cast(double) i; case 2, 3: { noreturn n; return cast() n; } } assert(false); } enum forceCasting0 = casting(0); enum forceCasting1 = casting(1); enum forceCasting2 = casting(2); /* struct HasNoreturnStruct { noreturn n; } int inStruct() { HasNoreturnStruct hn; return hn.n; } enum forceInStruct = inStruct(); class HasNoreturnClass { noreturn n; } int inClass() { HasNoreturnClass hn = new HasNoreturnClass(); return hn.n; } enum forceInClass = inClass(); int inClassRef() { static void byRef(ref noreturn n) {} HasNoreturnClass hn = new HasNoreturnClass(); byRef(hn.n); return 0; } enum forceInClassRef = inClassRef(); */ enum throwEnum = throw new Exception(""); /* https://issues.dlang.org/show_bug.cgi?id=23063 TEST_OUTPUT: --- fail_compilation/noreturn.d(135): Error: Accessed expression of type `noreturn` fail_compilation/noreturn.d(138): called from here: `func()` --- */ noreturn func() { noreturn a; return a; } enum f = func(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail163.d0000644000175000017500000000322315205374123020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail163.d(11): Error: cannot implicitly convert expression `q` of type `const(char)[]` to `char[]` --- */ void test1() { char[] p; const(char)[] q; p = q; } /* TEST_OUTPUT: --- fail_compilation/fail163.d(25): Error: cannot implicitly convert `const(int***)` to `const(int)***` fail_compilation/fail163.d(25): Note: Converting const to mutable requires an explicit cast (`cast(int*)`). --- */ void test2() { const int*** p; const(int)*** cp; cp = p; } /* TEST_OUTPUT: --- fail_compilation/fail163.d(38): Error: cannot modify `const` expression `p` --- */ void test3() { const(uint***) p; const(int)*** cp; p = cp; } /* TEST_OUTPUT: --- fail_compilation/fail163.d(51): Error: cannot implicitly convert expression `cp` of type `const(int)***[]` to `const(uint***)[]` --- */ void test4() { const(uint***)[] p; const(int)***[] cp; p = cp; } /* TEST_OUTPUT: --- fail_compilation/fail163.d(64): Error: cannot modify `const` expression `*p` --- */ void test5() { int x; const(int)* p = &x; *p = 3; } /* TEST_OUTPUT: --- fail_compilation/fail163.d(77): Error: cannot implicitly convert expression `& x` of type `int*` to `immutable(int)*` fail_compilation/fail163.d(78): Error: cannot modify `immutable` expression `*p` --- */ void test6() { int x; immutable(int)* p = &x; *p = 3; } /* TEST_OUTPUT: --- fail_compilation/fail163.d(91): Error: cannot implicitly convert `const(int)*` to `int*` fail_compilation/fail163.d(91): Note: Converting const to mutable requires an explicit cast (`cast(int*)`). --- */ void test7() { const(int) x = 3; int* p = &x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail284.d0000644000175000017500000000047215205374123020746 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail284.d(19): Error: `pure` function `fail284.foo` cannot call impure function pointer `a` --- */ static int nasty; int impure_evil_function(int x) { nasty++; return nasty; } pure int foo(int x) { int function(int) a = &impure_evil_function; return a(x); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16284.d0000644000175000017500000000106315205374123021156 0ustar fabiofabio/* REQUIRED_ARGS: -preview=fieldwise TEST_OUTPUT: --- fail_compilation/test16284.d(24): Error: reinterpretation through overlapped field `s` is not allowed in CTFE fail_compilation/test16284.d(27): called from here: `test()` fail_compilation/test16284.d(27): while evaluating: `static assert(test())` --- */ // https://issues.dlang.org/show_bug.cgi?id=16284 struct S {} struct T { union {int i; S s;} this(uint dummy) { s = S.init; } } bool test() { auto t1 = T(0); auto t2 = T(0); return t1 == t2; } static assert(test()); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail243.d0000644000175000017500000000143515205374123020741 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail243.d(23): Deprecation: class `fail243.DepClass` is deprecated fail_compilation/fail243.d(24): Deprecation: struct `fail243.DepStruct` is deprecated fail_compilation/fail243.d(25): Deprecation: union `fail243.DepUnion` is deprecated fail_compilation/fail243.d(26): Deprecation: enum `fail243.DepEnum` is deprecated fail_compilation/fail243.d(27): Deprecation: alias `fail243.DepAlias` is deprecated --- */ deprecated { class DepClass {} struct DepStruct {} union DepUnion {} enum DepEnum { A } alias int DepAlias; //typedef int DepTypedef; } void func(DepClass obj) {} void func(DepStruct obj) {} void func(DepUnion obj) {} void func(DepEnum obj) {} void func(DepAlias obj) {} //void func(DepTypedef obj) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag7477.d0000644000175000017500000000045615205374123021034 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag7477.d(13): Error: cannot generate 0 value of type `Foo` for `a` fail_compilation/diag7477.d(20): Error: cannot generate 0 value of type `string` for `a` --- */ struct Foo { int x; } enum Bar : Foo { a, b, c } enum Baz : string { a, b, } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13333.d0000644000175000017500000000147415205374123021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag13333.d(29): Error: template instance `VariantN!(maxSize!(S), T)` recursive template expansion fail_compilation/diag13333.d(29): Error: template instance `diag13333.maxSize!(S)` error instantiating fail_compilation/diag13333.d(34): instantiated from here: `Algebraic!(S)` --- */ template maxSize(T...) { static if (T.length == 1) { enum size_t maxSize = T[0].sizeof; } else { enum size_t maxSize = T[0].sizeof >= maxSize!(T[1 .. $]) ? T[0].sizeof : maxSize!(T[1 .. $]); } } struct VariantN(size_t maxDataSize, AllowedTypesX...) { } template Algebraic(T...) { alias Algebraic = VariantN!(maxSize!T, T); } struct DummyScope { alias A = Algebraic!S; static struct S // <- class { A entity; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag_err1.d0000644000175000017500000000162615205374123021434 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag_err1.d(21): Error: undefined identifier `x` fail_compilation/diag_err1.d(21): while evaluating `pragma(msg, [1, 2, x].length)` fail_compilation/diag_err1.d(22): Error: undefined identifier `x` fail_compilation/diag_err1.d(22): Error: undefined identifier `y` fail_compilation/diag_err1.d(22): while evaluating `pragma(msg, (x + y).sizeof)` fail_compilation/diag_err1.d(23): Error: undefined identifier `x` fail_compilation/diag_err1.d(23): while evaluating `pragma(msg, (n += x).sizeof)` fail_compilation/diag_err1.d(24): Error: incompatible types for `(s) ~ (n)`: `string` and `int` fail_compilation/diag_err1.d(24): while evaluating `pragma(msg, (s ~ n).sizeof)` --- */ void main() { int n; string s; pragma(msg, [1,2,x].length); pragma(msg, (x + y).sizeof); pragma(msg, (n += x).sizeof); pragma(msg, (s ~ n).sizeof); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21314.d0000644000175000017500000000053615205374123021104 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21314 /* TEST_OUTPUT: --- fail_compilation/fail21314.d(10): Error: variable `fail21314.C21314.c21314` cannot have `extern(C++)` linkage because it is `static` fail_compilation/fail21314.d(10): perhaps declare it as `__gshared` instead --- */ extern(C++) class C21314 { static C21314[] c21314; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/trait_loc_ov_err.d0000644000175000017500000000261415205374123023131 0ustar fabiofabiomodule trait_loc_ov_err; /* TEST_OUTPUT: --- fail_compilation/trait_loc_ov_err.d(24): Error: cannot get location of an overload set, use `__traits(getOverloads, ..., "ov1")[N]` to get the Nth overload fail_compilation/trait_loc_ov_err.d(25): Error: cannot get location of an overload set, use `__traits(getOverloads, ..., "ov2")[N]` to get the Nth overload --- */ void ov1(){} void ov1(int){} void ov21(){} void ov22(int){} alias ov2 = ov21; alias ov2 = ov22; template OvT(T, U){} template OvT(T){} auto func(T)(T t) {} auto func(T,U)(T t,U u) {} enum e1 = __traits(getLocation, ov1); enum e2 = __traits(getLocation, ov2); enum e3 = __traits(getLocation, OvT); enum e4 = __traits(getLocation, func); enum e5 = __traits(getLocation, __traits(getOverloads, trait_loc_ov_err, "ov1")[0]); enum e6 = __traits(getLocation, __traits(getOverloads, trait_loc_ov_err, "ov1")[1]); enum e7 = __traits(getLocation, __traits(getOverloads, trait_loc_ov_err, "ov2")[0]); enum e8 = __traits(getLocation, __traits(getOverloads, trait_loc_ov_err, "ov2")[1]); enum e9 = __traits(getLocation, __traits(getOverloads, trait_loc_ov_err, "OvT", true)[1]); enum e10 = __traits(getLocation, __traits(getOverloads, trait_loc_ov_err, "OvT", true)[0]); enum e11 = __traits(getLocation, __traits(getOverloads, trait_loc_ov_err, "func", true)[0]); enum e12 = __traits(getLocation, __traits(getOverloads, trait_loc_ov_err, "func", true)[1]); ./ldc-1.42.0-src/tests/dmd/fail_compilation/goto_skip.d0000644000175000017500000000173515205374123021576 0ustar fabiofabio/* REQUIRED_ARGS: -verrors=context TEST_OUTPUT: --- fail_compilation/goto_skip.d(28): Error: `goto` skips declaration of variable `goto_skip.skip.ch` goto Lskip; ^ fail_compilation/goto_skip.d(29): declared here char ch = '!'; ^ fail_compilation/goto_skip.d(36): Error: `goto` skips declaration of `with` temporary goto L1; ^ fail_compilation/goto_skip.d(38): declared here with (S()) { ^ fail_compilation/goto_skip.d(46): Error: `goto` skips declaration of variable `goto_skip.test8.e` goto L2; ^ fail_compilation/goto_skip.d(51): declared here catch (Exception e) { ^ --- */ char skip(bool b) { if (b) goto Lskip; char ch = '!'; Lskip: return ch; } int f() { goto L1; struct S { int e = 5; } with (S()) { L1: return e; } } void test8(int a) { goto L2; try { a += 2; } catch (Exception e) { a += 3; L2: ; a += 100; } assert(a == 100); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21096.d0000644000175000017500000000044415205374123021155 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21096 /* TEST_OUTPUT: --- fail_compilation/test21096.d(11): Error: identifier or new keyword expected following `(...)`. fail_compilation/test21096.d(11): Error: variable name expected after type `char[(__error)]`, not `;` --- */ char[(void*).]; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19757_m64.d0000644000175000017500000000030615205374123021607 0ustar fabiofabio// REQUIRED_ARGS: -m64 /* TEST_OUTPUT: --- fail_compilation/fail19757_m64.d(9): Error: cannot implicitly convert expression `"oops"` of type `string` to `ulong` --- */ auto s = new string("oops"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12809.d0000644000175000017500000000373215205374123021116 0ustar fabiofabio// REQUIRED_ARGS: -o- bool cond; /* TEST_OUTPUT: --- fail_compilation/fail12809.d(18): Error: `object.Exception` is thrown but not caught fail_compilation/fail12809.d(15): Error: function `fail12809.test_finally1` may throw but is marked as `nothrow` fail_compilation/fail12809.d(34): Error: `object.Exception` is thrown but not caught fail_compilation/fail12809.d(38): Error: `object.Exception` is thrown but not caught fail_compilation/fail12809.d(31): Error: function `fail12809.test_finally3` may throw but is marked as `nothrow` --- */ void test_finally1() nothrow { try throw new Exception(""); // error finally {} } void test_finally2() nothrow { try throw new Exception(""); // no error finally assert(0); // unconditional halt } void test_finally3() nothrow { try throw new Exception(""); // error finally { if (cond) throw new Exception(""); // error assert(0); // conditional halt } } /* TEST_OUTPUT: --- fail_compilation/fail12809.d(58): Error: `object.Exception` is thrown but not caught fail_compilation/fail12809.d(53): Error: function `fail12809.test_finally4` may throw but is marked as `nothrow` fail_compilation/fail12809.d(74): Error: `object.Exception` is thrown but not caught fail_compilation/fail12809.d(78): Error: `object.Exception` is thrown but not caught fail_compilation/fail12809.d(69): Error: function `fail12809.test_finally6` may throw but is marked as `nothrow` --- */ void test_finally4() nothrow { try {} finally throw new Exception(""); // error } void test_finally5() nothrow { try assert(0); // unconditional halt finally throw new Exception(""); // no error } void test_finally6() nothrow { try { if (cond) throw new Exception(""); // error assert(0); // conditional halt } finally throw new Exception(""); // error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail290.d0000644000175000017500000000030715205374123020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail290.d(15): Error: no `this` to create delegate for `foo` --- */ struct Foo { void foo(int x) {} } void main() { void delegate (int) a = &Foo.foo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14416.d0000644000175000017500000000024415205374123021105 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail14416.d(13): Error: template `S(T)` does not have property `sizeof` --- */ struct S(T) { int x; } enum n = S.sizeof; ./ldc-1.42.0-src/tests/dmd/fail_compilation/invalid_lib.d0000644000175000017500000000110215205374123022040 0ustar fabiofabio/* DISABLED: LDC // no library scanning from LDC side REQUIRED_ARGS: -lib REQUIRED_ARGS(linux freebsd osx openbsd): fail_compilation/extra-files/fake.a REQUIRED_ARGS(windows): -m32 fail_compilation/extra-files/fake.lib Use a regex because the path is really strange on Azure (OMF_32, 64): {{RESULTS_DIR}}\fail_compilation\{{RESULTS_DIR}}\fail_compilation\invalid_omf_0.obj TEST_OUTPUT: ---- Error: corrupt $?:windows=MS Coff|osx=Mach|ELF$ object `$r:.*$` module $?:windows=fail_compilation\extra-files\fake.lib|fail_compilation/extra-files/fake.a$ $n$ ---- */ void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice18469.d0000644000175000017500000000032715205374123020750 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice18469.d(10): Error: no property `opCall` for `this.~this()` of type `void` --- */ class Bar { ~this(){} this(){alias T = typeof(Bar.__dtor.opCall);} } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14249.d0000644000175000017500000000352315205374123021114 0ustar fabiofabio/* REQUIRED_ARGS: -unittest TEST_OUTPUT: --- fail_compilation/fail14249.d(21): Error: `shared static` constructor can only be member of module/aggregate/template, not function `main` fail_compilation/fail14249.d(22): Error: `shared static` destructor can only be member of module/aggregate/template, not function `main` fail_compilation/fail14249.d(23): Error: `static` constructor can only be member of module/aggregate/template, not function `main` fail_compilation/fail14249.d(24): Error: `static` destructor can only be member of module/aggregate/template, not function `main` fail_compilation/fail14249.d(25): Error: `unittest` can only be a member of module/aggregate/template, not function `main` fail_compilation/fail14249.d(26): Error: `invariant` can only be a member of aggregate, not function `main` fail_compilation/fail14249.d(27): Error: alias this can only be a member of aggregate, not function `main` fail_compilation/fail14249.d(28): Error: constructor can only be a member of aggregate, not function `main` fail_compilation/fail14249.d(29): Error: destructor can only be a member of aggregate, not function `main` fail_compilation/fail14249.d(30): Error: postblit can only be a member of struct, not function `main` fail_compilation/fail14249.d(31): Error: anonymous union can only be a part of an aggregate, not function `main` fail_compilation/fail14249.d(35): Error: mixin `fail14249.main.Mix!()` error instantiating --- */ mixin template Mix() { shared static this() {} shared static ~this() {} static this() {} // from fail197.d, 1510 ICE: Assertion failure: 'ad' on line 925 in file 'func.c' static ~this() {} unittest {} invariant {} alias a this; this() {} // from fail268.d ~this() {} // from fail268.d this(this) {} union { int x; double y; } } void main() { mixin Mix!(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/tolvalue.d0000644000175000017500000000312715205374123021430 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/tolvalue.d(28): Error: cannot take address of template `templateFunc(T)()`, perhaps instantiate it first fail_compilation/tolvalue.d(29): Error: cannot take address of type `int` fail_compilation/tolvalue.d(30): Error: cannot take address of constant `3` fail_compilation/tolvalue.d(31): Error: cannot take address of operator `$` fail_compilation/tolvalue.d(32): Error: cannot take address of compiler-generated variable `__ctfe` fail_compilation/tolvalue.d(33): Error: cannot take address of manifest constant `f` fail_compilation/tolvalue.d(38): Error: cannot create default argument for `ref` / `out` parameter from constant `3` fail_compilation/tolvalue.d(39): Error: cannot create default argument for `ref` / `out` parameter from compiler-generated variable `__ctfe` fail_compilation/tolvalue.d(40): Error: cannot create default argument for `ref` / `out` parameter from manifest constant `f` fail_compilation/tolvalue.d(45): Error: cannot modify constant `3` fail_compilation/tolvalue.d(46): Error: cannot modify compiler-generated variable `__ctfe` fail_compilation/tolvalue.d(47): Error: cannot modify manifest constant `f` --- */ // https://issues.dlang.org/show_bug.cgi?id=24238 void templateFunc(T)() {} alias intAlias = int; enum E { f } void addr() { int[] a; auto x0 = &templateFunc; auto x1 = &intAlias; auto x2 = &3; auto x3 = a[&$]; auto x4 = &__ctfe; auto x6 = &E.f; } void refArg() { void f0(ref int = 3) {} void f1(ref bool = __ctfe) {} void f3(ref E = E.f) {} } void inc(int lz) { 3++; __ctfe++; E.f++; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/previewin.d0000644000175000017500000000567215205374123021614 0ustar fabiofabio/* REQUIRED_ARGS: -preview=in -preview=dip1000 TEST_OUTPUT: ---- fail_compilation/previewin.d(4): Error: function `takeFunction` is not callable using argument types `(void function(real x) pure nothrow @nogc @safe)` fail_compilation/previewin.d(4): cannot pass argument `(real x) { }` of type `void function(real x) pure nothrow @nogc @safe` to parameter `void function(in real) f` fail_compilation/previewin.d(11): `previewin.takeFunction(void function(in real) f)` declared here fail_compilation/previewin.d(5): Error: function `takeFunction` is not callable using argument types `(void function(scope const(real) x) pure nothrow @nogc @safe)` fail_compilation/previewin.d(5): cannot pass argument `(scope const(real) x) { }` of type `void function(scope const(real) x) pure nothrow @nogc @safe` to parameter `void function(in real) f` fail_compilation/previewin.d(11): `previewin.takeFunction(void function(in real) f)` declared here fail_compilation/previewin.d(6): Error: function `takeFunction` is not callable using argument types `(void function(ref scope const(real) x) pure nothrow @nogc @safe)` fail_compilation/previewin.d(6): cannot pass argument `(ref scope const(real) x) { }` of type `void function(ref scope const(real) x) pure nothrow @nogc @safe` to parameter `void function(in real) f` fail_compilation/previewin.d(11): `previewin.takeFunction(void function(in real) f)` declared here fail_compilation/previewin.d(15): Error: assigning scope variable `arg` to global variable `myGlobal` is not allowed in a `@safe` function fail_compilation/previewin.d(16): Error: assigning scope variable `arg` to global variable `myGlobal` is not allowed in a `@safe` function fail_compilation/previewin.d(17): Error: scope parameter `arg` may not be returned fail_compilation/previewin.d(18): Error: assigning scope variable `arg` to `ref` variable `escape` with longer lifetime is not allowed in a `@safe` function fail_compilation/previewin.d(22): Error: escaping a reference to parameter `arg` by returning `arg` is not allowed in a `@safe` function fail_compilation/previewin.d(22): perhaps annotate the parameter with `return` ---- */ #line 1 void main () { // No covariance without explicit `in` takeFunction((real x) {}); takeFunction((const scope real x) {}); takeFunction((const scope ref real x) {}); tryEscape("Hello World"); // Yes by `tryEscape` is NG } void takeFunction(void function(in real) f); // Make sure things cannot be escaped (`scope` is applied) const(char)[] myGlobal; void tryEscape(in char[] arg) @safe { myGlobal = arg; } void tryEscape2(scope const char[] arg) @safe { myGlobal = arg; } const(char)[] tryEscape3(in char[] arg) @safe { return arg; } void tryEscape4(in char[] arg, ref const(char)[] escape) @safe { escape = arg; } // Okay: value type ulong[8] tryEscape5(in ulong[8] arg) @safe { return arg; } // NG: Ref ref const(ulong[8]) tryEscape6(in ulong[8] arg) @safe { return arg; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13356.d0000644000175000017500000000155415205374123020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13356.d(32): Error: template instance `Algebraic!(Tuple!(List))` recursive template expansion fail_compilation/ice13356.d(15): Error: template instance `ice13356.isPrintable!(List)` error instantiating fail_compilation/ice13356.d(33): instantiated from here: `Tuple!(List)` --- */ struct Tuple(Types...) { Types expand; alias expand this; static if (isPrintable!(Types[0])) { } } // T == Tuple!List, and accessing its .init will cause unresolved forward reference enum bool isPrintable(T) = is(typeof({ T t; })); struct Algebraic(AllowedTypesX...) { alias AllowedTypes = AllowedTypesX; double x; // dummy for the syntax Payload(d) } struct List { alias Payload = Algebraic!( Tuple!(List) ); Payload payload; this(double d) { payload = Payload(d); } } void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/biterrors4.d0000644000175000017500000000034415205374123021672 0ustar fabiofabio/* REQUIRED_ARGS: -preview=bitfields * TEST_OUTPUT: --- fail_compilation/biterrors4.d(109): Error: cannot take address of bitfield `s.a` --- */ #line 100 struct S { int a:3; } void test() { S s; int* p = &s.a; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail220.d0000644000175000017500000000105515205374123020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail220.d(12): Error: identifier expected for template value parameter fail_compilation/fail220.d(12): Error: found `==` when expecting `)` fail_compilation/fail220.d(12): Error: found `class` when expecting `)` fail_compilation/fail220.d(12): Error: declaration expected, not `)` fail_compilation/fail220.d(16): Error: unmatched closing brace --- */ template types (T) { static if (is (T V : V[K], K == class)) { static assert (false, "assoc"); } static const int types = 4; } int i = types!(int); ./ldc-1.42.0-src/tests/dmd/fail_compilation/failasm2.d0000644000175000017500000000260315205374123021271 0ustar fabiofabio/* DISABLED: LDC_not_x86 LDC // compiles without errors REQUIRED_ARGS: -m32 TEST_OUTPUT: --- fail_compilation/failasm2.d(108): Error: operand size for opcode `inc` is ambiguous, add `ptr byte/short/int/long` prefix fail_compilation/failasm2.d(110): Error: operand size for opcode `dec` is ambiguous, add `ptr byte/short/int/long` prefix fail_compilation/failasm2.d(111): Error: operand size for opcode `imul` is ambiguous, add `ptr byte/short/int/long` prefix fail_compilation/failasm2.d(112): Error: operand size for opcode `idiv` is ambiguous, add `ptr byte/short/int/long` prefix fail_compilation/failasm2.d(113): Error: operand size for opcode `mul` is ambiguous, add `ptr byte/short/int/long` prefix fail_compilation/failasm2.d(114): Error: operand size for opcode `div` is ambiguous, add `ptr byte/short/int/long` prefix fail_compilation/failasm2.d(115): Error: operand size for opcode `neg` is ambiguous, add `ptr byte/short/int/long` prefix fail_compilation/failasm2.d(116): Error: operand size for opcode `not` is ambiguous, add `ptr byte/short/int/long` prefix --- */ #line 100 // https://issues.dlang.org/show_bug.cgi?id=2617 uint test2617() { asm { naked; inc [EAX]; inc byte ptr [EAX]; dec [EAX]; imul [EAX]; idiv [EAX]; mul [EAX]; div [EAX]; neg [EAX]; not [EAX]; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/cppeh1.d0000644000175000017500000000064515205374124020760 0ustar fabiofabio// DISABLED: win32 win64 /* TEST_OUTPUT: --- fail_compilation/cppeh1.d(26): Error: catching C++ class objects is not allowed in a `@safe` function --- */ version (Windows) static assert(0, "This test should not run on this platform"); extern (C++, std) { class exception { } } @safe: void bar(); void abc(); void foo() { try { bar(); } catch (std.exception e) { abc(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test4946.d0000644000175000017500000000177015205374124021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test4946.d(13): Error: 'pure' cannot be placed after a template constraint fail_compilation/test4946.d(14): Error: 'const' cannot be placed after a template constraint fail_compilation/test4946.d(15): Error: 'immutable' cannot be placed after a template constraint fail_compilation/test4946.d(16): Error: 'inout' cannot be placed after a template constraint fail_compilation/test4946.d(17): Error: 'shared' cannot be placed after a template constraint fail_compilation/test4946.d(18): Error: 'nothrow' cannot be placed after a template constraint fail_compilation/test4946.d(19): Error: attributes cannot be placed after a template constraint --- */ void bar1(int x)() if (x > 0) pure { int a;} void bar2(int x)() if (x > 0) const { int a;} void bar3(int x)() if (x > 0) immutable { int a;} void bar4(int x)() if (x > 0) inout { int a;} void bar5(int x)() if (x > 0) shared { int a;} void bar6(int x)() if (x > 0) nothrow { int a;} void bar7(int x)() if (x > 0) @safe { int a;} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_scope.d0000644000175000017500000000626215205374124021705 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail_scope.d(43): Error: returning `cast(char[])string` escapes a reference to local variable `string` fail_compilation/fail_scope.d(61): Error: returning `s.bar()` escapes a reference to local variable `s` fail_compilation/fail_scope.d(72): Error: `fail_scope.foo8` called with argument types `(int)` matches multiple overloads exactly: fail_compilation/fail_scope.d(66): `fail_scope.foo8(ref int x)` and: fail_compilation/fail_scope.d(67): `fail_scope.foo8(return ref int x)` fail_compilation/fail_scope.d(80): Error: returning `& string` escapes a reference to local variable `string` fail_compilation/fail_scope.d(90): Error: returning `cast(int[])a` escapes a reference to local variable `a` fail_compilation/fail_scope.d(98): Error: returning `cast(int[])a` escapes a reference to local variable `a` fail_compilation/fail_scope.d(106): Error: escaping reference to outer local variable `x` fail_compilation/fail_scope.d(135): Error: returning `foo16226(i)` escapes a reference to local variable `i` --- //fail_compilation/fail_scope.d(35): Error: scope variable `da` may not be returned //fail_compilation/fail_scope.d(37): Error: scope variable `o` may not be returned //fail_compilation/fail_scope.d(38): Error: scope variable `dg` may not be returned //fail_compilation/fail_scope.d(40): Error: scope variable `p` may not be returned */ alias int delegate() dg_t; int[] checkEscapeScope1(scope int[] da) { return da; } int[3] checkEscapeScope2(scope int[3] sa) { return sa; } Object checkEscapeScope3(scope Object o) { return o; } dg_t checkEscapeScope4(scope dg_t dg) { return dg; } int[] checkEscapeScope1() { scope int[] da = []; return da; } int[3] checkEscapeScope2() { scope int[3] sa = [1,2,3]; return sa; } Object checkEscapeScope3() { scope Object o = new Object; return o; } // same with fail7294.d dg_t checkEscapeScope4() { scope dg_t dg = () => 1; return dg; } int* test(scope int* p) @safe { return p; } char[] foo140() { char[4] string = "abcd"; return string; } /************/ struct S { int x; ref int bar() return { return x; } } ref int test() { S s; return s.bar(); } /************/ ref int foo8(ref int x); ref int foo8(return ref int x); void testover() { int x; foo8(x); } /************/ char* fail141() { char[4] string = "abcd"; return string.ptr; } /************/ int[] test1313b() out{} do { int[2] a; return a; } int[] test1313a() //out{} do { int[2] a; return a; } /******************/ // https://issues.dlang.org/show_bug.cgi?id=15192 ref int fun15192(ref int x) @safe { ref int bar(){ return x; } return bar(); } ref int fun15192_2(return ref int x) @safe { ref int bar(){ return x; } return bar(); } /**************************/ // https://issues.dlang.org/show_bug.cgi?id=15193 ref int foo15193()@safe{ struct S{ int x; ref int bar() { return x; } } S s; return s.bar(); } /*****************************/ // https://issues.dlang.org/show_bug.cgi?id=16226 ref int test16226() @safe { int i; return foo16226(i); } ref foo16226(ref int bar) @safe { return bar; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag15713.d0000644000175000017500000000247315205374124021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag15713.d(20): Error: no property `widthSign` for `this` of type `diag15713.WrData.Data` fail_compilation/diag15713.d(16): struct `Data` defined here fail_compilation/diag15713.d(40): Error: template instance `diag15713.conwritefImpl!("parse-int", "width", "\n", Data(null))` error instantiating fail_compilation/diag15713.d(45): instantiated from here: `conwritefImpl!("main", "\n", Data(null))` fail_compilation/diag15713.d(50): instantiated from here: `fdwritef!()` --- */ void wrWriteWidthChar() {} auto WrData(int , int ) { struct Data { auto initInt(string name)() { __traits(getMember, this, name ~ "Sign"); } } return Data(); } template conwritefImpl(string state, string field, string fmt, alias data, AA...) if (state == "parse-int") { enum conwritefImpl = data.initInt!field; } template baz(string state, string fmt, alias data, AA...) {} template bar(string state, string fmt, alias data, AA...) {} enum a = "parse-format"; template conwritefImpl(string state, string fmt, alias data, AA...) if (state == "main") { enum conwritefImpl = conwritefImpl!("parse-int", "width", fmt, data); } void fdwritef()() { conwritefImpl!("main", "\n", WrData(0, 0)); } void conwriteln() { fdwritef(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice16657.d0000644000175000017500000000053415205374124020746 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice16657.d(9): Error: function `ice16657.RefCounted.refCountedPayload` has no `return` statement, but is expected to return a value of type `inout(RefCounted)` --- */ struct RefCounted { inout(RefCounted) refCountedPayload() inout { } alias refCountedPayload this; } struct Store { RefCounted p; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12838.d0000644000175000017500000000054415205374124020744 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12838.d(27): Error: cannot implicitly convert expression `1` of type `int` to `string` --- */ struct Tuple(T...) { T field; alias field this; } struct Data { string a; } template toTuple(T) { mixin(`alias toTuple = Tuple!(string);`); } void main() { toTuple!Data a; a[0] = 1; // ICE! } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail24.d0000644000175000017500000000111115205374124020646 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail24.d(11): Error: alias `fail24.strtype` conflicts with alias `fail24.strtype` at fail_compilation/fail24.d(10) fail_compilation/fail24.d(12): Error: alias `fail24.strtype` conflicts with alias `fail24.strtype` at fail_compilation/fail24.d(11) fail_compilation/fail24.d(13): Error: alias `fail24.strtype` conflicts with alias `fail24.strtype` at fail_compilation/fail24.d(12) --- */ alias char[] strtype; alias char[64] strtype; alias char[128] strtype; alias char[256] strtype; int main() { printf("%u", strtype.sizeof); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17275.d0000644000175000017500000000067215205374124021121 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17275.d(12): Error: undefined identifier `ModuleGroup`, did you mean function `moduleGroup`? fail_compilation/fail17275.d(12): Error: `inout` on `return` means `inout` must be on a parameter as well for `inout(ModuleGroup)()` --- */ // https://issues.dlang.org/show_bug.cgi?id=17275 struct DSO { inout(ModuleGroup) moduleGroup() { } } struct ThreadDSO { DSO* _pdso; void[] _tlsRange; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail237.d0000644000175000017500000000052615205374124020745 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail237.d(11): Error: undefined identifier `a` in module `fail237` fail_compilation/fail237.d(11): while evaluating: `static assert(module fail237.a!().b)` --- */ // https://issues.dlang.org/show_bug.cgi?id=581 // Error message w/o line number in dot-instantiated template static assert(.a!().b); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail5953s2.d0000644000175000017500000000047215205374124021304 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail5953s2.d(12): Error: expression expected, not `,` fail_compilation/fail5953s2.d(12): Error: expression expected, not `,` fail_compilation/fail5953s2.d(12): Error: expression expected, not `,` --- */ void main() { struct S{} S s3 = {,,,}; // invalid, but compiles } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11552.d0000644000175000017500000000024515205374124021105 0ustar fabiofabio/* REQUIRED_ARGS: -o- TEST_OUTPUT: --- fail_compilation/fail11552.d(11): Error: function `D main` label `label` is undefined --- */ void main() { goto label; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22039.d0000644000175000017500000000052715205374124021112 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22039 /* TEST_OUTPUT: --- fail_compilation/fail22039.d(11): Error: recursive evaluation of `func()` fail_compilation/fail22039.d(14): Error: recursive evaluation of `gun(func2())` --- */ int func(int x = func()) { return x; } int gun() { return 2; } int func2(int x = gun(func2())) { return x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17842.d0000644000175000017500000000122015205374124021107 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 * TEST_OUTPUT: --- fail_compilation/fail17842.d(14): Error: assigning scope variable `p` to non-scope `*q` is not allowed in a `@safe` function fail_compilation/fail17842.d(23): Error: copying scope variable `obj` into allocated memory is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=17842 void* testp(scope void* p) @safe { scope void** q; *q = p; // error void** t; *t = *q; return *t; } Object testobj(scope Object obj) @safe { scope Object[] arr; arr ~= obj; // error Object[] array; array ~= arr; return array[0]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/verrors0.d0000644000175000017500000000431215205374124021355 0ustar fabiofabio// REQUIRED_ARGS: -verrors=0 void main() { { T a; } // 1 { T a; } // 2 { T a; } // 3 { T a; } // 4 { T a; } // 5 { T a; } // 6 { T a; } // 7 { T a; } // 8 { T a; } // 9 { T a; } // 10 { T a; } // 11 { T a; } // 12 { T a; } // 13 { T a; } // 14 { T a; } // 15 { T a; } // 16 { T a; } // 17 { T a; } // 18 { T a; } // 19 { T a; } // 20 (default limit) { T a; } // 21 { T a; } // 22 { T a; } // 23 { T a; } // 24 { T a; } // 25 } /* TEST_OUTPUT: --- fail_compilation/verrors0.d(5): Error: undefined identifier `T` fail_compilation/verrors0.d(6): Error: undefined identifier `T` fail_compilation/verrors0.d(7): Error: undefined identifier `T` fail_compilation/verrors0.d(8): Error: undefined identifier `T` fail_compilation/verrors0.d(9): Error: undefined identifier `T` fail_compilation/verrors0.d(10): Error: undefined identifier `T` fail_compilation/verrors0.d(11): Error: undefined identifier `T` fail_compilation/verrors0.d(12): Error: undefined identifier `T` fail_compilation/verrors0.d(13): Error: undefined identifier `T` fail_compilation/verrors0.d(14): Error: undefined identifier `T` fail_compilation/verrors0.d(15): Error: undefined identifier `T` fail_compilation/verrors0.d(16): Error: undefined identifier `T` fail_compilation/verrors0.d(17): Error: undefined identifier `T` fail_compilation/verrors0.d(18): Error: undefined identifier `T` fail_compilation/verrors0.d(19): Error: undefined identifier `T` fail_compilation/verrors0.d(20): Error: undefined identifier `T` fail_compilation/verrors0.d(21): Error: undefined identifier `T` fail_compilation/verrors0.d(22): Error: undefined identifier `T` fail_compilation/verrors0.d(23): Error: undefined identifier `T` fail_compilation/verrors0.d(24): Error: undefined identifier `T` fail_compilation/verrors0.d(25): Error: undefined identifier `T` fail_compilation/verrors0.d(26): Error: undefined identifier `T` fail_compilation/verrors0.d(27): Error: undefined identifier `T` fail_compilation/verrors0.d(28): Error: undefined identifier `T` fail_compilation/verrors0.d(29): Error: undefined identifier `T` --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail45.d0000644000175000017500000000024715205374124020662 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail45.d(10): Error: variable `fail45.main.O` cannot be declared to be a function --- */ void main() { typeof(main) O = 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8101.d0000644000175000017500000000566215205374124021022 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8101.d(62): Error: function `f_0` is not callable using argument types `()` fail_compilation/diag8101.d(62): too few arguments, expected 1, got 0 fail_compilation/diag8101.d(34): `diag8101.f_0(int)` declared here fail_compilation/diag8101.d(63): Error: none of the overloads of `f_1` are callable using argument types `()` fail_compilation/diag8101.d(36): Candidates are: `diag8101.f_1(int)` fail_compilation/diag8101.d(37): `diag8101.f_1(int, int)` fail_compilation/diag8101.d(64): Error: none of the overloads of `f_2` are callable using argument types `()` fail_compilation/diag8101.d(39): Candidates are: `diag8101.f_2(int)` fail_compilation/diag8101.d(40): `diag8101.f_2(int, int)` fail_compilation/diag8101.d(41): `diag8101.f_2(int, int, int)` fail_compilation/diag8101.d(42): `diag8101.f_2(int, int, int, int)` fail_compilation/diag8101.d(43): `diag8101.f_2(int, int, int, int, int)` fail_compilation/diag8101.d(44): `diag8101.f_2(int, int, int, int, int, int)` fail_compilation/diag8101.d(64): ... (1 more, -v to show) ... fail_compilation/diag8101.d(66): Error: template `t_0` is not callable using argument types `!()()` fail_compilation/diag8101.d(47): Candidate is: `t_0(T1)()` fail_compilation/diag8101.d(67): Error: none of the overloads of template `diag8101.t_1` are callable using argument types `!()()` fail_compilation/diag8101.d(49): Candidates are: `t_1(T1)()` fail_compilation/diag8101.d(50): `t_1(T1, T2)()` fail_compilation/diag8101.d(68): Error: none of the overloads of template `diag8101.t_2` are callable using argument types `!()()` fail_compilation/diag8101.d(52): Candidates are: `t_2(T1)()` fail_compilation/diag8101.d(53): `t_2(T1, T2)()` fail_compilation/diag8101.d(54): `t_2(T1, T2, T3)()` fail_compilation/diag8101.d(55): `t_2(T1, T2, T3, T4)()` fail_compilation/diag8101.d(56): `t_2(T1, T2, T3, T4, T5)()` fail_compilation/diag8101.d(57): `t_2(T1, T2, T3, T4, T5, T6)()` fail_compilation/diag8101.d(68): ... (1 more, -v to show) ... --- */ void f_0(int); void f_1(int); void f_1(int, int); void f_2(int); void f_2(int, int); void f_2(int, int, int); void f_2(int, int, int, int); void f_2(int, int, int, int, int); void f_2(int, int, int, int, int, int); void f_2(int, int, int, int, int, int, int); void t_0(T1)(); void t_1(T1)(); void t_1(T1, T2)(); void t_2(T1)(); void t_2(T1, T2)(); void t_2(T1, T2, T3)(); void t_2(T1, T2, T3, T4)(); void t_2(T1, T2, T3, T4, T5)(); void t_2(T1, T2, T3, T4, T5, T6)(); void t_2(T1, T2, T3, T4, T5, T6, T7)(); void main() { f_0(); f_1(); f_2(); t_0(); t_1(); t_2(); } // ignored deprecated void f_2(char); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22529.d0000644000175000017500000000032515205374124021112 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22529 /* TEST_OUTPUT: --- fail_compilation/fail22529.d(13): Error: found `return` when expecting `;` following expression --- */ void main() { foo() return; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/e7804_1.d0000644000175000017500000000075415205374124020570 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/e7804_1.d(14): Error: undefined identifier `Aggr` fail_compilation/e7804_1.d(15): Error: unrecognized trait `farfelu` fail_compilation/e7804_1.d(17): Error: undefined identifier `Aggr` fail_compilation/e7804_1.d(18): Error: unrecognized trait `farfelu` --- */ module e7804_1; struct S {} __traits(farfelu, Aggr, "member") a; __traits(farfelu, S, "member") a2; alias foo = __traits(farfelu, Aggr, "member"); alias foo2 = __traits(farfelu, S, "member"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18236.d0000644000175000017500000000033615205374124021114 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail18236.d(20): Error: cannot cast expression `V(12)` of type `V` to `int` --- */ struct V { int a; } struct S { enum A = V(12); } void main() { int b = cast(int)S.A; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice21060.d0000644000175000017500000000073015205374124020724 0ustar fabiofabio/* EXTRA_FILES: imports/ice21060a/package.d imports/ice21060b/package.d imports/ice21060c/package.d imports/ice21060d/package.d TEST_OUTPUT: --- fail_compilation/imports/ice21060b/package.d(3): Error: struct `imports.ice21060d.P21060` already exists at fail_compilation/imports/ice21060d/package.d(3). Perhaps in another function with the same name? --- */ struct S21060 { void print() { import imports.ice21060a; import imports.ice21060b; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice8795b.d0000644000175000017500000000033615205374124021034 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice8795b.d-mixin-8(8): Error: { } expected following `interface` declaration fail_compilation/ice8795b.d-mixin-8(8): Error: anonymous interfaces not allowed --- */ mixin("interface;"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6107.d0000644000175000017500000000070715205374124021030 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail6107.d(12): Error: variable name `__ctor` is not allowed fail_compilation/fail6107.d(12): identifiers starting with `__` are reserved for internal use fail_compilation/fail6107.d(16): Error: variable name `__ctor` is not allowed fail_compilation/fail6107.d(16): identifiers starting with `__` are reserved for internal use --- */ struct Foo { enum __ctor = 4; } class Bar { int __ctor = 4; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b19717a.d0000644000175000017500000000077515205374124020577 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/b19717a.d(14): Error: forward reference to template `a` fail_compilation/b19717a.d(14): Error: forward reference to template `a` fail_compilation/b19717a.d(14): Error: none of the overloads of `a` are callable using argument types `()` fail_compilation/b19717a.d(13): Candidates are: `b19717a.a(int b)` fail_compilation/b19717a.d(14): `b19717a.a(int b = a)` --- */ module b19717a; auto a(int b) {} auto a(int b = a) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue22682.d0000644000175000017500000000114515205374124021330 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/issue22682.d(13): Error: `pragma(mangle)` expects string literal argument for mangled name fail_compilation/issue22682.d(14): Error: `pragma(mangle)` expects string literal argument for mangled name fail_compilation/issue22682.d(15): Error: `string` expected for pragma mangle argument, not `(0)` of type `int` fail_compilation/issue22682.d(16): Error: `pragma(mangle)` expects string literal argument for mangled name --- */ module issue22682; void main() { pragma(mangle) {} pragma(mangle) static int i0; pragma(mangle, 0) static int i1; pragma(mangle); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/alias_instance_member.d0000644000175000017500000000103615205374124024077 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/alias_instance_member.d(18): Error: cannot alias variable member `v` of variable `that` fail_compilation/alias_instance_member.d(18): Use `typeof(that)` instead to preserve behaviour --- */ @__edition_latest_do_not_use module aim; struct Foo { int v; void test(Foo that) const { alias a = this.v; // OK alias b = that.v; assert(&a is &b); alias b2 = typeof(that).v; // OK } } void main() { Foo a = Foo(1); Foo b = Foo(2); a.test(b); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_arrayop2.d0000644000175000017500000003434415205374124022335 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/fail_arrayop2.d(13): Error: array operation `[1, 2, 3] - [1, 2, 3]` without destination memory not allowed fail_compilation/fail_arrayop2.d(16): Error: invalid array operation `"a" - "b"` (possible missing []) --- */ void test2603() // https://issues.dlang.org/show_bug.cgi?id=2603 - ICE(cgcs.c) on subtracting string literals { auto c1 = [1,2,3] - [1,2,3]; // this variation is wrong code on D2, ICE ..\ztc\cgcs.c 358 on D1. string c2 = "a" - "b"; } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop2.d(38): Error: array operation `-a[]` without destination memory not allowed (possible missing []) fail_compilation/fail_arrayop2.d(39): Error: array operation `~a[]` without destination memory not allowed (possible missing []) fail_compilation/fail_arrayop2.d(41): Error: array operation `a[] + a[]` without destination memory not allowed (possible missing []) fail_compilation/fail_arrayop2.d(42): Error: array operation `a[] - a[]` without destination memory not allowed (possible missing []) fail_compilation/fail_arrayop2.d(43): Error: array operation `a[] * a[]` without destination memory not allowed (possible missing []) fail_compilation/fail_arrayop2.d(44): Error: array operation `a[] / a[]` without destination memory not allowed (possible missing []) fail_compilation/fail_arrayop2.d(45): Error: array operation `a[] % a[]` without destination memory not allowed (possible missing []) fail_compilation/fail_arrayop2.d(46): Error: array operation `a[] ^ a[]` without destination memory not allowed (possible missing []) fail_compilation/fail_arrayop2.d(47): Error: array operation `a[] & a[]` without destination memory not allowed (possible missing []) fail_compilation/fail_arrayop2.d(48): Error: array operation `a[] | a[]` without destination memory not allowed (possible missing []) fail_compilation/fail_arrayop2.d(49): Error: array operation `a[] ^^ a[]` without destination memory not allowed (possible missing []) --- */ void test9459() { int[] a = [1, 2, 3]; a = -a[]; a = ~a[]; a = a[] + a[]; a = a[] - a[]; a = a[] * a[]; a = a[] / a[]; a = a[] % a[]; a = a[] ^ a[]; a = a[] & a[]; a = a[] | a[]; a = a[] ^^ a[]; } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop2.d(75): Error: array operation `a[] + a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(76): Error: array operation `a[] - a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(77): Error: array operation `a[] * a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(78): Error: array operation `a[] / a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(79): Error: array operation `a[] % a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(80): Error: array operation `a[] ^ a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(81): Error: array operation `a[] & a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(82): Error: array operation `a[] | a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(83): Error: array operation `a[] ^^ 10` without destination memory not allowed fail_compilation/fail_arrayop2.d(84): Error: array operation `-a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(85): Error: array operation `~a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(90): Error: array operation `[1] + a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(91): Error: array operation `[1] + a[]` without destination memory not allowed --- */ void test12179() { void foo(int[]) {} int[1] a; foo(a[] + a[]); foo(a[] - a[]); foo(a[] * a[]); foo(a[] / a[]); foo(a[] % a[]); foo(a[] ^ a[]); foo(a[] & a[]); foo(a[] | a[]); foo(a[] ^^ 10); foo(-a[]); foo(~a[]); // from https://issues.dlang.org/show_bug.cgi?id=11992 int[] arr1; int[][] arr2; arr1 ~= [1] + a[]; // NG arr2 ~= [1] + a[]; // NG } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop2.d(105): Error: array operation `h * y[]` without destination memory not allowed --- */ void test12381() { double[2] y; double h; double[2] temp1 = cast(double[2])(h * y[]); } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop2.d(118): Error: array operation `-a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(120): Error: array operation `(-a[])[0..4]` without destination memory not allowed --- */ float[] test12769(float[] a) { if (a.length < 4) return -a[]; else return (-a[])[0..4]; } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop2.d(137): Error: array operation `a[] - a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(139): Error: array operation `a[] - a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(140): Error: array operation `a[] - a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(143): Error: array operation `a[] - a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(145): Error: array operation `a[] - a[]` without destination memory not allowed --- */ void test13208() { int[] a; auto arr = [a[] - a[]][0]; auto aa1 = [1 : a[] - a[]]; auto aa2 = [a[] - a[] : 1]; struct S { int[] a; } auto s = S(a[] - a[]); auto n = int(a[] - a[]); } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop2.d(160): Error: array operation `a[] * a[]` without destination memory not allowed fail_compilation/fail_arrayop2.d(161): Error: array operation `(a[] * a[])[0..1]` without destination memory not allowed fail_compilation/fail_arrayop2.d(164): Error: array operation `a[] * a[]` without destination memory not allowed (possible missing []) fail_compilation/fail_arrayop2.d(165): Error: array operation `(a[] * a[])[0..1]` without destination memory not allowed (possible missing []) --- */ void test13497() { int[1] a; auto b1 = (a[] * a[])[]; auto b2 = (a[] * a[])[0..1]; int[] c; c = (a[] * a[])[]; c = (a[] * a[])[0..1]; } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop2.d(181): Error: array operation `data[segmentId][28..29] & cast(ubyte)(1 << 0)` without destination memory not allowed --- */ void test13910() { ubyte[][] data; size_t segmentId; bool isGroup() { return !!((data[segmentId][28..29]) & (1 << 0)); } } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop2.d(195): Error: array operation `a[] + 1` without destination memory not allowed fail_compilation/fail_arrayop2.d(195): Error: array operation `a[] * 2` without destination memory not allowed --- */ void test14895() { int[] a; int[] b = (a[] + 1) ~ a[] * 2; } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop2.d(247): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(248): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(249): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(253): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(256): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(265): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(268): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(269): Error: array operation `"abc"[] + '\x01'` without destination memory not allowed fail_compilation/fail_arrayop2.d(272): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(275): Error: cannot take address of expression `([1] * 6)[0..2]` because it is not an lvalue fail_compilation/fail_arrayop2.d(278): Error: can only `*` a pointer, not a `int[]` fail_compilation/fail_arrayop2.d(284): Error: array operation `da[] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(287): Error: array operation `da[] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(290): Error: cannot modify expression `[1] * 6` because it is not an lvalue fail_compilation/fail_arrayop2.d(291): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(294): Error: cannot modify expression `[1] * 6` because it is not an lvalue fail_compilation/fail_arrayop2.d(295): Error: cannot modify expression `([1] * 6)[]` because it is not an lvalue fail_compilation/fail_arrayop2.d(298): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(299): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(300): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(303): Error: cannot modify expression `[1] * 6` because it is not an lvalue fail_compilation/fail_arrayop2.d(304): Error: cannot modify expression `[1] * 6` because it is not an lvalue fail_compilation/fail_arrayop2.d(307): Error: `[1] * 6` is not of integral type, it is a `int[]` fail_compilation/fail_arrayop2.d(308): Error: `[1] * 6` is not of integral type, it is a `int[]` fail_compilation/fail_arrayop2.d(309): Error: `[1] * 6` is not of integral type, it is a `int[]` fail_compilation/fail_arrayop2.d(312): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(313): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(316): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(317): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(318): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(321): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(321): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(321): Error: array operation `[1] * 6` without destination memory not allowed --- */ // Test all expressions, which can take arrays as their operands but cannot be a part of array operation. void test15407exp() { struct S { int[] a; } void f(int[] a) {} int[] da; int[6] sa; { auto r = [[1] * 6]; } // ArrayLiteralExp { auto r = [[1] * 6 : [1] * 6]; } // AssocArrayLiteralExp //TupleExp // StructLiteralExp.elements <- preFunctionParameters in CallExp { auto r = S([1] * 6); } // NewExp.arguments <- preFunctionParameters { auto r = new S([1] * 6); } // TODO: TypeidExp //auto ti = typeid([1] * 6); //auto foo(T)(T t) {} //foo(typeid([1] * 6)); //auto a = [typeid([1] * 6)]; // CommaExp.e1 { auto r = ([1] * 6, 1); } // AssertExp assert([1] * 6, cast(char)1 + "abc"[]); // CallExp.arguments <- preFunctionParameters f([1] * 6); // AddrExp, if a CT-known length slice can become an TypeSarray lvalue in the future. { auto r = &(([1] * 6)[0..2]); } // PtrExp, *([1] * 6).ptr is also invalid -> show better diagnostic { auto r = *([1] * 6); } // TypeDArray.dotExp, cannot check in ArrayLengthExp.semantic() { auto r = (6 * da[]).length; } // IndexExp - e1 { auto x1 = (da[] * 6)[1]; } // Pre, PostExp - e1 ([1] * 6)++; --([1] * 6); // AssignExp e1 ([1] * 6) = 10; ([1] * 6)[] = 10; // BinAssignExp e1 ([1] * 6) += 1; ([1] * 6)[] *= 2; ([1] * 6)[] ^^= 3; // CatExp e1 ([1] * 6) ~= 1; ([1] * 6)[] ~= 2; // Shl, Shr, UshrExp - e1, e2 --> checkIntegralBin { auto r = ([1] * 6) << 1; } { auto r = ([1] * 6) >> 1; } { auto r = ([1] * 6) >>> 1; } // AndAnd, OrOrExp - e1, e2 { auto r = sa[0..5] && [1] * 6; } { auto r = sa[0..5] || [1] * 6; } // Cmp, Equal, IdentityExp - e1, e2 { auto r = sa[0..5] <= [1] * 6; } { auto r = sa[0..5] == [1] * 6; } { auto r = sa[0..5] is [1] * 6; } // CondExp - econd, e1, e2 { auto r = [1] * 6 ? [1] * 6 : [1] * 6; } } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop2.d(342): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(345): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(348): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(349): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(350): Deprecation: `[1] * 6` has no effect fail_compilation/fail_arrayop2.d(350): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(353): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(356): Error: array operation `[1] * 6` without destination memory not allowed fail_compilation/fail_arrayop2.d(359): Error: array operation `"str"[] + cast(immutable(char))1` without destination memory not allowed fail_compilation/fail_arrayop2.d(367): Error: CTFE internal error: non-constant value `"uvt"` fail_compilation/fail_arrayop2.d(367): Error: `"uvt"[] - '\x01'` cannot be interpreted at compile time --- */ // Test all statements, which can take arrays as their operands. void test15407stmt() { // ExpStatement - exp [1] * 6; // DoStatement - condition do {} while ([1] * 6); // ForStatement - condition, increment for ([1] * 6; // init == ExpStatement [1] * 6; [1] * 6) {} // ForeachStatement - aggr -> lowered to ForStatement foreach (e; [1] * 6) {} // IfStatement condition if ([1] * 6) {} // SwitchStatement - condition switch ("str"[] + 1) { case "tus": break; default: break; } // CaseStatement - exp switch ("tus") { case "uvt"[] - 1: break; default: break; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail96.d0000644000175000017500000000051115205374124020662 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail96.d(21): Error: template instance `foo!long` `foo` is not a template declaration, it is a function alias --- */ // https://issues.dlang.org/show_bug.cgi?id=153 template bar(T) { void foo() {} } alias bar!(long).foo foo; alias bar!(char).foo foo; void main() { foo!(long); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/binexperr.d0000644000175000017500000000036715205374124021577 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/binexperr.d(12): Error: expression expected, not `)` fail_compilation/binexperr.d(12): Error: missing closing `)` after `if (A1 * (__error)` --- */ void main() { struct A1 {} if (A1*) {} return; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail189.d0000644000175000017500000000024515205374124020751 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail189.d(10): Error: undefined identifier `foo` --- */ void bar() { foo(); // should fail } version(none): void foo() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18372.d0000644000175000017500000000051015205374124021107 0ustar fabiofabio/* DISABLED: win32 win64 linux32 osx32 freebsd32 openbsd32 LDC TEST_OUTPUT: --- fail_compilation/fail18372.d(103): Error: `__va_list_tag` is not defined, perhaps `import core.stdc.stdarg;` ? --- */ #line 100 // https://issues.dlang.org/show_bug.cgi?id=18372 void fun(const(char)* a, ...) { } void test() { fun("abc"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/foreach.d0000644000175000017500000000063515205374124021206 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/foreach.d(12): Error: cannot declare `out` loop variable, use `ref` instead fail_compilation/foreach.d(13): Error: cannot declare `out` loop variable, use `ref` instead fail_compilation/foreach.d(13): Error: cannot declare `out` loop variable, use `ref` instead --- */ void main () { int[] array; foreach (out val; array) {} foreach (out idx, out val; array) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice1144.d0000644000175000017500000000077415205374124020655 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice1144.d(14): Error: undefined identifier `a` fail_compilation/ice1144.d(23): Error: template instance `ice1144.testHelper!("hello", "world")` error instantiating --- */ // https://issues.dlang.org/show_bug.cgi?id=1144 // ICE(template.c) template mixin causes DMD crash char[] testHelper(A ...)() { char[] result; foreach (t; a) { result ~= "int " ~ t ~ ";\n"; } return result; } void main() { mixin(testHelper!("hello", "world")()); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10806.d0000644000175000017500000000062315205374124021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10806.d(12): Error: function `fail10806.Class.clone` incompatible covariant types `First()` and `Second()` --- */ interface First { First clone(); } interface Second { Second clone(); void call(); } class Class : First, Second { override Class clone() { return this; } override void call() { } } void main() { (cast(Second) new Class).clone().call(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17868b.d0000644000175000017500000000112115205374124021325 0ustar fabiofabio/* DISABLED: LDC // passes due to slightly different semantics TEST_OUTPUT: ---- fail_compilation/test17868b.d(9): Error: pragma `crt_constructor` can only apply to a single declaration fail_compilation/test17868b.d(14): Error: function `test17868b.bar` must return `void` for `pragma(crt_constructor)` fail_compilation/test17868b.d(18): Error: function `test17868b.baz` must be `extern(C)` for `pragma(crt_constructor)` when taking parameters ---- */ pragma(crt_constructor): void foo() { } extern(C) int bar() { } void baz(int argc, char** argv) { } extern(C) void bazC(int, char**) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13938.d0000644000175000017500000000036515205374124021122 0ustar fabiofabio// REQUIRED_ARGS: -o- /* DISABLED: LDC // works as expected TEST_OUTPUT: --- fail_compilation/fail13938.d(14): Error: cannot directly load TLS variable `val` --- */ void test1() { static int val; asm { mov EAX, val; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail2195.d0000644000175000017500000000120415205374124021024 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=2195 // REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail2195.d(17): Deprecation: variable `variable` is shadowing variable `fail2195.main.variable` fail_compilation/fail2195.d(14): declared here --- */ void main() { int[int] arr; int variable; foreach (i, j; arr) { int variable; // shadowing is disallowed but not detected } } void fun() { int var1, var2, var3; void gun() { int var1; // OK? int[] arr; foreach (i, var2; arr) {} // OK? int[int] aa; foreach (k, var3; aa) {} // Not OK?? } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail222.d0000644000175000017500000000127215205374124020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail222.d(11): Error: template `fail222.getMixin(TArg..., int i = 0)()` template sequence parameter must be the last one fail_compilation/fail222.d(18): Error: template instance `getMixin!()` does not match template declaration `getMixin(TArg..., int i = 0)()` fail_compilation/fail222.d(21): Error: template instance `fail222.Thing!()` error instantiating fail_compilation/fail222.d(23): Error: template `fail222.fooBar(A..., B...)()` template sequence parameter must be the last one --- */ string getMixin(TArg..., int i = 0)() { return ``; } class Thing(TArg...) { mixin(getMixin!(TArg)()); } public Thing!() stuff; void fooBar (A..., B...)() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6497.d0000644000175000017500000000102515205374124021036 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail6497.d(13): Error: taking the address of stack-allocated local variable `n` is not allowed in a `@safe` function fail_compilation/fail6497.d(13): Error: taking the address of stack-allocated local variable `n` is not allowed in a `@safe` function fail_compilation/fail6497.d(19): Error: taking the address of local variable `i` is not allowed in a `@safe` function --- */ void main() @safe { int n; auto b = &(0 ? n : n); } void f() @safe { ref i = *new int; auto b = &i; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3673a.d0000644000175000017500000000023015205374124021165 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail3673a.d(8): Error: template constraints only allowed for templates --- */ class A {} class B : A if(false) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b20011.d0000644000175000017500000000401415205374124020377 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/b20011.d(28): Error: cannot modify expression `S1(cast(ubyte)0u).member` because it is not an lvalue fail_compilation/b20011.d(31): Error: cannot modify expression `S2(null).member` because it is not an lvalue fail_compilation/b20011.d(32): Error: cannot modify expression `S2(null).member` because it is not an lvalue fail_compilation/b20011.d(35): Error: cannot modify expression `U1(cast(ubyte)0u, ).m2` because it is not an lvalue fail_compilation/b20011.d(40): Error: function `assignableByRef` is not callable using argument types `(ubyte)` fail_compilation/b20011.d(40): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `ref ubyte p` fail_compilation/b20011.d(37): `b20011.main.assignableByRef(ref ubyte p)` declared here fail_compilation/b20011.d(41): Error: function `assignableByOut` is not callable using argument types `(ubyte)` fail_compilation/b20011.d(41): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `out ubyte p` fail_compilation/b20011.d(38): `b20011.main.assignableByOut(out ubyte p)` declared here fail_compilation/b20011.d(42): Error: function `assignableByConstRef` is not callable using argument types `(ubyte)` fail_compilation/b20011.d(42): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `ref const(ubyte) p` fail_compilation/b20011.d(39): `b20011.main.assignableByConstRef(ref const(ubyte) p)` declared here --- */ module b20011; struct S1 { ubyte member; } struct S2 { ubyte[] member; } union U1 { ubyte m1; int m2; } void main() { enum S1 s1 = {}; s1.member = 42; enum S2 s2 = {}; s2.member = []; s2.member ~= []; enum U1 u1 = {m1 : 0}; u1.m2 = 42; void assignableByRef(ref ubyte p){ p = 42; } void assignableByOut(out ubyte p){ p = 42; } void assignableByConstRef(ref const ubyte p){} assignableByRef(s1.member); assignableByOut(s1.member); assignableByConstRef(s1.member); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11822.d0000644000175000017500000000114715205374124020734 0ustar fabiofabio // REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/ice11822.d(33): Deprecation: function `ice11822.d` is deprecated fail_compilation/ice11822.d(16): instantiated from here: `__lambda_L33_C15!int` fail_compilation/ice11822.d(22): instantiated from here: `S!(__lambda_L33_C15)` fail_compilation/ice11822.d(33): instantiated from here: `g!((n) => d(i))` --- */ struct S(alias pred) { this(int) { pred(1); } void f() { pred(2); } } auto g(alias pred)() { return S!pred(3); } deprecated bool d(int) { return true; } auto h() { int i; return g!(n => d(i))(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/cerrors.d0000644000175000017500000000127715205374124021261 0ustar fabiofabio/* REQUIRED_ARGS: -wi TEST_OUTPUT: --- fail_compilation/cerrors.d(13): Error: C preprocessor directive `#if` is not supported, use `version` or `static if` fail_compilation/cerrors.d(13): Error: declaration expected, not `#` fail_compilation/cerrors.d(17): Error: C preprocessor directive `#endif` is not supported fail_compilation/cerrors.d(17): Error: declaration expected, not `#` fail_compilation/cerrors.d(21): Error: token string requires valid D tokens, not `#if` fail_compilation/cerrors.d(22): Deprecation: token string requires valid D tokens, not `#include` --- */ #if 1 void test(wchar_t u); #endif // https://issues.dlang.org/show_bug.cgi?id=23792 enum s1 = q{ #if 1 #include }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/parse12924.d0000644000175000017500000000155315205374124021313 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/parse12924.d(14): Error: declaration expected following attribute, not `;` fail_compilation/parse12924.d(15): Error: declaration expected following attribute, not `;` fail_compilation/parse12924.d(16): Error: declaration expected following attribute, not `;` fail_compilation/parse12924.d(17): Error: declaration expected following attribute, not `;` fail_compilation/parse12924.d(18): Error: declaration expected following attribute, not `;` fail_compilation/parse12924.d(19): Error: declaration expected following attribute, not `;` fail_compilation/parse12924.d(20): Error: declaration expected following attribute, not `;` --- */ static; void f1() {} deprecated; void f2() {} deprecated(""); void f3() {} extern(C); void f4() {} public; void f5() {} align(1); void f6() {} @(1); void f7() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail353.d0000644000175000017500000000062015205374124020737 0ustar fabiofabio// DISABLED: LDC // DMD assembler restriction test - not clear how this applies to LDC. void foo() { enum NOP = 0x9090_9090_9090_9090; asm { L1: dq NOP,NOP,NOP,NOP; // 32 dq NOP,NOP,NOP,NOP; // 64 dq NOP,NOP,NOP,NOP; // 96 dq NOP,NOP,NOP,NOP; // 128 // unnoticed signed underflow of rel8 with DMD2.056 loop L1; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/named_arguments_error.d0000644000175000017500000000512715205374124024162 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/named_arguments_error.d(38): Error: function `f` is not callable using argument types `(int, int, int)` fail_compilation/named_arguments_error.d(38): parameter `x` assigned twice fail_compilation/named_arguments_error.d(32): `named_arguments_error.f(int x, int y, int z)` declared here fail_compilation/named_arguments_error.d(39): Error: function `f` is not callable using argument types `(int, int, int)` fail_compilation/named_arguments_error.d(39): argument `4` goes past end of parameter list fail_compilation/named_arguments_error.d(32): `named_arguments_error.f(int x, int y, int z)` declared here fail_compilation/named_arguments_error.d(40): Error: function `f` is not callable using argument types `(int, int, int)` fail_compilation/named_arguments_error.d(40): parameter `y` assigned twice fail_compilation/named_arguments_error.d(32): `named_arguments_error.f(int x, int y, int z)` declared here fail_compilation/named_arguments_error.d(41): Error: function `f` is not callable using argument types `(int, int, int)` fail_compilation/named_arguments_error.d(41): no parameter named `a` fail_compilation/named_arguments_error.d(32): `named_arguments_error.f(int x, int y, int z)` declared here fail_compilation/named_arguments_error.d(42): Error: function `g` is not callable using argument types `(int, int)` fail_compilation/named_arguments_error.d(42): missing argument for parameter #1: `int x` fail_compilation/named_arguments_error.d(34): `named_arguments_error.g(int x, int y, int z = 3)` declared here fail_compilation/named_arguments_error.d(44): Error: no named argument `element` allowed for array dimension fail_compilation/named_arguments_error.d(45): Error: no named argument `number` allowed for scalar fail_compilation/named_arguments_error.d(46): Error: cannot implicitly convert expression `g(x: 3, y: 4, z: 5)` of type `int` to `string` fail_compilation/named_arguments_error.d(47): Error: template `tempfun` is not callable using argument types `!()(int, int)` fail_compilation/named_arguments_error.d(47): argument `1` goes past end of parameter list fail_compilation/named_arguments_error.d(50): Candidate is: `tempfun(T, U)(T t, U u)` --- */ void f(int x, int y, int z); int g(int x, int y, int z = 3); void main() { f(x: 3, x: 3, 5); f(z: 3, 4, 5); f(y: 3, x: 4, 5); f(a: 3, b: 4, 5); g(y: 4, z: 3); auto g0 = new int[](element: 3); auto g1 = new int(number: 3); string s = g(x: 3, y: 4, z: 5); enum x = tempfun(u: 0, 1); } int tempfun(T, U)(T t, U u) { return 3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3354.d0000644000175000017500000000103515205374124021024 0ustar fabiofabio/* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/fail3354.d(18): Error: too many operands for instruction fail_compilation/fail3354.d(18): Error: wrong number of operands fail_compilation/fail3354.d(19): Error: too many operands for instruction fail_compilation/fail3354.d(19): Error: wrong number of operands --- */ void main() { version(D_InlineAsm_X86) {} else version(D_InlineAsm_X86_64) {} else static assert(0); asm { fldz ST(0), ST(1), ST(2), ST(3); fld ST(0), ST(1), ST(2), ST(3); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375b.d0000644000175000017500000000051615205374124021175 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375b.d(15): Error: else is dangling, add { } after condition at fail_compilation/fail4375b.d(11) --- */ void main() { // disallowed if (true) foreach (i; 0 .. 5) if (true) assert(5); else assert(6); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9210a.d0000644000175000017500000000042515205374124021155 0ustar fabiofabio// REQUIRED_ARGS: -o- // EXTRA_FILES: imports/diag9210b.d imports/diag9210c.d imports/diag9210stdcomplex.d imports/diag9210stdtraits.d /* TEST_OUTPUT: --- fail_compilation/imports/diag9210b.d(6): Error: undefined identifier `A` --- */ import imports.diag9210b; interface A {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail344.d0000644000175000017500000000166615205374124020752 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=3737 /* TEST_OUTPUT: --- fail_compilation/fail344.d(20): Error: undefined identifier `Q` fail_compilation/fail344.d(20): Error: undefined identifier `Q` fail_compilation/fail344.d(20): Error: undefined identifier `V` fail_compilation/fail344.d(23): while evaluating: `static assert(Alike!(SIB!(crayon)))` fail_compilation/fail344.d(23): Error: template instance `fail344.SIB!(crayon).SIB.Alike!(SIB!(crayon))` error instantiating fail_compilation/fail344.d(23): while evaluating: `static assert(Alike!(SIB!(crayon)))` fail_compilation/fail344.d(28): Error: template instance `fail344.SIB!(crayon).SIB.opDispatch!"E"` error instantiating --- */ int crayon; struct SIB(alias junk) { template Alike(V) { enum bool Alike = Q == V.garbage; } void opDispatch(string s)() { static assert(Alike!(SIB!(crayon))); } } void main() { SIB!(SIB!(crayon).E)(3.0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7751.d0000644000175000017500000000056615205374124021041 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7751.d(15): Error: no constructor for `Foo` fail_compilation/fail7751.d(23): Error: template instance `fail7751.foo!int` error instantiating --- */ class Foo(T) { T x; Foo y; } auto foo(T)(T x, Foo!T y=null) { return new Foo!T(x, y); } void bar(U)(U foo, U[] spam=[]) { spam ~= []; } void main() { bar(foo(0)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail346.d0000644000175000017500000000110115205374124020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail346.d(15): Error: undefined identifier `P` fail_compilation/fail346.d(15): Error: variable `fail346.S.T!0.T` - cannot use template to add field to aggregate `S` fail_compilation/fail346.d(20): Error: template instance `fail346.S.T!0` error instantiating fail_compilation/fail346.d(23): instantiated from here: `V!(S, 0)` --- */ struct S { int x; template T(int val) { const P T = { val }; // the P here is an error it should be S } } template V(R,int val){ const R V=R.T!(val); } const S x = V!(S,0); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21651.d0000644000175000017500000000043515205374124021153 0ustar fabiofabio// 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; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24015.d0000644000175000017500000000063215205374124021147 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 * TEST_OUTPUT: --- fail_compilation/test24015.d(19): Error: assigning scope variable `v` to non-scope parameter `...` calling `jer` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=24105 @safe: extern (C) void ben(int i, scope ...); extern (C) void jer(int i, ...); void bar(scope const char* v) { ben(3, v); jer(3, v); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24110.d0000644000175000017500000000042315205374124021141 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24110 /* TEST_OUTPUT: --- fail_compilation/test24110.d(12): Error: static assert: `__traits(compiles, __error)` is false --- */ struct S { int x; } alias T = shared S; static assert(__traits(compiles, (T[] a, T[] b) => a < b)); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6781.d0000644000175000017500000000057315205374124021041 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail6781.d(9): Error: undefined identifier `some_error` fail_compilation/fail6781.d(14): Error: template instance `fail6781.C6781.makeSortedIndices.bug6781!(greater)` error instantiating --- */ void bug6781(alias xxx)() { some_error; } struct C6781 { void makeSortedIndices() { int greater; bug6781!greater(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17646.d0000644000175000017500000000075715205374124021127 0ustar fabiofabio/* REQUIRED_ARGS: -o- EXTRA_FILES: imports/fail17646.d TEST_OUTPUT: --- fail_compilation/imports/fail17646.d(10): Error: found `}` instead of statement fail_compilation/fail17646.d(15): Error: template instance `allTestData!Modules` template `allTestData` is not defined fail_compilation/fail17646.d(18): Error: template instance `fail17646.runTests!""` error instantiating --- */ int runTests(Modules...)() { import imports.fail17646; allTestData!Modules; } alias fail = runTests!""; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag15001.d0000644000175000017500000000024115205374124021063 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/diag15001.d(11): Error: undefined identifier `X` --- */ void main() { if (X x = 1) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18057b.d0000644000175000017500000000044315205374124021256 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/fail18057b.d(12): Error: variable `fail18057b.Recursive.field` recursive initialization of field --- */ // https://issues.dlang.org/show_bug.cgi?id=18057 // Recursive field initializer causes segfault. struct Recursive { int field = Recursive(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375j.d0000644000175000017500000000060215205374124021201 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375j.d(15): Error: else is dangling, add { } after condition at fail_compilation/fail4375j.d(10) --- */ void main() { if (true) final switch (1) // o_O case 1: if (false) assert(119); else assert(120); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18127.d0000644000175000017500000002140015205374124021152 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/imports/imp18127b.c(3): Error: struct `struct_or_union` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(3): previously declared here fail_compilation/imports/imp18127b.c(3): `imp18127b.struct_or_union` is a struct while `imp18127a.struct_or_union` is a union fail_compilation/imports/imp18127b.c(3): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(8): Error: struct `S_n_fields` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(8): previously declared here fail_compilation/imports/imp18127b.c(8): `imp18127b.S_n_fields` has 1 field(s) while `imp18127a.S_n_fields` has 2 field(s) fail_compilation/imports/imp18127b.c(8): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(13): Error: struct `S_types` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(13): previously declared here fail_compilation/imports/imp18127b.c(14): Field 0 differs in type fail_compilation/imports/imp18127b.c(14): typeof(x): int fail_compilation/imports/imp18127a.c(14): typeof(x): float fail_compilation/imports/imp18127b.c(13): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(18): Error: struct `S_names` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(18): previously declared here fail_compilation/imports/imp18127b.c(19): Field 0 differs in name fail_compilation/imports/imp18127b.c(19): y fail_compilation/imports/imp18127a.c(19): x fail_compilation/imports/imp18127b.c(18): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(22): Error: struct `B` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(22): previously declared here fail_compilation/imports/imp18127b.c(23): Field 0 differs in type fail_compilation/imports/imp18127b.c(23): typeof(x): float fail_compilation/imports/imp18127a.c(23): typeof(x): int fail_compilation/imports/imp18127b.c(22): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(27): Error: struct `S_b` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(27): previously declared here fail_compilation/imports/imp18127b.c(27): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(33): Error: struct `(anonymous struct)` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(33): previously declared here fail_compilation/imports/imp18127b.c(34): Field 0 differs in type fail_compilation/imports/imp18127b.c(34): typeof(x): float fail_compilation/imports/imp18127a.c(34): typeof(x): int fail_compilation/imports/imp18127b.c(32): Error: struct `S_contains_anon_named` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(32): previously declared here fail_compilation/imports/imp18127b.c(35): Field 0 differs in type fail_compilation/imports/imp18127b.c(35): typeof(a): (anonymous struct) fail_compilation/imports/imp18127a.c(35): typeof(a): (anonymous struct) fail_compilation/imports/imp18127b.c(32): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(38): Error: struct `S_contains_anon_unnamed` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(38): previously declared here fail_compilation/imports/imp18127b.c(40): Field 0 differs in type fail_compilation/imports/imp18127b.c(40): typeof(x): float fail_compilation/imports/imp18127a.c(40): typeof(x): int fail_compilation/imports/imp18127b.c(38): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(45): Error: struct `S_bitfields_mismatch1` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(45): previously declared here fail_compilation/imports/imp18127b.c(47): Field 1 differs in being a bitfield fail_compilation/imports/imp18127b.c(47): `imp18127b.S_bitfields_mismatch1.y` is not a bitfield fail_compilation/imports/imp18127a.c(47): `imp18127a.S_bitfields_mismatch1.y` is a bitfield fail_compilation/imports/imp18127b.c(45): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(49): Error: struct `S_bitfields_mismatch2` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(49): previously declared here fail_compilation/imports/imp18127b.c(50): Field 0 differs in being a bitfield fail_compilation/imports/imp18127b.c(50): `imp18127b.S_bitfields_mismatch2.x` *is a bitfield fail_compilation/imports/imp18127a.c(50): `imp18127a.S_bitfields_mismatch2.x` is not a bitfield fail_compilation/imports/imp18127b.c(49): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(54): Error: struct `S_bitfields_widths` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(54): previously declared here fail_compilation/imports/imp18127b.c(56): Field 1 differs in bitfield width fail_compilation/imports/imp18127b.c(56): `imp18127b.S_bitfields_widths.y`: 2 fail_compilation/imports/imp18127a.c(56): `imp18127a.S_bitfields_widths.y`: 1 fail_compilation/imports/imp18127b.c(54): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(59): Error: struct `S_bitfields_anon` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(59): previously declared here fail_compilation/imports/imp18127b.c(61): Field 1 differs in name fail_compilation/imports/imp18127b.c(61): y fail_compilation/imports/imp18127a.c(61): (anonymous) fail_compilation/imports/imp18127b.c(59): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(65): Error: struct `S_alignas` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(65): previously declared here fail_compilation/imports/imp18127b.c(66): Field 0 differs in alignment or packing fail_compilation/imports/imp18127b.c(66): `imp18127b.S_alignas.x` alignment: default fail_compilation/imports/imp18127a.c(66): `imp18127a.S_alignas.x` alignment: 8 fail_compilation/imports/imp18127b.c(65): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(68): Error: struct `S_aligned` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(68): previously declared here fail_compilation/imports/imp18127b.c(68): `imp18127b.S_aligned` has different alignment or packing fail_compilation/imports/imp18127b.c(68): `imp18127b.S_aligned` alignment: 4 fail_compilation/imports/imp18127a.c(68): `imp18127a.S_aligned` alignment: 8 fail_compilation/imports/imp18127b.c(68): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(73): Error: struct `S_pack_1` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(73): previously declared here fail_compilation/imports/imp18127b.c(73): `imp18127b.S_pack_1` has different alignment or packing fail_compilation/imports/imp18127b.c(73): `imp18127b.S_pack_1` alignment: default fail_compilation/imports/imp18127a.c(73): `imp18127a.S_pack_1` alignment: 1 fail_compilation/imports/imp18127b.c(73): `imp18127b.S_pack_1` packed: false fail_compilation/imports/imp18127a.c(73): `imp18127a.S_pack_1` packed: true fail_compilation/imports/imp18127b.c(73): C structs with the same name from different imports are merged fail_compilation/imports/imp18127b.c(77): Error: struct `S_pack_2` already exists with an incompatible definition. fail_compilation/imports/imp18127a.c(79): previously declared here fail_compilation/imports/imp18127b.c(77): `imp18127b.S_pack_2` has different alignment or packing fail_compilation/imports/imp18127b.c(77): `imp18127b.S_pack_2` alignment: default fail_compilation/imports/imp18127a.c(79): `imp18127a.S_pack_2` alignment: 1 fail_compilation/imports/imp18127b.c(77): C structs with the same name from different imports are merged --- */ // https://github.com/dlang/dmd/issues/18127 import imports.imp18127a; import imports.imp18127b; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test5412b.d0000644000175000017500000000046315205374124021233 0ustar fabiofabio/* EXTRA_FILES: imports/test5412a.d imports/test5412b.d TEST_OUTPUT: --- fail_compilation/test5412b.d(11): Error: static import `test5412b.A` conflicts with import `test5412b.A` at fail_compilation/test5412b.d(10) --- */ module test5412b; import A = imports.test5412a; static import A = imports.test5412b; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test19473.d0000644000175000017500000000100615205374124021157 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test19473.d(15): Error: union `test19473.P` no size because of forward reference fail_compilation/test19473.d(31): error on member `test19473.P.p` --- */ // https://issues.dlang.org/show_bug.cgi?id=19473 struct A { P p; struct UTpl() { union { P p; } } alias U = UTpl!(); } alias B = A.U; struct C { union D { B b; } } union P { C.D p; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19890a.d0000644000175000017500000000040715205374124021263 0ustar fabiofabio/* REQUIRED_ARGS: -m32 DISABLED: LDC // no static array size limits TEST_OUTPUT: --- fail_compilation/fail19890a.d(8): Error: `void[cast(size_t)4294967295]` size 1 * 4294967295 exceeds 0x7fffffff size limit for static array --- */ void[] f = cast(void[-1]) "a"; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail304.d0000644000175000017500000000046415205374124020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail304.d(15): Error: cannot cast expression `foo()` of type `Small` to `Large` because of different sizes --- */ struct Small { uint x; } struct Large { uint x, y, z; } Small foo() { return Small(); } void main() { Large l; Small s; l = cast(Large)foo(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/void_cat.d0000644000175000017500000000126115205374124021363 0ustar fabiofabio/* REQUIRED_ARGS: -preview=fixImmutableConv TEST_OUTPUT: --- fail_compilation/void_cat.d(15): Error: cannot copy `const(void)[]` to `void[]` fail_compilation/void_cat.d(15): Source data has incompatible type qualifier(s) fail_compilation/void_cat.d(15): Use `cast(void[])` to force copy fail_compilation/void_cat.d(19): Error: cannot append type `const(void)[]` to type `void[]` --- */ void g(int*[] a, const(int*)[] b) @system { void[] va = a; va[] = va.init ~ b; // a now contains b's data *a[0] = 0; // modify const data const(void)[] vb = b; va ~= vb; // also leaks const pointers into void[] // va could be copied into `a` via another void[] } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ctfe11467.d0000644000175000017500000000277715205374124021134 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ctfe11467.d(15): Error: overlapping slice assignment `[0..4] = [1..5]` fail_compilation/ctfe11467.d(24): called from here: `test11467a()` fail_compilation/ctfe11467.d(24): while evaluating: `static assert(test11467a())` fail_compilation/ctfe11467.d(21): Error: overlapping slice assignment `[1..5] = [0..4]` fail_compilation/ctfe11467.d(25): called from here: `test11467b()` fail_compilation/ctfe11467.d(25): while evaluating: `static assert(test11467b())` --- */ int test11467a() { auto a = [0, 1, 2, 3, 4]; a[0 .. 4] = a[1 .. 5]; return 1; } int test11467b() { auto a = [0, 1, 2, 3, 4]; a[1 .. 5] = a[0 .. 4]; return 1; } static assert(test11467a()); static assert(test11467b()); /* TEST_OUTPUT: --- fail_compilation/ctfe11467.d(41): Error: overlapping slice assignment `[0..4] = [1..5]` fail_compilation/ctfe11467.d(50): called from here: `test11467c()` fail_compilation/ctfe11467.d(50): while evaluating: `static assert(test11467c())` fail_compilation/ctfe11467.d(47): Error: overlapping slice assignment `[1..5] = [0..4]` fail_compilation/ctfe11467.d(51): called from here: `test11467d()` fail_compilation/ctfe11467.d(51): while evaluating: `static assert(test11467d())` --- */ int test11467c() { auto a = "abcde".dup; a[0 .. 4] = a[1 .. 5]; return 1; } int test11467d() { auto a = "abcde".dup; a[1 .. 5] = a[0 .. 4]; return 1; } static assert(test11467c()); static assert(test11467d()); ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag23355.d0000644000175000017500000000115015205374124021076 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag23355.d(1): Error: undefined identifier `n` fail_compilation/diag23355.d(4): Error: template `ffi1` is not callable using argument types `!()(int[4])` fail_compilation/diag23355.d(1): Candidate is: `ffi1(T)(T[n] s)` fail_compilation/diag23355.d(2): Error: undefined identifier `n` fail_compilation/diag23355.d(4): Error: template `ffi2` is not callable using argument types `!()(int[4])` fail_compilation/diag23355.d(2): Candidate is: `ffi2()(T[n] s)` --- */ #line 1 void ffi1(T)(T[n] s) { } void ffi2()(T[n] s) { } void main() { int[4] x; ffi1(x); ffi2(x); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test4682.d0000644000175000017500000000064315205374124021101 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/test4682.d(10): Error: integer overflow: `int.min / -1` fail_compilation/test4682.d(11): Error: integer overflow: `long.min / -1L` fail_compilation/test4682.d(12): Error: integer overflow: `int.min % -1` fail_compilation/test4682.d(13): Error: integer overflow: `long.min % -1L` ---- */ auto a = int.min / -1; auto b = long.min / -1; auto c = int.min % -1; auto d = long.min % -1; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag15974.d0000644000175000017500000000116415205374124021113 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag15974.d(21): Error: variable `f` cannot be read at compile time fail_compilation/diag15974.d(21): called from here: `format("%s", f)` fail_compilation/diag15974.d(26): Error: variable `f` cannot be read at compile time fail_compilation/diag15974.d(26): called from here: `format("%s", f)` --- */ void test15974() { string format(Args...)(string fmt, Args args) { return ""; } string f = "vkCreateSampler"; // CompileStatement mixin(format("%s", f)); struct S { // MixinDeclaration mixin(format("%s", f)); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail98.d0000644000175000017500000000211115205374124020662 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail98.d(20): Error: cannot implicitly convert expression `256` of type `int` to `E` fail_compilation/fail98.d(21): Error: cannot automatically assign value to enum member `fail98.D3DTS_WORLD1` because base type `E` is an enum; provide an explicit value fail_compilation/fail98.d(22): Error: cannot automatically assign value to enum member `fail98.D3DTS_WORLD2` because base type `E` is an enum; provide an explicit value fail_compilation/fail98.d(23): Error: cannot automatically assign value to enum member `fail98.D3DTS_WORLD3` because base type `E` is an enum; provide an explicit value --- */ // https://issues.dlang.org/show_bug.cgi?id=139 E foo(int index) { return index + 256; } enum : E { D3DTS_WORLD = 256, D3DTS_WORLD1, D3DTS_WORLD2, D3DTS_WORLD3 } enum E { D3DTS_VIEW = 2, D3DTS_PROJECTION, D3DTS_TEXTURE0 = 16, D3DTS_TEXTURE1, D3DTS_TEXTURE2, D3DTS_TEXTURE3, D3DTS_TEXTURE4, D3DTS_TEXTURE5, D3DTS_TEXTURE6, D3DTS_TEXTURE7, // = 23 D3DTS_FORCE_DWORD = 0xffffffff } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail47.d0000644000175000017500000000026615205374124020665 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail47.d(8): Error: variable `fail47._foo` is aliased to a function --- */ void foo() {} int _foo; alias _foo foo; void main() { foo = 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/unmatchedbrace.d0000644000175000017500000000031415205374124022536 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/unmatchedbrace.d(11): Error: matching `}` expected, not `End of File` fail_compilation/unmatchedbrace.d(8): unmatched `{` --- */ @safe { // struct S {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/bug8891.d0000644000175000017500000000056315205374124020706 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/bug8891.d(21): Error: calling non-static function `opCall` requires an instance of type `S` --- */ struct S { int value = 10; S opCall(int n) // non-static { //printf("this.value = %d\n", this.value); // prints garbage! S s; s.value = n; return s; } } void main() { S s = 10; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/varargsstc.d0000644000175000017500000000063515205374124021756 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/varargsstc.d(102): Error: variadic parameter cannot have attributes `out` fail_compilation/varargsstc.d(103): Error: variadic parameter cannot have attributes `ref` --- */ #line 100 int printf(const(char)*, const return scope shared ...); int printf(const(char)*, return ref out scope immutable shared ...); int printf(const(char)*, return ref scope immutable shared ...); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375a.d0000644000175000017500000000044515205374124021175 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375a.d(13): Error: else is dangling, add { } after condition at fail_compilation/fail4375a.d(10) --- */ void main() { if (true) if (false) assert(3); else assert(4); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/parse14745.d0000644000175000017500000000047515205374124021320 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/parse14745.d(11): Error: function literal cannot be `immutable` fail_compilation/parse14745.d(12): Error: function literal cannot be `const` --- */ void test14745() { auto fp1 = function () pure immutable { return 0; }; auto fp2 = function () pure const { return 0; }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/enumtype2.c0000644000175000017500000000023715205374124021524 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/enumtype2.c(101): Error: circular reference to enum base type `int` --- */ #line 100 enum E3 { A3 = sizeof(enum E3) }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test5412c2.di0000644000175000017500000000002315205374124021457 0ustar fabiofabiomodule test5412c2; ./ldc-1.42.0-src/tests/dmd/fail_compilation/parse13361.d0000644000175000017500000000052515205374124021305 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/parse13361.d(11): Error: empty attribute list is not allowed fail_compilation/parse13361.d(14): Error: empty attribute list is not allowed fail_compilation/parse13361.d(14): Error: use `@(attributes)` instead of `[attributes]` --- */ struct A { @() int b; [] // deprecated style int c; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag12063.d0000644000175000017500000000250415205374124021074 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag12063.d(21): Error: cannot check `diag12063.Bar.b` value for overflow fail_compilation/diag12063.d(18): Error: no property `max` for type `Foo`, perhaps `import std.algorithm;` is needed? fail_compilation/diag12063.d(21): Error: cannot generate value for `diag12063.Bar.b` fail_compilation/diag12063.d(21): Error: operator `+` is not defined for type `Bar` fail_compilation/diag12063.d(16): perhaps overload the operator with `auto opBinary(string op : "+")(int rhs) {}` fail_compilation/diag12063.d(31): Error: cannot check `diag12063.b` value for overflow fail_compilation/diag12063.d(31): Error: no operator `==` for type `S` fail_compilation/diag12063.d(24): perhaps overload it with `bool opEquals(int other) const {}` fail_compilation/diag12063.d(40): Error: enum member `diag12063.d` initialization with `__anonymous.c+1` causes overflow for type `Q` --- */ struct Foo {} enum Bar : Foo { a = Foo(), b // no max, can't +1 } struct S { S opBinary(string s: "+")(int) => this; enum max = 1; // wrong type } enum { a = S(), b // can't do S() == 1 } struct Q { enum max = Q(); } enum { c = Q(), d // overflow detected } struct R { int i; R opBinary(string s: "+")(int) => this; enum max = R(1); } enum ER { e = R(), f // OK } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail322.d0000644000175000017500000000166115205374124020741 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/fail322.d(15): Error: function `digestToString2` is not callable using argument types `(string)` fail_compilation/fail322.d(15): cannot pass rvalue argument `"1234567890123456"` of type `string` to parameter `ref char[16] digest` fail_compilation/fail322.d(20): `fail322.digestToString2(ref char[16] digest)` declared here fail_compilation/fail322.d(17): Error: function `digestToString2` is not callable using argument types `(const(char[16]))` fail_compilation/fail322.d(17): cannot pass argument `s` of type `const(char[16])` to parameter `ref char[16] digest` fail_compilation/fail322.d(20): `fail322.digestToString2(ref char[16] digest)` declared here ---- */ void main() { digestToString2("1234567890123456"); const char[16] s; digestToString2(s); } void digestToString2(ref char[16] digest) { assert(digest[0] == 0xc3); assert(digest[15] == 0x3b); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b15875.d0000644000175000017500000000043715205374124020432 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/b15875.d(9): Error: undefined identifier `a` fail_compilation/b15875.d(10): Error: circular reference to `b15875.f` --- */ // https://issues.dlang.org/show_bug.cgi?id=15875 // https://issues.dlang.org/show_bug.cgi?id=17290 d o(int[a]a)(){} f.T f(){} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22339.c0000644000175000017500000000206115205374124021153 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test22339.c(101): Error: expression expected, not `.` fail_compilation/test22339.c(101): Error: found `'a'` when expecting `}` fail_compilation/test22339.c(101): Error: identifier or `(` expected fail_compilation/test22339.c(101): Error: expected identifier for declarator fail_compilation/test22339.c(101): Error: expected identifier for declaration fail_compilation/test22339.c(101): Error: `=`, `;` or `,` expected to end declaration instead of `}` fail_compilation/test22339.c(102): Error: expression expected, not `.` fail_compilation/test22339.c(102): Error: found `'\x03'` when expecting `}` fail_compilation/test22339.c(102): Error: identifier or `(` expected fail_compilation/test22339.c(102): Error: expected identifier for declarator fail_compilation/test22339.c(102): Error: expected identifier for declaration fail_compilation/test22339.c(102): Error: `=`, `;` or `,` expected to end declaration instead of `}` --- */ // https://issues.dlang.org/show_bug.cgi?id=22339 #line 100 enum { A = .'a' }; enum { B = .'\x03' }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19917.d0000644000175000017500000000136615205374124021127 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19917.d(22): Error: overlapping default initialization for field `c` and `a` fail_compilation/fail19917.d(22): Error: overlapping default initialization for field `d` and `b` fail_compilation/fail19917.d(39): Error: overlapping default initialization for field `b` and `a` --- */ struct S { union { struct { int a = 3; int b = 4; } } } struct X { union { struct { int a = 3; int b = 4; } struct { int c = 3; int d = 4; } } } struct Y { union { struct { union { int a = 3; } } int b = 4; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test12430.d0000644000175000017500000000053615205374124021150 0ustar fabiofabio/* DISABLED: LDC // unsupported __simd syntax REQUIRED_ARGS: -m64 TEST_OUTPUT: --- fail_compilation/test12430.d(17): Error: simd operator must be an integer constant, not `op` --- */ // https://issues.dlang.org/show_bug.cgi?id=12430 import core.simd; void foo() { float4 a; auto op = XMM.RSQRTPS; auto b = __simd(op, a); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10346.d0000644000175000017500000000027515205374124021110 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10346.d(9): Error: undefined identifier `T` --- */ struct Foo(T) {} void bar(T x, T)(Foo!T) {} void main() { Foo!int spam; bar!10(spam); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/dip25flag.d0000644000175000017500000000014415205374124021347 0ustar fabiofabio/* REQUIRED_ARGS: -de -dip25 TEST_OUTPUT: --- Deprecation: `-dip25` no longer has any effect --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17105.d0000644000175000017500000000112415205374124021102 0ustar fabiofabio/* REQUIRED_ARGS: -m64 DISABLED: win32 linux32 osx32 freebsd32 openbsd32 LDC TEST_OUTPUT: --- fail_compilation/fail17105.d(20): Error: missing 4th parameter to `__simd()` --- */ // https://issues.dlang.org/show_bug.cgi?id=17105 module foo; import core.simd; struct bug { version (D_SIMD) { float4 value; auto normalize() { value = cast(float4) __simd(XMM.DPPS, value, value, 0xFF); value = cast(float4) __simd(XMM.DPPS, value, value); } } } /* https://www.felixcloutier.com/x86/dpps 66 0F 3A 40 /r ib DPPS xmm1, xmm2/m128, imm8 */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11969.d0000644000175000017500000000053015205374124020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11969.d(9): Error: undefined identifier `index` fail_compilation/ice11969.d(10): Error: undefined identifier `cond` fail_compilation/ice11969.d(11): Error: undefined identifier `msg` --- */ void test1() { mixin ([index]); } void test2() { mixin (assert(cond)); } void test3() { mixin (assert(0, msg)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice23865.d0000644000175000017500000000103315205374124020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice23865.d(64): Error: alias `ice23865.AssignableRange.back` conflicts with alias `ice23865.AssignableRange.back` at fail_compilation/ice23865.d(58) --- */ module ice23865; #line 50 class AssignableRange { int element; int front() { return element; } alias back = front; void front(int newValue) { element = newValue; } alias back = element; } void test() { AssignableRange a = new AssignableRange(); a.back; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fob1.d0000644000175000017500000000275315205374124020431 0ustar fabiofabio// REQUIRED_ARGS: -preview=dip1021 /* TEST_OUTPUT: --- fail_compilation/fob1.d(104): Error: variable `fob1.foo1.p` has undefined state and cannot be read fail_compilation/fob1.d(104): Error: variable `fob1.foo1.p` is returned but is Undefined --- */ #line 100 @live int* foo1() { int* p = void; return p; } /* TEST_OUTPUT: --- fail_compilation/fob1.d(204): Error: variable `fob1.foo2.p` assigning to Owner without disposing of owned value fail_compilation/fob1.d(203): Error: variable `fob1.foo2.p` is not disposed of before return --- */ #line 200 @live void foo2() { int* p; p = null; } /* TEST_OUTPUT: --- fail_compilation/fob1.d(304): Error: variable `fob1.foo3.p` has undefined state and cannot be read fail_compilation/fob1.d(304): Error: variable `fob1.foo3.p` is returned but is Undefined fail_compilation/fob1.d(303): Error: variable `fob1.foo3.q` is not disposed of before return --- */ #line 300 @live int* foo3(int* p) { int* q = p; return p; } /* TEST_OUTPUT: --- fail_compilation/fob1.d(405): Error: variable `fob1.foo4.bq` has undefined state and cannot be read --- */ #line 400 @live int* foo4(int* p) { scope int* bq = p; scope const int* cq = p; *bq = 1; return p; } /* TEST_OUTPUT: --- fail_compilation/fob1.d(503): Error: more than one mutable reference to `a` in arguments to `fob1.foo5()` --- */ // https://issues.dlang.org/show_bug.cgi?id=20781 #line 500 void test5() { int a; foo5(a, a); } @live void foo5(ref int, ref int); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13459.d0000644000175000017500000000066515205374124020750 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13459.d(12): Error: undefined identifier `B` fail_compilation/ice13459.d(18): Error: none of the overloads of `opSlice` are callable using argument types `(int, int)` fail_compilation/ice13459.d(11): Candidate is: `ice13459.A.opSlice() const` --- */ struct A { auto opSlice() const {} auto opSlice() { return B; } } void main() { auto df = A(); foreach (fi; df[0..0]) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11746.d0000644000175000017500000000101515205374124021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11746.d(18): Error: cannot implicitly convert expression `1` of type `int` to `string` fail_compilation/fail11746.d(25): Error: cannot implicitly convert expression `1` of type `int` to `string` fail_compilation/fail11746.d(26): Error: cannot implicitly convert expression `2` of type `int` to `string` --- */ string bb(T, U)(T x, U y) { return "3"; } enum E1 { foo = bb(bar, baz), bar = 1, baz = "2", } enum E2 { foo = bb(bar, baz), bar = 1, baz = 2 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failcontracts.d0000644000175000017500000000207015205374124022426 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/failcontracts.d(18): Error: missing `{ ... }` for function literal fail_compilation/failcontracts.d(18): Error: semicolon expected following auto declaration, not `bode` fail_compilation/failcontracts.d(19): Error: function declaration without return type fail_compilation/failcontracts.d(19): Note that constructors are always named `this` fail_compilation/failcontracts.d(19): Error: variable name expected after type `test1()`, not `bode` fail_compilation/failcontracts.d(19): Error: semicolon expected following function declaration, not `bode` fail_compilation/failcontracts.d(20): Error: semicolon expected following function declaration, not `bode` fail_compilation/failcontracts.d(22): Error: unexpected `(` in declarator fail_compilation/failcontracts.d(22): Error: found `T` when expecting `)` fail_compilation/failcontracts.d(22): Error: expected `{`, not `;` for enum declaration --- */ void test() { auto f1 = function() bode; auto test1() bode; auto test2()() bode; enum : int (int function() bode T); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/callconst.d0000644000175000017500000000062415205374124021557 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/callconst.d(14): Error: function `func` is not callable using argument types `(const(X))` fail_compilation/callconst.d(14): cannot pass argument `x` of type `const(X)` to parameter `ref X` fail_compilation/callconst.d(17): `callconst.func(ref X)` declared here --- */ struct X {} void main() { auto x = const X(); func(x); } void func(ref X); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7369.d0000644000175000017500000000024515205374124021040 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7369.d(9): Error: cannot modify `this.a` in `const` function --- */ struct S7369 { int a; invariant() { a += 5; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8425.d0000644000175000017500000000135215205374124021023 0ustar fabiofabio/* DISABLED: LDC // not all error messages are true for LDC; replaced by ldc_diag8425.d REQUIRED_ARGS: -m64 -o- TEST_OUTPUT: --- fail_compilation/diag8425.d(12): Error: T in __vector(T) must be a static array, not `void` fail_compilation/diag8425.d(13): Error: 1 byte vector type `__vector(void[1])` is not supported on this platform fail_compilation/diag8425.d(14): Error: 99 byte vector type `__vector(void[99])` is not supported on this platform fail_compilation/diag8425.d(15): Error: vector type `__vector(void*[4])` is not supported on this platform --- */ alias a = __vector(void); // not static array alias b = __vector(void[1]); // wrong size alias c = __vector(void[99]); // wrong size alias d = __vector(void*[4]); // wrong base type ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail99.d0000644000175000017500000000062315205374124020671 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail99.d(13): Error: delegate `dg` is not callable using argument types `()` fail_compilation/fail99.d(13): too few arguments, expected 1, got 0 --- */ //import std.stdio; void foo(void delegate(int) dg) { dg(); //writefln("%s", dg(3)); } void main() { foo(delegate(int i) { //writefln("i = %d\n", i); } ); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail160.d0000644000175000017500000000065515205374124020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail160.d(22): Error: `typeid(fail160.Foo).vtbl` is not yet implemented at compile time --- */ interface Foo { void work(); } template Wrapper(B, alias Func, int func) { alias typeof(&Func) FuncPtr; private static FuncPtr get_funcptr() { return func; } } int main(char[][] args) { auto x = new Wrapper!(Foo, Foo.work, cast(int)(Foo.classinfo.vtbl[0]))(); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail14997.d0000644000175000017500000000071315205374124021125 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=14997 /* TEST_OUTPUT: --- fail_compilation/fail14997.d(19): Error: none of the overloads of `this` are callable using argument types `()` fail_compilation/fail14997.d(14): Candidates are: `fail14997.Foo.this(int a)` fail_compilation/fail14997.d(15): `fail14997.Foo.this(string a)` --- */ class Foo { this (int a) {} this (string a) {} } void main() { auto a = new Foo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17612.d0000644000175000017500000000115115205374124021105 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17612.d(17): Error: undefined identifier `string` fail_compilation/fail17612.d(20): Error: `TypeInfo` not found. object.d may be incorrectly installed or corrupt. fail_compilation/fail17612.d(20): ldc2 might not be correctly installed. fail_compilation/fail17612.d(20): Please check your ldc2.conf configuration file. fail_compilation/fail17612.d(20): Installation instructions can be found at http://wiki.dlang.org/LDC. --- */ // https://issues.dlang.org/show_bug.cgi?id=17612 module object; class Object { string toString(); } class TypeInfo {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_arrayop1.d0000644000175000017500000001053115205374124022324 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/fail_arrayop1.d(11): Error: invalid array operation `a + a` (possible missing []) fail_compilation/fail_arrayop1.d(11): did you mean to concatenate (`a ~ a`) instead ? --- */ void test2199(int[] a) // https://issues.dlang.org/show_bug.cgi?id=2199 - Segfault using array operation in function call (from fail266.d) { #line 11 test2199(a + a); } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop1.d(29): Error: invalid array operation `-a` (possible missing []) --- */ void fail323() // from fail323.d, maybe was a part of https://issues.dlang.org/show_bug.cgi?id=3471 fix? { void foo(double[]) {} auto a = new double[10], b = a.dup, c = a.dup, d = a.dup; #line 29 foo(-a); // a[] = -(b[] * (c[] + 4)) + 5 * d[]; // / 3; } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop1.d(54): Error: invalid array operation `-a` (possible missing []) fail_compilation/fail_arrayop1.d(55): Error: invalid array operation `~a` (possible missing []) fail_compilation/fail_arrayop1.d(56): Error: invalid array operation `a + a` (possible missing []) fail_compilation/fail_arrayop1.d(56): did you mean to concatenate (`a ~ a`) instead ? fail_compilation/fail_arrayop1.d(57): Error: invalid array operation `a - a` (possible missing []) fail_compilation/fail_arrayop1.d(58): Error: invalid array operation `a * a` (possible missing []) fail_compilation/fail_arrayop1.d(59): Error: invalid array operation `a / a` (possible missing []) fail_compilation/fail_arrayop1.d(60): Error: invalid array operation `a % a` (possible missing []) fail_compilation/fail_arrayop1.d(61): Error: invalid array operation `a ^^ a` (possible missing []) fail_compilation/fail_arrayop1.d(62): Error: invalid array operation `a & a` (possible missing []) fail_compilation/fail_arrayop1.d(63): Error: invalid array operation `a | a` (possible missing []) fail_compilation/fail_arrayop1.d(64): Error: invalid array operation `a ^ a` (possible missing []) --- */ void test3903() { int[] a = [1, 2]; int[] r; #line 54 r = -a; r = ~a; r = a + a; r = a - a; r = a * a; r = a / a; r = a % a; r = a ^^ a; r = a & a; r = a | a; r = a ^ a; } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop1.d(85): Error: invalid array operation `a += a[]` (possible missing []) fail_compilation/fail_arrayop1.d(85): did you mean to concatenate (`a ~= a[]`) instead ? fail_compilation/fail_arrayop1.d(86): Error: invalid array operation `a -= a[]` (possible missing []) fail_compilation/fail_arrayop1.d(87): Error: invalid array operation `a *= a[]` (possible missing []) fail_compilation/fail_arrayop1.d(88): Error: invalid array operation `a /= a[]` (possible missing []) fail_compilation/fail_arrayop1.d(89): Error: invalid array operation `a %= a[]` (possible missing []) fail_compilation/fail_arrayop1.d(90): Error: invalid array operation `a ^= a[]` (possible missing []) fail_compilation/fail_arrayop1.d(91): Error: invalid array operation `a &= a[]` (possible missing []) fail_compilation/fail_arrayop1.d(92): Error: invalid array operation `a |= a[]` (possible missing []) fail_compilation/fail_arrayop1.d(93): Error: invalid array operation `a ^^= a[]` (possible missing []) --- */ void test9459() { int[] a = [1, 2, 3]; #line 85 a += a[]; a -= a[]; a *= a[]; a /= a[]; a %= a[]; a ^= a[]; a &= a[]; a |= a[]; a ^^= a[]; } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop1.d(105): Error: invalid array operation `a[] <<= 1` (possible missing []) --- */ void test11566() { int[] a; #line 105 a[] <<= 1; } /* TEST_OUTPUT: --- fail_compilation/fail_arrayop1.d(121): Error: invalid array operation `a + b` (possible missing []) fail_compilation/fail_arrayop1.d(121): did you mean to concatenate (`a ~ b`) instead ? fail_compilation/fail_arrayop1.d(122): Error: invalid array operation `x + y` (possible missing []) fail_compilation/fail_arrayop1.d(122): did you mean to concatenate (`x ~ y`) instead ? fail_compilation/fail_arrayop1.d(123): Error: invalid array operation `"hel" + "lo."` (possible missing []) fail_compilation/fail_arrayop1.d(123): did you mean to concatenate (`"hel" ~ "lo."`) instead ? --- */ void test14649() { char[] a, b, r; string x, y; #line 121 r[] = a + b; r[] = x + y; r[] = "hel" + "lo."; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue3827.d0000644000175000017500000000111715205374124021247 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/issue3827.d(14): Error: implicit string concatenation is error-prone and disallowed in D fail_compilation/issue3827.d(14): Use the explicit syntax instead (concatenating literals is `@nogc`): "Hello" ~ "World" fail_compilation/issue3827.d(15): Error: implicit string concatenation is error-prone and disallowed in D fail_compilation/issue3827.d(15): Use the explicit syntax instead (concatenating literals is `@nogc`): "A" ~ "B" --- */ void main () { string[] arr = [ "Hello" "World" ]; auto foo = "A" "B"; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12485.sh0000755000175000017500000000020415205374124021300 0ustar fabiofabio#!/usr/bin/env bash # redirecting stderr to nirvana saves ~30 secs on Windows... ! $DMD -c ${EXTRA_FILES}/fail12485.d 2> /dev/null ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20772.d0000644000175000017500000000070115205374124021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail20772.d(20): Error: cannot pass types with postblits or copy constructors as variadic arguments fail_compilation/fail20772.d(21): Error: cannot pass types with postblits or copy constructors as variadic arguments --- */ extern void variadic(...); struct S20772 { int field; this(int) { } this(ref S20772 o) { } } void test() { auto v = S20772(0); variadic(v, S20772(1)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/retscope2.d0000644000175000017500000001341715205374124021507 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/retscope2.d(102): Error: assigning scope variable `s` to `ref` variable `p` with longer lifetime is not allowed in a `@safe` function fail_compilation/retscope2.d(107): Error: assigning address of variable `s` to `p` with longer lifetime is not allowed in a `@safe` function --- */ #line 100 @safe foo1(ref char[] p, scope char[] s) { p = s; } @safe bar1(ref char* p, char s) { p = &s; } /**********************************************/ // https://issues.dlang.org/show_bug.cgi?id=17123 void test200() { char[256] buffer; char[] delegate() read = () { return buffer[]; }; } /**********************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope2.d(302): Error: assigning scope variable `a` to return scope `b` is not allowed in a `@safe` function --- */ #line 300 @safe int* test300(scope int* a, return scope int* b) { b = a; return b; } /**********************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope2.d(403): Error: assigning scope variable `a` to return scope `c` is not allowed in a `@safe` function --- */ #line 400 @safe int* test400(scope int* a, return scope int* b) { auto c = b; // infers 'return scope' for 'c' c = a; return c; } /**********************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope2.d(504): Error: returning scope variable `c` is not allowed in a `@safe` function --- */ #line 500 @safe int* test500(scope int* a, return scope int* b) { scope c = b; // does not infer 'return' for 'c' c = a; return c; } /**********************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope2.d(604): Error: assigning scope variable `__param_0` to non-scope anonymous parameter calling `foo600` is not allowed in a `@safe` function fail_compilation/retscope2.d(604): Error: assigning scope variable `__param_1` to non-scope anonymous parameter calling `foo600` is not allowed in a `@safe` function fail_compilation/retscope2.d(614): Error: template instance `retscope2.test600!(int*, int*)` error instantiating --- */ #line 600 @safe test600(A...)(scope A args) { foreach (i, Arg; A) { foo600(args[i]); } } @safe void foo600(int*); @safe bar600() { scope int* p; scope int* q; test600(p, q); } /*************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope2.d(719): Error: returning `get2(s)` escapes a reference to local variable `s` fail_compilation/retscope2.d(721): Error: returning `s.get1()` escapes a reference to local variable `s` --- */ #line 700 // https://issues.dlang.org/show_bug.cgi?id=17049 @safe S700* get2(return ref S700 _this) { return &_this; } struct S700 { @safe S700* get1() return ref scope { return &this; } } S700* escape700(int i) @safe { S700 s; if (i) return s.get2(); // 719 else return s.get1(); // 721 } /*************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope2.d(804): Error: throwing scope variable `e` is not allowed in a `@safe` function --- */ #line 800 void foo800() @safe { scope Exception e; throw e; } /*************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope2.d(907): Error: assigning address of variable `this` to `p17568` with longer lifetime is not allowed in a `@safe` function --- */ #line 900 int* p17568; struct T17568 { int a; void escape() @safe scope { p17568 = &a; } } /*************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope2.d(1005): Error: assigning scope variable `p` to non-scope `this._p` is not allowed in a `@safe` function fail_compilation/retscope2.d(1021): Error: assigning scope variable `p` to non-scope `c._p` is not allowed in a `@safe` function fail_compilation/retscope2.d(1024): Error: assigning scope variable `p` to non-scope `d._p` is not allowed in a `@safe` function --- */ #line 1000 class C17428 { void set(scope int* p) @safe { _p = p; } int* _p; } class C17428b { int* _p; } void test17428() @safe { int x; int* p = &x; scope C17428b c; c._p = p; // bad C17428b d; d._p = p; // bad } /*************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope2.d(1107): Error: returning scope variable `dg` is not allowed in a `@safe` function --- */ #line 1100 struct S17430 { void foo() {} } void delegate() test17430() @safe { S17430 s; auto dg = &s.foo; // infer dg as scope return dg; } /****************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope2.d(1216): Error: returning `s.foo()` escapes a reference to local variable `s` fail_compilation/retscope2.d(1233): Error: returning `t.foo()` escapes a reference to local variable `t` --- */ #line 1200 // https://issues.dlang.org/show_bug.cgi?id=17388 struct S17388 { //int* auto foo() return @safe { return &x; } int x; } @safe int* f17388() { S17388 s; return s.foo(); } struct T17388 { //int[] auto foo() return @safe { return x[]; } int[4] x; } @safe int[] g17388() { T17388 t; return t.foo(); } /****************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope2.d(1306): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function --- */ #line 1300 // https://issues.dlang.org/show_bug.cgi?id=17370 void test1300() @safe { int i; auto p = new S1300(&i).oops; } struct S1300 { int* oops; // this(int* p) @safe { oops = p; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/makedeps_wrongflag.d0000644000175000017500000000100315205374124023424 0ustar fabiofabio/* DISABLED: LDC // irrelevant CLI difference PERMUTE_ARGS: REQUIRED_ARGS: -makedepsbla -Jcompilable/extra-files -Icompilable/extra-files TEST_OUTPUT: --- Error: unrecognized switch '-makedepsbla' run `dmd` to print the compiler manual run `dmd -man` to open browser on manual --- */ module makedeps_wrongflag; // Test import statement import makedeps_a; // Test import expression enum text = import("makedeps-import.txt"); static assert(text == "Imported text\x0a"); void main() { a_func(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/match_func_ptr.d0000644000175000017500000000115615205374124022572 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/match_func_ptr.d(13): Error: cannot match delegate literal to function pointer type `void function()` fail_compilation/match_func_ptr.d(14): Error: cannot match function literal to delegate type `void delegate()` fail_compilation/match_func_ptr.d(15): Error: cannot infer parameter types from `int function()` fail_compilation/match_func_ptr.d(16): Error: cannot infer parameter types from `int delegate(int, int)` --- */ void main() { void function() f = delegate {}; void delegate() d = function {}; int function() f2 = i => 2; int delegate(int, int) d2 = i => 2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7524b.d0000644000175000017500000000026115205374124021171 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=7524 /* TEST_OUTPUT: --- fail_compilation/fail7524b.d(9): Error: invalid filename for `#line` directive --- */ #line 47 __VERSION__ ./ldc-1.42.0-src/tests/dmd/fail_compilation/reserved_version.d0000644000175000017500000004364615205374124023174 0ustar fabiofabio// REQUIRED_ARGS: -verrors=0 /* TEST_OUTPUT: --- fail_compilation/reserved_version.d(105): Error: version identifier `MSP430` is reserved and cannot be set fail_compilation/reserved_version.d(106): Error: version identifier `D_P16` is reserved and cannot be set fail_compilation/reserved_version.d(107): Error: version identifier `DigitalMars` is reserved and cannot be set fail_compilation/reserved_version.d(108): Error: version identifier `GNU` is reserved and cannot be set fail_compilation/reserved_version.d(109): Error: version identifier `LDC` is reserved and cannot be set fail_compilation/reserved_version.d(110): Error: version identifier `SDC` is reserved and cannot be set fail_compilation/reserved_version.d(111): Error: version identifier `Windows` is reserved and cannot be set fail_compilation/reserved_version.d(112): Error: version identifier `Win32` is reserved and cannot be set fail_compilation/reserved_version.d(113): Error: version identifier `Win64` is reserved and cannot be set fail_compilation/reserved_version.d(114): Error: version identifier `linux` is reserved and cannot be set fail_compilation/reserved_version.d(115): Error: version identifier `OSX` is reserved and cannot be set fail_compilation/reserved_version.d(116): Error: version identifier `iOS` is reserved and cannot be set fail_compilation/reserved_version.d(117): Error: version identifier `TVOS` is reserved and cannot be set fail_compilation/reserved_version.d(118): Error: version identifier `WatchOS` is reserved and cannot be set fail_compilation/reserved_version.d(119): Error: version identifier `FreeBSD` is reserved and cannot be set fail_compilation/reserved_version.d(120): Error: version identifier `OpenBSD` is reserved and cannot be set fail_compilation/reserved_version.d(121): Error: version identifier `NetBSD` is reserved and cannot be set fail_compilation/reserved_version.d(122): Error: version identifier `DragonFlyBSD` is reserved and cannot be set fail_compilation/reserved_version.d(123): Error: version identifier `BSD` is reserved and cannot be set fail_compilation/reserved_version.d(124): Error: version identifier `Solaris` is reserved and cannot be set fail_compilation/reserved_version.d(125): Error: version identifier `Posix` is reserved and cannot be set fail_compilation/reserved_version.d(126): Error: version identifier `AIX` is reserved and cannot be set fail_compilation/reserved_version.d(127): Error: version identifier `Haiku` is reserved and cannot be set fail_compilation/reserved_version.d(128): Error: version identifier `SkyOS` is reserved and cannot be set fail_compilation/reserved_version.d(129): Error: version identifier `SysV3` is reserved and cannot be set fail_compilation/reserved_version.d(130): Error: version identifier `SysV4` is reserved and cannot be set fail_compilation/reserved_version.d(131): Error: version identifier `Hurd` is reserved and cannot be set fail_compilation/reserved_version.d(132): Error: version identifier `Android` is reserved and cannot be set fail_compilation/reserved_version.d(133): Error: version identifier `PlayStation` is reserved and cannot be set fail_compilation/reserved_version.d(134): Error: version identifier `PlayStation4` is reserved and cannot be set fail_compilation/reserved_version.d(135): Error: version identifier `Cygwin` is reserved and cannot be set fail_compilation/reserved_version.d(136): Error: version identifier `MinGW` is reserved and cannot be set fail_compilation/reserved_version.d(137): Error: version identifier `FreeStanding` is reserved and cannot be set fail_compilation/reserved_version.d(138): Error: version identifier `X86` is reserved and cannot be set fail_compilation/reserved_version.d(139): Error: version identifier `X86_64` is reserved and cannot be set fail_compilation/reserved_version.d(140): Error: version identifier `ARM` is reserved and cannot be set fail_compilation/reserved_version.d(141): Error: version identifier `ARM_Thumb` is reserved and cannot be set fail_compilation/reserved_version.d(142): Error: version identifier `ARM_SoftFloat` is reserved and cannot be set fail_compilation/reserved_version.d(143): Error: version identifier `ARM_SoftFP` is reserved and cannot be set fail_compilation/reserved_version.d(144): Error: version identifier `ARM_HardFloat` is reserved and cannot be set fail_compilation/reserved_version.d(145): Error: version identifier `AArch64` is reserved and cannot be set fail_compilation/reserved_version.d(146): Error: version identifier `Epiphany` is reserved and cannot be set fail_compilation/reserved_version.d(147): Error: version identifier `PPC` is reserved and cannot be set fail_compilation/reserved_version.d(148): Error: version identifier `PPC_SoftFloat` is reserved and cannot be set fail_compilation/reserved_version.d(149): Error: version identifier `PPC_HardFloat` is reserved and cannot be set fail_compilation/reserved_version.d(150): Error: version identifier `PPC64` is reserved and cannot be set fail_compilation/reserved_version.d(151): Error: version identifier `IA64` is reserved and cannot be set fail_compilation/reserved_version.d(152): Error: version identifier `MIPS32` is reserved and cannot be set fail_compilation/reserved_version.d(153): Error: version identifier `MIPS64` is reserved and cannot be set fail_compilation/reserved_version.d(154): Error: version identifier `MIPS_O32` is reserved and cannot be set fail_compilation/reserved_version.d(155): Error: version identifier `MIPS_N32` is reserved and cannot be set fail_compilation/reserved_version.d(156): Error: version identifier `MIPS_O64` is reserved and cannot be set fail_compilation/reserved_version.d(157): Error: version identifier `MIPS_N64` is reserved and cannot be set fail_compilation/reserved_version.d(158): Error: version identifier `MIPS_EABI` is reserved and cannot be set fail_compilation/reserved_version.d(159): Error: version identifier `MIPS_SoftFloat` is reserved and cannot be set fail_compilation/reserved_version.d(160): Error: version identifier `MIPS_HardFloat` is reserved and cannot be set fail_compilation/reserved_version.d(161): Error: version identifier `NVPTX` is reserved and cannot be set fail_compilation/reserved_version.d(162): Error: version identifier `NVPTX64` is reserved and cannot be set fail_compilation/reserved_version.d(163): Error: version identifier `RISCV32` is reserved and cannot be set fail_compilation/reserved_version.d(164): Error: version identifier `RISCV64` is reserved and cannot be set fail_compilation/reserved_version.d(165): Error: version identifier `SPARC` is reserved and cannot be set fail_compilation/reserved_version.d(166): Error: version identifier `SPARC_V8Plus` is reserved and cannot be set fail_compilation/reserved_version.d(167): Error: version identifier `SPARC_SoftFloat` is reserved and cannot be set fail_compilation/reserved_version.d(168): Error: version identifier `SPARC_HardFloat` is reserved and cannot be set fail_compilation/reserved_version.d(169): Error: version identifier `SPARC64` is reserved and cannot be set fail_compilation/reserved_version.d(170): Error: version identifier `S390` is reserved and cannot be set fail_compilation/reserved_version.d(171): Error: version identifier `S390X` is reserved and cannot be set fail_compilation/reserved_version.d(172): Error: version identifier `SystemZ` is reserved and cannot be set fail_compilation/reserved_version.d(173): Error: version identifier `HPPA` is reserved and cannot be set fail_compilation/reserved_version.d(174): Error: version identifier `HPPA64` is reserved and cannot be set fail_compilation/reserved_version.d(175): Error: version identifier `SH` is reserved and cannot be set fail_compilation/reserved_version.d(176): Error: version identifier `Alpha` is reserved and cannot be set fail_compilation/reserved_version.d(177): Error: version identifier `Alpha_SoftFloat` is reserved and cannot be set fail_compilation/reserved_version.d(178): Error: version identifier `Alpha_HardFloat` is reserved and cannot be set fail_compilation/reserved_version.d(179): Error: version identifier `LoongArch32` is reserved and cannot be set fail_compilation/reserved_version.d(180): Error: version identifier `LoongArch64` is reserved and cannot be set fail_compilation/reserved_version.d(181): Error: version identifier `LoongArch_HardFloat` is reserved and cannot be set fail_compilation/reserved_version.d(182): Error: version identifier `LoongArch_SoftFloat` is reserved and cannot be set fail_compilation/reserved_version.d(183): Error: version identifier `Xtensa` is reserved and cannot be set fail_compilation/reserved_version.d(184): Error: version identifier `LittleEndian` is reserved and cannot be set fail_compilation/reserved_version.d(185): Error: version identifier `BigEndian` is reserved and cannot be set fail_compilation/reserved_version.d(186): Error: version identifier `ELFv1` is reserved and cannot be set fail_compilation/reserved_version.d(187): Error: version identifier `ELFv2` is reserved and cannot be set fail_compilation/reserved_version.d(188): Error: version identifier `CRuntime_Bionic` is reserved and cannot be set fail_compilation/reserved_version.d(189): Error: version identifier `CRuntime_DigitalMars` is reserved and cannot be set fail_compilation/reserved_version.d(190): Error: version identifier `CRuntime_Glibc` is reserved and cannot be set fail_compilation/reserved_version.d(191): Error: version identifier `CRuntime_Microsoft` is reserved and cannot be set fail_compilation/reserved_version.d(192): Error: version identifier `CRuntime_Musl` is reserved and cannot be set fail_compilation/reserved_version.d(193): Error: version identifier `CRuntime_Newlib` is reserved and cannot be set fail_compilation/reserved_version.d(194): Error: version identifier `CRuntime_UClibc` is reserved and cannot be set fail_compilation/reserved_version.d(195): Error: version identifier `CRuntime_WASI` is reserved and cannot be set fail_compilation/reserved_version.d(196): Error: version identifier `D_Coverage` is reserved and cannot be set fail_compilation/reserved_version.d(197): Error: version identifier `D_Ddoc` is reserved and cannot be set fail_compilation/reserved_version.d(198): Error: version identifier `D_InlineAsm_X86` is reserved and cannot be set fail_compilation/reserved_version.d(199): Error: version identifier `D_InlineAsm_X86_64` is reserved and cannot be set fail_compilation/reserved_version.d(200): Error: version identifier `D_LP64` is reserved and cannot be set fail_compilation/reserved_version.d(201): Error: version identifier `D_X32` is reserved and cannot be set fail_compilation/reserved_version.d(202): Error: version identifier `D_HardFloat` is reserved and cannot be set fail_compilation/reserved_version.d(203): Error: version identifier `D_SoftFloat` is reserved and cannot be set fail_compilation/reserved_version.d(204): Error: version identifier `D_PIC` is reserved and cannot be set fail_compilation/reserved_version.d(205): Error: version identifier `D_SIMD` is reserved and cannot be set fail_compilation/reserved_version.d(206): Error: version identifier `D_Version2` is reserved and cannot be set fail_compilation/reserved_version.d(207): Error: version identifier `D_NoBoundsChecks` is reserved and cannot be set fail_compilation/reserved_version.d(210): Error: version identifier `all` is reserved and cannot be set fail_compilation/reserved_version.d(211): Error: version identifier `none` is reserved and cannot be set fail_compilation/reserved_version.d(212): Error: version identifier `AsmJS` is reserved and cannot be set fail_compilation/reserved_version.d(213): Error: version identifier `Emscripten` is reserved and cannot be set fail_compilation/reserved_version.d(214): Error: version identifier `WebAssembly` is reserved and cannot be set fail_compilation/reserved_version.d(215): Error: version identifier `WASI` is reserved and cannot be set fail_compilation/reserved_version.d(216): Error: version identifier `CppRuntime_LLVM` is reserved and cannot be set fail_compilation/reserved_version.d(217): Error: version identifier `CppRuntime_DigitalMars` is reserved and cannot be set fail_compilation/reserved_version.d(218): Error: version identifier `CppRuntime_GNU` is reserved and cannot be set fail_compilation/reserved_version.d(219): Error: version identifier `CppRuntime_Microsoft` is reserved and cannot be set fail_compilation/reserved_version.d(220): Error: version identifier `CppRuntime_Sun` is reserved and cannot be set fail_compilation/reserved_version.d(221): Error: version identifier `D_PIE` is reserved and cannot be set fail_compilation/reserved_version.d(222): Error: version identifier `AVR` is reserved and cannot be set fail_compilation/reserved_version.d(223): Error: version identifier `D_PreConditions` is reserved and cannot be set fail_compilation/reserved_version.d(224): Error: version identifier `D_PostConditions` is reserved and cannot be set fail_compilation/reserved_version.d(225): Error: version identifier `D_ProfileGC` is reserved and cannot be set fail_compilation/reserved_version.d(226): Error: version identifier `D_Invariants` is reserved and cannot be set fail_compilation/reserved_version.d(227): Error: version identifier `D_Optimized` is reserved and cannot be set fail_compilation/reserved_version.d(228): Error: version identifier `VisionOS` is reserved and cannot be set --- */ // Some extra empty lines to help fixup the manual line numbering after adding new version identifiers #line 105 version = MSP430; version = D_P16; version = DigitalMars; version = GNU; version = LDC; version = SDC; version = Windows; version = Win32; version = Win64; version = linux; version = OSX; version = iOS; version = TVOS; version = WatchOS; version = FreeBSD; version = OpenBSD; version = NetBSD; version = DragonFlyBSD; version = BSD; version = Solaris; version = Posix; version = AIX; version = Haiku; version = SkyOS; version = SysV3; version = SysV4; version = Hurd; version = Android; version = PlayStation; version = PlayStation4; version = Cygwin; version = MinGW; version = FreeStanding; version = X86; version = X86_64; version = ARM; version = ARM_Thumb; version = ARM_SoftFloat; version = ARM_SoftFP; version = ARM_HardFloat; version = AArch64; version = Epiphany; version = PPC; version = PPC_SoftFloat; version = PPC_HardFloat; version = PPC64; version = IA64; version = MIPS32; version = MIPS64; version = MIPS_O32; version = MIPS_N32; version = MIPS_O64; version = MIPS_N64; version = MIPS_EABI; version = MIPS_SoftFloat; version = MIPS_HardFloat; version = NVPTX; version = NVPTX64; version = RISCV32; version = RISCV64; version = SPARC; version = SPARC_V8Plus; version = SPARC_SoftFloat; version = SPARC_HardFloat; version = SPARC64; version = S390; version = S390X; version = SystemZ; version = HPPA; version = HPPA64; version = SH; version = Alpha; version = Alpha_SoftFloat; version = Alpha_HardFloat; version = LoongArch32; version = LoongArch64; version = LoongArch_HardFloat; version = LoongArch_SoftFloat; version = Xtensa; version = LittleEndian; version = BigEndian; version = ELFv1; version = ELFv2; version = CRuntime_Bionic; version = CRuntime_DigitalMars; version = CRuntime_Glibc; version = CRuntime_Microsoft; version = CRuntime_Musl; version = CRuntime_Newlib; version = CRuntime_UClibc; version = CRuntime_WASI; version = D_Coverage; version = D_Ddoc; version = D_InlineAsm_X86; version = D_InlineAsm_X86_64; version = D_LP64; version = D_X32; version = D_HardFloat; version = D_SoftFloat; version = D_PIC; version = D_SIMD; version = D_Version2; version = D_NoBoundsChecks; //version = unittest; //version = assert; version = all; version = none; version = AsmJS; version = Emscripten; version = WebAssembly; version = WASI; version = CppRuntime_LLVM; version = CppRuntime_DigitalMars; version = CppRuntime_GNU; version = CppRuntime_Microsoft; version = CppRuntime_Sun; version = D_PIE; version = AVR; version = D_PreConditions; version = D_PostConditions; version = D_ProfileGC; version = D_Invariants; version = D_Optimized; version = VisionOS; // This should work though debug = DigitalMars; debug = GNU; debug = LDC; debug = SDC; debug = Windows; debug = Win32; debug = Win64; debug = linux; debug = OSX; debug = FreeBSD; debug = OpenBSD; debug = NetBSD; debug = DragonFlyBSD; debug = BSD; debug = Solaris; debug = Posix; debug = AIX; debug = Haiku; debug = SkyOS; debug = SysV3; debug = SysV4; debug = Hurd; debug = Android; debug = Cygwin; debug = MinGW; debug = FreeStanding; debug = X86; debug = X86_64; debug = ARM; debug = ARM_Thumb; debug = ARM_SoftFloat; debug = ARM_SoftFP; debug = ARM_HardFloat; debug = AArch64; debug = Epiphany; debug = PPC; debug = PPC_SoftFloat; debug = PPC_HardFloat; debug = PPC64; debug = IA64; debug = MIPS32; debug = MIPS64; debug = MIPS_O32; debug = MIPS_N32; debug = MIPS_O64; debug = MIPS_N64; debug = MIPS_EABI; debug = MIPS_SoftFloat; debug = MIPS_HardFloat; debug = NVPTX; debug = NVPTX64; debug = RISCV32; debug = RISCV64; debug = SPARC; debug = SPARC_V8Plus; debug = SPARC_SoftFloat; debug = SPARC_HardFloat; debug = SPARC64; debug = S390; debug = S390X; debug = SystemZ; debug = HPPA; debug = HPPA64; debug = SH; debug = WebAssembly; debug = WASI; debug = Alpha; debug = Alpha_SoftFloat; debug = Alpha_HardFloat; debug = LoongArch32; debug = LoongArch64; debug = LoongArch_HardFloat; debug = LoongArch_SoftFloat; debug = Xtensa; debug = LittleEndian; debug = BigEndian; debug = ELFv1; debug = ELFv2; debug = CRuntime_Bionic; debug = CRuntime_DigitalMars; debug = CRuntime_Glibc; debug = CRuntime_Microsoft; debug = CRuntime_Musl; debug = CRuntime_Newlib; debug = CRuntime_UClibc; debug = CRuntime_WASI; debug = CppRuntime_LLVM; debug = CppRuntime_DigitalMars; debug = CppRuntime_GNU; debug = CppRuntime_Microsoft; debug = CppRuntime_Sun; debug = D_Coverage; debug = D_Ddoc; debug = D_InlineAsm_X86; debug = D_InlineAsm_X86_64; debug = D_LP64; debug = D_X32; debug = D_HardFloat; debug = D_SoftFloat; debug = D_PIC; debug = D_PIE; debug = D_SIMD; debug = D_Version2; debug = D_NoBoundsChecks; //debug = unittest; //debug = assert; debug = all; debug = none; debug = D_P16; debug = MSP430; debug = AVR; debug = D_PreConditions; debug = D_PostConditions; debug = D_ProfileGC; debug = D_Optimized; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20903.d0000644000175000017500000000047015205374124021151 0ustar fabiofabio/* REQUIRED_ARGS: -O -m64 * TEST_OUTPUT: --- fail_compilation/test20903.d(14): Error: integer overflow --- */ // https://issues.dlang.org/show_bug.cgi?id=20903 // LLVM optimizes to an undefined value. // DISABLED: LDC long test() { long r = 0x8000_0000_0000_0000L; long x = -1L; return r / x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13609b.d0000644000175000017500000000046515205374124021251 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag13609b.d(10): Error: base classes are not allowed for `struct`, did you mean `;`? fail_compilation/diag13609b.d(11): Error: basic type expected, not `End of File` fail_compilation/diag13609b.d(11): Error: { } expected following `struct` declaration --- */ struct S : ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_casting.d0000644000175000017500000001570615205374124022227 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/fail_casting.d(12): Error: cannot cast expression `x` of type `short[2]` to `int[2]` because of different sizes --- */ void test3133() { short[2] x = [1, 2]; auto y = cast(int[2])x; // error } /* TEST_OUTPUT: --- fail_compilation/fail_casting.d(28): Error: cannot cast expression `null` of type `typeof(null)` to `S1` fail_compilation/fail_casting.d(29): Error: cannot cast expression `null` of type `typeof(null)` to `S2` fail_compilation/fail_casting.d(30): Error: cannot cast expression `s1` of type `S1` to `typeof(null)` fail_compilation/fail_casting.d(31): Error: cannot cast expression `s2` of type `S2` to `typeof(null)` --- */ void test9904() { static struct S1 { size_t m; } static struct S2 { size_t m; byte b; } { auto x = cast(S1)null; } { auto x = cast(S2)null; } { S1 s1; auto x = cast(typeof(null))s1; } { S2 s2; auto x = cast(typeof(null))s2; } } /* TEST_OUTPUT: --- fail_compilation/fail_casting.d(46): Error: cannot cast expression `x` of type `Object[]` to `object.Object` fail_compilation/fail_casting.d(47): Error: cannot cast expression `x` of type `Object[2]` to `object.Object` fail_compilation/fail_casting.d(49): Error: cannot cast expression `x` of type `object.Object` to `Object[]` fail_compilation/fail_casting.d(50): Error: cannot cast expression `x` of type `object.Object` to `Object[2]` --- */ void test10646() { // T[] or T[n] --> Tclass { Object[] x; auto y = cast(Object)x; } { Object[2] x; auto y = cast(Object)x; } // T[] or T[n] <-- Tclass { Object x; auto y = cast(Object[] )x; } { Object x; auto y = cast(Object[2])x; } } /* TEST_OUTPUT: --- fail_compilation/fail_casting.d(69): Error: cannot cast expression `x` of type `int[1]` to `int` fail_compilation/fail_casting.d(70): Error: cannot cast expression `x` of type `int` to `int[1]` fail_compilation/fail_casting.d(71): Error: cannot cast expression `x` of type `float[1]` to `int` fail_compilation/fail_casting.d(72): Error: cannot cast expression `x` of type `int` to `float[1]` fail_compilation/fail_casting.d(75): Error: cannot cast expression `x` of type `int[]` to `int` fail_compilation/fail_casting.d(76): Error: cannot cast expression `x` of type `int` to `int[]` fail_compilation/fail_casting.d(77): Error: cannot cast expression `x` of type `float[]` to `int` fail_compilation/fail_casting.d(78): Error: cannot cast expression `x` of type `int` to `float[]` --- */ void test11484() { // Tsarray <--> integer { int[1] x; auto y = cast(int ) x; } { int x; auto y = cast(int[1] ) x; } { float[1] x; auto y = cast(int ) x; } { int x; auto y = cast(float[1]) x; } // Tarray <--> integer { int[] x; auto y = cast(int ) x; } { int x; auto y = cast(int[] ) x; } { float[] x; auto y = cast(int ) x; } { int x; auto y = cast(float[]) x; } } /* TEST_OUTPUT: --- fail_compilation/fail_casting.d(97): Error: cannot cast expression `x` of type `int` to `fail_casting.test11485.C` fail_compilation/fail_casting.d(98): Error: cannot cast expression `x` of type `int` to `fail_casting.test11485.I` fail_compilation/fail_casting.d(101): Error: cannot cast expression `x` of type `fail_casting.test11485.C` to `int` fail_compilation/fail_casting.d(102): Error: cannot cast expression `x` of type `fail_casting.test11485.I` to `int` --- */ void test11485() { class C {} interface I {} // https://issues.dlang.org/show_bug.cgi?id=11485 TypeBasic --> Tclass { int x; auto y = cast(C)x; } { int x; auto y = cast(I)x; } // https://issues.dlang.org/show_bug.cgi?id=7472 TypeBasic <-- Tclass { C x; auto y = cast(int)x; } { I x; auto y = cast(int)x; } } /* TEST_OUTPUT: --- fail_compilation/fail_casting.d(114): Error: cannot cast expression `x` of type `typeof(null)` to `int[2]` fail_compilation/fail_casting.d(115): Error: cannot cast expression `x` of type `int[2]` to `typeof(null)` --- */ void test8179() { { typeof(null) x; auto y = cast(int[2])x; } { int[2] x; auto y = cast(typeof(null))x; } } /* TEST_OUTPUT: --- fail_compilation/fail_casting.d(128): Error: cannot cast expression `x` of type `S` to `int*` fail_compilation/fail_casting.d(130): Error: cannot cast expression `x` of type `void*` to `S` --- */ void test13959() { struct S { int* p; } { S x; auto y = cast(int*)x; } { int* x; auto y = cast(S)x; } // no error so it's rewritten as: S(x) { void* x; auto y = cast(S)x; } } /* TEST_OUTPUT: --- fail_compilation/fail_casting.d(144): Error: cannot cast expression `mi` of type `MyInt14154` to `MyUbyte14154` because of different sizes --- */ struct MyUbyte14154 { ubyte x; alias x this; } struct MyInt14154 { int x; alias x this; } void test14154() { MyInt14154 mi; ubyte t = cast(MyUbyte14154)mi; } /* TEST_OUTPUT: --- fail_compilation/fail_casting.d(179): Error: cannot cast expression `point` of type `Tuple14093!(int, "x", int, "y")` to `object.Object` --- */ alias TypeTuple14093(T...) = T; struct Tuple14093(T...) { static if (T.length == 4) { alias Types = TypeTuple14093!(T[0], T[2]); Types expand; @property ref inout(Tuple14093!Types) _Tuple_super() inout @trusted { return *cast(typeof(return)*) &(expand[0]); } alias _Tuple_super this; } else { alias Types = T; Types expand; alias expand this; } } void test14093() { Tuple14093!(int, "x", int, "y") point; auto newPoint = cast(Object)(point); } /* TEST_OUTPUT: --- fail_compilation/fail_casting.d(192): Error: cannot cast expression `p` of type `void*` to `char[]` fail_compilation/fail_casting.d(193): Error: cannot cast expression `p` of type `void*` to `char[2]` --- */ void test14596() { void* p = null; auto arr = cast(char[])p; char[2] sarr = cast(char[2])p; } /* TEST_OUTPUT: --- fail_compilation/fail_casting.d(217): Error: cannot cast expression `c` of type `fail_casting.test14629.C` to `typeof(null)` fail_compilation/fail_casting.d(218): Error: cannot cast expression `p` of type `int*` to `typeof(null)` fail_compilation/fail_casting.d(219): Error: cannot cast expression `da` of type `int[]` to `typeof(null)` fail_compilation/fail_casting.d(220): Error: cannot cast expression `aa` of type `int[int]` to `typeof(null)` fail_compilation/fail_casting.d(221): Error: cannot cast expression `fp` of type `int function()` to `typeof(null)` fail_compilation/fail_casting.d(222): Error: cannot cast expression `dg` of type `int delegate()` to `typeof(null)` --- */ void test14629() { alias P = int*; P p; alias DA = int[]; DA da; alias AA = int[int]; AA aa; alias FP = int function(); FP fp; alias DG = int delegate(); DG dg; class C {} C c; alias N = typeof(null); { auto x = cast(N)c; } { auto x = cast(N)p; } { auto x = cast(N)da; } { auto x = cast(N)aa; } { auto x = cast(N)fp; } { auto x = cast(N)dg; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23760.d0000644000175000017500000000125315205374124021111 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23760 /* TEST_OUTPUT: --- fail_compilation/fail23760.d(16): Error: type of variable `fail23760.A.state` has errors fail_compilation/fail23760.d(16): Error: `(A).state` cannot be resolved fail_compilation/fail23760.d(21): Error: template instance `fail23760.JavaBridge!(A)` error instantiating fail_compilation/fail23760.d(24): instantiated from here: `JavaClass!(A)` --- */ class JavaBridge(Class) { static if(is(typeof(__traits(getMember, Class, "state")))) {} alias T = __traits(getOverloads, Class, "state"); } class JavaClass(CRTP) { JavaBridge!(CRTP) _javaDBridge; } class A : JavaClass!A { State* state; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23491.d0000644000175000017500000000137315205374124021161 0ustar fabiofabio/** REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test23491.d(16): Error: reference to local variable `buffer` assigned to non-scope anonymous parameter is not allowed in a `@safe` function fail_compilation/test23491.d(17): Error: assigning reference to local variable `buffer` to non-scope anonymous parameter calling `sinkF` is not allowed in a `@safe` function fail_compilation/test23491.d(18): Error: assigning reference to local variable `buffer` to non-scope parameter `buf` is not allowed in a `@safe` function --- */ void sinkF(char[]) @safe; void toString(void delegate (char[]) @safe sink, void delegate(char[] buf) @safe sinkNamed) @safe { char[20] buffer = void; sink(buffer[]); sinkF(buffer[]); sinkNamed(buffer[]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4269f.d0000644000175000017500000000033015205374124021175 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4269f.d(9): Error: `alias X16 = X16;` cannot alias itself, use a qualified name to create an overload set --- */ static if(is(typeof(X16))) {} alias X16 X16; void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/ctypes.d0000644000175000017500000000037015205374124021102 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ctypes.d(11): Error: use `real` instead of `long double` fail_compilation/ctypes.d(12): Error: use `long` for a 64 bit integer instead of `long long` --- */ void test() { long double r; long long ll; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13109.d0000644000175000017500000000016115205374124021073 0ustar fabiofabio/* REQUIRED_ARGS: -lib -run fail_compilation/diag13109.d TEST_OUTPUT: --- Error: flags conflict with -run --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21227_posix.d0000644000175000017500000000152415205374124022330 0ustar fabiofabio/* REQUIRED_ARGS: -Jfail_compilation DISABLED: win TEST_OUTPUT: --- fail_compilation/fail21227_posix.d(2): Error: absolute path is not allowed in import expression: `"/abs/path/to/file.txt"` fail_compilation/fail21227_posix.d(3): Error: path refers to parent (`..`) directory: `"../file.txt"` fail_compilation/fail21227_posix.d(4): Error: path refers to parent (`..`) directory: `"path/to/parent/../file.txt"` fail_compilation/fail21227_posix.d(5): Error: file `"do_not_exist"` cannot be found or not in a path specified with `-J` fail_compilation/fail21227_posix.d(5): Path(s) searched (as provided by `-J`): fail_compilation/fail21227_posix.d(5): [0]: `fail_compilation` --- */ #line 1 enum val = import("/abs/path/to/file.txt") ~ import("../file.txt") ~ import("path/to/parent/../file.txt") ~ import("do_not_exist") ; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9710.d0000644000175000017500000000021515205374124021025 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9710.d(9): Error: static variable `e` cannot be read at compile time --- */ int* e; enum v = e[1]; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23112.d0000644000175000017500000000130115205374124021136 0ustar fabiofabio/* REQUIRED_ARGS: -betterC DISABLED: LDC // FIXME: don't know how to fix this; should probably be handled properly in the frontend TEST_OUTPUT: --- fail_compilation/test23112.d(106): Error: function `test23112.bar` is `@nogc` yet allocates closure for `bar()` with the GC fail_compilation/test23112.d(108): function `f` closes over variable `a` fail_compilation/test23112.d(106): `a` declared here --- */ // https://issues.dlang.org/show_bug.cgi?id=23112 #line 100 struct Forward(alias F) { auto call()() { return F(); } } auto bar(int a) nothrow @safe { auto f() { return a; } return Forward!f(); } extern(C) void main() { assert(bar(3).call() == 3); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22145.d0000644000175000017500000000074115205374124021152 0ustar fabiofabio/* TEST_OUTPUT: REQUIRED_ARGS: -preview=dip1000 --- fail_compilation/test22145.d(115): Error: assigning scope variable `x` to global variable `global` is not allowed in a `@safe` function --- */ // issues.dlang.org/show_bug.cgi?id=22145 #line 100 struct S { int opApply (scope int delegate (scope int* ptr) @safe dg) @safe { return 0; } } void test() @safe { static int* global; S s; foreach (scope int* x; s) { global = x; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9413.d0000644000175000017500000000535015205374124021032 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9413.d(45): Error: variable `fail9413.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9413.d(32): Error: variable `fail9413.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9413.d(33): Error: variable `fail9413.foo.bar.y` cannot modify parameter `y` in contract fail_compilation/fail9413.d(38): Error: variable `fail9413.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9413.d(39): Error: variable `fail9413.foo.bar.y` cannot modify parameter `y` in contract fail_compilation/fail9413.d(40): Error: variable `fail9413.foo.bar.s` cannot modify result `s` in contract fail_compilation/fail9413.d(50): Error: variable `fail9413.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9413.d(73): Error: variable `fail9413.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9413.d(74): Error: variable `fail9413.foo.r` cannot modify result `r` in contract fail_compilation/fail9413.d(58): Error: variable `fail9413.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9413.d(59): Error: variable `fail9413.foo.r` cannot modify result `r` in contract fail_compilation/fail9413.d(60): Error: variable `fail9413.foo.baz.y` cannot modify parameter `y` in contract fail_compilation/fail9413.d(65): Error: variable `fail9413.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9413.d(66): Error: variable `fail9413.foo.r` cannot modify result `r` in contract fail_compilation/fail9413.d(67): Error: variable `fail9413.foo.baz.y` cannot modify parameter `y` in contract fail_compilation/fail9413.d(68): Error: variable `fail9413.foo.baz.s` cannot modify result `s` in contract fail_compilation/fail9413.d(79): Error: variable `fail9413.foo.x` cannot modify parameter `x` in contract fail_compilation/fail9413.d(80): Error: variable `fail9413.foo.r` cannot modify result `r` in contract --- */ int foo(int x) in { int a; int bar(int y) in { x = 10; // err y = 10; // err a = 1; // OK } out(s) { x = 10; // err y = 10; // err s = 10; // err a = 1; // OK } do { x = 10; // err y = 1; // OK a = 1; // OK return 2; } x = 10; // err } out(r) { int a; int baz(int y) in { x = 10; // err r = 10; // err y = 10; // err a = 1; // OK } out(s) { x = 10; // err r = 10; // err y = 10; // err s = 10; // err a = 1; // OK } do { x = 10; // err r = 10; // err y = 1; // OK a = 1; // OK return 2; } x = 10; // err r = 10; // err } do { return 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail58.d0000644000175000017500000000232715205374124020667 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/fail58.d(28): Error: function `SomeFunc` is not callable using argument types `(string, int)` fail_compilation/fail58.d(28): cannot pass argument `"123"` of type `string` to parameter `dchar[] pText` fail_compilation/fail58.d(14): `fail58.SomeFunc(dchar[] pText, out int pStopPosn)` declared here fail_compilation/fail58.d(32): Error: function `SomeFunc` is not callable using argument types `(string, int)` fail_compilation/fail58.d(32): cannot pass argument `""` of type `string` to parameter `dchar[] pText` fail_compilation/fail58.d(14): `fail58.SomeFunc(dchar[] pText, out int pStopPosn)` declared here ---- */ debug import std.stdio; const int anything = -1000; // Line #2 dchar[] SomeFunc( dchar[] pText, out int pStopPosn) { if (pText.length == 0) pStopPosn = 0; else pStopPosn = -1; debug writefln("DEBUG: using '%s' we get %d", pText, pStopPosn); return pText.dup; } int main(char[][] pArgs) { int sp; SomeFunc("123", sp); debug writefln("DEBUG: got %d", sp); assert(sp == -1); SomeFunc("", sp); // if (sp != 0){} // Line #22 debug writefln("DEBUG: got %d", sp); assert(sp == -1); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21740b.i0000644000175000017500000000016115205374124021251 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail21740b.i(7): Error: undefined identifier `é` --- */ void *p = &\u00e9; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375w.d0000644000175000017500000000043715205374124021224 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375w.d(12): Error: else is dangling, add { } after condition at fail_compilation/fail4375w.d(10) --- */ static if (true) version (B) struct G1 {} else struct G2 {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17422.d0000644000175000017500000000070715205374124021156 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test17422.d(23): Error: returning scope variable `p` is not allowed in a `@safe` function --- */ struct RC { Object get() return @trusted { return cast(Object) &store[0]; } private: ubyte[__traits(classInstanceSize, Object)] store; } Object test() @safe { RC rc; auto p = rc.get; // p must be inferred as scope variable, works for int* return p; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19911a.d0000644000175000017500000000030415205374124021251 0ustar fabiofabio/* REQUIRED_ARGS: -betterC TEST_OUTPUT: --- fail_compilation/fail19911a.d(9): Error: function `fail19911a.fun` D-style variadic functions cannot be used with `-fno-rtti` --- */ void fun(...) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue22820.d0000644000175000017500000000337115205374124021325 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/issue22820.d(138): Error: upper and lower bounds are needed to slice a pointer fail_compilation/issue22820.d(138): pointer `s1` points to an aggregate that defines an `opIndex`, perhaps you meant `(*s1)[]` fail_compilation/issue22820.d(139): Error: upper and lower bounds are needed to slice a pointer fail_compilation/issue22820.d(139): pointer `s2` points to an aggregate that defines an `opSlice`, perhaps you meant `(*s2)[]` fail_compilation/issue22820.d(140): Error: upper and lower bounds are needed to slice a pointer fail_compilation/issue22820.d(140): pointer `s3` points to an aggregate that defines an `opIndex`, perhaps you meant `(*s3)[]` fail_compilation/issue22820.d(141): Error: upper and lower bounds are needed to slice a pointer fail_compilation/issue22820.d(141): pointer `cp` points to an aggregate that defines an `opIndex`, perhaps you meant `(*cp)[]` fail_compilation/issue22820.d(142): Error: upper and lower bounds are needed to slice a pointer fail_compilation/issue22820.d(142): pointer `e` points to an aggregate that defines an `opIndex`, perhaps you meant `(*e)[]` --- */ #line 100 // normal functions struct S1 { int[] opIndex() { return a; } int[] a; } // opSlice alternative struct S2 { int[] opSlice() { return a; } int[] a; } // templates struct S3 { int[] opIndex()() { return a; } int[] a; } class C { int[] opIndex()() { return a; } int[] a; } enum E : S1 { a = S1([1]) } void main() { S1* s1 = new S1; S2* s2 = new S2; S3* s3 = new S3; C c = new C; C* cp = &c; E* e = new E; int* p; p = s1[].ptr; p = s2[].ptr; p = s3[].ptr; p = cp[].ptr; p = e[].ptr; p = (*s1)[].ptr; p = (*s2)[].ptr; p = (*s3)[].ptr; p = (*cp)[].ptr; p = (*e)[].ptr; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail264.d0000644000175000017500000000030115205374124020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail264.d(10): Error: undefined identifier `undef` --- */ void main() { foreach (element; undef) { fn(element); } } void fn(int i) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10727a.d0000644000175000017500000000063315205374124021077 0ustar fabiofabio// REQUIRED_ARGS: -c // EXTRA_FILES: imports/foo10727a.d imports/stdtraits10727.d /* TEST_OUTPUT: --- fail_compilation/imports/foo10727a.d(34): Error: undefined identifier `Frop` fail_compilation/imports/foo10727a.d(26): Error: template instance `foo10727a.CirBuff!(Foo)` error instantiating fail_compilation/imports/foo10727a.d(31): instantiated from here: `Bar!(Foo)` --- */ import imports.foo10727a; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail213.d0000644000175000017500000000107015205374124020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail213.d(18): Error: template instance `Foo!int` does not match template declaration `Foo(T : immutable(T))` fail_compilation/fail213.d(25): Error: template instance `Foo!(const(int))` does not match template declaration `Foo(T : immutable(T))` --- */ template Foo(T:immutable(T)) { alias T Foo; } void main() { { int x; alias Foo!(typeof(x)) f; //printf("%s\n", typeid(f).toString().ptr); assert(is(typeof(x) == int)); assert(is(f == int)); } { const int x; alias Foo!(typeof(x)) f; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4082.d0000644000175000017500000000120515205374124021022 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4082.d(14): Error: destructor `fail4082.Foo.~this` is not `nothrow` fail_compilation/fail4082.d(12): Error: function `fail4082.test1` may throw but is marked as `nothrow` --- */ struct Foo { ~this() { throw new Exception(""); } } nothrow void test1() { Foo f; goto NEXT; NEXT: ; } /* TEST_OUTPUT: --- fail_compilation/fail4082.d(32): Error: destructor `fail4082.Bar.~this` is not `nothrow` fail_compilation/fail4082.d(32): Error: function `fail4082.test2` may throw but is marked as `nothrow` --- */ struct Bar { ~this() { throw new Exception(""); } } nothrow void test2(Bar t) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20040.d0000644000175000017500000000100415205374124021067 0ustar fabiofabio/* REQUIRED_ARGS: -o- TEST_OUTPUT: --- fail_compilation/fail20040.d(13): Error: no property `joiner` for type `string[]`, perhaps `import std.algorithm;` is needed? fail_compilation/fail20040.d(14): Error: no property `split` for type `string[]`, perhaps `import std.array;` is needed? fail_compilation/fail20040.d(15): Error: no property `startsWith` for type `string[]`, perhaps `import std.algorithm;` is needed? --- */ void main() { auto x = ["a","b","c"]; x.joiner(); x.split(); x.startsWith; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13816.d0000644000175000017500000000112115205374124020731 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13816.d(17): Error: template instance `TypeTuple!(ItemProperty!())` recursive template expansion fail_compilation/ice13816.d(17): Error: alias `ice13816.ItemProperty!().ItemProperty` recursive alias declaration fail_compilation/ice13816.d(22): Error: template instance `ice13816.ItemProperty!()` error instantiating --- */ alias TypeTuple(T...) = T; template ItemProperty() { static if (true) { alias ItemProperty = TypeTuple!(ItemProperty!()); } } void main() { alias items = ItemProperty!(); enum num = items.length; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail77.d0000644000175000017500000000035315205374124020665 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail77.d(11): Error: cannot cast expression `& i` of type `int*` to `ubyte[4]` --- */ void test() { int i; ubyte[4] ub; ub[] = cast(ubyte[4]) &i; //ub[] = (cast(ubyte*) &i)[0..4]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/nogc3.d0000644000175000017500000000661315205374124020612 0ustar fabiofabio// REQUIRED_ARGS: -o- /***************** AssignExp *******************/ /* TEST_OUTPUT: --- fail_compilation/nogc3.d(15): Error: setting this array's `length` causes a GC allocation in `@nogc` function `testArrayLength` fail_compilation/nogc3.d(16): Error: setting this array's `length` causes a GC allocation in `@nogc` function `testArrayLength` fail_compilation/nogc3.d(17): Error: setting this array's `length` causes a GC allocation in `@nogc` function `testArrayLength` --- */ @nogc void testArrayLength(int[] a) { a.length = 3; a.length += 1; a.length -= 1; } /***************** CallExp *******************/ void barCall(); /* TEST_OUTPUT: --- fail_compilation/nogc3.d(34): Error: `@nogc` function `nogc3.testCall` cannot call non-@nogc function pointer `fp` fail_compilation/nogc3.d(35): Error: `@nogc` function `nogc3.testCall` cannot call non-@nogc function `nogc3.barCall` --- */ @nogc void testCall() { auto fp = &barCall; (*fp)(); barCall(); } /****************** Closure ***********************/ @nogc void takeDelegate2(scope int delegate() dg) {} @nogc void takeDelegate3( int delegate() dg) {} /* TEST_OUTPUT: --- fail_compilation/nogc3.d(54): Error: function `nogc3.testClosure1` is `@nogc` yet allocates closure for `testClosure1()` with the GC fail_compilation/nogc3.d(57): function `bar` closes over variable `x` fail_compilation/nogc3.d(56): `x` declared here fail_compilation/nogc3.d(66): Error: function `nogc3.testClosure3` is `@nogc` yet allocates closure for `testClosure3()` with the GC fail_compilation/nogc3.d(69): function `bar` closes over variable `x` fail_compilation/nogc3.d(68): `x` declared here --- */ @nogc auto testClosure1() { int x; int bar() { return x; } return &bar; } @nogc void testClosure2() { int x; int bar() { return x; } takeDelegate2(&bar); // no error } @nogc void testClosure3() { int x; int bar() { return x; } takeDelegate3(&bar); } /****************** ErrorExp ***********************/ /* TEST_OUTPUT: --- fail_compilation/nogc3.d(87): Error: this array literal causes a GC allocation in `@nogc` function `foo13702` fail_compilation/nogc3.d(88): Error: this array literal causes a GC allocation in `@nogc` function `foo13702` fail_compilation/nogc3.d(94): Error: this array literal causes a GC allocation in `@nogc` function `bar13702` fail_compilation/nogc3.d(93): Error: this array literal causes a GC allocation in `@nogc` function `bar13702` --- */ int[] foo13702(bool b) @nogc { if (b) return [1]; // error return 1 ~ [2]; // error } int[] bar13702(bool b) @nogc { if (b) return [1]; // error <- no error report auto aux = 1 ~ [2]; // error return aux; } /********** Enum and pointer types ***************/ // https://github.com/dlang/dmd/issues/21052 /* TEST_OUTPUT: --- fail_compilation/nogc3.d(111): Error: this array literal causes a GC allocation in `@nogc` function `f` fail_compilation/nogc3.d(112): Error: this array literal causes a GC allocation in `@nogc` function `f` --- */ void f() @nogc { enum DA : int[] { a = [1,2,3] } DA da = DA.a; int i = *cast(int*)cast(char[4])['0', '0', '0', '0']; } /* TEST_OUTPUT: --- fail_compilation/nogc3.d(125): Error: this array literal causes a GC allocation in `@nogc` function `g` --- */ // https://github.com/dlang/dmd/issues/21054 void g() @nogc { int[] x = (int[2]).init[]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_contracts3.d0000644000175000017500000000043515205374124022653 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail_contracts3.d(13): Error: function `fail_contracts3.D.foo` cannot have an in contract when overridden function `fail_contracts3.C.foo` does not have an in contract --- */ class C { void foo(){} } class D : C { override void foo()in{}do{} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20609.d0000644000175000017500000000352215205374124021111 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail20609.d(26): Error: none of the overloads of `this` are callable using argument types `(int)` fail_compilation/fail20609.d(23): Candidate is: `fail20609.Foo.this(string[] args)` fail_compilation/fail20609.d(27): Error: none of the overloads of `this` are callable using argument types `(int)` fail_compilation/fail20609.d(22): Candidates are: `fail20609.Foo.this(Object __param_0)` fail_compilation/fail20609.d(23): `fail20609.Foo.this(string[] args)` fail_compilation/fail20609.d(37): Error: none of the overloads of `this` are callable using argument types `(int)` fail_compilation/fail20609.d(37): All possible candidates are marked as `deprecated` or `@disable` fail_compilation/fail20609.d(43): Error: undefined identifier `deprecatedTypo_` fail_compilation/fail20609.d(44): Error: undefined identifier `deprecatedTypo_`, did you mean function `deprecatedTypo`? fail_compilation/fail20609.d(45): Error: undefined identifier `disabledTypo_` --- */ // Only show `this(string[])` in non-deprecated context. // Show both `this(string[])` and ` this(Object)` in deprecated context. struct Foo { @disable this(); deprecated this(Object) {} this(string[] args) {} } void test1() { auto f = Foo(42); } deprecated void test2() { auto f = Foo(42); } // Make sure we do not show a message promising candidates, // then no candidates in the special case where nothing // would be usable struct WhoDoesThat { @disable this(); deprecated this(Object) {} } void test3() { auto f = WhoDoesThat(42); } // Make sure we don't suggest disabled or deprecated functions deprecated void deprecatedTypo () {} @disable void disabledTypo () {} void test4 () { deprecatedTypo_("42"); } deprecated void test5 () { deprecatedTypo_("42"); } void test6 () { disabledTypo_("42"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag18460.d0000644000175000017500000000036015205374124021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag18460.d(12): Error: no property `opCall` for type `diag18460.Foo`, did you mean `new Foo`? --- */ // https://issues.dlang.org/show_bug.cgi?id=18460 class Foo {} void main() { auto f = Foo(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail55.d0000644000175000017500000000076715205374124020672 0ustar fabiofabio/* TEST_OUTPUT: --- 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` --- */ // $HeadURL$ // $Date$ // $Author$ // @author@ zwang // @date@ 2005-02-03 // @uri@ news:cttjjg$4i0$2@digitaldaemon.com // __DSTRESS_ELINE__ 14 module dstress.nocompile.bug_mtype_507_D; void test() { 0 < Exception; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/nestedtempl3.d0000644000175000017500000000054515205374124022206 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/nestedtempl3.d(23): Error: cannot access frame pointer of `nestedtempl3.test.S!(i).S` --- */ void test() { int i; auto f0() { int j = 10; struct S(alias a) { auto get() { return j; } } return S!i(); } alias S = typeof(f0()); auto s = S(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7077.d0000644000175000017500000000024115205374124021030 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7077.d(11): Error: undefined identifier `x` --- */ void main() { if(0) mixin("auto x = 2;"); assert(x == 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail228.d0000644000175000017500000000046215205374124020744 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail228.d(22): Error: undefined identifier `localVariable` --- */ //import core.stdc.stdio : printf; int ToTypeString(T : int)() { return 1; } int ToTypeString(T : string)() { return 2; } void main() { auto x = ToTypeString!(typeof(localVariable))(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/objc_class1.d0000644000175000017500000000050715205374124021760 0ustar fabiofabio// EXTRA_OBJC_SOURCES: /* TEST_OUTPUT: --- fail_compilation/objc_class1.d(13): Error: function `objc_class1.A.oneTwo` must have Objective-C linkage to attach a selector --- */ import core.attribute : selector; class A { void oneTwo(int a, int b) @selector("one:two:"); // selector attached in non-Objective-C interface } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail16206a.d0000644000175000017500000000050115205374124021242 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail16206a.d(14): Error: `bool` expected as third argument of `__traits(getOverloads)`, not `"Not a bool"` of type `string` --- */ struct S { static int foo()() { return 0; } } alias AliasSeq(T...) = T; alias allFoos = AliasSeq!(__traits(getOverloads, S, "foo", "Not a bool")); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20658.d0000644000175000017500000000041015205374124021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail20658.d(14): Error: modifying field `U.m` which overlaps with fields with other storage classes is not allowed in a `@safe` function --- */ union U { int m; immutable int i; } U u; enum e = () @safe { u.m = 13; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/deprecate12979a.d0000644000175000017500000000037415205374124022310 0ustar fabiofabio// REQUIRED_ARGS: -de /* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/deprecate12979a.d(12): Error: `asm` statement is assumed to throw - mark it with `nothrow` if it does not --- */ void foo() nothrow { asm { ret; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/cpp_cast.d0000644000175000017500000000137115205374124021371 0ustar fabiofabio// See also: fail20000.d /* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/cpp_cast.d(19): Error: cast from `cpp_cast.I` to `cpp_cast.C` is not allowed in a `@safe` function fail_compilation/cpp_cast.d(19): No dynamic type information for extern(C++) classes fail_compilation/cpp_cast.d(21): Deprecation: cast from `cpp_cast.C` to `cpp_cast.D` will become `@system` in a future release fail_compilation/cpp_cast.d(21): No dynamic type information for extern(C++) classes --- */ extern(C++) interface I { void f(); } extern(C++) class C : I { void f() { } } extern(C++) class D : C { } void main() @safe { I i; C c = cast(C) i; // unsafe i = cast(I) c; // OK c = cast(D) c; // reinterpret cast c = cast(C) new D; // OK } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail176.d0000644000175000017500000000064415205374124020750 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail176.d(13): Error: cannot modify `immutable` expression `a[1]` fail_compilation/fail176.d(16): Error: cannot modify `immutable` expression `b[1]` fail_compilation/fail176.d(19): Error: cannot modify `const` expression `c[1]` --- */ void foo() { auto a = "abc"; a[1] = 'd'; immutable char[3] b = "abc"; b[1] = 'd'; const char[3] c = "abc"; c[1] = 'd'; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4269a.d0000644000175000017500000000050015205374124021167 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4269a.d(12): Error: undefined identifier `B` fail_compilation/fail4269a.d(12): Error: field `blah` not allowed in interface fail_compilation/fail4269a.d(13): Error: undefined identifier `B` --- */ enum bool WWW = is(typeof(A.x)); interface A { B blah; void foo(B b){} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21198.d0000644000175000017500000000055115205374124021160 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21198 /* TEST_OUTPUT: --- fail_compilation/test21198.d(23): Error: generating an `inout` copy constructor for `struct test21198.U` failed, therefore instances of it are uncopyable --- */ struct S { this(ref inout(S) other) inout {} } union U { S s; } void fun() { U original; U copy = original; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/constraints_func1.d0000755000175000017500000000731615205374124023250 0ustar fabiofabio/* EXTRA_FILES: imports/constraints.d TEST_OUTPUT: --- fail_compilation/constraints_func1.d(79): Error: template `test1` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(9): Candidate is: `test1(T)(T v)` with `T = int` must satisfy the following constraint: ` N!T` fail_compilation/constraints_func1.d(80): Error: template `test2` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(10): Candidate is: `test2(T)(T v)` with `T = int` must satisfy the following constraint: ` !P!T` fail_compilation/constraints_func1.d(81): Error: template `test3` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(11): Candidate is: `test3(T)(T v)` with `T = int` must satisfy the following constraint: ` N!T` fail_compilation/constraints_func1.d(82): Error: template `test4` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(12): Candidate is: `test4(T)(T v)` with `T = int` must satisfy the following constraint: ` N!T` fail_compilation/constraints_func1.d(83): Error: template `test5` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(13): Candidate is: `test5(T)(T v)` with `T = int` must satisfy one of the following constraints: ` N!T N!T` fail_compilation/constraints_func1.d(84): Error: template `test6` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(14): Candidate is: `test6(T)(T v)` with `T = int` must satisfy one of the following constraints: ` N!T N!T !P!T` fail_compilation/constraints_func1.d(85): Error: template `test7` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(15): Candidate is: `test7(T)(T v)` with `T = int` must satisfy one of the following constraints: ` N!T N!T` fail_compilation/constraints_func1.d(86): Error: template `test8` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(16): Candidate is: `test8(T)(T v)` with `T = int` must satisfy the following constraint: ` N!T` fail_compilation/constraints_func1.d(87): Error: template `test9` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(17): Candidate is: `test9(T)(T v)` with `T = int` must satisfy the following constraint: ` !P!T` fail_compilation/constraints_func1.d(88): Error: template `test10` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(18): Candidate is: `test10(T)(T v)` with `T = int` must satisfy the following constraint: ` !P!T` fail_compilation/constraints_func1.d(89): Error: template `test11` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(19): Candidate is: `test11(T)(T v)` with `T = int` must satisfy one of the following constraints: ` N!T !P!T` fail_compilation/constraints_func1.d(90): Error: template `test12` is not callable using argument types `!()(int)` fail_compilation/imports/constraints.d(20): Candidate is: `test12(T)(T v)` with `T = int` must satisfy the following constraint: ` !P!T` fail_compilation/constraints_func1.d(92): Error: template `test1` is not callable using argument types `!()(int, int)` fail_compilation/imports/constraints.d(9): Candidate is: `test1(T)(T v)` --- */ void main() { import imports.constraints; test1(0); test2(0); test3(0); test4(0); test5(0); test6(0); test7(0); test8(0); test9(0); test10(0); test11(0); test12(0); test1(0, 0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10359.d0000644000175000017500000000025615205374124021104 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10359.d(10): Error: pointer slicing is not allowed in a `@safe` function --- */ void foo(int* p) @safe { auto a = p[0 .. 10]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20730b.d0000644000175000017500000000177615205374124021257 0ustar fabiofabio/* REQUIRED_ARGS: -verrors=spec -o- TEST_OUTPUT: --- (spec:1) fail_compilation/fail20730b.d-mixin-43(43): Error: C style cast illegal, use `cast(int)mod` fail_compilation/fail20730b.d(26): Error: template `atomicOp` is not callable using argument types `!("+=")(shared(uint), int)` fail_compilation/fail20730b.d(41): Candidate is: `atomicOp(string op, T, V1)(ref shared T val, V1 mod)` with `op = "+=", T = uint, V1 = int` must satisfy the following constraint: ` __traits(compiles, mixin("(int)mod"))` --- */ void test20730() { auto f = File().byLine; } struct File { shared uint refs; this(this) { atomicOp!"+="(refs, 1); } struct ByLineImpl(Char) { File file; char[] line; } auto byLine() { return ByLineImpl!char(); } } T atomicOp(string op, T, V1)(ref shared T val, V1 mod) // C-style cast causes raises a parser error whilst gagged. if (__traits(compiles, mixin("(int)mod"))) { return val; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20800.d0000644000175000017500000000104615205374124021101 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20800 /* TEST_OUTPUT: ---- fail_compilation/fail20800.d(23): Error: function `fun` is not callable using argument types `(string)` fail_compilation/fail20800.d(23): cannot pass argument `(m()).index()` of type `string` to parameter `int a` fail_compilation/fail20800.d(19): `fail20800.fun(int a)` declared here ---- */ struct RegexMatch { string index() { return null; } ~this() { } } static m() { return RegexMatch(); } void fun(int a); void initCommands() { fun(m.index); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20763.d0000644000175000017500000000213715205374124021157 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/test20763.d(25): Deprecation: type `ulong` has no value fail_compilation/test20763.d(25): perhaps use `ulong.init` fail_compilation/test20763.d(26): Deprecation: type `ulong` has no value fail_compilation/test20763.d(26): perhaps use `ulong.init` fail_compilation/test20763.d(27): Error: type `ulong` has no value fail_compilation/test20763.d(27): perhaps use `ulong.init` fail_compilation/test20763.d(28): Error: type `ulong` has no value fail_compilation/test20763.d(28): perhaps use `ulong.init` fail_compilation/test20763.d(29): Error: type `ulong` has no value fail_compilation/test20763.d(29): perhaps use `ulong.init` fail_compilation/test20763.d(30): Error: type `ulong` has no value fail_compilation/test20763.d(30): perhaps use `ulong.init` --- */ // https://github.com/dlang/dmd/issues/20763 void test() { alias I = ulong; alias U0 = typeof(I + 1u); alias U1 = typeof(1 - I); alias U2 = typeof(+I); alias U3 = typeof(I * 1); alias U4 = typeof(I << 1); alias U5 = typeof(I | 1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19914.d0000644000175000017500000000036515205374124021122 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19914.d(8): Error: undefined identifier `c` in module `fail19914` fail_compilation/fail19914.d(9): Error: mixin `fail19914.a!string` error instantiating --- */ class a(b) { align.c d; } mixin a!(string); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20267.d0000644000175000017500000000152715205374124021160 0ustar fabiofabio/* EXTRA_FILES: imports/test20267.d TEST_OUTPUT: --- fail_compilation/test20267.d(20): Error: variable `string` is used as a type fail_compilation/test20267.d(19): variable `string` is declared here fail_compilation/test20267.d(23): Error: variable `boolean` is used as a type fail_compilation/test20267.d(22): variable `boolean` is declared here fail_compilation/test20267.d(30): Error: variable `array` is used as a type fail_compilation/test20267.d(28): variable `array` is imported here from: `imports.test20267` fail_compilation/imports/test20267.d(3): variable `array` is declared here --- */ alias boolean = bool; void foo(string[] args) { immutable string = "bar"; string[] args2 = args; bool boolean = true; boolean b = false; } void bar() { import imports.test20267 : array; array foo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18620.d0000644000175000017500000000114715205374124021112 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail18620.d(14): Error: `strlen` cannot be interpreted at compile time, because it has no available source code fail_compilation/fail18620.d(19): compile time context created here fail_compilation/fail18620.d(14): Error: `strlen` cannot be interpreted at compile time, because it has no available source code fail_compilation/fail18620.d(20): compile time context created here --- */ class A{ this(const(char)* s) { import core.stdc.string; auto a=strlen(s); } } void main(){ static a = new A("a"); __gshared b = new A("b"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20610.d0000644000175000017500000000045315205374124021145 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test20610.d(20): Error: cannot modify `const` expression `field` --- */ // https://issues.dlang.org/show_bug.cgi?id=20610 struct S { int what; } void main() { S record; foreach (const ref field; record.tupleof) { field = 10; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail354.d0000644000175000017500000000040515205374124020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail354.d(11): Error: template instance `T!N` template `T` is not defined fail_compilation/fail354.d(13): Error: template instance `fail354.S!1` error instantiating --- */ struct S(int N) { this(T!N) { } } alias S!1 M; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3895.d0000644000175000017500000000033515205374124021040 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail3895.d(12): Error: cannot append type `double[]` to type `float[]` --- */ void main() { double[] stuff = [1.,2.,3.,4.,5.]; float[] otherStuff; otherStuff ~= stuff; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix5212.d0000644000175000017500000000052015205374124020670 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fix5212.d(14): Error: assigning scope variable `args_` to non-scope `this.args` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=5212 class Foo { int[] args; @safe this(int[] args_...) { args = args_; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14146.d0000644000175000017500000000052715205374124020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice14146.d(15): Error: constructor `ice14146.Array.this` default constructor for structs only allowed with `@disable`, no body, and no parameters --- */ struct RangeT(A) { A[1] XXXouter; } struct Array { this() { } alias Range = RangeT!Array; bool opEquals(Array) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11151.d0000644000175000017500000000134415205374124021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11151.d(30): Error: overlapping initialization for field `a` and `y` --- */ //extern(C) int printf(const char*, ...); union U { struct { align(1) long a; align(1) int b; } struct { align(1) int x; align(1) long y; } } void main() { static assert(U.a.offsetof == 0); static assert(U.b.offsetof == 8); static assert(U.x.offsetof == 0); static assert(U.y.offsetof == 4); U u = {a:1, y:2}; // overlapped initializing U.a and U.y //printf("u.a = %lld\n", u.a); // 8589934593 , Wrong! //printf("u.b = %d\n", u.b); // 0 //printf("u.x = %d\n", u.x); // 1 //printf("u.y = %lld\n", u.y); // 2 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/interpolatedexpressionsequence_postfix.d0000644000175000017500000000106415205374124027713 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/interpolatedexpressionsequence_postfix.d(10): Error: String postfixes on interpolated expression sequences are not allowed. fail_compilation/interpolatedexpressionsequence_postfix.d(11): Error: String postfixes on interpolated expression sequences are not allowed. fail_compilation/interpolatedexpressionsequence_postfix.d(12): Error: String postfixes on interpolated expression sequences are not allowed. --- */ void main() { // all postfixes are banned auto c = i"foo"c; auto w = i"foo"w; auto d = i"foo"d; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9013.d0000644000175000017500000000026215205374124020650 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9013.d(9): Error: undefined identifier `missing` --- */ void main() { foreach (i; 0 .. missing) int[] foo = cast(int[])[i]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15068.d0000644000175000017500000000061515205374124021114 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail15068.d(17): Error: `T!int` is not a valid template instance, because `T` is not a template declaration but a type (`T == int`) fail_compilation/fail15068.d(13): Error: template instance `fail15068.Stuff!int` error instantiating --- */ // https://issues.dlang.org/show_bug.cgi?id=15068 void main() { Stuff!int s; } struct Stuff(T) { T!int var; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/skip.d0000644000175000017500000000174515205374124020550 0ustar fabiofabio/* * REQUIRED_ARGS: -de * TEST_OUTPUT: --- fail_compilation/skip.d(23): Error: `switch` skips declaration of `with` temporary fail_compilation/skip.d(28): declared here fail_compilation/skip.d(45): Error: `switch` skips declaration of variable `skip.test14532.n` fail_compilation/skip.d(47): declared here --- */ // https://issues.dlang.org/show_bug.cgi?id=10524 struct S { int field; } void test10524() { int a = 1; S struct_with_long_name; switch( a ) { case 0: struct_with_long_name.field = 444; // ok break; with( struct_with_long_name ) { case 1: field = 555; // segfault break; } default: break; } } // https://issues.dlang.org/show_bug.cgi?id=14532 void test14532() { char ch = '!'; switch (ch) { int n = 42; case '!': assert(n == 42); break; default: } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/enum_function.d0000644000175000017500000000076315205374124022452 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/enum_function.d(11): Deprecation: function cannot have enum storage class fail_compilation/enum_function.d(12): Deprecation: function cannot have enum storage class fail_compilation/enum_function.d(13): Deprecation: function cannot have enum storage class fail_compilation/enum_function.d(14): Deprecation: function cannot have enum storage class --- */ enum void f1() { return; } enum f2() { return 5; } enum f3() => 5; enum int f4()() => 5; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail142.d0000644000175000017500000000054015205374124020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail142.d(21): Error: cannot create instance of abstract class `B` fail_compilation/fail142.d(15): class `B` is declared here fail_compilation/fail142.d(12): function `void test()` is not implemented --- */ class A { abstract void test() {} } class B : A { } void main() { B b = new B(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15544.d0000644000175000017500000000170615205374124021161 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test15544.d(20): Error: assigning reference to local `this` to non-scope `_del` is not allowed in a `@safe` function fail_compilation/test15544.d(22): Error: assigning reference to local `this` to non-scope `_del` is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=15544 void delegate() @safe _del; struct S { int x = 42; @safe void test() { void foo() { assert(x == 42); } _del = &foo; _del = { assert(x == 42); }; } } /* TEST_OUTPUT: --- fail_compilation/test15544.d(46): Error: assigning reference to local `y` to non-scope `dg` is not allowed in a `@safe` function --- */ int delegate() dg; void testClosure1() { int* x; int bar() { return *x; } dg = &bar; } @safe void testClosure2() { scope int* y; int bar() { return *y; } dg = &bar; // Error auto dg2 = &bar; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12836.d0000644000175000017500000000026415205374124020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12836.d(9): Error: undefined identifier `C` fail_compilation/ice12836.d(9): Error: undefined identifier `K` --- */ immutable C L = 1 << K; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9279.d0000644000175000017500000000061115205374124021037 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9279.d(10): Error: escaping reference to stack allocated value returned by `b()` fail_compilation/fail9279.d(13): Error: escaping reference to stack allocated value returned by `getArr()` --- */ char[2] b()() { char[2] ret; return ret; } string a() { return b(); } char[12] getArr() { return "Hello World!"; } string getString() { return getArr(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/hidden_ctor.d0000644000175000017500000000077715205374124022070 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/hidden_ctor.d(25): Error: constructor `hidden_ctor.B.this(string s)` is not callable using argument types `()` fail_compilation/hidden_ctor.d(25): Note: constructor `hidden_ctor.B.this` hides base class constructor `hidden_ctor.A.this` --- */ class A { int a; this() { this.a = 1; } } class B : A { string b; this(string s) { super(); this.b = s; } } void main() { auto b = new B(); b = new B("Hi, Mom!"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail144.d0000644000175000017500000000073715205374124020746 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail144.d(13): Error: message fail_compilation/fail144.d(26): called from here: `bar(7)` --- */ //import core.stdc.stdio : printf; int bar(int i) { assert(i < 0, "message"); foreach_reverse (k, v; "hello") { i <<= 1; if (k == 2) break; i += v; } return i; } void main() { static b = bar(7); auto c = bar(7); //printf("b = %d, %d\n", b, c); assert(b == 674); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11553.d0000644000175000017500000000055515205374124020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11553.d(22): Error: recursive template expansion while looking for `A!().A()` fail_compilation/ice11553.d(22): Error: expression `A()` of type `void` does not have a boolean value --- */ template A(alias T) { template A() { alias A = T!(); } } template B() { alias B = A!(.B); } static if (A!B) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail247.d0000644000175000017500000000031215205374124020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail247.d-mixin-9(9): Error: identifier expected, not `End of File` fail_compilation/fail247.d-mixin-9(9): Error: `;` expected after `mixin` --- */ mixin(`mixin`); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21091a.d0000644000175000017500000000061215205374124021243 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21091 /* TRANSFORM_OUTPUT: remove_lines("^import path") TEST_OUTPUT: ---- fail_compilation/fail21091a.d(14): Error: unable to read module `Ternary` fail_compilation/fail21091a.d(14): Expected 'Ternary.d' or 'Ternary/package.d' in one of the following import paths: ---- */ struct NullAllocator { import Ternary; Ternary owns() { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail281.d0000644000175000017500000000072415205374124020744 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=2920 // recursive templates blow compiler stack // template_29_B. /* TEST_OUTPUT: --- fail_compilation/fail281.d(15): Error: template instance `fail281.foo!4294966795u` recursive expansion exceeded allowed nesting limit --- */ template foo(uint i) { static if (i > 0) { const uint bar = foo!(i - 1).bar; } else { const uint bar = 1; } } int main() { return foo!(uint.max).bar; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21025.d0000644000175000017500000000112415205374124021142 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21025 // REQUIRED_ARGS: -preview=dip1021 /* TEST_OUTPUT: --- fail_compilation/test21025.d(15): Error: variable `r` cannot be read at compile time fail_compilation/test21025.d(15): called from here: `binaryFun(r, r)` fail_compilation/test21025.d(24): Error: template `uniq` is not callable using argument types `!()(void[])` fail_compilation/test21025.d(14): Candidate is: `uniq()(int[] r)` --- */ void uniq()(int[] r) if (binaryFun(r, r)) {} bool binaryFun(T, U)(T, U) { return true; } void generateStatements() { uniq([]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/testhtml3.html0000644000175000017500000000043315205374124022243 0ustar fabiofabio dstress: html_tag_space_01
< CODE >
int main(){
	return 0;
}
./ldc-1.42.0-src/tests/dmd/fail_compilation/diag21883.d0000644000175000017500000000042715205374124021110 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag21883.d(15): Error: `diag21883.ClassB`: base class must be specified first, before any interfaces. --- */ // https://issues.dlang.org/show_bug.cgi?id=21883 interface InterfaceA { } class ClassA { } class ClassB: InterfaceA, ClassA { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice23564.d0000644000175000017500000000056315205374124020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice23564.d(10): Error: cannot construct nested class `FreeList` because no implicit `this` reference to outer class `RBTree` is available --- */ class BlockHeader { this() { new FreeList; } } class RBTree { class FreeList { } void _each_reverse() { } } alias FreeList = RBTree.FreeList; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20324.d0000644000175000017500000000064515205374124021152 0ustar fabiofabio/* REQUIRED_ARGS: -unittest TEST_OUTPUT: --- fail_compilation/test20324.d(16): Error: argument `Test()` to __traits(getUnitTests) must be a module or aggregate, not a template fail_compilation/test20324.d(16): while evaluating `pragma(msg, __traits(getUnitTests, Test))` --- */ // https://issues.dlang.org/show_bug.cgi?id=20324 template Test() { unittest { } } pragma(msg, __traits(getUnitTests, Test)); ./ldc-1.42.0-src/tests/dmd/fail_compilation/b19730.d0000644000175000017500000000037415205374124020424 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/b19730.d(10): Error: found `)` while expecting `=` or identifier fail_compilation/b19730.d(11): Error: found `)` while expecting `=` or identifier --- */ void func() { bool x; if (const x) {} if (auto x) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15616d.d0000644000175000017500000000132715205374124021260 0ustar fabiofabio/* REQUIRED_ARGS: -verror-supplements=2 TEST_OUTPUT: --- fail_compilation/fail15616d.d(44): Error: none of the overloads of `foo` are callable using argument types `(double)` fail_compilation/fail15616d.d(17): Candidates are: `fail15616d.foo(int a)` fail_compilation/fail15616d.d(20): `fail15616d.foo(int a, int b)` fail_compilation/fail15616d.d(44): ... (6 more, -v to show) ... --- */ #line 17 void foo(int a) {} void foo(int a, int b) {} void foo(T)(T a) if (is(T == float)) {} void foo(T)(T a) if (is(T == char)) {} void foo(int a, int b, int c) {} void foo(string a) {} void foo(string a, string b) {} void foo(string a, string b, string c) {} void main() { foo(3.14); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21304.d0000644000175000017500000000020315205374124021137 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test21304.d(6): Error: undefined identifier `unknown` --- */ int[unknown] values = [1, 2, 3]; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22881.d0000644000175000017500000000377615205374124021130 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail22881.d(101): Error: pointer slice `[0..6]` exceeds allocated memory block `[0..5]` fail_compilation/fail22881.d(102): Error: pointer slice `[0..6]` exceeds allocated memory block `[0..5]` fail_compilation/fail22881.d(110): Error: pointer slice `[3..5]` exceeds allocated memory block `[0..4]` fail_compilation/fail22881.d(113): called from here: `ptr22881()` fail_compilation/fail22881.d(113): while evaluating: `static assert(ptr22881())` fail_compilation/fail22881.d(203): Error: slice `[0..2]` is out of bounds fail_compilation/fail22881.d(207): called from here: `null22881()` fail_compilation/fail22881.d(207): while evaluating: `static assert(null22881())` fail_compilation/fail22881.d(305): Error: slice `[2..4]` exceeds array bounds `[0..3]` fail_compilation/fail22881.d(308): called from here: `slice22881()` fail_compilation/fail22881.d(308): while evaluating: `static assert(slice22881())` fail_compilation/fail22881.d(401): Error: slice `[0..1]` exceeds array bounds `[0..0]` fail_compilation/fail22881.d(403): Error: slice `[0..1]` exceeds array bounds `[0..0]` --- */ #line 100 // SliceExp: e1.type.ty == pointer static pstr22881 = "hello".ptr[0 .. 6]; static parr22881 = ['h','e','l','l','o'].ptr[0 .. 6]; bool ptr22881() { char *p1 = new char[4].ptr; p1[0 .. 4] = "str\0"; char *s1 = p1[1 .. 3].ptr; char *s2 = s1[1 .. 3].ptr; // = p1[2 .. 4] char *s3 = s2[1 .. 3].ptr; // = p1[3 .. 5] return true; } static assert(ptr22881()); #line 200 // SliceExp: e1.op == null bool null22881() { string[][1] nullexp; nullexp[0][0 .. 2] = "st"; return true; } static assert(null22881()); #line 300 // SliceExp: e1.op == slice bool slice22881() { char[] str = "abcd".dup; char[] slice = str[1 .. 4]; slice[2 .. 4] = "ab"; return true; } static assert(slice22881()); #line 400 // SliceExp: e1.op == arrayLiteral static arr22881 = [][0 .. 1]; // SliceExp: e1.op == string_ static str22881 = ""[0 .. 1]; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22818.d0000644000175000017500000000061015205374124021154 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 * TEST_OUTPUT: --- fail_compilation/test22818.d(102): Deprecation: typesafe variadic parameters with a `class` type (`C c...`) are deprecated fail_compilation/test22818.d(104): Error: scope parameter `c` may not be returned --- */ // issues.dlang.org/show_bug.cgi?id=22818 #line 100 @safe: ref int g(C c ...) { return c.x; } class C { int x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail5851.d0000644000175000017500000000031415205374124021027 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail5851.d(11): Error: alias this is not reachable as `Foo` already converts to `object.Object` --- */ class Foo { Object o; alias o this; } void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix20075.d0000644000175000017500000000075115205374124020762 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix20075.d(15): Error: none of the overloads of `this` can construct an immutable object with argument types `(int*)`. Expected `immutable(int*)` fail_compilation/fix20075.d(11): Candidate is: `fix20075.Foo.this(immutable(int*) a) immutable` --- */ struct Foo { @disable this(); immutable this(immutable int* a) {} } immutable(Foo) getFoo(int* a) { return immutable Foo(a); } void main() { int x; auto foo = getFoo(&x); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7424e.d0000644000175000017500000000032215205374124021171 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7424e.d(10): Error: template `this.g()() immutable` has no value --- */ struct S7424e { @property int g()() immutable { return 0; } void test() { int f = g; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11626.d0000644000175000017500000000017115205374124020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11626.d(8): Error: undefined identifier `Bar` --- */ void foo(const ref Bar) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17689.d0000644000175000017500000000023515205374124021125 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail17689.d(10): Error: undefined identifier `x` --- */ void main(){ try{} finally int x=3; assert(x==3); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix19613.d0000644000175000017500000000067415205374124020774 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix19613.d(15): Error: function `fix19613.B.a` cannot override `final` function `fix19613.A.a` fail_compilation/fix19613.d(15): Error: function `fix19613.B.a` does not override any function fail_compilation/fix19613.d(15): Did you mean to override `void fix19613.A.a(string)`? --- */ class A { final void a(int) {} void a(string) {} } class B : A { override void a(int) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/alignas3.c0000644000175000017500000000056215205374124021276 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/alignas3.c(12): Error: `_Alignas` specifier cannot be less strict than alignment of `c` fail_compilation/alignas3.c(13): Error: alignment must be an integer positive power of 2, not 0x1 --- */ struct S { _Alignas(1) _Alignas(int) int a; _Alignas(1) _Alignas(16) int b; _Alignas(1) int c; _Alignas((void*)1) int d; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22574.d0000644000175000017500000000026215205374124021156 0ustar fabiofabio//https://issues.dlang.org/show_bug.cgi?id=22574 /* TEST_OUTPUT: --- fail_compilation/test22574.d(100): Error: undefined identifier `x` --- */ #line 100 template test(x* x) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail78.d0000644000175000017500000000020415205374124020661 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail78.d(9): Error: undefined identifier `inch` --- */ auto yd = ft * 3; auto ft = inch * 12; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail328.d0000644000175000017500000000040115205374124020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail328.d(13): Error: `@safe` function `fail328.foo` cannot call `@system` function `fail328.bar` fail_compilation/fail328.d(9): `fail328.bar` is declared here --- */ void bar(); @safe void foo() { bar(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail92.d0000644000175000017500000000055715205374124020670 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail92.d(15): Error: invalid `foreach` aggregate `t` of type `typeof(null)` fail_compilation/fail92.d(23): Error: template instance `fail92.crash!(typeof(null))` error instantiating --- */ // [25] template crash(T) { void crash(T t) { foreach (u; t) { } } } void main() { crash(null); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue21203.d0000644000175000017500000000060115205374124021310 0ustar fabiofabio// Ideally this should work, at least give a nice error messae /** REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/issue21203.d(12): Error: `pragma(mangle)` cannot apply to a template declaration fail_compilation/issue21203.d(12): use `template F(Args...) { pragma(mangle, "gdkfjgh") ... }` --- */ extern(C++) pragma(mangle,"gdkfjgh") class F(T) { } void use(F!int a) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/constraints_func4.d0000755000175000017500000000661015205374124023247 0ustar fabiofabio/* EXTRA_FILES: imports/constraints.d REQUIRED_ARGS: -verrors=context TEST_OUTPUT: ---- fail_compilation/constraints_func4.d(90): Error: none of the overloads of template `imports.constraints.overload` are callable using argument types `!()(int)` overload(0); ^ fail_compilation/imports/constraints.d(39): Candidates are: `overload(T)(T v)` with `T = int` must satisfy the following constraint: ` N!T` void overload(T)(T v) if (N!T); ^ fail_compilation/imports/constraints.d(40): `overload(T)(T v)` with `T = int` must satisfy the following constraint: ` !P!T` void overload(T)(T v) if (!P!T); ^ fail_compilation/imports/constraints.d(41): `overload(T)(T v1, T v2)` void overload(T)(T v1, T v2) if (N!T); ^ fail_compilation/imports/constraints.d(42): `overload(T, V)(T v1, V v2)` void overload(T, V)(T v1, V v2) if (N!T || N!V); ^ fail_compilation/constraints_func4.d(91): Error: none of the overloads of template `imports.constraints.overload` are callable using argument types `!()(int, string)` overload(0, ""); ^ fail_compilation/imports/constraints.d(39): Candidates are: `overload(T)(T v)` void overload(T)(T v) if (N!T); ^ fail_compilation/imports/constraints.d(40): `overload(T)(T v)` void overload(T)(T v) if (!P!T); ^ fail_compilation/imports/constraints.d(41): `overload(T)(T v1, T v2)` void overload(T)(T v1, T v2) if (N!T); ^ fail_compilation/imports/constraints.d(42): `overload(T, V)(T v1, V v2)` with `T = int, V = string` must satisfy one of the following constraints: ` N!T N!V` void overload(T, V)(T v1, V v2) if (N!T || N!V); ^ fail_compilation/constraints_func4.d(93): Error: template `variadic` is not callable using argument types `!()()` variadic(); ^ fail_compilation/imports/constraints.d(43): Candidate is: `variadic(A, T...)(A a, T v)` void variadic(A, T...)(A a, T v) if (N!int); ^ fail_compilation/constraints_func4.d(94): Error: template `variadic` is not callable using argument types `!()(int)` variadic(0); ^ fail_compilation/imports/constraints.d(43): Candidate is: `variadic(A, T...)(A a, T v)` with `A = int, T = ()` must satisfy the following constraint: ` N!int` void variadic(A, T...)(A a, T v) if (N!int); ^ fail_compilation/constraints_func4.d(95): Error: template `variadic` is not callable using argument types `!()(int, int)` variadic(0, 1); ^ fail_compilation/imports/constraints.d(43): Candidate is: `variadic(A, T...)(A a, T v)` with `A = int, T = (int)` must satisfy the following constraint: ` N!int` void variadic(A, T...)(A a, T v) if (N!int); ^ fail_compilation/constraints_func4.d(96): Error: template `variadic` is not callable using argument types `!()(int, int, int)` variadic(0, 1, 2); ^ fail_compilation/imports/constraints.d(43): Candidate is: `variadic(A, T...)(A a, T v)` with `A = int, T = (int, int)` must satisfy the following constraint: ` N!int` void variadic(A, T...)(A a, T v) if (N!int); ^ ---- */ void main() { import imports.constraints; overload(0); overload(0, ""); variadic(); variadic(0); variadic(0, 1); variadic(0, 1, 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/disable_new.d0000644000175000017500000000103615205374124022047 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/disable_new.d(23): Error: cannot allocate `class C` with `new` because it is annotated with `@disable new()` fail_compilation/disable_new.d(24): Error: cannot allocate `struct S` with `new` because it is annotated with `@disable new()` --- */ class C { // force user of a type to use an external allocation strategy @disable new(); } struct S { // force user of a type to use an external allocation strategy @disable new(); } void main() { auto c = new C(); auto s = new S(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail315.d0000644000175000017500000000152115205374124020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail315.d-mixin-17(17): Error: found `;` when expecting `,` fail_compilation/fail315.d-mixin-17(17): Error: expression expected, not `}` fail_compilation/fail315.d-mixin-17(17): Error: found `End of File` when expecting `,` fail_compilation/fail315.d-mixin-17(17): Error: found `End of File` when expecting `]` fail_compilation/fail315.d-mixin-17(17): Error: found `End of File` when expecting `;` following `return` statement fail_compilation/fail315.d-mixin-17(17): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/fail315.d-mixin-17(17): unmatched `{` fail_compilation/fail315.d(22): Error: template instance `fail315.foo!()` error instantiating --- */ void foo(S...)(S u) { alias typeof(mixin("{ return a[1;}()")) z; } void main() { foo!()(0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11404.d0000644000175000017500000000033415205374124020725 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11404.d(10): Error: cannot have associative array of `(int, int)` --- */ template TypeTuple(TL...) { alias TL TypeTuple; } void main() { TypeTuple!(int, int)[string] my_map; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/parse12967b.d0000644000175000017500000000453115205374124021463 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/parse12967b.d(24): Error: function `parse12967b.C.pre_c` without `this` cannot be `const` fail_compilation/parse12967b.d(25): Error: function `parse12967b.C.pre_i` without `this` cannot be `immutable` fail_compilation/parse12967b.d(26): Error: function `parse12967b.C.pre_w` without `this` cannot be `inout` fail_compilation/parse12967b.d(27): Error: function `parse12967b.C.pre_s` without `this` cannot be `shared` fail_compilation/parse12967b.d(29): Error: function `parse12967b.C.post_c` without `this` cannot be `const` fail_compilation/parse12967b.d(30): Error: function `parse12967b.C.post_i` without `this` cannot be `immutable` fail_compilation/parse12967b.d(31): Error: function `parse12967b.C.post_w` without `this` cannot be `inout` fail_compilation/parse12967b.d(32): Error: function `parse12967b.C.post_s` without `this` cannot be `shared` fail_compilation/parse12967b.d(37): Error: function `parse12967b.D.pre_c` without `this` cannot be `const` fail_compilation/parse12967b.d(38): Error: function `parse12967b.D.pre_i` without `this` cannot be `immutable` fail_compilation/parse12967b.d(39): Error: function `parse12967b.D.pre_w` without `this` cannot be `inout` fail_compilation/parse12967b.d(40): Error: function `parse12967b.D.pre_s` without `this` cannot be `shared` fail_compilation/parse12967b.d(41): Error: function `parse12967b.D.post_c` without `this` cannot be `const` fail_compilation/parse12967b.d(42): Error: function `parse12967b.D.post_i` without `this` cannot be `immutable` fail_compilation/parse12967b.d(43): Error: function `parse12967b.D.post_w` without `this` cannot be `inout` fail_compilation/parse12967b.d(44): Error: function `parse12967b.D.post_s` without `this` cannot be `shared` --- */ class C { const static pre_c() {} immutable static pre_i() {} inout static pre_w() {} shared static pre_s() {} static post_c() const {} static post_i() immutable {} static post_w() inout {} static post_s() shared {} } class D { const static void pre_c() {} immutable static void pre_i() {} inout static void pre_w() {} shared static void pre_s() {} static void post_c() const {} static void post_i() immutable {} static void post_w() inout {} static void post_s() shared {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11503a.d0000644000175000017500000000076115205374124021245 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11503a.d(24): Error: cannot implicitly convert expression `makes()` of type `immutable(S)*` to `S*` --- */ struct S { immutable(S)* s; this(int) immutable pure { s = &this; } int data; } immutable(S)* makes() pure { return new immutable S(0); } void main() { S* s = makes(); // s is mutable and contains an immutable reference to itself //s.s.data = 7; // this is immutable s.data = 3; // but this is not!!! } ./ldc-1.42.0-src/tests/dmd/fail_compilation/biterrors.d0000644000175000017500000000047315205374124021612 0ustar fabiofabio/* REQUIRED_ARGS: -preview=bitfields * TEST_OUTPUT: --- fail_compilation/biterrors.d(103): Error: initializer not allowed for bitfield declaration fail_compilation/biterrors.d(104): Error: storage class not allowed for bitfield declaration --- */ #line 100 struct S { int i : 3 = 7; static int j : 3; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/enum_member.d0000644000175000017500000000110315205374124022061 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/enum_member.d(14): Error: basic type expected, not `for` fail_compilation/enum_member.d(15): Error: no identifier for declarator `T` fail_compilation/enum_member.d(15): Error: found `@` when expecting `,` fail_compilation/enum_member.d(22): Error: found `}` when expecting `identifier` fail_compilation/enum_member.d(24): Error: found `End of File` when expecting `,` fail_compilation/enum_member.d(24): Error: premature end of file --- */ enum { for, T @a b = 1 } // See also: fail10285.d enum E { @a } // See also: fail20538.d ./ldc-1.42.0-src/tests/dmd/fail_compilation/staticassertargsfail.d0000644000175000017500000000050315205374124024013 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/staticassertargsfail.d(10): Error: incompatible types for `('x') : (new Object)`: `char` and `object.Object` fail_compilation/staticassertargsfail.d(10): while evaluating `static assert` argument `['x', new Object] ~ ""` --- */ static assert(0, "abc", ['x', new Object] ~ ""); ./ldc-1.42.0-src/tests/dmd/fail_compilation/lookup.d0000644000175000017500000000142615205374124021107 0ustar fabiofabio/* EXTRA_FILES: imports/imp1.d imports/imp2.d TEST_OUTPUT: --- fail_compilation/lookup.d(26): Error: no property `X` for type `lookup.B` fail_compilation/imports/imp2.d(3): did you mean `imports.imp2.X`? fail_compilation/lookup.d(26): while evaluating: `static assert((B).X == 0)` fail_compilation/lookup.d(27): Error: no property `Y` for type `lookup.B` fail_compilation/imports/imp2.d(4): did you mean `imports.imp2.Y`? fail_compilation/lookup.d(27): while evaluating: `static assert((B).Y == 2)` --- */ import imports.imp1; enum X = 0; class B { import imports.imp2; static assert(X == 0); static assert(Y == 2); } class C : B { static assert(B.X == 0); static assert(B.Y == 2); static assert(X == 0); static assert(Y == 1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bug15613.d0000644000175000017500000000251215205374124020750 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/bug15613.d(21): Error: function `f` is not callable using argument types `(typeof(null))` fail_compilation/bug15613.d(21): cannot pass argument `null` of type `typeof(null)` to parameter `int...` fail_compilation/bug15613.d(16): `bug15613.f(int...)` declared here fail_compilation/bug15613.d(22): Error: function `f` is not callable using argument types `()` fail_compilation/bug15613.d(22): expected an argument for parameter `int...` fail_compilation/bug15613.d(16): `bug15613.f(int...)` declared here fail_compilation/bug15613.d(23): Error: function `g` is not callable using argument types `(int)` fail_compilation/bug15613.d(23): cannot pass argument `8` of type `int` to parameter `Object` fail_compilation/bug15613.d(17): `bug15613.g(Object, ...)` declared here --- */ void f(int...); void g(Object, ...); void main() { f(null); f(); g(8); } #line 22 /* TEST_OUTPUT: --- fail_compilation/bug15613.d(35): Error: function `h` is not callable using argument types `(int, void function(int[]...))` fail_compilation/bug15613.d(35): cannot pass argument `& h` of type `void function(int[]...)` to parameter `int[]...` fail_compilation/bug15613.d(31): `bug15613.h(int[]...)` declared here --- */ void h(int[]...); void test() { h(7, &h); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21740c.i0000644000175000017500000000047515205374124021262 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail21740c.i(9): Error: character '\' is not a valid token fail_compilation/fail21740c.i(10): Error: character '\' is not a valid token fail_compilation/fail21740c.i(10): Error: missing comma or semicolon after declaration of `é`, found `q` instead --- */ int \uq; int \u00e9\q; ./ldc-1.42.0-src/tests/dmd/fail_compilation/protattr1.d0000644000175000017500000000042015205374124021527 0ustar fabiofabio/* EXTRA_FILES: protection/subpkg/test1.d TEST_OUTPUT: --- fail_compilation/protection/subpkg/test1.d(3): Error: visibility attribute `package(undefined)` does not bind to one of ancestor packages of module `protection.subpkg.test1` --- */ import protection.subpkg.test1; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10599.d0000644000175000017500000000074015205374124020744 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=10599 // ICE(interpret.c) /* TEST_OUTPUT: --- fail_compilation/ice10599.d(13): Error: cannot implicitly convert expression `3.45` of type `double` to `int` fail_compilation/ice10599.d(21): called from here: `bug10599()` fail_compilation/ice10599.d(21): while evaluating: `static assert(bug10599())` --- */ struct Bug { int val = 3.45; } int bug10599() { Bug p = Bug(); return 1; } static assert(bug10599()); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice20056.d0000644000175000017500000000072215205374124020731 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice20056.d(19): Error: calling non-static function `iter` requires an instance of type `RangeWrapper` --- */ struct Def(alias fn) { alias func = alias_selector!(fn).VOverloads[0]; } template alias_selector(alias fn) { alias VOverloads = __traits(getOverloads, __traits(parent, fn), __traits(identifier, fn)); } void init_rangewrapper() { Def!(RangeWrapper.iter).func; } struct RangeWrapper { void iter() { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15691.d0000644000175000017500000000065215205374124021117 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail15691.d(15): Error: `c` is not a member of `Foo` fail_compilation/fail15691.d(20): Error: `bc` is not a member of `Foo`, did you mean variable `abc`? --- */ struct Foo { int a; int abc; } void main() { Foo z = { // line 13 a: 3, c: 4, // line 15 }; Foo z2 = { // line 18 a: 3, bc: 4, // line 20 }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/pragmamangle2.d0000644000175000017500000001044715205374124022316 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/pragmamangle2.d(37): Error: `pragma(mangle)` expects string literal argument for mangled name fail_compilation/pragmamangle2.d(39): Error: `pragma(mangle)` expects string literal argument for mangled name fail_compilation/pragmamangle2.d(46): Error: `pragma(mangle)` must be attached to a declaration fail_compilation/pragmamangle2.d(48): Error: `pragma(mangle)` must be attached to a declaration fail_compilation/pragmamangle2.d(55): Error: `pragma(mangle)` expects string literal argument for mangled name fail_compilation/pragmamangle2.d(58): Error: `pragma(mangle)` zero-length string not allowed for mangled name fail_compilation/pragmamangle2.d(61): Error: pragma(mangle)` expects 1 or 2 arguments fail_compilation/pragmamangle2.d(64): Error: `pragma(mangle)` cannot apply to a template declaration fail_compilation/pragmamangle2.d(64): use `template cannot_apply(Args...) { pragma(mangle, "template") ... }` fail_compilation/pragmamangle2.d(67): Error: `pragma(mangle)` takes a single argument that must be a string literal fail_compilation/pragmamangle2.d(70): Error: `pragma(mangle)` takes a single argument that must be a string literal fail_compilation/pragmamangle2.d(73): Error: `string` expected for pragma mangle argument, not `(T)` of type `T` fail_compilation/pragmamangle2.d(76): Error: `string` expected for pragma mangle argument, not `(T[T])` of type `T[T]` fail_compilation/pragmamangle2.d(79): Error: `pragma(mangle)` must be attached to a declaration fail_compilation/pragmamangle2.d(85): Error: `class` or `struct` type expected for pragma mangle argument, not `"mangle"` of type `string` fail_compilation/pragmamangle2.d(88): Error: `class` or `struct` type expected for pragma mangle argument, not `F()` of type `T` fail_compilation/pragmamangle2.d(91): Error: `class` or `struct` type expected for pragma mangle argument, not `F()` of type `T` fail_compilation/pragmamangle2.d(94): Error: `string` expected for pragma mangle argument, not `(F())` of type `T` fail_compilation/pragmamangle2.d(97): Error: `string` expected for pragma mangle argument, not `(F())` of type `T` fail_compilation/pragmamangle2.d(100): Error: `string` expected for pragma mangle argument, not `(V)` of type `T` fail_compilation/pragmamangle2.d(103): Error: `string` expected for pragma mangle argument, not `(V)` of type `T` fail_compilation/pragmamangle2.d(106): Error: `string` expected for pragma mangle argument, not `T` of type `T` fail_compilation/pragmamangle2.d(109): Error: `class` or `struct` type expected for pragma mangle argument, not `int` of type `int` fail_compilation/pragmamangle2.d(112): Error: `class` or `struct` type expected for pragma mangle argument, not `T[T]` of type `T[T]` --- */ void pragma_statement_test() { struct T { } T F() { return T(); } T V; alias A = T[T]; pragma(mangle); pragma(mangle) { synchronized { } } pragma(mangle, "no_declaration"); pragma(mangle, "no_declaration") { synchronized { } } pragma(mangle) void no_string_literal(); pragma(mangle, "") void empty_string_mangle(); pragma(mangle, "too", "many", "arguments") void expects_less_arguments(); pragma(mangle, "template") template cannot_apply(T) { } pragma(mangle, "func", "mangle") void func_too_many_arguments(); pragma(mangle, "var", "mangle") static int var_too_many_arguments; pragma(mangle, T) void func_arg1_not_a_string(); pragma(mangle, A) static int var_arg1_not_a_string; pragma(mangle, "too_many_declarations") { nothrow pure void func1(); @nogc extern(C++) void func2(); } pragma(mangle, "struct", "mangle") struct arg2_must_be_symbol { } pragma(mangle, "struct", F) struct struct_wrong_symbol { } pragma(mangle, "class", F) class class_wrong_symbol { } pragma(mangle, F(), T) struct arg1_not_ctfe_string { } pragma(mangle, T, F()) struct arg2_not_ctfe_string { } pragma(mangle, V, T) struct arg1_not_string { } pragma(mangle, T, V) struct arg2_not_string { } pragma(mangle, T, T) struct arg2_expect_string { } pragma(mangle, int) struct arg1_not_class_or_struct { } pragma(mangle, "struct", A) struct arg2_not_class_or_struct { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ddoc_18083.d0000644000175000017500000000071715205374124021254 0ustar fabiofabio// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/fail_compilation -o- -w -c /* TEST_OUTPUT: --- fail_compilation/ddoc_18083.d(14): Warning: Ddoc: function declaration has no parameter 'this' fail_compilation/ddoc_18083.d(14): Warning: Ddoc: parameter count mismatch, expected 0, got 1 Error: warnings are treated as errors Use -wi if you wish to treat warnings only as informational. --- */ /** Params: this = non-existent parameter */ int foo() { return 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/goto2.d0000644000175000017500000000460115205374124020626 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/goto2.d(1024): Error: case cannot be in different `try` block level from `switch` fail_compilation/goto2.d(1026): Error: default cannot be in different `try` block level from `switch` fail_compilation/goto2.d(1003): Error: cannot `goto` into `try` block --- */ void foo(); void bar(); #line 1000 void test1() { goto L1; try { foo(); L1: { } } finally { bar(); } /********************************/ int i; switch (i) { case 1: try { foo(); case 2: { } default: { } } finally { bar(); } break; } } /************************************************** https://issues.dlang.org/show_bug.cgi?id=11540 goto label + try-catch-finally / with statement TEST_OUTPUT: --- fail_compilation/goto2.d(1121): Error: cannot `goto` into `try` block --- */ #line 1100 int interpret3a() { // enter to TryCatchStatement.body { bool c = false; try { if (c) // need to bypass front-end optimization throw new Exception(""); else { goto Lx; L1: c = true; } } catch (Exception e) {} Lx: if (!c) goto L1; } return 1; } /************************************************** https://issues.dlang.org/show_bug.cgi?id=11540 goto label + try-catch-finally / with statement TEST_OUTPUT: --- fail_compilation/goto2.d(1217): Error: cannot `goto` into `try` block --- */ #line 1200 int interpret3b() { // enter back to TryFinallyStatement.body { bool c = false; try { goto Lx; L1: c = true; } finally { } Lx: if (!c) goto L1; } return 1; } /************************************************** https://issues.dlang.org/show_bug.cgi?id=13815 TEST_OUTPUT: --- fail_compilation/goto2.d(1234): Error: cannot `goto` into `try` block --- */ bool f() { goto L; try { L: // line 7 throw new Exception(""); // line 8 } catch (Exception e) { return true; } return false; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail42.d0000644000175000017500000000035215205374124020654 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail42.d(22): Error: struct `fail42.Qwert` no size because of forward reference --- */ /+ struct Qwert { Qwert asdfg; } +/ struct Qwert { Yuiop asdfg; } struct Yuiop { Qwert hjkl; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11963.d0000644000175000017500000000053615205374124020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11963.d(10): Error: unexpected `(` in declarator fail_compilation/ice11963.d(10): Error: identifier expected for template type parameter fail_compilation/ice11963.d(10): Error: variable name expected after type `A`, not `""` fail_compilation/ice11963.d(10): Error: declaration expected, not `""` --- */ A("")= ./ldc-1.42.0-src/tests/dmd/fail_compilation/test3818.d0000644000175000017500000000110215205374124021070 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test3818.d(104): Error: missing `; expression` before `)` of `foreach` fail_compilation/test3818.d(104): perhaps the `;` goes before `a` fail_compilation/test3818.d(109): Error: missing `; expression` before `)` of `foreach` fail_compilation/test3818.d(109): perhaps the `;` goes before `c` fail_compilation/test3818.d(110): Error: declaration expected, not `{` --- */ // https://issues.dlang.org/show_bug.cgi?id=3818 #line 100 void test1() { int[10] a; foreach (i, x, a) { } } static foreach (a, b, c) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13835.d0000644000175000017500000000063515205374124020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13835.d(15): Error: value of `this` is not known at compile time fail_compilation/ice13835.d(21): Error: template instance `ice13835.Foo!int` error instantiating --- */ class Foo(T) { private T* _data; final private void siftUp(int position) nothrow { static T crash = *(this._data + position); } } void main() { auto heap = new Foo!(int); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19609.d0000644000175000017500000000215015205374124021115 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19609 /* EXTRA_FILES: imports/fail19609a.d imports/fail19609b.d imports/fail19609c.d imports/fail19609d.d TEST_OUTPUT: --- fail_compilation/imports/fail19609a.d(1): Error: `string` expected for deprecation message, not `([""])` of type `string[]` fail_compilation/fail19609.d(16): Deprecation: module `imports.fail19609a` is deprecated fail_compilation/imports/fail19609b.d(1): Error: `string` expected for deprecation message, not `([1])` of type `int[]` fail_compilation/fail19609.d(17): Deprecation: module `imports.fail19609b` is deprecated fail_compilation/imports/fail19609c.d(1): Error: `string` expected for deprecation message, not `(123.4F)` of type `float` fail_compilation/fail19609.d(18): Deprecation: module `imports.fail19609c` is deprecated fail_compilation/imports/fail19609d.d(1): Error: undefined identifier `msg` fail_compilation/fail19609.d(20): Deprecation: module `imports.fail19609d` is deprecated --- */ import imports.fail19609a; import imports.fail19609b; import imports.fail19609c; enum msg = "You should not be able to see me"; import imports.fail19609d; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23674.d0000644000175000017500000000047415205374124021165 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23674 /* TEST_OUTPUT: --- fail_compilation/test23674.d(14): Error: array index 2 is out of bounds `arr[0 .. 2]` fail_compilation/test23674.d(14): Error: array index 3 is out of bounds `arr[0 .. 2]` --- */ void main() { string[2] arr; assert(arr[2] == arr[3]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21518.d0000644000175000017500000000317515205374124021161 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=21518 TEST_OUTPUT: --- fail_compilation/test21518.d(19): Error: cannot implicitly convert expression `[dg]` of type `const(void delegate() pure nothrow @nogc @system)[]` to `void delegate() @safe[]` fail_compilation/test21518.d(23): Error: cannot implicitly convert expression `[dg]` of type `const(void delegate() pure nothrow @nogc @system)[]` to `const(void delegate() @safe)[]` fail_compilation/test21518.d(28): Error: cannot implicitly convert expression `sysA` of type `const(void delegate() @system)[]` to `const(void delegate() @safe)[]` fail_compilation/test21518.d(31): Error: cannot implicitly convert expression `sysA` of type `const(void delegate() @system)[]` to `const(void delegate() @safe)` fail_compilation/test21518.d(32): Error: cannot implicitly convert expression `dg` of type `const(void delegate() pure nothrow @nogc @system)` to `const(void delegate() @safe)` --- */ void delegates() { const dg = delegate() @system { int* p; int x; p = &x; }; // pragma(msg, typeof(dg)); // const(void delegate() pure nothrow @nogc @system) // Correctly fails void delegate() @safe[] arg2 = [ dg ]; void delegate() @system[] arg3 = [ dg ]; // But doesnt break this // Previously ignored const(void delegate() @safe)[] arg = [ dg ]; // pragma(msg, typeof(arg)); // const(void delegate() @safe)[] // Also for variables, not only array literals const(void delegate() @system)[] sysA = [ dg ]; const(void delegate() @safe)[] safeA = sysA; // Original bug report: func(sysA); func(dg); } void func(const void delegate() @safe [] paramDGs...) @safe { if (paramDGs.length > 0) paramDGs[0](); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice8604.d0000644000175000017500000000025315205374124020655 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice8604.d(9): Error: undefined identifier `i` --- */ struct StructFoo { static if(i) { } else enum z = ""; } void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/parseStc5.d0000644000175000017500000000645415205374124021455 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/parseStc5.d(10): Error: constructor cannot be static fail_compilation/parseStc5.d(11): Error: postblit cannot be `static` --- */ class C1 { static pure this(int) {} // `static pure` + `this(int)` static pure this(this) {} // `static pure` + `this(this)` } /* TEST_OUTPUT: --- fail_compilation/parseStc5.d(27): Error: use `shared static this()` to declare a shared static constructor fail_compilation/parseStc5.d(28): Error: use `shared static this()` to declare a shared static constructor fail_compilation/parseStc5.d(30): Error: use `shared static this()` to declare a shared static constructor fail_compilation/parseStc5.d(32): Error: use `shared static ~this()` to declare a shared static destructor fail_compilation/parseStc5.d(33): Error: use `shared static ~this()` to declare a shared static destructor fail_compilation/parseStc5.d(35): Error: use `shared static ~this()` to declare a shared static destructor --- */ class C2 // wrong combinations of `shared`, `static`, and `~?this()` { shared pure static this() {} // `shared pure` + `static this()` shared static pure this() {} // `shared static pure` + `this()` static this() shared {} // `shared pure` + `static this()` shared pure static ~this() {} // `shared pure` + `static ~this()` shared static pure ~this() {} // `shared static pure` + `~this()` static ~this() shared {} // `shared` + `static ~this()` } /* TEST_OUTPUT: --- fail_compilation/parseStc5.d(47): Error: use `static this()` to declare a static constructor fail_compilation/parseStc5.d(48): Error: use `static ~this()` to declare a static destructor --- */ class C3 // wrong combinations of `static` and `~?this()` { static pure this() {} // `static pure` + `this()` static pure ~this() {} // `static pure` + `~this()` } /* TEST_OUTPUT: --- fail_compilation/parseStc5.d(63): Error: redundant attribute `shared` fail_compilation/parseStc5.d(64): Error: redundant attribute `shared` fail_compilation/parseStc5.d(66): Error: redundant attribute `static` fail_compilation/parseStc5.d(68): Error: redundant attribute `static shared` fail_compilation/parseStc5.d(69): Error: redundant attribute `static shared` --- */ class C4 // redundancy of `shared` and/or `static` { shared shared static this() {} // `shared` + `shared static this()` shared static this() shared {} // `shared` + `shared static this()` static static this() {} // `static` + `shared static this()` shared static shared static this() {} // shared static + `shared static this()` shared static shared static this() shared {} // shared shared static + `shared static this()` } /* TEST_OUTPUT: --- fail_compilation/parseStc5.d(83): Error: static constructor cannot be `const` fail_compilation/parseStc5.d(84): Error: static destructor cannot be `const` fail_compilation/parseStc5.d(85): Error: shared static constructor cannot be `const` fail_compilation/parseStc5.d(86): Error: shared static destructor cannot be `const` --- */ class C5 // wrong MemberFunctionAttributes on `shared? static (con|de)structor` { static this() const {} static ~this() const {} shared static this() const {} shared static ~this() const {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail127.d0000644000175000017500000000050415205374124020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail127.d(9): Error: a struct is not a valid initializer for a `char[][]` fail_compilation/fail127.d(10): Error: a struct is not a valid initializer for a `string[]` --- */ char[][] Level2Text1 = {"LOW", "MEDIUM", "HIGH"}; string[] Level2Text2 = {"LOW", "MEDIUM", "HIGH"}; // for D2 ./ldc-1.42.0-src/tests/dmd/fail_compilation/dtorfields_attributes.d0000644000175000017500000000412315205374124024200 0ustar fabiofabio/* Informative error messages if the compiler inserted an optional destructor call into the constructor. REQUIRED_ARGS: -preview=dtorfields TEST_OUTPUT: --- fail_compilation/dtorfields_attributes.d(117): Error: `pure` constructor `dtorfields_attributes.Strict.this` cannot call impure destructor `dtorfields_attributes.Strict.~this` fail_compilation/dtorfields_attributes.d(119): generated `Strict.~this` is impure because of the following field's destructors: fail_compilation/dtorfields_attributes.d(115): - HasDtor member fail_compilation/dtorfields_attributes.d(103): impure `HasDtor.~this` is declared here fail_compilation/dtorfields_attributes.d(117): Error: `@safe` constructor `dtorfields_attributes.Strict.this` cannot call `@system` destructor `dtorfields_attributes.Strict.~this` fail_compilation/dtorfields_attributes.d(119): `dtorfields_attributes.Strict.~this` is declared here fail_compilation/dtorfields_attributes.d(119): generated `Strict.~this` is @system because of the following field's destructors: fail_compilation/dtorfields_attributes.d(115): - HasDtor member fail_compilation/dtorfields_attributes.d(103): @system `HasDtor.~this` is declared here fail_compilation/dtorfields_attributes.d(117): Error: `@nogc` constructor `dtorfields_attributes.Strict.this` cannot call non-@nogc destructor `dtorfields_attributes.Strict.~this` fail_compilation/dtorfields_attributes.d(119): generated `Strict.~this` is non-@nogc because of the following field's destructors: fail_compilation/dtorfields_attributes.d(115): - HasDtor member fail_compilation/dtorfields_attributes.d(103): non-@nogc `HasDtor.~this` is declared here --- */ #line 100 struct HasDtor { ~this() { // Enforce @system, ... just to be sure __gshared int i; if (++i) throw new Exception(new immutable(char)[](10)); } } // The user-defined dtor matches the ctor attributes struct Strict { HasDtor member; this(int) pure @nogc @safe {} // nothrow doesn't generate dtor call ~this() pure @nogc @safe {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22329.d0000644000175000017500000000132415205374124021154 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22329 // EXTRA_FILES: imports/imp22329.d /* TEST_OUTPUT: --- fail_compilation/imports/imp22329.d(3): Error: no property `values` for type `test22329.Foo` fail_compilation/test22329.d(14): struct `Foo` defined here fail_compilation/imports/imp22329.d(3): Error: operator `+` is not defined for type `Foo` fail_compilation/test22329.d(14): perhaps overload the operator with `auto opBinary(string op : "+")(int rhs) {}` fail_compilation/test22329.d(22): Error: template instance `imp22329.func!(Foo)` error instantiating --- */ public struct Foo { private int values; alias values this; } void main() { import imports.imp22329 : func; func(Foo()); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13027.d0000644000175000017500000000023515205374124020730 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13027.d(9): Error: template instance `b!"c"` template `b` is not defined --- */ void main() { scope a = b!"c"; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b20875.d0000644000175000017500000000174515205374124020431 0ustar fabiofabiomodule b20875; /* TEST_OUTPUT: --- fail_compilation/b20875.d(10): Error: template instance `Foo!int` does not match template declaration `Foo(alias T : None!U, U...)` fail_compilation/b20875.d(10): while evaluating: `static assert(Foo!int)` fail_compilation/b20875.d(11): Error: template instance `Bar!int` does not match template declaration `Bar(alias T : None!U, U...)` fail_compilation/b20875.d(11): while evaluating: `static assert(!Bar!int)` fail_compilation/b20875.d(14): Error: template parameter specialization for a type must be a type and not `NotAType()` fail_compilation/b20875.d(15): while looking for match for `Baz!int` fail_compilation/b20875.d(15): while evaluating: `static assert(!Baz!int)` --- */ #line 7 enum Foo(alias T : None!U, U...) = true; enum Bar(alias T : None!U, U...) = false; static assert( Foo!(int)); static assert(!Bar!(int)); template NotAType(){} enum Baz(alias T : NotAType) = false; static assert(!Baz!(int)); void main(){} ./ldc-1.42.0-src/tests/dmd/fail_compilation/noreturn2.d0000644000175000017500000000565715205374124021546 0ustar fabiofabio/* REQUIRED_ARGS: -w -o- TEST_OUTPUT: --- fail_compilation/noreturn2.d(18): Error: expected return type of `noreturn`, not `void` --- https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1034.md */ alias noreturn = typeof(*null); void doStuff(); noreturn returnVoid() { return doStuff(); } /+ TEST_OUTPUT: --- fail_compilation/noreturn2.d(37): Error: expected return type of `int`, not `string`: fail_compilation/noreturn2.d(35): Return type of `int` inferred here. --- +/ auto missmatch(int i) { if (i < 0) return assert(false); if (i == 0) return i; if (i > 0) return ""; } /+ TEST_OUTPUT: --- fail_compilation/noreturn2.d(50): Error: function `noreturn2.returns` is typed as `NR` but does return fail_compilation/noreturn2.d(50): `noreturn` functions must either throw, abort or loop indefinitely --- +/ enum NR : noreturn; NR returns() { // Fallthrough despite noreturn } /+ TEST_OUTPUT: --- fail_compilation/noreturn2.d(64): Error: return value `1` of type `int` does not match return type `noreturn`, and cannot be implicitly converted --- +/ noreturn returnsValue() { return 1; } /+ TEST_OUTPUT: --- fail_compilation/noreturn2.d(75): Error: expected return type of `int`, not `void` --- +/ int returnVoid2() { return doStuff(); } /+ TEST_OUTPUT: --- fail_compilation/noreturn2.d(89): Error: mismatched function return type inference of `void` and `int` --- +/ auto returnVoid3(int i) { if (i > 0) return i; else return doStuff(); } /+ TEST_OUTPUT: --- fail_compilation/noreturn2.d(104): Error: `object.Exception` is thrown but not caught fail_compilation/noreturn2.d(100): Error: function `noreturn2.doesNestedThrow` may throw but is marked as `nothrow` --- +/ int doesNestedThrow(int i) nothrow { // Weird formatting is intended to check the loc return i ? i++ : throw new Exception("") ; } int doesNestedThrowThrowable(int i) nothrow { return i ? i++ : throw new Error(""); } /+ TEST_OUTPUT: --- fail_compilation/noreturn2.d(130): Error: cannot create instance of interface `I` fail_compilation/noreturn2.d(133): Error: can only throw class objects derived from `Throwable`, not type `int[]` fail_compilation/noreturn2.d(139): Error: undefined identifier `UnkownException` --- +/ int throwInvalid(int i) nothrow { static interface I {} // Weird formatting is intended to check the loc return throw new I() ? throw new int[4] : throw new UnkownException("") ; } /+ https://issues.dlang.org/show_bug.cgi?id=24054 TEST_OUTPUT: --- fail_compilation/noreturn2.d(153): Error: cannot return from `noreturn` function fail_compilation/noreturn2.d(153): Consider adding an endless loop, `assert(0)`, or another `noreturn` expression --- +/ const(noreturn) f() { return; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice5996.d0000644000175000017500000000027615205374124020675 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice5996.d(8): Error: undefined identifier `anyOldGarbage` --- */ auto bug5996() { if (anyOldGarbage) {} return 2; } enum uint h5996 = bug5996(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11552.d0000644000175000017500000000057515205374124020740 0ustar fabiofabio/* REQUIRED_ARGS: -o- TEST_OUTPUT: --- fail_compilation/ice11552.d(13): Error: function `ice11552.test11552` label `label` is undefined fail_compilation/ice11552.d(16): called from here: `test11552()` fail_compilation/ice11552.d(16): while evaluating: `static assert(test11552())` --- */ int test11552() { goto label; return 1; } static assert(test11552()); ./ldc-1.42.0-src/tests/dmd/fail_compilation/traits_alone.d0000644000175000017500000000052115205374124022255 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/traits_alone.d(11): Error: found `End of File` when expecting `(` fail_compilation/traits_alone.d(11): Error: `__traits(identifier, args...)` expected fail_compilation/traits_alone.d(11): Error: variable name expected after type `$r:_?_error_?$`, not `End of File` --- */ //used to segfault __traits ./ldc-1.42.0-src/tests/dmd/fail_compilation/sarif_test.d0000644000175000017500000000146515205374124021744 0ustar fabiofabio// REQUIRED_ARGS: -verror-style=sarif /* TEST_OUTPUT: --- { "version": "2.1.0", "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json", "runs": [{ "tool": { "driver": { "name": "LDC", "version": "$r:\d+\.\d+\.\d+$", "informationUri": "https://dlang.org/dmd.html" } }, "invocations": [{ "executionSuccessful": false }], "results": [ { "ruleId": "DMD-error", "message": { "text": "undefined identifier `x`" }, "level": "error", "locations": [{ "physicalLocation": { "artifactLocation": { "uri": "fail_compilation/sarif_test.d" }, "region": { "startLine": 45, "startColumn": 5 } } }] } ] }] } --- */ void main() { x = 5; // Undefined variable to trigger the error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15399.d0000644000175000017500000000305715205374124021172 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=15399 TEST_OUTPUT: --- fail_compilation/test15399.d(32): Error: modifying misaligned pointers through field `S1.ptr` is not allowed in a `@safe` function fail_compilation/test15399.d(33): Error: modifying misaligned pointers through field `S2.ptr` is not allowed in a `@safe` function fail_compilation/test15399.d(34): Error: modifying misaligned pointers through field `S1.ptr` is not allowed in a `@safe` function fail_compilation/test15399.d(35): Error: modifying misaligned pointers through field `S2.ptr` is not allowed in a `@safe` function fail_compilation/test15399.d(36): Error: modifying misaligned pointers through field `S1.ptr` is not allowed in a `@safe` function fail_compilation/test15399.d(37): Error: modifying misaligned pointers through field `S2.ptr` is not allowed in a `@safe` function fail_compilation/test15399.d(38): Error: modifying misaligned pointers through field `S1.ptr` is not allowed in a `@safe` function fail_compilation/test15399.d(39): Error: modifying misaligned pointers through field `S2.ptr` is not allowed in a `@safe` function --- */ struct S1 { char c; align (1) int* ptr; } align (1) struct S2 { int* ptr; } @safe void test(S1* s1, S2* s2) { int* p = s1.ptr; p = s2.ptr; s1.ptr = null; s2.ptr = null; int** pp = &s1.ptr; pp = &s2.ptr; bar(s1.ptr); bar(s2.ptr); sinister(s1.ptr); sinister(s2.ptr); cbar(s1.ptr); cbar(s2.ptr); } @safe void bar(ref int*); @safe void cbar(ref const int*); @safe void sinister(out int*); ./ldc-1.42.0-src/tests/dmd/fail_compilation/cpp_abi_tag.d0000644000175000017500000000325015205374124022023 0ustar fabiofabio/* DISABLED: win32 win64 REQUIRED_ARGS: -extern-std=c++11 TEST_OUTPUT: --- fail_compilation/cpp_abi_tag.d(111): Error: `@gnuAbiTag` can only apply to C++ symbols fail_compilation/cpp_abi_tag.d(131): Error: `@gnuAbiTag` cannot be applied to namespaces fail_compilation/cpp_abi_tag.d(102): Error: `@gnuAbiTag` at least one argument expected fail_compilation/cpp_abi_tag.d(105): Error: `@gnuAbiTag` at least one argument expected fail_compilation/cpp_abi_tag.d(108): Error: `@gnuAbiTag` char `0x99` not allowed in mangling fail_compilation/cpp_abi_tag.d(114): Error: argument `2` to `@gnuAbiTag` cannot be `null` fail_compilation/cpp_abi_tag.d(114): Error: argument `3` to `@gnuAbiTag` cannot be empty fail_compilation/cpp_abi_tag.d(117): Error: `@gnuAbiTag` at least one argument expected fail_compilation/cpp_abi_tag.d(137): Error: only one `@gnuAbiTag` allowed per symbol fail_compilation/cpp_abi_tag.d(137): instead of `@gnuAbiTag(["x"]) @gnuAbiTag(["a"])`, use `@gnuAbiTag("x", "a")` --- */ #line 100 import core.attribute; @gnuAbiTag extern(C++) struct A {} @gnuAbiTag() extern(C++) struct B {} @gnuAbiTag("a\x99") extern(C++) struct D {} @gnuAbiTag("a") struct F {} @gnuAbiTag("a", null, "") extern(C++) struct G {} @gnuAbiTag((string[]).init) extern(C++) struct H {} // Note: There is no way to distinguish between // `extern(C++, "ns") { ... }` and `extern(C++, "ns") ...;` // So ABI tags have to be on the inside extern(C++, "ns") @gnuAbiTag("x") void func1(); extern(C++, ns2) @gnuAbiTag("x") void func2(); @gnuAbiTag("x") extern(C++, "ns3") { void func3(); } @gnuAbiTag("x") extern(C++, ns4) { void func4(); } @gnuAbiTag("x") @gnuAbiTag("a") extern(C++) void func5(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/retscope4.d0000644000175000017500000000046715205374124021512 0ustar fabiofabio/* REQUIRED_ARGS: -de */ /* TEST_OUTPUT: --- fail_compilation/retscope4.d(3007): Deprecation: slice of static array temporary returned by `func()` assigned to longer lived variable `a` --- */ #line 3000 // https://issues.dlang.org/show_bug.cgi?id=12625 int[16] func(); void foo() { int[] a = func(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13465b.d0000644000175000017500000000073415205374124021104 0ustar fabiofabio// REQUIRED_ARGS: -o- // EXTRA_SOURCES: imports/b13465.d /* TEST_OUTPUT: --- fail_compilation/imports/b13465.d(10): Error: cannot infer type from template instance `isMaskField!()` fail_compilation/ice13465b.d(17): Error: template instance `imports.b13465.isMatchingMaskField!()` error instantiating --- */ module ice13465b; import imports.b13465; auto createCheckpointMixins() { enum b = isMatchingMaskField!(); } immutable checkpointMixins = createCheckpointMixins; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22840.d0000644000175000017500000000075215205374124021156 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 * TEST_OUTPUT: --- fail_compilation/test22840.d(25): Error: returning `sb.slice()` escapes a reference to local variable `sb` --- */ // inout method with inferred @safe escapes local data // https://issues.dlang.org/show_bug.cgi?id=22840 // See also: https://issues.dlang.org/show_bug.cgi?id=20149 struct S { int buf; auto slice() inout { return &buf; } } int* fun() @safe { S sb; return sb.slice(); // should error } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23816.d0000644000175000017500000000032615205374124021113 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23816 // DISABLED: LDC_not_x86 /* TEST_OUTPUT: --- fail_compilation/fail23816.d(14): Error: unknown opcode `NOP` --- */ void main() { asm { NOP; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail152.d0000644000175000017500000000100615205374124020733 0ustar fabiofabio/* DISABLED: LDC_not_x86 LDC // differing output TEST_OUTPUT: --- fail_compilation/fail152.d(16): Error: cannot use type `double` as an operand fail_compilation/fail152.d(22): Error: template instance `fail152.a!double` error instantiating --- */ // https://issues.dlang.org/show_bug.cgi?id=1028 // Segfault using tuple inside asm code. void a(X...)(X expr) { alias X[0] var1; asm { //fld double ptr X[0]; // (1) segfaults fstp double ptr var1; // (2) ICE } } void main() { a(3.6); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19744.d0000644000175000017500000000030015205374124021110 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19744.d(8): Error: top-level function `test` has no `this` to which `return` can apply --- */ int* test(return scope int* n) return { return n; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bug5.d0000644000175000017500000000027215205374124020436 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/bug5.d(8): Error: function `bug5.test1` no `return exp;` or `assert(0);` at end of function --- */ int test1() { if (false) return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22853b.c0000644000175000017500000000026115205374124021252 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail22853b.c(8): Error: found `/` instead of statement --- */ void test22853() { /+ https://issues.dlang.org/show_bug.cgi?id=22853 +/ } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13142.d0000644000175000017500000000072215205374124021073 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag13142.d(25): Error: cannot implicitly convert expression `3` of type `int` to `TYPE` --- */ class Button { enum TYPE // button type { COMMAND, CHECK, OPTION, } } class Toolbar { enum ButtonTYPE // button type { COMMAND = Button.TYPE.COMMAND, CHECK = Button.TYPE.CHECK, OPTION = Button.TYPE.OPTION, DELIMETER = Button.TYPE.max + 1 } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail355.d0000644000175000017500000000027715205374124020751 0ustar fabiofabio/* EXTRA_FILES: imports/fail355.d TEST_OUTPUT: --- fail_compilation/fail355.d(9): Error: module `imports.fail355` import `nonexistent` not found --- */ import imports.fail355 : nonexistent; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice16035.d0000644000175000017500000000062615205374124020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice16035.d(18): Error: forward reference to inferred return type of function call `this.a[0].toString()` fail_compilation/ice16035.d(13): Error: template instance `ice16035.Value.get!string` error instantiating --- */ struct Value { auto toString() inout { get!string; } T get(T)() { a[0].toString(); } const(Value)* a; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failcstuff6.c0000644000175000017500000000140015205374124022001 0ustar fabiofabio// check dsymbolSemantic analysis of C files /* TEST_OUTPUT: REQUIRED_ARGS: -verrors=context --- fail_compilation/failcstuff6.c(56): Error: enum member `failcstuff6.test_overflow.boom` initialization with `2147483647+1` causes overflow for type `int` boom, ^ --- */ /***************************************************/ #line 50 enum test_overflow { three = 2147483645, two, one, boom, }; /***************************************************/ #line 100 enum test_enum_fits { intMinFits = -2147483648, intMaxFits = 4294967295, firstMinError = -2147483649, firstMaxError = 4294967296, lastMaxError = 0xffffffff7fffffff, firstBlindSpot = 0xffffffff80000000, lastBlindSpot = 0xffffffffffffffff, }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/verrors5.d0000644000175000017500000000175415205374124021371 0ustar fabiofabio// REQUIRED_ARGS: -verrors=5 void main() { { T a; } // 1 { T a; } // 2 { T a; } // 3 { T a; } // 4 { T a; } // 5 { T a; } // 6 { T a; } // 7 { T a; } // 8 { T a; } // 9 { T a; } // 10 { T a; } // 11 { T a; } // 12 { T a; } // 13 { T a; } // 14 { T a; } // 15 { T a; } // 16 { T a; } // 17 { T a; } // 18 { T a; } // 19 { T a; } // 20 (default limit) { T a; } // 21 { T a; } // 22 { T a; } // 23 { T a; } // 24 { T a; } // 25 } /* TEST_OUTPUT: --- fail_compilation/verrors5.d(5): Error: undefined identifier `T` fail_compilation/verrors5.d(6): Error: undefined identifier `T` fail_compilation/verrors5.d(7): Error: undefined identifier `T` fail_compilation/verrors5.d(8): Error: undefined identifier `T` fail_compilation/verrors5.d(9): Error: undefined identifier `T` error limit (5) reached, use `-verrors=0` to show all --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10651.d0000644000175000017500000000124315205374124020730 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10651.d(13): Error: can only throw class objects derived from `Throwable`, not type `int*` fail_compilation/ice10651.d(19): Deprecation: cannot throw object of qualified type `immutable(Exception)` fail_compilation/ice10651.d(20): Deprecation: cannot throw object of qualified type `const(Dummy)` --- */ void main() { alias T = int; throw new T(); // ICE } void f() { immutable c = new Exception(""); if (c) throw c; throw new const Dummy([]); } class Dummy: Exception { int[] data; @safe pure nothrow this(immutable int[] data) immutable { super("Dummy"); this.data = data; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6242.d0000644000175000017500000000041215205374124021021 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail6242.d(9): Error: cannot implicitly override base class method `fail6242.A.fun` with `fail6242.B.fun`; add `override` attribute --- */ class A { void fun(int) {} } class B : A { void fun(int x) in { assert(x > 0); } do {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12397.d0000644000175000017500000000035215205374124020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12397.d(12): Error: undefined identifier `tokenLookup` --- */ struct DSplitter { enum Token : int { max = tokenLookup.length } immutable string[Token.max] tokenText; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test19971.d0000644000175000017500000000122415205374124021164 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test19971.d(16): Error: function `f` is not callable using argument types `(string)` fail_compilation/test19971.d(16): cannot pass argument `"%s"` of type `string` to parameter `int x` fail_compilation/test19971.d(13): `test19971.f(int x)` declared here fail_compilation/test19971.d(17): Error: function literal `(int x) { }` is not callable using argument types `(string)` fail_compilation/test19971.d(17): cannot pass argument `"%s"` of type `string` to parameter `int x` --- */ // https://issues.dlang.org/show_bug.cgi?id=19971 void f(int x) {} void main() { f("%s"); (int x) {} ("%s"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22121.d0000644000175000017500000000054015205374124021075 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22121 // EXTRA_FILES: fail22121/imports/test22121/package.d /* TEST_OUTPUT: --- fail_compilation/fail22121/imports/test22121/package.d(1): Error: package name 'fail22121' conflicts with usage as a module name in file fail_compilation/fail22121.d --- */ module fail22121; import fail22121.imports.test22121; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix18575.d0000644000175000017500000000152515205374124020776 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fix18575.d(27): Error: returning `s.foo()` escapes a reference to parameter `s` fail_compilation/fix18575.d(31): Error: returning `s.foo()` escapes a reference to parameter `s` fail_compilation/fix18575.d(35): Error: returning `s.abc()` escapes a reference to parameter `s` fail_compilation/fix18575.d(39): Error: returning `s.ghi(t)` escapes a reference to parameter `t` --- */ // https://issues.dlang.org/show_bug.cgi?id=18575 @safe: struct S { @safe: int x; void bar() { } auto foo() { return &this.bar; } auto def() { return &bar; } auto abc() { return &x; } auto ghi(ref S s) { return &s.bar; } } auto f(S s) { return s.foo(); } auto g(S s) { return s.foo(); } auto h(S s) { return s.abc(); } auto j(S s, S t) { return s.ghi(t); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b19717.d0000644000175000017500000000063115205374124020425 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/b19717.d(16): Error: undefined identifier `Foo`, did you mean function `foo`? fail_compilation/b19717.d(13): Error: forward reference to template `foo` fail_compilation/b19717.d(13): Error: forward reference to inferred return type of function call `foo()` --- */ enum bar = __traits(getMember, mixin(__MODULE__), "foo"); auto foo() { return foo(); } void foo(Foo) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21995.d0000644000175000017500000000044315205374124021165 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test21995.d(10): Error: max object size 4294967295 exceeded from adding field size 3 + alignment adjustment 1 + field offset 4294967292 when placing field in aggregate --- */ struct S { ubyte[0x7ffffffe] a; ubyte[0x7ffffffe] b; ubyte[3] c; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19209.d0000644000175000017500000000057415205374124021121 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19209.d(16): Error: function `fail19209.Spammer.method()` does not override any function, did you mean to override variable `fail19209.Spam.method`? fail_compilation/fail19209.d(16): Functions are the only declarations that may be overridden --- */ class Spam { int method; } class Spammer : Spam { override method() {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test314.d0000644000175000017500000000113715205374124021004 0ustar fabiofabio/* EXTRA_FILES: imports/a314.d imports/b314.d imports/c314.d TEST_OUTPUT: --- fail_compilation/test314.d(19): Error: undefined identifier `renamed` fail_compilation/test314.d(20): Error: undefined identifier `bug` fail_compilation/test314.d(22): Error: undefined identifier `renamedpkg` fail_compilation/test314.d(23): Error: undefined identifier `bugpkg` --- */ module test314; import imports.a314; import imports.b314; void main() { renamed.bug("This should not work.\n"); bug("This should not work.\n"); renamedpkg.bug("This should not work.\n"); bugpkg("This should not work.\n"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag6539.d0000644000175000017500000000045315205374124021030 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag6539.d(21): Error: overloadset `diag6539.Rectangle` is used as a type --- */ mixin template foo() { struct Rectangle(T) {} } mixin template bar() { bool Rectangle(bool, int, int, int, int) {} } mixin foo; mixin bar; void test(Rectangle rect) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20000.d0000644000175000017500000000753315205374124021100 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail20000.d(37): Error: cast from `fail20000.DClass` to `fail20000.CppClass` is not allowed in a `@safe` function fail_compilation/fail20000.d(37): Source object type is incompatible with target type fail_compilation/fail20000.d(38): Error: cast from `fail20000.DInterface` to `fail20000.CppClass` is not allowed in a `@safe` function fail_compilation/fail20000.d(38): Source object type is incompatible with target type fail_compilation/fail20000.d(39): Error: cast from `fail20000.CppClass2` to `fail20000.CppClass` is not allowed in a `@safe` function fail_compilation/fail20000.d(39): Source object type is incompatible with target type fail_compilation/fail20000.d(40): Error: cast from `fail20000.CppInterface2` to `fail20000.CppClass` is not allowed in a `@safe` function fail_compilation/fail20000.d(40): Source object type is incompatible with target type fail_compilation/fail20000.d(42): Error: cast from `fail20000.DClass` to `fail20000.CppInterface` is not allowed in a `@safe` function fail_compilation/fail20000.d(42): Source object type is incompatible with target type fail_compilation/fail20000.d(43): Error: cast from `fail20000.DInterface` to `fail20000.CppInterface` is not allowed in a `@safe` function fail_compilation/fail20000.d(43): Source object type is incompatible with target type fail_compilation/fail20000.d(44): Error: cast from `fail20000.CppClass2` to `fail20000.CppInterface` is not allowed in a `@safe` function fail_compilation/fail20000.d(44): Source object type is incompatible with target type fail_compilation/fail20000.d(45): Error: cast from `fail20000.CppInterface2` to `fail20000.CppInterface` is not allowed in a `@safe` function fail_compilation/fail20000.d(45): Source object type is incompatible with target type fail_compilation/fail20000.d(47): Error: cast from `fail20000.CppClass` to `fail20000.DClass` is not allowed in a `@safe` function fail_compilation/fail20000.d(47): Source object type is incompatible with target type fail_compilation/fail20000.d(48): Error: cast from `fail20000.CppInterface` to `fail20000.DClass` is not allowed in a `@safe` function fail_compilation/fail20000.d(48): Source object type is incompatible with target type fail_compilation/fail20000.d(50): Error: cast from `fail20000.CppClass` to `fail20000.DInterface` is not allowed in a `@safe` function fail_compilation/fail20000.d(50): Source object type is incompatible with target type fail_compilation/fail20000.d(51): Error: cast from `fail20000.CppInterface` to `fail20000.DInterface` is not allowed in a `@safe` function fail_compilation/fail20000.d(51): Source object type is incompatible with target type --- */ extern(C++) class CppClass { int a; } extern(C++) class CppClass2 { void* a; } extern(C++) interface CppInterface { int b(); } extern(C++) interface CppInterface2 { void* b(); } class DClass { int c; } interface DInterface { int d(); } bool isCppClass(DClass a) @safe { return cast(CppClass) a !is null; } bool isCppClass(DInterface a) @safe { return cast(CppClass) a !is null; } bool isCppClass(CppClass2 a) @safe { return cast(CppClass) a !is null; } bool isCppClass(CppInterface2 a) @safe { return cast(CppClass) a !is null; } bool isCppInterface(DClass a) @safe { return cast(CppInterface) a !is null; } bool isCppInterface(DInterface a) @safe { return cast(CppInterface) a !is null; } bool isCppInterface(CppClass2 a) @safe { return cast(CppInterface) a !is null; } bool isCppInterface(CppInterface2 a) @safe { return cast(CppInterface) a !is null; } bool isDClass(CppClass a) @safe { return cast(DClass) a !is null; } bool isDClass(CppInterface a) @safe { return cast(DClass) a !is null; } bool isDInterface(CppClass a) @safe { return cast(DInterface) a !is null; } bool isDInterface(CppInterface a) @safe { return cast(DInterface) a !is null; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21247b.d0000644000175000017500000000042215205374124021312 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test21247b.d(10): Error: anonymous union can only be a part of an aggregate, not function `test21247` --- */ // https://github.com/dlang/dmd/issues/21247 void test21247() { union { uint u = void; ubyte[4] b; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail95.d0000644000175000017500000000063115205374124020664 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail95.d(19): Error: template `A` is not callable using argument types `!()(int)` fail_compilation/fail95.d(11): Candidate is: `A(alias T)(T)` --- */ // https://issues.dlang.org/show_bug.cgi?id=142 // Assertion failure: '0' on line 610 in file 'template.c' template A(alias T) { void A(T) { T = 2; } } void main() { int i; A(i); assert(i == 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11472.d0000644000175000017500000000056015205374124020733 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11472.d(13): Error: template instance `fun2!fun` `fun2` is not a template declaration, it is a function fail_compilation/ice11472.d(18): Error: template instance `ice11472.fun1!(fun3)` error instantiating --- */ void fun3() {} void fun2(string a) {} void fun1(alias fun=fun3)() { "a".fun2!fun; } void main() { fun1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/deprecations.d0000644000175000017500000000230615205374124022254 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/deprecations.d(43): Deprecation: struct `deprecations.S` is deprecated fail_compilation/deprecations.d(64): instantiated from here: `otherPar!()` fail_compilation/deprecations.d(55): Deprecation: struct `deprecations.S` is deprecated fail_compilation/deprecations.d(65): instantiated from here: `otherVar!()` fail_compilation/deprecations.d(55): Deprecation: struct `deprecations.S` is deprecated fail_compilation/deprecations.d(65): instantiated from here: `otherVar!()` --- https://issues.dlang.org/show_bug.cgi?id=20474 */ deprecated struct S {} deprecated void foo()(S par) if (is(S == S)) { S var; } deprecated template bar() if (is(S == S)) { void bar(S par) { S var; } } deprecated void foobar (T) (T par) if (is(T == S)) { T inst; } template otherPar() { deprecated void otherPar(S par) { S var; } void par(S par) {} } template otherVar() { deprecated void otherVar(S par) { S var; } void var() { S var; } } deprecated void main() { foo(S.init); bar(S.init); foobar(S.init); otherPar(S.init); otherVar(S.init); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail60.d0000644000175000017500000000032115205374124020650 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail60.d(14): Error: cannot construct nested class `B` because no implicit `this` reference to outer class `A` is available --- */ class A { class B { } B b=new B; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice24188.d0000644000175000017500000000052315205374124020742 0ustar fabiofabio/* REQUIRED_ARGS: fail_compilation/ice24188_a/ice24188_c.d TEST_OUTPUT: --- fail_compilation/ice24188.d(9): Error: module `ice24188_c` from file fail_compilation/ice24188_a/ice24188_c.d must be imported with 'import ice24188_c;' --- */ auto b() { import fail_compilation.ice24188_a.ice24188_c : D; struct A { D e; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail250.d0000644000175000017500000000036715205374124020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail250.d(10): Error: constructor `fail250.A.this` default constructor for structs only allowed with `@disable`, no body, and no parameters --- */ struct A { this() {} } void main() { auto a = A(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9735.d0000644000175000017500000000032115205374124021032 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/fail9735.d(10): Deprecation: casting from void delegate() to void* is deprecated --- */ void* dg2ptr(void delegate() dg) { return cast(void*) dg; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23003.c0000644000175000017500000000043515205374124021143 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23003.c(101): Error: `size_t` is not defined, perhaps `#include ` ? fail_compilation/test23003.c(102): Error: undefined identifier `object` --- */ /* https://issues.dlang.org/show_bug.cgi?id=23003 */ #line 100 size_t x; object y; ./ldc-1.42.0-src/tests/dmd/fail_compilation/lexer1.d0000644000175000017500000000406715205374124021002 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/lexer1.d(30): Error: declaration expected, not `x"01 02 03"w` fail_compilation/lexer1.d(31): Error: declaration expected, not `2147483649U` fail_compilation/lexer1.d(32): Error: declaration expected, not `0.1` fail_compilation/lexer1.d(33): Error: declaration expected, not `0.1f` fail_compilation/lexer1.d(34): Error: declaration expected, not `0.1L` fail_compilation/lexer1.d(35): Error: declaration expected, not `0.1i` fail_compilation/lexer1.d(36): Error: declaration expected, not `0.1fi` fail_compilation/lexer1.d(37): Error: declaration expected, not `0.1Li` fail_compilation/lexer1.d(38): Error: declaration expected, not `' '` fail_compilation/lexer1.d(39): Error: declaration expected, not `'\ud7ff'` fail_compilation/lexer1.d(40): Error: declaration expected, not `'\U00010000'` fail_compilation/lexer1.d(41): Error: declaration expected, not `"ab\\c\"\u1234a\U00011100a\0ab"d` fail_compilation/lexer1.d(43): Error: declaration expected, not `module` fail_compilation/lexer1.d(45): Error: escape hex sequence has 1 hex digits instead of 2 fail_compilation/lexer1.d(46): Error: undefined escape hex sequence \xG fail_compilation/lexer1.d(47): Error: unnamed character entity &unnamedentity; fail_compilation/lexer1.d(48): Error: unterminated named entity &1; fail_compilation/lexer1.d(49): Error: unterminated named entity &*; fail_compilation/lexer1.d(50): Error: unterminated named entity &s1"; fail_compilation/lexer1.d(51): Error: unterminated named entity &2; fail_compilation/lexer1.d(52): Error: escape octal sequence \400 is larger than \377 fail_compilation/lexer1.d(53): Error: html entity requires 2 code units, use a string instead of a character --- */ // https://dlang.dawg.eu/coverage/src/lexer.c.gcov.html x"01 02 03"w; 0x80000001; 0.1; 0.1f; 0.1L; 0.1i; 0.1fi; 0.1Li; ' '; '\uD7FF'; '\U00010000'; "ab\\c\"\u1234a\U00011100a\000ab"d; module x; static s1 = "\x1G"; static s2 = "\xGG"; static s3 = "\&unnamedentity;"; static s4 = "\&1"; static s5 = "\&*"; static s6 = "\&s1"; static s7 = "\&2;"; static s7 = "\400;"; dchar s8 = '\∾̳'; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail289.d0000644000175000017500000000031615205374124020751 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail289.d(12): Error: cannot cast from function pointer to delegate --- */ alias void delegate() Dg; void fun() {} void gun() { Dg d = cast(void delegate())&fun; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15616b.d0000644000175000017500000000327715205374124021264 0ustar fabiofabio/* REQUIRED_ARGS: -v TRANSFORM_OUTPUT: remove_lines("^(predefs|binary|version|config|DFLAG|parse|import|\(imported|semantic|entry|\s*$)") TEST_OUTPUT: --- fail_compilation/fail15616b.d(44): Error: none of the overloads of `foo` are callable using argument types `(double)` fail_compilation/fail15616b.d(17): Candidates are: `fail15616b.foo(int a)` fail_compilation/fail15616b.d(20): `fail15616b.foo(int a, int b)` fail_compilation/fail15616b.d(29): `fail15616b.foo(int a, int b, int c)` fail_compilation/fail15616b.d(32): `fail15616b.foo(string a)` fail_compilation/fail15616b.d(35): `fail15616b.foo(string a, string b)` fail_compilation/fail15616b.d(38): `fail15616b.foo(string a, string b, string c)` fail_compilation/fail15616b.d(23): `foo(T)(T a)` with `T = double` whose parameters have the following constraints: `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` ` > is(T == float) ` `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` fail_compilation/fail15616b.d(26): `foo(T)(T a)` with `T = double` whose parameters have the following constraints: `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` ` > is(T == char) ` `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` Tip: not satisfied constraints are marked with `>` --- */ #line 17 void foo(int a) {} void foo(int a, int b) {} void foo(T)(T a) if (is(T == float)) {} void foo(T)(T a) if (is(T == char)) {} void foo(int a, int b, int c) {} void foo(string a) {} void foo(string a, string b) {} void foo(string a, string b, string c) {} void main() { foo(3.14); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/write_error.d0000644000175000017500000000030015205374124022127 0ustar fabiofabio/++ https://issues.dlang.org/show_bug.cgi?id=23019 ARG_SETS: -of=fail_compilation TEST_OUTPUT: --- Error: cannot write file 'fail_compilation': $r:(i|I)s$ a directory --- ++/ void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10319.d0000644000175000017500000000300115205374124021067 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10319.d(30): Error: `pure` function `D main` cannot call impure function `diag10319.foo` fail_compilation/diag10319.d(30): Error: `@safe` function `D main` cannot call `@system` function `diag10319.foo` fail_compilation/diag10319.d(19): `diag10319.foo` is declared here fail_compilation/diag10319.d(31): Error: `pure` function `D main` cannot call impure function `diag10319.bar!int.bar` fail_compilation/diag10319.d(23): and accessing mutable static data `g` makes it fail to infer `pure` fail_compilation/diag10319.d(31): Error: `@safe` function `D main` cannot call `@system` function `diag10319.bar!int.bar` fail_compilation/diag10319.d(24): and taking the address of stack-allocated local variable `x` makes it fail to infer `@safe` fail_compilation/diag10319.d(21): `diag10319.bar!int.bar` is declared here fail_compilation/diag10319.d(30): Error: function `diag10319.foo` is not `nothrow` fail_compilation/diag10319.d(31): Error: function `diag10319.bar!int.bar` is not `nothrow` fail_compilation/diag10319.d(25): and `object.Exception` being thrown but not caught makes it fail to infer `nothrow` fail_compilation/diag10319.d(28): Error: function `D main` may throw but is marked as `nothrow` --- */ void foo() {} void bar(T)() { static int g; g = 10; // impure int x; auto p = &x; // system throw new Exception(""); // may throw } @safe pure nothrow void main() // L23 { foo(); // L25 bar!int(); // L26 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10768.d0000644000175000017500000000107215205374124021105 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10768.d(35): Error: cannot implicitly override base class method `diag10768.Frop.frop` with `diag10768.Foo.frop`; add `override` attribute --- */ struct CirBuff(T) { CirBuff!T opAssign(R)(R) {} T[] toArray() { T[] ret; // = new T[this.length]; return ret; } alias toArray this; } class Bar(T=int) { CirBuff!T _bar; } class Once { Bar!Foo _foobar; } class Foo : Frop { // override public int frop() { return 1; } } class Frop { public int frop() { return 0; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10922.d0000644000175000017500000000103615205374124020731 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10922.d(11): Error: function `(in uint n) { enum self = __lambda_L10_C12; return n < 2 ? n : self(n - 1) + ...` is not callable using argument types `()` fail_compilation/ice10922.d(11): too few arguments, expected 1, got 0 fail_compilation/ice10922.d(10): `ice10922.__lambda_L10_C12(in uint n)` declared here --- */ auto fib = (in uint n) pure nothrow { enum self = __traits(parent, {}); return (n < 2) ? n : self(n - 1) + self(n - 2); }; void main() { auto n = fib(39); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail288.d0000644000175000017500000000036315205374124020752 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail288.d(14): Error: case ranges not allowed in `final switch` --- */ void main() { enum E { a, b } E i = E.a; final switch (i) { case E.a: .. case E.b: break; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice4094.d0000644000175000017500000000055615205374124020662 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice4094.d(11): Error: circular reference to variable `ice4094.Zug!0.Zug.bahn` fail_compilation/ice4094.d(19): Error: template instance `ice4094.Zug!0` error instantiating --- */ // REQUIRED_ARGS: -d struct Zug(int Z) { const bahn = Bug4094!(0).hof.bahn; } struct Bug4094(int Q) { Zug!(0) hof; } const a = Zug!(0).bahn; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag5385.d0000644000175000017500000000277615205374124021040 0ustar fabiofabio/* EXTRA_FILES: imports/fail5385.d TEST_OUTPUT: --- fail_compilation/diag5385.d(28): Error: no property `privX` for type `imports.fail5385.C` fail_compilation/imports/fail5385.d(3): class `C` defined here fail_compilation/diag5385.d(29): Error: no property `packX` for type `imports.fail5385.C` fail_compilation/imports/fail5385.d(3): class `C` defined here fail_compilation/diag5385.d(30): Error: no property `privX2` for type `imports.fail5385.C` fail_compilation/imports/fail5385.d(3): class `C` defined here fail_compilation/diag5385.d(31): Error: no property `packX2` for type `imports.fail5385.C` fail_compilation/imports/fail5385.d(3): class `C` defined here fail_compilation/diag5385.d(32): Error: no property `privX` for type `imports.fail5385.S` fail_compilation/imports/fail5385.d(11): struct `S` defined here fail_compilation/diag5385.d(33): Error: no property `packX` for type `imports.fail5385.S` fail_compilation/imports/fail5385.d(11): struct `S` defined here fail_compilation/diag5385.d(34): Error: no property `privX2` for type `imports.fail5385.S` fail_compilation/imports/fail5385.d(11): struct `S` defined here fail_compilation/diag5385.d(35): Error: no property `packX2` for type `imports.fail5385.S` fail_compilation/imports/fail5385.d(11): struct `S` defined here --- */ import imports.fail5385; void main() { C.privX = 1; C.packX = 1; C.privX2 = 1; C.packX2 = 1; S.privX = 1; S.packX = 1; S.privX2 = 1; S.packX2 = 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail310.d0000644000175000017500000000054715205374124020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail310.d(10): Error: undefined identifier `Foo`, did you mean function `foo`? fail_compilation/fail310.d(14): Error: template instance `fail310.foo!(1, 2)` error instantiating fail_compilation/fail310.d(14): while evaluating: `static assert(foo!(1, 2)())` --- */ Foo foo(A...)() { } static assert(foo!(1, 2)()); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail110.d0000644000175000017500000000124715205374124020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail110.d(19): Error: variable `i` is shadowing variable `fail110.main.i` fail_compilation/fail110.d(17): declared here fail_compilation/fail110.d(20): Error: variable `i` is shadowing variable `fail110.main.i` fail_compilation/fail110.d(17): declared here fail_compilation/fail110.d(21): Error: variable `i` is shadowing variable `fail110.main.i` fail_compilation/fail110.d(17): declared here --- */ // https://issues.dlang.org/show_bug.cgi?id=297 // Shadowing declarations allowed in foreach type lists void main() { int i; int[] a; foreach (i; a) {} foreach (size_t i, n; a) {} for (int i;;) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4421.d0000644000175000017500000000124015205374124021016 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4421.d(16): Error: function `fail4421.U1.this(this)` destructors, postblits and invariants are not allowed in union `U1` fail_compilation/fail4421.d(17): Error: destructor `fail4421.U1.~this` destructors, postblits and invariants are not allowed in union `U1` fail_compilation/fail4421.d(18): Error: function `fail4421.U1.invariant` destructors, postblits and invariants are not allowed in union `U1` --- */ union U1 { this(this); ~this(); invariant() { } } struct S1 { this(this); ~this(); invariant() { } } union U2 { S1 s1; } struct S2 { union { S1 s1; int j; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail76.d0000644000175000017500000000030615205374124020662 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail76.d(9): Error: alias `fail76.a` conflicts with alias `fail76.a` at fail_compilation/fail76.d(8) --- */ alias main a; alias void a; void main() { a; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/cppvar.d0000644000175000017500000000235515205374124021073 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/cppvar.d(10): Error: variable `cppvar.funcLiteral` cannot have `extern(C++)` linkage because it is `static` fail_compilation/cppvar.d(10): perhaps declare it as `__gshared` instead fail_compilation/cppvar.d(20): Error: variable `cppvar.threadLocalVar` cannot have `extern(C++)` linkage because it is `static` fail_compilation/cppvar.d(20): perhaps declare it as `__gshared` instead fail_compilation/cppvar.d(21): Error: variable `cppvar.staticVar` cannot have `extern(C++)` linkage because it is `static` fail_compilation/cppvar.d(21): perhaps declare it as `__gshared` instead fail_compilation/cppvar.d(22): Error: variable `cppvar.sharedVar` cannot have `extern(C++)` linkage because it is `shared` fail_compilation/cppvar.d(22): perhaps declare it as `__gshared` instead fail_compilation/cppvar.d(30): Error: delegate `() { bool[3] a = false; return a; }` cannot return type `bool[3]` because its linkage is `extern(C++)` --- */ #line 10 extern(C++) bool[3] funcLiteral = () { bool[3] a; return a; }; #line 20 extern(C++) int threadLocalVar; extern(C++) static int staticVar; extern(C++) shared int sharedVar; #line 30 extern(C++) __gshared bool[3] gfuncLiteral = () { bool[3] a; return a; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20859.d0000644000175000017500000000053615205374124021166 0ustar fabiofabio/** DISABLED: LDC // succeeds, as LDC doesn't add a (undocumented) magic __vtbl member variable (unused `ClassDeclaration.vtblSymbol()`) TEST_OUTPUT: --- fail_compilation/test20859.d(8): Error: variable `test20859.ICE.__vtbl` conflicts with variable `test20859.ICE.__vtbl` at fail_compilation/test20859.d(10) --- */ class ICE { void **__vtbl; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19923.d0000644000175000017500000000035215205374124021116 0ustar fabiofabio/* DFLAGS: TEST_OUTPUT: --- fail_compilation/fail19923.d(16): Error: `object.TypeInfo_Class` could not be found, but is implicitly used --- */ module object; class Object {} void test() { Object o; auto ti = o.classinfo; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag14818.d0000644000175000017500000000263115205374124021107 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag14818.d(40): Error: none of the overloads of `func` are callable using argument types `(string)` fail_compilation/diag14818.d(18): Candidates are: `diag14818.foo(int __param_0)` fail_compilation/diag14818.d(19): `diag14818.bar(double __param_0)` fail_compilation/diag14818.d(41): Error: template instance `diag14818.X!string` does not match any template declaration fail_compilation/diag14818.d(41): Candidates are: fail_compilation/diag14818.d(24): Foo(T) if (is(T == int)) fail_compilation/diag14818.d(25): Bar(T) if (is(T == double)) fail_compilation/diag14818.d(42): Error: template instance `diag14818.Y!string` does not match any template declaration fail_compilation/diag14818.d(42): Candidates are: fail_compilation/diag14818.d(25): Bar(T) if (is(T == double)) fail_compilation/diag14818.d(24): Foo(T) if (is(T == int)) --- */ void foo(int) {} void bar(double) {} alias func = foo; alias func = bar; // in here, func is a FuncAliasDeclaration; template Foo(T) if (is(T == int)) {} template Bar(T) if (is(T == double)) {} alias X = Foo; alias X = Bar; // in here, X is an OverDeclaration template Mix1() { alias M = Foo; } template Mix2() { alias M = Bar; } mixin Mix1; mixin Mix2; alias Y = M; // in here, Y is an OverloadSet void main() { func("abc"); alias x = X!string; alias y = Y!string; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/gag4269d.d0000644000175000017500000000033615205374124021024 0ustar fabiofabio// REQUIRED_ARGS: -c -o- /* TEST_OUTPUT: --- fail_compilation/gag4269d.d(10): Error: undefined identifier `Y4`, did you mean function `X4`? --- */ static if(is(typeof(X4.init))) {} Y4 X4() { return typeof(return).init; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/template_enum_param.d0000644000175000017500000000043315205374124023612 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/template_enum_param.d(15): Error: static assert: `false` is false fail_compilation/template_enum_param.d(17): instantiated from here: `X!(E.a)` --- */ enum E { a,b,c } template X(E e) { static assert(false); } alias Y = X!(E.a); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail75.d0000644000175000017500000000026115205374124020661 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail75.d(13): Error: cannot append type `fail75.C` to type `C[1]` --- */ class C { C[1] c; this() { c ~= this; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12622.d0000644000175000017500000000247715205374124021115 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail12622.d(26): Error: `pure` function `fail12622.foo` cannot call impure function pointer `fp` fail_compilation/fail12622.d(26): Error: `@nogc` function `fail12622.foo` cannot call non-@nogc function pointer `fp` fail_compilation/fail12622.d(26): Error: `@safe` function `fail12622.foo` cannot call `@system` function pointer `fp` fail_compilation/fail12622.d(28): Error: `pure` function `fail12622.foo` cannot call impure function pointer `fp` fail_compilation/fail12622.d(28): Error: `@nogc` function `fail12622.foo` cannot call non-@nogc function pointer `fp` fail_compilation/fail12622.d(28): Error: `@safe` function `fail12622.foo` cannot call `@system` function pointer `fp` fail_compilation/fail12622.d(30): Error: `pure` function `fail12622.foo` cannot call impure function `fail12622.bar` fail_compilation/fail12622.d(30): Error: `@safe` function `fail12622.foo` cannot call `@system` function `fail12622.bar` fail_compilation/fail12622.d(20): `fail12622.bar` is declared here fail_compilation/fail12622.d(30): Error: `@nogc` function `fail12622.foo` cannot call non-@nogc function `fail12622.bar` --- */ // Note that, today nothrow violation errors are accidentally hidden. void bar(); pure nothrow @nogc @safe void foo() { auto fp = &bar; (*fp)(); fp(); bar(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9936.d0000644000175000017500000000147615205374124021051 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail9936.d(25): Error: `S().opBinary` isn't a template fail_compilation/fail9936.d(26): Error: `S().opBinaryRight` isn't a template fail_compilation/fail9936.d(27): Error: `S().opOpAssign` isn't a template fail_compilation/fail9936.d(29): Error: `S().opIndexUnary` isn't a template fail_compilation/fail9936.d(30): Error: `S().opUnary` isn't a template --- */ struct S { auto opBinary(S s) { return 1; } auto opBinaryRight(int n) { return 1; } auto opOpAssign(S s) { return 1; } auto opIndexUnary(S s) { return 1; } auto opUnary(S s) { return 1; } } void main() { static assert(!is(typeof( S() + S() ))); static assert(!is(typeof( 100 + S() ))); static assert(!is(typeof( S() += S() ))); S() + S(); 100 + S(); S() += S(); +S()[0]; +S(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/commaexp.d0000644000175000017500000000456615205374124021417 0ustar fabiofabio/* REQUIRED_ARGS: -o- TEST_OUTPUT: --- fail_compilation/commaexp.d(27): Error: using the result of a comma expression is not allowed fail_compilation/commaexp.d(39): Error: using the result of a comma expression is not allowed fail_compilation/commaexp.d(40): Error: using the result of a comma expression is not allowed fail_compilation/commaexp.d(41): Error: using the result of a comma expression is not allowed fail_compilation/commaexp.d(42): Error: using the result of a comma expression is not allowed fail_compilation/commaexp.d(44): Error: using the result of a comma expression is not allowed fail_compilation/commaexp.d(45): Error: using the result of a comma expression is not allowed fail_compilation/commaexp.d(56): Error: using the result of a comma expression is not allowed fail_compilation/commaexp.d(69): Error: using the result of a comma expression is not allowed fail_compilation/commaexp.d(81): Error: using the result of a comma expression is not allowed --- */ class Entry {} class MyContainerClass { bool append (Entry) { return false; } } int main () { bool ok; size_t aggr; MyContainerClass mc; // https://issues.dlang.org/show_bug.cgi?id=15997 enum WINHTTP_ERROR_BASE = 4200; enum ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED = (WINHTTP_ERROR_BASE, + 44); // OK for (size_t i; i < 5; ++i, i += 1) {} for (size_t i; i < 5; ++i, i += 1, i++) {} if (!mc) mc = new MyContainerClass, mc.append(new Entry); if (Object o = cast(Object)mc) {} // Lowering ok = true, mc.append(new Entry); assert(ok); // NOPE for (size_t i; i < 5; ++i, i += (i++, 1)) {} for (; aggr++, aggr > 5;) {} if (Object o = (ok = true, null)) {} ok = (true, mc.append(new Entry)); assert(!ok); ok = true, (ok = (true, false)); return 42, 0; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=16022 bool test16022() { enum Type { Colon, Comma } Type type; return type == Type.Colon, type == Type.Comma; } bool test16022_structs() { struct A { int i; string s; } enum Type { Colon = A(0, "zero"), Comma = A(1, "one") } Type type; return type == Type.Colon, type == Type.Comma; } /********************************************/ void bar11(int*, int*) { } void test11() { static int* p; static int i; bar11((i,p), &i); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4269e.d0000644000175000017500000000043115205374124021176 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4269e.d(10): Error: semicolon needed to end declaration of `Y` instead of `X5` fail_compilation/fail4269e.d(10): Error: variable name expected after type `X5`, not `;` --- */ static if(is(typeof(X5.init))) {} typedef Y X5; void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/deprecate_getVirtualFunctions.d0000644000175000017500000000077215205374124025634 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/deprecate_getVirtualFunctions.d(18): Deprecation: `traits(isVirtualFunction)` is deprecated. Use `traits(isVirtualMethod)` instead fail_compilation/deprecate_getVirtualFunctions.d(19): Deprecation: `traits(getVirtualFunctions)` is deprecated. Use `traits(getVirtualMethods)` instead --- */ class A { void fun() {} } void main() { auto a = __traits(isVirtualFunction, A.fun); foreach(f; __traits(getVirtualFunctions, A, "fun")) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag23295.d0000644000175000017500000000166015205374124021107 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/diag23295.d(21): Error: assigning scope variable `x` to non-scope parameter `y` calling `foo` is not allowed in a `@safe` function fail_compilation/diag23295.d(32): which is assigned to non-scope parameter `z` fail_compilation/diag23295.d(34): which is not `scope` because of `f = & z` fail_compilation/diag23295.d(24): Error: assigning scope variable `ex` to non-scope parameter `e` calling `thro` is not allowed in a `@safe` function fail_compilation/diag23295.d(39): which is not `scope` because of `throw e` --- */ // explain why scope inference failed // https://issues.dlang.org/show_bug.cgi?id=23295 @safe: void main() { scope int* x; foo(x, null); scope Exception ex; thro(ex); } auto foo(int* y, int** w) { fooImpl(y, null); } auto fooImpl(int* z, int** w) { auto f = &z; } auto thro(Exception e) { throw e; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/objc_non_objc_base.d0000644000175000017500000000037715205374124023360 0ustar fabiofabio// EXTRA_OBJC_SOURCES: /* TEST_OUTPUT: --- fail_compilation/objc_non_objc_base.d(12): Error: class `objc_non_objc_base.A` base class for an Objective-C class must be `extern (Objective-C)` --- */ interface Base {} extern (Objective-C) class A : Base {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice21095.d0000644000175000017500000000073215205374124020736 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21095 /* TEST_OUTPUT: --- fail_compilation/ice21095.d(14): Error: constructor `ice21095.Mutex.this!().this` `in` and `out` contracts can only appear without a body when they are virtual interface functions or abstract fail_compilation/ice21095.d(12): Error: template instance `ice21095.Mutex.this!()` error instantiating --- */ class Mutex { this(Object obj) { this(obj, true); } this()(Object, bool) in { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11591b.d0000644000175000017500000000144515205374124021255 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11591b.d(16): Error: AA key type `S11591` does not have `bool opEquals(ref const S11591) const` --- */ struct S11591 { bool opEquals(int i) { return false; } Object o; // needed to suppress compiler generated opEquals } void test11591() { int[S11591] aa; } /* TEST_OUTPUT: --- fail_compilation/fail11591b.d(30): Error: AA key type `S12307a` does not have `bool opEquals(ref const S12307a) const` fail_compilation/fail11591b.d(31): Error: AA key type `S12307b` does not have `bool opEquals(ref const S12307b) const` --- */ struct S12307a { bool opEquals(T : typeof(this))(T) { return false; } } void test12307() { int[S12307a] aa1; // a int[S12307b] aa2; // b } struct S12307b { bool opEquals(T : typeof(this))(T) { return false; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/e15876_4.d0000644000175000017500000000210515205374124020653 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/e15876_4.d(26): Error: found `)` when expecting `(` fail_compilation/e15876_4.d(27): Error: found `End of File` when expecting `(` fail_compilation/e15876_4.d(27): Error: found `End of File` instead of statement fail_compilation/e15876_4.d(27): Error: expression expected, not `End of File` fail_compilation/e15876_4.d(27): Error: found `End of File` when expecting `;` following `for` condition fail_compilation/e15876_4.d(27): Error: expression expected, not `End of File` fail_compilation/e15876_4.d(27): Error: found `End of File` when expecting `)` fail_compilation/e15876_4.d(27): Error: found `End of File` instead of statement fail_compilation/e15876_4.d(27): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/e15876_4.d(26): unmatched `{` fail_compilation/e15876_4.d(27): Error: found `End of File` when expecting `)` fail_compilation/e15876_4.d(27): Error: variable name expected after type `typeof(() { for (__error__ __error; __error) { __error__ } } )`, not `End of File` --- */ typeof){for ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue21295.d0000644000175000017500000000023315205374124021324 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/issue21295.d(8): Error: undefined identifier `Visitor` --- */ import imports.issue21295ast_node; Visitor should_fail; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail113.d0000644000175000017500000000036415205374124020736 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail113.d(10): Error: forward reference to `test` --- */ // https://issues.dlang.org/show_bug.cgi?id=370 // Compiler stack overflow on recursive typeof in function declaration. void test(typeof(test) p) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail11445.d0000644000175000017500000000035315205374124021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail11445.d(11): Error: illegal operator `+` for `a` of type `double[string]` --- */ void main() { double[string] a = [ "foo" : 22.2 ]; double[string] b = [ "bar" : 22.2 ]; auto c = a + b; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14116.d0000644000175000017500000000041015205374124020723 0ustar fabiofabio// EXTRA_SOURCES: imports/a14116.d /* TEST_OUTPUT: --- fail_compilation/imports/a14116.d(3): Error: module `ice14116.ice14116` from file fail_compilation/ice14116.d must be imported with 'import ice14116.ice14116;' --- */ module ice14116.ice14116; void foo() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8318.d0000644000175000017500000000235615205374124021031 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8318.d(18): Error: function `diag8318.Bar8318.foo` return type inference is not supported if may override base class function fail_compilation/diag8318.d(23): Error: function `diag8318.C10021.makeI` return type inference is not supported if may override base class function fail_compilation/diag8318.d(31): Error: function `diag8318.Bar10195.baz` return type inference is not supported if may override base class function fail_compilation/diag8318.d(37): Error: function `diag8318.B14173.foo` does not override any function fail_compilation/diag8318.d(23): Error: class `diag8318.C10021` interface function `I10021 makeI()` is not implemented fail_compilation/diag8318.d(29): Error: class `diag8318.Bar10195` interface function `int baz()` is not implemented --- */ class Foo8318 { auto foo() { return "Foo.foo"; } } class Bar8318 : Foo8318 { override auto foo() { return "Bar.foo"; } } interface I10021 { I10021 makeI(); } class D10021 : I10021 { D10021 makeI() { return this; } } class C10021 : I10021 { auto makeI() { return this; } } interface Foo10195 { int baz(); } class Bar10195 : Foo10195 { override auto baz() { return 1; } } class A14173 {} class B14173 : A14173 { override foo() {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23.d0000644000175000017500000000033115205374124020650 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail23.d(14): Error: `break` is not inside a loop or `switch` --- */ // ICE(s2ir.c) DMD0.100 void main() { try { break; } catch (Throwable) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix21166.d0000644000175000017500000000047015205374124020762 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix21166.d(12): Error: invalid array operation `"foo" + "bar"` (possible missing []) fail_compilation/fix21166.d(12): did you mean to concatenate (`"foo" ~ "bar"`) instead ? --- */ // Test case for https://github.com/dlang/dmd/issues/21166 auto r = "foo" + "bar"; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18243.d0000644000175000017500000000070115205374124021106 0ustar fabiofabio/* EXTRA_FILES: imports/a18243.d imports/b18243.d TEST_OUTPUT: --- fail_compilation/fail18243.d(17): Error: none of the overloads of `isNaN` are callable using argument types `!()(float)` fail_compilation/imports/b18243.d(3): Candidates are: `isNaN(T)(T x)` fail_compilation/imports/a18243.d(5): `imports.a18243.isNaN()` --- */ module fail18243; import imports.a18243; void main() { bool b = isNaN(float.nan); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail_contracts1.d0000644000175000017500000000026515205374124022652 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail_contracts1.d(8): Error: `(identifier) { ... }` or `(identifier; expression)` following `out` expected, not `)` --- */ void foo() out()){} ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice15332.d0000644000175000017500000000063715205374124020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice15332.d(16): Error: calling non-static function `fun` requires an instance of type `C` fail_compilation/ice15332.d(17): Error: accessing non-static variable `var` requires an instance of `C` --- */ class C { int fun() { return 5; } int var; void test() { int a1 = function() { return fun; }(); int a2 = function() { return var; }(); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test13152.d0000644000175000017500000000131015205374124021141 0ustar fabiofabio/* EXTRA_FILES: imports/test13152a.d imports/test13152b.d imports/test13152c.d imports/test13152d.d imports/test13152e.d imports/test13152f.d imports/test13152g.d imports/test13152h.d imports/test13152i.d imports/test13152j.d imports/test13152k.d imports/test13152l.d imports/test13152m.d imports/test13152n.d imports/test13152o.d imports/test13152p.d imports/test13152q.d imports/test13152r.d imports/test13152s.d imports/test13152t.d imports/test13152u.d imports/test13152v.d imports/test13152w.d imports/test13152x.d imports/test13152y.d imports/test13152z.d TEST_OUTPUT: --- fail_compilation/test13152.d(12): Error: undefined identifier `x` --- */ import imports.test13152a; void main() { auto y = x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23626a.d0000644000175000017500000000136715205374124021261 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail23626a.d(10): Deprecation: function `fail23626a.ambig` cannot overload `extern(D)` function at fail_compilation/fail23626a.d(9) fail_compilation/fail23626a.d(13): Error: function `fail23626a.ambigC` cannot overload `extern(C)` function at fail_compilation/fail23626a.d(12) fail_compilation/fail23626a.d(16): Error: function `fail23626a.ambigCxx(int a)` conflicts with previous declaration at fail_compilation/fail23626a.d(15) --- */ extern(D) int ambig(int a) { return 0; } extern(D) int ambig(int a) @system { return 1; } extern(C) int ambigC(int a) { return 2; } extern(C) int ambigC(int a) @system { return 3; } extern(C++) int ambigCxx(int a) { return 4; } extern(C++) int ambigCxx(int a) @system { return 5; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12158.d0000644000175000017500000000025115205374124020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12158.d(7): Error: module `object` import `nonexisting` not found --- */ import object : nonexisting; auto x = nonexisting.init; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13435.d0000644000175000017500000000126015205374124021105 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=13435 /* TEST_OUTPUT: --- fail_compilation/fail13435.d(22): Error: cannot implicitly convert expression `d` of type `int[]` to `S!int` fail_compilation/fail13435.d(22): `this._a = d` is the first assignment of `this._a` therefore it represents its initialization fail_compilation/fail13435.d(22): `opAssign` methods are not used for initialization, but for subsequent assignments --- */ struct S(T) { void opAssign(T[] arg) {} } class B { this(int[] d) { S!int c; _a = d; // Error: cannot implicitly convert expression (d) of type int[] to S!int c = d; // compiles OK } S!int _a; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/dassert.d0000644000175000017500000000175315205374124021246 0ustar fabiofabio/* REQUIRED_ARGS: -checkaction=context TEST_OUTPUT: --- fail_compilation/dassert.d(14): Error: expression `AliasSeq!(0, 0)` of type `(int, int)` does not have a boolean value fail_compilation/dassert.d(21): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/dassert.d(29): Error: assignment cannot be used as a condition, perhaps `==` was meant? fail_compilation/dassert.d(40): Error: expression `issue()` of type `void` does not have a boolean value --- */ #line 10 struct Baguette { int bread, floor; } void main () { assert(Baguette.init.tupleof); } // https://issues.dlang.org/show_bug.cgi?id=21590 void issue21590() { int a, b = 1; assert (a = b); static ref int get() { static int i; return i; } assert(get() = 1); // No errors for binary assignments (regardless of -checkaction=context) int[] arr; assert(arr ~= 1); assert(a += b); } // https://issues.dlang.org/show_bug.cgi?id=21798 void issue() { assert(issue()); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail252.d0000644000175000017500000000060215205374124020735 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail252.d(13): Error: cannot implicitly override base class method `fail252.Timer.Task.run` with `fail252.Timer.__anonclass1.run`; add `override` attribute --- */ class Timer { abstract class Task { public abstract void run(); } private Task IDLE = new class() Task { int d; public void run(){ } }; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22827.d0000644000175000017500000000050415205374124021112 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22827 /* TEST_OUTPUT: --- fail_compilation/fail22827.d(8): Error: `cent` and `ucent` types are obsolete, use `core.int128.Cent` instead fail_compilation/fail22827.d(9): Error: `cent` and `ucent` types are obsolete, use `core.int128.Cent` instead --- */ cent i22827; ucent j22827; ./ldc-1.42.0-src/tests/dmd/fail_compilation/testhtml.html0000644000175000017500000007300515205374124022165 0ustar fabiofabio dstress: html_entity_01

int main(){
	assert('~'==0x7E);
	assert('~'==0x7E);
	assert('अ'==0x905);
	assert('अ'==0x905);
	assert('𐌀'==0x10300);
	assert('𐌀'==0x10300);
	assert('􏿽'==0x10FFFD);
	assert('􏿽'==0x10FFFD);
	assert('«'=='«');

	assert('α'=='α');
	assert('β'=='β');
	assert('γ'=='γ');
	assert('Γ'=='Γ');



	

	return 0;
}




static assert(0); ./ldc-1.42.0-src/tests/dmd/fail_compilation/enum_auto_increment.d0000644000175000017500000000043015205374124023630 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation\enum_auto_increment.d(17): Error: cannot automatically assign value to enum member `enum_auto_increment.A2.d` because base type `A1` is an enum; provide an explicit value --- */ enum A1 : int { a, b, } enum A2 : A1 { c, d, } ./ldc-1.42.0-src/tests/dmd/fail_compilation/cenums.c0000644000175000017500000000174315205374124021071 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/cenums.c(202): Error: `enum E2` is incomplete without members fail_compilation/cenums.c(303): Error: redeclaring `union E3` as `enum E3` fail_compilation/cenums.c(502): Error: enum member `cenums.test5.F.a` conflicts with enum member `cenums.test5.F.a` at fail_compilation/cenums.c(502) --- */ #line 100 enum E1 { a }; void test1() { enum E1 e1; } #line 200 void test2() { enum E2 e2; } #line 300 union E3; void test3() { enum E3 e3; } #line 400 void test4() { enum E4 { a, b, c = 3, d }; _Static_assert(sizeof(enum E4) == 4, "in"); _Static_assert(a == 0, "in"); _Static_assert(b == 1, "in"); _Static_assert(c == 3, "in"); _Static_assert(d == 4, "in"); } #line 500 void test5() { enum F { a, a }; } #line 600 enum E6 { a6, b6 } c6; _Static_assert(a6 == 0, "in"); _Static_assert(b6 == 1, "in"); #line 700 void test() { enum E { a, b } c; _Static_assert(a == 0, "in"); _Static_assert(b == 1, "in"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail224.d0000644000175000017500000000071315205374124020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail224.d(22): Error: need `this` of type `A` to access member `x` from static function `f` --- */ int gi; class A { int x = 42; void am() { static void f() { class B { void bm() { gi = x; } } (new B).bm(); } f(); } } void main() { (new A).am(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/parseStc3.d0000644000175000017500000000431415205374124021444 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/parseStc3.d(10): Error: redundant attribute `pure` fail_compilation/parseStc3.d(11): Error: redundant attribute `nothrow` fail_compilation/parseStc3.d(12): Error: redundant attribute `@nogc` fail_compilation/parseStc3.d(13): Error: redundant attribute `@property` --- */ pure void f1() pure {} nothrow void f2() nothrow {} @nogc void f3() @nogc {} @property void f4() @property {} //ref int f5() ref { static int g; return g; } /* TEST_OUTPUT: --- fail_compilation/parseStc3.d(24): Error: redundant attribute `@safe` fail_compilation/parseStc3.d(25): Error: redundant attribute `@system` fail_compilation/parseStc3.d(26): Error: redundant attribute `@trusted` --- */ @safe void f6() @safe {} @system void f7() @system {} @trusted void f8() @trusted {} /* TEST_OUTPUT: --- fail_compilation/parseStc3.d(39): Error: conflicting attribute `@system` fail_compilation/parseStc3.d(40): Error: conflicting attribute `@trusted` fail_compilation/parseStc3.d(41): Error: conflicting attribute `@safe` fail_compilation/parseStc3.d(42): Error: conflicting attribute `@trusted` fail_compilation/parseStc3.d(43): Error: conflicting attribute `@safe` fail_compilation/parseStc3.d(44): Error: conflicting attribute `@system` --- */ @safe void f9() @system {} @safe void f10() @trusted {} @system void f11() @safe {} @system void f12() @trusted {} @trusted void f13() @safe {} @trusted void f14() @system {} /* TEST_OUTPUT: --- fail_compilation/parseStc3.d(59): Error: conflicting attribute `@system` fail_compilation/parseStc3.d(59): Error: conflicting attribute `@trusted` fail_compilation/parseStc3.d(60): Error: conflicting attribute `@system` fail_compilation/parseStc3.d(60): Error: redundant attribute `@system` fail_compilation/parseStc3.d(61): Error: conflicting attribute `@safe` fail_compilation/parseStc3.d(61): Error: redundant attribute `@system` fail_compilation/parseStc3.d(62): Error: conflicting attribute `@safe` fail_compilation/parseStc3.d(62): Error: redundant attribute `@trusted` --- */ @safe @system void f15() @trusted {} @safe @system void f16() @system {} @system @safe void f17() @system {} @trusted @safe void f18() @trusted {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/b17918.d0000644000175000017500000000035415205374124020430 0ustar fabiofabio/* EXTRA_FILES: imports/b17918a.d TEST_OUTPUT: --- fail_compilation/imports/b17918a.d(7): Error: undefined identifier `_listMap` --- */ // https://issues.dlang.org/show_bug.cgi?id=17918 import imports.b17918a; class Derived : Base { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12378.d0000644000175000017500000000743315205374124021122 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail12378.d(18): Error: undefined identifier `ANYTHING` fail_compilation/fail12378.d(18): Error: undefined identifier `GOES` fail_compilation/fail12378.d(91): instantiated from here: `MapResultS!((x0) => ANYTHING - GOES, Result)` fail_compilation/fail12378.d(17): instantiated from here: `mapS!(Result)` fail_compilation/fail12378.d(100): instantiated from here: `__lambda_L16_C19!int` fail_compilation/fail12378.d(91): instantiated from here: `MapResultS!((y0) => iota(2).mapS!((x0) => ANYTHING - GOES), Result)` fail_compilation/fail12378.d(16): instantiated from here: `mapS!(Result)` --- */ void testS() { auto r = iota(1).mapS!(y0 => iota(2).mapS!(x0 => ANYTHING-GOES ) ); } /* TEST_OUTPUT: --- fail_compilation/fail12378.d(40): Error: undefined identifier `ANYTHING` fail_compilation/fail12378.d(40): Error: undefined identifier `GOES` fail_compilation/fail12378.d(112): instantiated from here: `MapResultC!((x0) => ANYTHING - GOES, Result)` fail_compilation/fail12378.d(39): instantiated from here: `mapC!(Result)` fail_compilation/fail12378.d(123): instantiated from here: `__lambda_L38_C19!int` fail_compilation/fail12378.d(112): instantiated from here: `MapResultC!((y0) => iota(2).mapC!((x0) => ANYTHING - GOES), Result)` fail_compilation/fail12378.d(38): instantiated from here: `mapC!(Result)` --- */ void testC() { auto r = iota(1).mapC!(y0 => iota(2).mapC!(x0 => ANYTHING-GOES ) ); } /* TEST_OUTPUT: --- fail_compilation/fail12378.d(64): Error: undefined identifier `ANYTHING` fail_compilation/fail12378.d(64): Error: undefined identifier `GOES` fail_compilation/fail12378.d(135): instantiated from here: `MapResultI!((x0) => ANYTHING - GOES, Result)` fail_compilation/fail12378.d(63): instantiated from here: `mapI!(Result)` fail_compilation/fail12378.d(143): instantiated from here: `__lambda_L62_C19!int` fail_compilation/fail12378.d(135): instantiated from here: `MapResultI!((y0) => iota(2).mapI!((x0) => ANYTHING - GOES), Result)` fail_compilation/fail12378.d(62): instantiated from here: `mapI!(Result)` --- */ void testI() { auto r = iota(1).mapI!(y0 => iota(2).mapI!(x0 => ANYTHING-GOES ) ); } auto iota(E)(E end) { alias Value = E; static struct Result { private Value current, pastLast; @property inout(Value) front() inout { return current; } } return Result(0, end); } template mapS(fun...) { auto mapS(R)(R r) { alias AppliedReturnType(alias f) = typeof(f(r.front)); static assert(!is(AppliedReturnType!fun == void), "Mapping function must not return void."); return MapResultS!(fun, R)(r); } } struct MapResultS(alias fun, R) { R _input; @property auto ref front() { return fun(_input.front); } } template mapC(fun...) { auto mapC(R)(R r) { alias AppliedReturnType(alias f) = typeof(f(r.front)); static assert(!is(AppliedReturnType!fun == void), "Mapping function must not return void."); return new MapResultC!(fun, R)(r); } } class MapResultC(alias fun, R) { R _input; this(R r) { _input = r; } @property auto ref front() { return fun(_input.front); } } template mapI(fun...) { auto mapI(R)(R r) { alias AppliedReturnType(alias f) = typeof(f(r.front)); static assert(!is(AppliedReturnType!fun == void), "Mapping function must not return void."); return MapResultI!(fun, R).init; } } interface MapResultI(alias fun, R) { static @property auto ref front() { R _input; return fun(_input.front); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice7645.d0000644000175000017500000000066215205374124020665 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice7645.d(28): Error: accessing non-static variable `t` requires an instance of `C2` fail_compilation/ice7645.d(31): Error: calling non-static function `fn` requires an instance of type `S2` --- */ class C { class C2() { char t; } } struct S { struct S2(T) { void fn() {} } } void main() { C c; auto v = c.C2!().t; S s; s.S2!int.fn(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10221.d0000644000175000017500000000027515205374124021071 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10221.d(10): Error: cannot implicitly convert expression `256` of type `int` to `ubyte` --- */ void main() { foreach(ref ubyte i; 0..256) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failcstuff3.c0000644000175000017500000000047015205374124022004 0ustar fabiofabio// check importAll analysis of C files /* TEST_OUTPUT: --- fail_compilation/failcstuff3.c(54): Error: redeclaration of `S22061` --- */ /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22061 #line 50 struct S22061 { int field; }; typedef union S22061 S22061; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18143.d0000644000175000017500000000266415205374124021117 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail18143.d(20): Error: cannot modify member variable `fail18143.S.a` in contract fail_compilation/fail18143.d(21): Error: cannot modify member variable `fail18143.S.a` in contract fail_compilation/fail18143.d(25): Error: cannot modify member variable `fail18143.S.a` in contract fail_compilation/fail18143.d(26): Error: cannot modify member variable `fail18143.S.a` in contract fail_compilation/fail18143.d(35): Error: cannot modify member variable `fail18143.C.a` in contract fail_compilation/fail18143.d(36): Error: cannot modify member variable `fail18143.C.a` in contract fail_compilation/fail18143.d(40): Error: cannot modify member variable `fail18143.C.a` in contract fail_compilation/fail18143.d(41): Error: cannot modify member variable `fail18143.C.a` in contract --- */ struct S { int a; this(int n) in { a = n; } // error, modifying this.a in contract out { a = n; } // error, modifying this.a in contract do { } void foo(int n) in { a = n; } // error, modifying this.a in contract out { a = n; } // error, modifying this.a in contract do { } } class C { int a; this(int n) in { a = n; } // error, modifying this.a in contract out { a = n; } // error, modifying this.a in contract do { } void foo(int n) in { a = n; } // error, modifying this.a in contract out { a = n; } // error, modifying this.a in contract do { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failsafea.d0000644000175000017500000000050515205374124021506 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/failsafea.d(14): Error: `@safe` function `failsafea.callingsystem` cannot call `@system` function `failsafea.systemfunc` fail_compilation/failsafea.d(9): `failsafea.systemfunc` is declared here --- */ void systemfunc() @system {} @safe void callingsystem() { systemfunc(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21001.d0000644000175000017500000000025415205374124021073 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail21001.d(12): Error: undefined identifier `Alias` --- */ module fail21001; import imports.fail21001b; void main() { Alias var; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix22265.c0000644000175000017500000000041515205374124020761 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix22265.c(104): Error: cannot modify `const` expression `*buf` --- */ // https://issues.dlang.org/show_bug.cgi?id=22265 #line 100 void test(const char *buf, char *const p) { char a = *buf++; *buf = 'a'; // 104 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10327.d0000644000175000017500000000052515205374124021076 0ustar fabiofabio/* TRANSFORM_OUTPUT: remove_lines("^import path") TEST_OUTPUT: --- fail_compilation/diag10327.d(10): Error: unable to read module `test10327` fail_compilation/diag10327.d(10): Expected 'imports/test10327.d' or 'imports/test10327/package.d' in one of the following import paths: --- */ import imports.test10327; // package.d missing ./ldc-1.42.0-src/tests/dmd/fail_compilation/ctor_self_assignment.d0000644000175000017500000000075715205374124024014 0ustar fabiofabio/** REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/ctor_self_assignment.d(17): Deprecation: cannot initialize field `location` with itself fail_compilation/ctor_self_assignment.d(15): did you mean to use parameter `locaction`? --- */ // https://forum.dlang.org/post/teghfhpmvkdcfwfeovua@forum.dlang.org alias Location = int; struct Node { this(Location locaction, uint f) { this.location = location; this.f = f; } Location location; uint f; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/reserved_version_switch.d0000644000175000017500000003662415205374124024553 0ustar fabiofabio// REQUIRED_ARGS: -verrors=0 // REQUIRED_ARGS: -version=DigitalMars // REQUIRED_ARGS: -version=GNU // REQUIRED_ARGS: -version=LDC // REQUIRED_ARGS: -version=SDC // REQUIRED_ARGS: -version=Windows // REQUIRED_ARGS: -version=Win32 // REQUIRED_ARGS: -version=Win64 // REQUIRED_ARGS: -version=linux // REQUIRED_ARGS: -version=OSX // REQUIRED_ARGS: -version=FreeBSD // REQUIRED_ARGS: -version=OpenBSD // REQUIRED_ARGS: -version=NetBSD // REQUIRED_ARGS: -version=DragonFlyBSD // REQUIRED_ARGS: -version=BSD // REQUIRED_ARGS: -version=Solaris // REQUIRED_ARGS: -version=Posix // REQUIRED_ARGS: -version=AIX // REQUIRED_ARGS: -version=Haiku // REQUIRED_ARGS: -version=SkyOS // REQUIRED_ARGS: -version=SysV3 // REQUIRED_ARGS: -version=SysV4 // REQUIRED_ARGS: -version=Hurd // REQUIRED_ARGS: -version=Android // REQUIRED_ARGS: -version=Cygwin // REQUIRED_ARGS: -version=MinGW // REQUIRED_ARGS: -version=FreeStanding // REQUIRED_ARGS: -version=X86 // REQUIRED_ARGS: -version=X86_64 // REQUIRED_ARGS: -version=ARM // REQUIRED_ARGS: -version=ARM_Thumb // REQUIRED_ARGS: -version=ARM_SoftFloat // REQUIRED_ARGS: -version=ARM_SoftFP // REQUIRED_ARGS: -version=ARM_HardFloat // REQUIRED_ARGS: -version=AArch64 // REQUIRED_ARGS: -version=AVR // REQUIRED_ARGS: -version=Epiphany // REQUIRED_ARGS: -version=PPC // REQUIRED_ARGS: -version=PPC_SoftFloat // REQUIRED_ARGS: -version=PPC_HardFloat // REQUIRED_ARGS: -version=PPC64 // REQUIRED_ARGS: -version=IA64 // REQUIRED_ARGS: -version=MIPS32 // REQUIRED_ARGS: -version=MIPS64 // REQUIRED_ARGS: -version=MIPS_O32 // REQUIRED_ARGS: -version=MIPS_N32 // REQUIRED_ARGS: -version=MIPS_O64 // REQUIRED_ARGS: -version=MIPS_N64 // REQUIRED_ARGS: -version=MIPS_EABI // REQUIRED_ARGS: -version=MIPS_SoftFloat // REQUIRED_ARGS: -version=MIPS_HardFloat // REQUIRED_ARGS: -version=NVPTX // REQUIRED_ARGS: -version=NVPTX64 // REQUIRED_ARGS: -version=RISCV32 // REQUIRED_ARGS: -version=RISCV64 // REQUIRED_ARGS: -version=SPARC // REQUIRED_ARGS: -version=SPARC_V8Plus // REQUIRED_ARGS: -version=SPARC_SoftFloat // REQUIRED_ARGS: -version=SPARC_HardFloat // REQUIRED_ARGS: -version=SPARC64 // REQUIRED_ARGS: -version=S390 // REQUIRED_ARGS: -version=S390X // REQUIRED_ARGS: -version=SystemZ // REQUIRED_ARGS: -version=HPPA // REQUIRED_ARGS: -version=HPPA64 // REQUIRED_ARGS: -version=SH // REQUIRED_ARGS: -version=WebAssembly // REQUIRED_ARGS: -version=WASI // REQUIRED_ARGS: -version=Alpha // REQUIRED_ARGS: -version=Alpha_SoftFloat // REQUIRED_ARGS: -version=Alpha_HardFloat // REQUIRED_ARGS: -version=LoongArch32 // REQUIRED_ARGS: -version=LoongArch64 // REQUIRED_ARGS: -version=LoongArch_HardFloat // REQUIRED_ARGS: -version=LoongArch_SoftFloat // REQUIRED_ARGS: -version=Xtensa // REQUIRED_ARGS: -version=LittleEndian // REQUIRED_ARGS: -version=BigEndian // REQUIRED_ARGS: -version=ELFv1 // REQUIRED_ARGS: -version=ELFv2 // REQUIRED_ARGS: -version=CRuntime_Bionic // REQUIRED_ARGS: -version=CRuntime_DigitalMars // REQUIRED_ARGS: -version=CRuntime_Glibc // REQUIRED_ARGS: -version=CRuntime_Microsoft // REQUIRED_ARGS: -version=CRuntime_Musl // REQUIRED_ARGS: -version=CRuntime_Newlib // REQUIRED_ARGS: -version=CRuntime_UClibc // REQUIRED_ARGS: -version=CRuntime_WASI // REQUIRED_ARGS: -version=CppRuntime_LLVM // REQUIRED_ARGS: -version=CppRuntime_DigitalMars // REQUIRED_ARGS: -version=CppRuntime_GNU // REQUIRED_ARGS: -version=CppRuntime_Microsoft // REQUIRED_ARGS: -version=CppRuntime_Sun // REQUIRED_ARGS: -version=D_Coverage // REQUIRED_ARGS: -version=D_Ddoc // REQUIRED_ARGS: -version=D_InlineAsm_X86 // REQUIRED_ARGS: -version=D_InlineAsm_X86_64 // REQUIRED_ARGS: -version=D_LP64 // REQUIRED_ARGS: -version=D_X32 // REQUIRED_ARGS: -version=D_HardFloat // REQUIRED_ARGS: -version=D_SoftFloat // REQUIRED_ARGS: -version=D_PIC // REQUIRED_ARGS: -version=D_SIMD // REQUIRED_ARGS: -version=D_Version2 // REQUIRED_ARGS: -version=D_NoBoundsChecks // REQUIRED_ARGS: -version=unittest // REQUIRED_ARGS: -version=assert // REQUIRED_ARGS: -version=all // REQUIRED_ARGS: -version=none // REQUIRED_ARGS: -version=D_PreConditions // REQUIRED_ARGS: -version=D_PostConditions // REQUIRED_ARGS: -version=D_ProfileGC // REQUIRED_ARGS: -version=D_Invariants // REQUIRED_ARGS: -version=D_Optimized // REQUIRED_ARGS: -debug=DigitalMars // REQUIRED_ARGS: -debug=GNU // REQUIRED_ARGS: -debug=LDC // REQUIRED_ARGS: -debug=SDC // REQUIRED_ARGS: -debug=Windows // REQUIRED_ARGS: -debug=Win32 // REQUIRED_ARGS: -debug=Win64 // REQUIRED_ARGS: -debug=linux // REQUIRED_ARGS: -debug=OSX // REQUIRED_ARGS: -debug=FreeBSD // REQUIRED_ARGS: -debug=OpenBSD // REQUIRED_ARGS: -debug=NetBSD // REQUIRED_ARGS: -debug=DragonFlyBSD // REQUIRED_ARGS: -debug=BSD // REQUIRED_ARGS: -debug=Solaris // REQUIRED_ARGS: -debug=Posix // REQUIRED_ARGS: -debug=AIX // REQUIRED_ARGS: -debug=Haiku // REQUIRED_ARGS: -debug=SkyOS // REQUIRED_ARGS: -debug=SysV3 // REQUIRED_ARGS: -debug=SysV4 // REQUIRED_ARGS: -debug=Hurd // REQUIRED_ARGS: -debug=Android // REQUIRED_ARGS: -debug=Cygwin // REQUIRED_ARGS: -debug=MinGW // REQUIRED_ARGS: -debug=FreeStanding // REQUIRED_ARGS: -debug=X86 // REQUIRED_ARGS: -debug=X86_64 // REQUIRED_ARGS: -debug=ARM // REQUIRED_ARGS: -debug=ARM_Thumb // REQUIRED_ARGS: -debug=ARM_SoftFloat // REQUIRED_ARGS: -debug=ARM_SoftFP // REQUIRED_ARGS: -debug=ARM_HardFloat // REQUIRED_ARGS: -debug=AArch64 // REQUIRED_ARGS: -debug=Epiphany // REQUIRED_ARGS: -debug=PPC // REQUIRED_ARGS: -debug=PPC_SoftFloat // REQUIRED_ARGS: -debug=PPC_HardFloat // REQUIRED_ARGS: -debug=PPC64 // REQUIRED_ARGS: -debug=IA64 // REQUIRED_ARGS: -debug=MIPS32 // REQUIRED_ARGS: -debug=MIPS64 // REQUIRED_ARGS: -debug=MIPS_O32 // REQUIRED_ARGS: -debug=MIPS_N32 // REQUIRED_ARGS: -debug=MIPS_O64 // REQUIRED_ARGS: -debug=MIPS_N64 // REQUIRED_ARGS: -debug=MIPS_EABI // REQUIRED_ARGS: -debug=MIPS_SoftFloat // REQUIRED_ARGS: -debug=MIPS_HardFloat // REQUIRED_ARGS: -debug=NVPTX // REQUIRED_ARGS: -debug=NVPTX64 // REQUIRED_ARGS: -debug=SPARC // REQUIRED_ARGS: -debug=SPARC_V8Plus // REQUIRED_ARGS: -debug=SPARC_SoftFloat // REQUIRED_ARGS: -debug=SPARC_HardFloat // REQUIRED_ARGS: -debug=SPARC64 // REQUIRED_ARGS: -debug=S390 // REQUIRED_ARGS: -debug=S390X // REQUIRED_ARGS: -debug=SystemZ // REQUIRED_ARGS: -debug=HPPA // REQUIRED_ARGS: -debug=HPPA64 // REQUIRED_ARGS: -debug=SH // REQUIRED_ARGS: -debug=WebAssembly // REQUIRED_ARGS: -debug=WASI // REQUIRED_ARGS: -debug=Alpha // REQUIRED_ARGS: -debug=Alpha_SoftFloat // REQUIRED_ARGS: -debug=Alpha_HardFloat // REQUIRED_ARGS: -debug=LoongArch32 // REQUIRED_ARGS: -debug=LoongArch64 // REQUIRED_ARGS: -debug=LoongArch_HardFloat // REQUIRED_ARGS: -debug=LoongArch_SoftFloat // REQUIRED_ARGS: -debug=Xtensa // REQUIRED_ARGS: -debug=LittleEndian // REQUIRED_ARGS: -debug=BigEndian // REQUIRED_ARGS: -debug=ELFv1 // REQUIRED_ARGS: -debug=ELFv2 // REQUIRED_ARGS: -debug=CRuntime_Bionic // REQUIRED_ARGS: -debug=CRuntime_DigitalMars // REQUIRED_ARGS: -debug=CRuntime_Glibc // REQUIRED_ARGS: -debug=CRuntime_Microsoft // REQUIRED_ARGS: -debug=CRuntime_Musl // REQUIRED_ARGS: -debug=CRuntime_Newlib // REQUIRED_ARGS: -debug=CRuntime_UClibc // REQUIRED_ARGS: -debug=CRuntime_WASI // REQUIRED_ARGS: -debug=CppRuntime_LLVM // REQUIRED_ARGS: -debug=CppRuntime_DigitalMars // REQUIRED_ARGS: -debug=CppRuntime_GNU // REQUIRED_ARGS: -debug=CppRuntime_Microsoft // REQUIRED_ARGS: -debug=CppRuntime_Sun // REQUIRED_ARGS: -debug=D_Coverage // REQUIRED_ARGS: -debug=D_Ddoc // REQUIRED_ARGS: -debug=D_InlineAsm_X86 // REQUIRED_ARGS: -debug=D_InlineAsm_X86_64 // REQUIRED_ARGS: -debug=D_LP64 // REQUIRED_ARGS: -debug=D_X32 // REQUIRED_ARGS: -debug=D_HardFloat // REQUIRED_ARGS: -debug=D_SoftFloat // REQUIRED_ARGS: -debug=D_PIC // REQUIRED_ARGS: -debug=D_SIMD // REQUIRED_ARGS: -debug=D_Version2 // REQUIRED_ARGS: -debug=D_NoBoundsChecks // REQUIRED_ARGS: -debug=unittest // REQUIRED_ARGS: -debug=assert // REQUIRED_ARGS: -debug=all // REQUIRED_ARGS: -debug=none // REQUIRED_ARGS: -debug=D_PreConditions // REQUIRED_ARGS: -debug=D_PostConditions // REQUIRED_ARGS: -debug=D_ProfileGC // REQUIRED_ARGS: -debug=D_Invariants // REQUIRED_ARGS: -debug=D_Optimized /* TEST_OUTPUT: --- Error: version identifier `DigitalMars` is reserved and cannot be set Error: version identifier `GNU` is reserved and cannot be set Error: version identifier `LDC` is reserved and cannot be set Error: version identifier `SDC` is reserved and cannot be set Error: version identifier `Windows` is reserved and cannot be set Error: version identifier `Win32` is reserved and cannot be set Error: version identifier `Win64` is reserved and cannot be set Error: version identifier `linux` is reserved and cannot be set Error: version identifier `OSX` is reserved and cannot be set Error: version identifier `FreeBSD` is reserved and cannot be set Error: version identifier `OpenBSD` is reserved and cannot be set Error: version identifier `NetBSD` is reserved and cannot be set Error: version identifier `DragonFlyBSD` is reserved and cannot be set Error: version identifier `BSD` is reserved and cannot be set Error: version identifier `Solaris` is reserved and cannot be set Error: version identifier `Posix` is reserved and cannot be set Error: version identifier `AIX` is reserved and cannot be set Error: version identifier `Haiku` is reserved and cannot be set Error: version identifier `SkyOS` is reserved and cannot be set Error: version identifier `SysV3` is reserved and cannot be set Error: version identifier `SysV4` is reserved and cannot be set Error: version identifier `Hurd` is reserved and cannot be set Error: version identifier `Android` is reserved and cannot be set Error: version identifier `Cygwin` is reserved and cannot be set Error: version identifier `MinGW` is reserved and cannot be set Error: version identifier `FreeStanding` is reserved and cannot be set Error: version identifier `X86` is reserved and cannot be set Error: version identifier `X86_64` is reserved and cannot be set Error: version identifier `ARM` is reserved and cannot be set Error: version identifier `ARM_Thumb` is reserved and cannot be set Error: version identifier `ARM_SoftFloat` is reserved and cannot be set Error: version identifier `ARM_SoftFP` is reserved and cannot be set Error: version identifier `ARM_HardFloat` is reserved and cannot be set Error: version identifier `AArch64` is reserved and cannot be set Error: version identifier `AVR` is reserved and cannot be set Error: version identifier `Epiphany` is reserved and cannot be set Error: version identifier `PPC` is reserved and cannot be set Error: version identifier `PPC_SoftFloat` is reserved and cannot be set Error: version identifier `PPC_HardFloat` is reserved and cannot be set Error: version identifier `PPC64` is reserved and cannot be set Error: version identifier `IA64` is reserved and cannot be set Error: version identifier `MIPS32` is reserved and cannot be set Error: version identifier `MIPS64` is reserved and cannot be set Error: version identifier `MIPS_O32` is reserved and cannot be set Error: version identifier `MIPS_N32` is reserved and cannot be set Error: version identifier `MIPS_O64` is reserved and cannot be set Error: version identifier `MIPS_N64` is reserved and cannot be set Error: version identifier `MIPS_EABI` is reserved and cannot be set Error: version identifier `MIPS_SoftFloat` is reserved and cannot be set Error: version identifier `MIPS_HardFloat` is reserved and cannot be set Error: version identifier `NVPTX` is reserved and cannot be set Error: version identifier `NVPTX64` is reserved and cannot be set Error: version identifier `RISCV32` is reserved and cannot be set Error: version identifier `RISCV64` is reserved and cannot be set Error: version identifier `SPARC` is reserved and cannot be set Error: version identifier `SPARC_V8Plus` is reserved and cannot be set Error: version identifier `SPARC_SoftFloat` is reserved and cannot be set Error: version identifier `SPARC_HardFloat` is reserved and cannot be set Error: version identifier `SPARC64` is reserved and cannot be set Error: version identifier `S390` is reserved and cannot be set Error: version identifier `S390X` is reserved and cannot be set Error: version identifier `SystemZ` is reserved and cannot be set Error: version identifier `HPPA` is reserved and cannot be set Error: version identifier `HPPA64` is reserved and cannot be set Error: version identifier `SH` is reserved and cannot be set Error: version identifier `WebAssembly` is reserved and cannot be set Error: version identifier `WASI` is reserved and cannot be set Error: version identifier `Alpha` is reserved and cannot be set Error: version identifier `Alpha_SoftFloat` is reserved and cannot be set Error: version identifier `Alpha_HardFloat` is reserved and cannot be set Error: version identifier `LoongArch32` is reserved and cannot be set Error: version identifier `LoongArch64` is reserved and cannot be set Error: version identifier `LoongArch_HardFloat` is reserved and cannot be set Error: version identifier `LoongArch_SoftFloat` is reserved and cannot be set Error: version identifier `Xtensa` is reserved and cannot be set Error: version identifier `LittleEndian` is reserved and cannot be set Error: version identifier `BigEndian` is reserved and cannot be set Error: version identifier `ELFv1` is reserved and cannot be set Error: version identifier `ELFv2` is reserved and cannot be set Error: version identifier `CRuntime_Bionic` is reserved and cannot be set Error: version identifier `CRuntime_DigitalMars` is reserved and cannot be set Error: version identifier `CRuntime_Glibc` is reserved and cannot be set Error: version identifier `CRuntime_Microsoft` is reserved and cannot be set Error: version identifier `CRuntime_Musl` is reserved and cannot be set Error: version identifier `CRuntime_Newlib` is reserved and cannot be set Error: version identifier `CRuntime_UClibc` is reserved and cannot be set Error: version identifier `CRuntime_WASI` is reserved and cannot be set Error: version identifier `CppRuntime_LLVM` is reserved and cannot be set Error: version identifier `CppRuntime_DigitalMars` is reserved and cannot be set Error: version identifier `CppRuntime_GNU` is reserved and cannot be set Error: version identifier `CppRuntime_Microsoft` is reserved and cannot be set Error: version identifier `CppRuntime_Sun` is reserved and cannot be set Error: version identifier `D_Coverage` is reserved and cannot be set Error: version identifier `D_Ddoc` is reserved and cannot be set Error: version identifier `D_InlineAsm_X86` is reserved and cannot be set Error: version identifier `D_InlineAsm_X86_64` is reserved and cannot be set Error: version identifier `D_LP64` is reserved and cannot be set Error: version identifier `D_X32` is reserved and cannot be set Error: version identifier `D_HardFloat` is reserved and cannot be set Error: version identifier `D_SoftFloat` is reserved and cannot be set Error: version identifier `D_PIC` is reserved and cannot be set Error: version identifier `D_SIMD` is reserved and cannot be set Error: version identifier `D_Version2` is reserved and cannot be set Error: version identifier `D_NoBoundsChecks` is reserved and cannot be set Error: version identifier `unittest` is reserved and cannot be set Error: version identifier `assert` is reserved and cannot be set Error: version identifier `all` is reserved and cannot be set Error: version identifier `none` is reserved and cannot be set Error: version identifier `D_PreConditions` is reserved and cannot be set Error: version identifier `D_PostConditions` is reserved and cannot be set Error: version identifier `D_ProfileGC` is reserved and cannot be set Error: version identifier `D_Invariants` is reserved and cannot be set Error: version identifier `D_Optimized` is reserved and cannot be set --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17955.d0000644000175000017500000000564615205374124021134 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=17955 /* TEST_OUTPUT: --- fail_compilation/fail17955.d(82): Error: cannot create instance of abstract class `SimpleTimeZone` fail_compilation/fail17955.d(76): class `SimpleTimeZone` is declared here fail_compilation/fail17955.d(73): function `bool hasDST()` is not implemented fail_compilation/fail17955.d(94): Error: template instance `fail17955.SimpleTimeZone.fromISOExtString!dstring` error instantiating fail_compilation/fail17955.d(26): instantiated from here: `fromISOExtString!string` fail_compilation/fail17955.d(57): instantiated from here: `isISOExtStringSerializable!(SysTime)` fail_compilation/fail17955.d(50): instantiated from here: `toRedis!(SysTime)` fail_compilation/fail17955.d(41): ... (2 instantiations, -v to show) ... fail_compilation/fail17955.d(33): instantiated from here: `indicesOf!(isRedisType, resetCodeExpireTime)` fail_compilation/fail17955.d(68): instantiated from here: `RedisStripped!(User, true)` fail_compilation/fail17955.d(94): Error: calling non-static function `fromISOExtString` requires an instance of type `SimpleTimeZone` fail_compilation/fail17955.d(96): Error: undefined identifier `DateTimeException` fail_compilation/fail17955.d(26): Error: variable `fail17955.isISOExtStringSerializable!(SysTime).isISOExtStringSerializable` - type `void` is inferred from initializer `fromISOExtString("")`, and variables cannot be of type `void` fail_compilation/fail17955.d(55): Error: function `fail17955.toRedis!(SysTime).toRedis` has no `return` statement, but is expected to return a value of type `string` --- */ alias Alias(alias a) = a; template isISOExtStringSerializable(T) { enum isISOExtStringSerializable = T.fromISOExtString(""); } template RedisObjectCollection(){} struct RedisStripped(T, bool strip_id = true) { alias unstrippedMemberIndices = indicesOf!(Select!(strip_id, isRedisTypeAndNotID, isRedisType), T.tupleof); } template indicesOf(alias PRED, T...) { template impl(size_t i) { static if (PRED!T) impl TypeTuple; } alias indicesOf = impl!0; } template isRedisType(alias F) { enum isRedisType = toRedis!(typeof(F)); } template isRedisTypeAndNotID(){} string toRedis(T)() { static if (isISOExtStringSerializable!T) return; } struct User { SysTime resetCodeExpireTime; } class RedisUserManController { RedisObjectCollection!(RedisStripped!User) m_users; } class TimeZone { abstract bool hasDST(); } class SimpleTimeZone : TimeZone { unittest {} immutable(SimpleTimeZone) fromISOExtString(S)(S) { new SimpleTimeZone; } } struct SysTime { static fromISOExtString(S)(S) { dstring zoneStr; try SimpleTimeZone.fromISOExtString(zoneStr); catch (DateTimeException e) {} } } template Select(bool condition, T...) { alias Select = Alias!(T[condition]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/switches.d0000644000175000017500000000064315205374124021427 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/switches.d(14): Error: `case 2` not found fail_compilation/switches.d(25): Error: no `case` statement following `goto case;` --- */ void test1(int i) { switch (i) { case 1: goto case 2; defaut: break; } } void test2(int i) { switch (i) { case 1: goto case; defaut: break; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15616a.d0000644000175000017500000000205615205374124021255 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail15616a.d(41): Error: none of the overloads of `foo` are callable using argument types `(double)` fail_compilation/fail15616a.d(14): Candidates are: `fail15616a.foo(int a)` fail_compilation/fail15616a.d(17): `fail15616a.foo(int a, int b)` fail_compilation/fail15616a.d(26): `fail15616a.foo(int a, int b, int c)` fail_compilation/fail15616a.d(29): `fail15616a.foo(string a)` fail_compilation/fail15616a.d(32): `fail15616a.foo(string a, string b)` fail_compilation\fail15616a.d(35): `fail15616a.foo(string a, string b, string c)` fail_compilation/fail15616a.d(41): ... (2 more, -v to show) ... --- */ #line 14 void foo(int a) {} void foo(int a, int b) {} void foo(T)(T a) if (is(T == float)) {} void foo(T)(T a) if (is(T == char)) {} void foo(int a, int b, int c) {} void foo(string a) {} void foo(string a, string b) {} void foo(string a, string b, string c) {} void main() { foo(3.14); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/dep_d1_ops.d0000644000175000017500000005475015205374124021623 0ustar fabiofabio/* REQUIRED_ARGS: TEST_OUTPUT: --- fail_compilation/dep_d1_ops.d(281): Error: operator `+` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "+")(int rhs) {}` fail_compilation/dep_d1_ops.d(282): Error: operator `+` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "+")(int rhs) {}` fail_compilation/dep_d1_ops.d(283): Error: operator `-` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "-")(int rhs) {}` fail_compilation/dep_d1_ops.d(284): Error: operator `-` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "-")(int rhs) {}` fail_compilation/dep_d1_ops.d(285): Error: operator `*` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "*")(int rhs) {}` fail_compilation/dep_d1_ops.d(286): Error: operator `*` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "*")(int rhs) {}` fail_compilation/dep_d1_ops.d(287): Error: operator `/` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "/")(int rhs) {}` fail_compilation/dep_d1_ops.d(288): Error: operator `/` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "/")(int rhs) {}` fail_compilation/dep_d1_ops.d(289): Error: operator `%` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "%")(int rhs) {}` fail_compilation/dep_d1_ops.d(290): Error: operator `%` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "%")(int rhs) {}` fail_compilation/dep_d1_ops.d(292): Error: operator `&` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "&")(int rhs) {}` fail_compilation/dep_d1_ops.d(293): Error: operator `|` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "|")(int rhs) {}` fail_compilation/dep_d1_ops.d(294): Error: operator `^` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "^")(int rhs) {}` fail_compilation/dep_d1_ops.d(296): Error: operator `<<` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "<<")(int rhs) {}` fail_compilation/dep_d1_ops.d(297): Error: operator `<<` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "<<")(int rhs) {}` fail_compilation/dep_d1_ops.d(298): Error: operator `>>` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : ">>")(int rhs) {}` fail_compilation/dep_d1_ops.d(299): Error: operator `>>` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : ">>")(int rhs) {}` fail_compilation/dep_d1_ops.d(300): Error: operator `>>>` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : ">>>")(int rhs) {}` fail_compilation/dep_d1_ops.d(301): Error: operator `>>>` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : ">>>")(int rhs) {}` fail_compilation/dep_d1_ops.d(303): Error: operator `~` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "~")(int rhs) {}` fail_compilation/dep_d1_ops.d(304): Error: operator `~` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "~")(int rhs) {}` fail_compilation/dep_d1_ops.d(306): Error: operator `+` is not defined for `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opUnary(string op : "+")() {}` fail_compilation/dep_d1_ops.d(307): Error: operator `-` is not defined for `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opUnary(string op : "-")() {}` fail_compilation/dep_d1_ops.d(308): Error: operator `~` is not defined for `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opUnary(string op : "~")() {}` fail_compilation/dep_d1_ops.d(309): Error: operator `++` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opUnary(string op : "++")() {}` or `auto opOpAssign(string op : "+")(int) {}` fail_compilation/dep_d1_ops.d(310): Error: operator `--` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opUnary(string op : "--")() {}` or `auto opOpAssign(string op : "-")(int) {}` fail_compilation/dep_d1_ops.d(311): Error: operator `*` is not defined for `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opUnary(string op : "*")() {}` fail_compilation/dep_d1_ops.d(313): Error: operator `in` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinary(string op : "in")(int rhs) {}` fail_compilation/dep_d1_ops.d(314): Error: operator `in` is not defined for type `S` fail_compilation/dep_d1_ops.d(174): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int rhs) {}` fail_compilation/dep_d1_ops.d(316): Error: operator `+=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "+")(int) {}` fail_compilation/dep_d1_ops.d(317): Error: operator `-=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "-")(int) {}` fail_compilation/dep_d1_ops.d(318): Error: operator `*=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "*")(int) {}` fail_compilation/dep_d1_ops.d(319): Error: operator `/=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "/")(int) {}` fail_compilation/dep_d1_ops.d(320): Error: operator `%=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "%")(int) {}` fail_compilation/dep_d1_ops.d(321): Error: operator `&=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "&")(int) {}` fail_compilation/dep_d1_ops.d(322): Error: operator `|=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "|")(int) {}` fail_compilation/dep_d1_ops.d(323): Error: operator `^=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "^")(int) {}` fail_compilation/dep_d1_ops.d(324): Error: operator `<<=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "<<")(int) {}` fail_compilation/dep_d1_ops.d(325): Error: operator `>>=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : ">>")(int) {}` fail_compilation/dep_d1_ops.d(326): Error: operator `>>>=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : ">>>")(int) {}` fail_compilation/dep_d1_ops.d(327): Error: operator `~=` not supported for `s` of type `S` fail_compilation/dep_d1_ops.d(174): perhaps implement `auto opOpAssign(string op : "~")(int) {}` fail_compilation/dep_d1_ops.d(331): Error: operator `+` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "+")(int rhs) {}` fail_compilation/dep_d1_ops.d(332): Error: operator `+` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "+")(int rhs) {}` fail_compilation/dep_d1_ops.d(333): Error: operator `-` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "-")(int rhs) {}` fail_compilation/dep_d1_ops.d(334): Error: operator `-` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "-")(int rhs) {}` fail_compilation/dep_d1_ops.d(335): Error: operator `*` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "*")(int rhs) {}` fail_compilation/dep_d1_ops.d(336): Error: operator `*` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "*")(int rhs) {}` fail_compilation/dep_d1_ops.d(337): Error: operator `/` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "/")(int rhs) {}` fail_compilation/dep_d1_ops.d(338): Error: operator `/` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "/")(int rhs) {}` fail_compilation/dep_d1_ops.d(339): Error: operator `%` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "%")(int rhs) {}` fail_compilation/dep_d1_ops.d(340): Error: operator `%` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "%")(int rhs) {}` fail_compilation/dep_d1_ops.d(342): Error: operator `&` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "&")(int rhs) {}` fail_compilation/dep_d1_ops.d(343): Error: operator `|` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "|")(int rhs) {}` fail_compilation/dep_d1_ops.d(344): Error: operator `^` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "^")(int rhs) {}` fail_compilation/dep_d1_ops.d(346): Error: operator `<<` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "<<")(int rhs) {}` fail_compilation/dep_d1_ops.d(347): Error: operator `<<` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "<<")(int rhs) {}` fail_compilation/dep_d1_ops.d(348): Error: operator `>>` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : ">>")(int rhs) {}` fail_compilation/dep_d1_ops.d(349): Error: operator `>>` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : ">>")(int rhs) {}` fail_compilation/dep_d1_ops.d(350): Error: operator `>>>` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : ">>>")(int rhs) {}` fail_compilation/dep_d1_ops.d(351): Error: operator `>>>` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : ">>>")(int rhs) {}` fail_compilation/dep_d1_ops.d(353): Error: operator `~` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "~")(int rhs) {}` fail_compilation/dep_d1_ops.d(354): Error: operator `~` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "~")(int rhs) {}` fail_compilation/dep_d1_ops.d(356): Error: operator `+` is not defined for `C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opUnary(string op : "+")() {}` fail_compilation/dep_d1_ops.d(357): Error: operator `-` is not defined for `C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opUnary(string op : "-")() {}` fail_compilation/dep_d1_ops.d(358): Error: operator `~` is not defined for `C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opUnary(string op : "~")() {}` fail_compilation/dep_d1_ops.d(359): Error: operator `++` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opUnary(string op : "++")() {}` or `auto opOpAssign(string op : "+")(int) {}` fail_compilation/dep_d1_ops.d(360): Error: operator `--` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opUnary(string op : "--")() {}` or `auto opOpAssign(string op : "-")(int) {}` fail_compilation/dep_d1_ops.d(361): Error: operator `*` is not defined for `C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opUnary(string op : "*")() {}` fail_compilation/dep_d1_ops.d(363): Error: operator `in` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinary(string op : "in")(int rhs) {}` fail_compilation/dep_d1_ops.d(364): Error: operator `in` is not defined for type `dep_d1_ops.C` fail_compilation/dep_d1_ops.d(225): perhaps overload the operator with `auto opBinaryRight(string op : "in")(int rhs) {}` fail_compilation/dep_d1_ops.d(366): Error: operator `+=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "+")(int) {}` fail_compilation/dep_d1_ops.d(367): Error: operator `-=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "-")(int) {}` fail_compilation/dep_d1_ops.d(368): Error: operator `*=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "*")(int) {}` fail_compilation/dep_d1_ops.d(369): Error: operator `/=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "/")(int) {}` fail_compilation/dep_d1_ops.d(370): Error: operator `%=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "%")(int) {}` fail_compilation/dep_d1_ops.d(371): Error: operator `&=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "&")(int) {}` fail_compilation/dep_d1_ops.d(372): Error: operator `|=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "|")(int) {}` fail_compilation/dep_d1_ops.d(373): Error: operator `^=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "^")(int) {}` fail_compilation/dep_d1_ops.d(374): Error: operator `<<=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "<<")(int) {}` fail_compilation/dep_d1_ops.d(375): Error: operator `>>=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : ">>")(int) {}` fail_compilation/dep_d1_ops.d(376): Error: operator `>>>=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : ">>>")(int) {}` fail_compilation/dep_d1_ops.d(377): Error: operator `~=` not supported for `c` of type `C` fail_compilation/dep_d1_ops.d(225): perhaps implement `auto opOpAssign(string op : "~")(int) {}` fail_compilation/dep_d1_ops.d(386): Error: operator `~` is not defined for `NoDeprecation` fail_compilation/dep_d1_ops.d(390): perhaps overload the operator with `auto opUnary(string op : "~")() {}` --- */ struct S { int opAdd(int i) { return 0; } int opAdd_r(int i) { return 0; } int opSub(int i) { return 0; } int opSub_r(int i) { return 0; } int opMul(int i) { return 0; } int opMul_r(int i) { return 0; } int opDiv(int i) { return 0; } int opDiv_r(int i) { return 0; } int opMod(int i) { return 0; } int opMod_r(int i) { return 0; } int opAnd(int i) { return 0; } int opOr(int i) { return 0; } int opXor(int i) { return 0; } int opShl(int i) { return 0; } int opShl_r(int i) { return 0; } int opShr(int i) { return 0; } int opShr_r(int i) { return 0; } int opUShr(int i) { return 0; } int opUShr_r(int i) { return 0; } int opCat(int i) { return 0; } int opCat_r(int i) { return 0; } int opPos() { return 0; } int opNeg() { return 0; } int opCom() { return 0; } int opPostInc() { return 0; } int opPostDec() { return 0; } int opStar() { return 0; } int opIn(int i) { return 0; } int opIn_r(int i) { return 0; } int opAddAssign(int i) { return 0; } int opSubAssign(int i) { return 0; } int opMulAssign(int i) { return 0; } int opDivAssign(int i) { return 0; } int opModAssign(int i) { return 0; } int opAndAssign(int i) { return 0; } int opOrAssign(int i) { return 0; } int opXorAssign(int i) { return 0; } int opShlAssign(int i) { return 0; } int opShrAssign(int i) { return 0; } int opUShrAssign(int i) { return 0; } int opCatAssign(int i) { return 0; } } class C { int opAdd(int i) { return 0; } int opAdd_r(int i) { return 0; } int opSub(int i) { return 0; } int opSub_r(int i) { return 0; } int opMul(int i) { return 0; } int opMul_r(int i) { return 0; } int opDiv(int i) { return 0; } int opDiv_r(int i) { return 0; } int opMod(int i) { return 0; } int opMod_r(int i) { return 0; } int opAnd(int i) { return 0; } int opOr(int i) { return 0; } int opXor(int i) { return 0; } int opShl(int i) { return 0; } int opShl_r(int i) { return 0; } int opShr(int i) { return 0; } int opShr_r(int i) { return 0; } int opUShr(int i) { return 0; } int opUShr_r(int i) { return 0; } int opCat(int i) { return 0; } int opCat_r(int i) { return 0; } int opPos() { return 0; } int opNeg() { return 0; } int opCom() { return 0; } int opPostInc() { return 0; } int opPostDec() { return 0; } int opStar() { return 0; } int opIn(int i) { return 0; } int opIn_r(int i) { return 0; } int opAddAssign(int i) { return 0; } int opSubAssign(int i) { return 0; } int opMulAssign(int i) { return 0; } int opDivAssign(int i) { return 0; } int opModAssign(int i) { return 0; } int opAndAssign(int i) { return 0; } int opOrAssign(int i) { return 0; } int opXorAssign(int i) { return 0; } int opShlAssign(int i) { return 0; } int opShrAssign(int i) { return 0; } int opUShrAssign(int i) { return 0; } int opCatAssign(int i) { return 0; } } void main() { int i; { S s; i = s + 1; i = 1 + s; i = s - 1; i = 1 - s; i = s * 1; i = 1 * s; i = s / 1; i = 1 / s; i = s % 1; i = 1 % s; i = s & 1; i = s | 1; i = s ^ 1; i = s << 1; i = 1 << s; i = s >> 1; i = 1 >> s; i = s >>> 1; i = 1 >>> s; i = s ~ 1; i = 1 ~ s; i = +s; i = -s; i = ~s; s++; s--; i = *s; i = s in 1; i = 1 in s; s += 1; s -= 1; s *= 1; s /= 1; s %= 1; s &= 1; s |= 1; s ^= 1; s <<= 1; s >>= 1; s >>>= 1; s ~= 1; } { C c; i = c + 1; i = 1 + c; i = c - 1; i = 1 - c; i = c * 1; i = 1 * c; i = c / 1; i = 1 / c; i = c % 1; i = 1 % c; i = c & 1; i = c | 1; i = c ^ 1; i = c << 1; i = 1 << c; i = c >> 1; i = 1 >> c; i = c >>> 1; i = 1 >>> c; i = c ~ 1; i = 1 ~ c; i = +c; i = -c; i = ~c; c++; c--; i = *c; i = c in 1; i = 1 in c; c += 1; c -= 1; c *= 1; c /= 1; c %= 1; c &= 1; c |= 1; c ^= 1; c <<= 1; c >>= 1; c >>>= 1; c ~= 1; } scope nd = new NoDeprecation; assert((42 in nd) == 0); assert((nd in 42) == 0); assert((nd ~ 42) == 0); assert((42 ~ nd) == 0); ~nd; } /// See https://github.com/dlang/dmd/pull/10716 class NoDeprecation { int opIn(int i) { return 0; } int opIn_r(int i) { return 0; } int opCat(int i) { return 0; } int opCat_r(int i) { return 0; } /// This is considered because there is no `opUnary` /// However, the other overloads (`opBinary` / `opBinaryRight`) /// means that other operator overloads would not be considered. int opCom() { return 0; } int opBinary(string op)(int arg) if (op == "in" || op == "~") { static if (op == "in") return this.opIn(arg); else static if (op == "~") return this.opCat(arg); } int opBinaryRight(string op)(int arg) if (op == "in" || op == "~") { static if (op == "in") return this.opIn_r(arg); else static if (op == "~") return this.opCat_r(arg); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail218.d0000644000175000017500000000040515205374124020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail218.d(15): Error: cannot modify string literal `", "` --- */ // https://issues.dlang.org/show_bug.cgi?id=1788 // dmd segfaults without info void main() { string a = "abc"; double b = 7.5; a ~= ", " ~= b; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag12380.d0000644000175000017500000000027715205374124021103 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag12380.d(12): Error: cannot implicitly convert expression `E.a` of type `E` to `void*` --- */ enum E { a, b, } void main() { void* a = E.init; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13116.d0000644000175000017500000000100415205374124021075 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail13116.d(14): Error: cannot `ref` return expression `this` because it is not an lvalue fail_compilation/fail13116.d(23): Error: cannot `ref` return expression `super` because it is not an lvalue --- */ struct S { ref S notEvil() return { return this; } // this should be accepted } class C { ref C evil() { return this; } // this should be rejected } void main() { } class Base { } class Derived : Base { ref Base evil() { return super; } // should be rejected } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bug5b.d0000644000175000017500000000026215205374124020577 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/bug5b.d(8): Error: function `bug5b.test1` has no `return` statement, but is expected to return a value of type `int` --- */ int test1() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test24365.d0000644000175000017500000000074115205374124021160 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=243645 /* TEST_OUTPUT: --- fail_compilation/test24365.d(16): Error: `f` cannot be interpreted at compile time, because it has no available source code fail_compilation/test24365.d(14): compile time context created here fail_compilation/test24365.d(19): while evaluating: `static assert(r == 2)` --- */ void main() { enum r = () { void f(); f(); return 2; }(); static assert(r == 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag7050a.d0000644000175000017500000000047115205374124021156 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag7050a.d(15): Error: `@safe` function `diag7050a.foo` cannot call `@system` constructor `diag7050a.Foo.this` fail_compilation/diag7050a.d(11): `diag7050a.Foo.this` is declared here --- */ struct Foo { this (int a) {} } @safe void foo() { auto f = Foo(3); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21214.d0000644000175000017500000000130515205374124021077 0ustar fabiofabio/* expected output slightly adapted for LDC REQUIRED_ARGS: -m64 TEST_OUTPUT: --- fail_compilation/fail21214.d(12): Error: vector type `__vector(__vector(int[2])[2])` is not supported on this platform fail_compilation/fail21214.d(13): Error: vector type `__vector(__vector(int[2])[4])` is not supported on this platform fail_compilation/fail21214.d(14): Error: vector type `__vector(__vector(int[4])[2])` is not supported on this platform fail_compilation/fail21214.d(15): Error: vector type `__vector(__vector(int[4])[4])` is not supported on this platform --- */ __vector(__vector(int[2])[2]) v2x2; __vector(__vector(int[2])[4]) v2x4; __vector(__vector(int[4])[2]) v4x2; __vector(__vector(int[4])[4]) v4x4; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ldc_llvm_inline_ir_2.d0000644000175000017500000000051415205374124023640 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ldc_llvm_inline_ir_2.d(10): Error: All parameters of a template defined with pragma `LDC_inline_ir`, except for the first one or the first three, should be types --- */ pragma(LDC_inline_ir) R inlineIR(string s, R, P...)(); alias foo = inlineIR!(``, void, 1, 2, 3); void bar() { foo(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail309.d0000644000175000017500000000024415205374124020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail309.d(10): Error: circular reference to variable `fail309.S.x` --- */ // REQUIRED_ARGS: -d struct S { const x = S.x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/iconv_interface_array.d0000644000175000017500000000324115205374124024127 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/iconv_interface_array.d(48): Error: function `testA` is not callable using argument types `(C[4])` fail_compilation/iconv_interface_array.d(48): cannot pass argument `arr` of type `C[4]` to parameter `I1[4] arr` fail_compilation/iconv_interface_array.d(27): `iconv_interface_array.testA(I1[4] arr)` declared here fail_compilation/iconv_interface_array.d(49): Error: function `testB` is not callable using argument types `(C[4])` fail_compilation/iconv_interface_array.d(49): cannot pass argument `arr` of type `C[4]` to parameter `I2[4] arr` fail_compilation/iconv_interface_array.d(33): `iconv_interface_array.testB(I2[4] arr)` declared here fail_compilation/iconv_interface_array.d(50): Error: function `testC` is not callable using argument types `(C[4])` fail_compilation/iconv_interface_array.d(50): cannot pass argument `arr` of type `C[4]` to parameter `I3[4] arr` fail_compilation/iconv_interface_array.d(39): `iconv_interface_array.testC(I3[4] arr)` declared here --- */ interface I1 { int a(int); } interface I2 { int b(int); } interface I3 { int c(int); } class C : I1, I2, I3 { int a(int i) { return 1 * i; } int b(int i) { return 2 * i; } int c(int i) { return 3 * i; } } void testA(I1[4] arr) { foreach (uint idx, obj; arr) assert(obj.a(idx) == 1 * idx); } void testB(I2[4] arr) { foreach (idx, obj; arr) assert(obj.b(cast(int) idx) == 2 * idx); } void testC(I3[4] arr) { foreach (idx, obj; arr) assert(obj.c(cast(int) idx) == 3 * idx); } void main() { C[4] arr = [ new C, new C, new C, new C ]; testA(arr); testB(arr); testC(arr); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18057.d0000644000175000017500000000067115205374124021117 0ustar fabiofabio/** TEST_OUTPUT: --- fail_compilation/fail18057.d(16): Error: template instance `RBNode!int` `RBNode` is not a template declaration, it is a struct fail_compilation/fail18057.d(13): Error: variable `fail18057.RBNode.copy` recursive initialization of field --- */ // https://issues.dlang.org/show_bug.cgi?id=18057 // Recursive field initializer causes segfault. struct RBNode { RBNode *copy = new RBNode; } alias bug18057 = RBNode!int; ./ldc-1.42.0-src/tests/dmd/fail_compilation/protattr3.d0000644000175000017500000000033615205374124021537 0ustar fabiofabio/* EXTRA_FILES: protection/subpkg/test3.d TEST_OUTPUT: --- fail_compilation/protection/subpkg/test3.d(3): Error: `protection package` expected as dot-separated identifiers, got `123` --- */ import protection.subpkg.test3; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20073.d0000644000175000017500000000111015205374124021073 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20073 /* TEST_OUTPUT: --- fail_compilation/fail20073.d(20): Error: cannot implicitly convert expression `s` of type `S` to `string` fail_compilation/fail20073.d(21): Error: return value `s` of type `S` does not match return type `string`, and cannot be implicitly converted --- */ struct S { char[10] x; auto slice() inout { return x[0 .. 10]; } alias slice this; } string test() { S s; string str = s; // cannot implicitly convert expression `s` of type `S` to `string` return s; // and suddenly we can! } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test13867.d0000644000175000017500000000173415205374124021170 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test13867.d(12): Error: function `void test13867.X.blah()` does not override any function, did you mean to override `extern (C++) void test13867.Base.blah()`? fail_compilation/test13867.d(19): Error: function `void test13867.Z.blah()` does not override any function, did you mean to override `extern (C++) void test13867.Base.blah()`? --- */ extern (C++) class Base { void blah() {} } class X : Base { override void blah();//Error } extern (C++) class Y : Base { override void blah(){} } class Z : Base { alias blah = typeof(super).blah; override void blah(){}//Error } class O : Base { extern (C++) override void blah(){} } extern (C++) class OK : Base { alias blah = typeof(super).blah; override void blah(){} } void main() { scope b = new Base(); b.blah(); scope x = new X(); x.blah(); scope y = new Y(); y.blah(); scope o = new O(); o.blah(); scope z = new Z(); z.blah(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20714.d0000644000175000017500000000137015205374124021105 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20714 // REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail20714.d(19): Deprecation: `struct Adder` implicitly-generated postblit hides copy constructor. fail_compilation/fail20714.d(19): The field postblit will have priority over the copy constructor. fail_compilation/fail20714.d(19): To change this, the postblit should be disabled for `struct Adder` --- */ struct Blitter { int payload; this(this){} } struct Adder { Blitter blitter; this(int payload) {this.blitter.payload = payload;} this(ref Adder rhs) {this.blitter.payload = rhs.blitter.payload + 1;} } void main() { Adder piece1 = 1; auto piece2 = piece1; assert(piece2.blitter.payload == 2); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice8795.d0000644000175000017500000000142615205374124020673 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice8795.d-mixin-16(16): Error: found `End of File` when expecting `(` fail_compilation/ice8795.d-mixin-16(16): Error: expression expected, not `End of File` fail_compilation/ice8795.d-mixin-16(16): Error: missing closing `)` after `switch (__error` fail_compilation/ice8795.d-mixin-16(16): Error: found `End of File` instead of statement fail_compilation/ice8795.d-mixin-16(16): while parsing string mixin statement fail_compilation/ice8795.d-mixin-17(17): Error: { } expected following `interface` declaration fail_compilation/ice8795.d-mixin-17(17): Error: anonymous interfaces not allowed fail_compilation/ice8795.d-mixin-17(17): while parsing string mixin statement --- */ void main() { mixin("switch"); mixin("interface;"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8894.d0000644000175000017500000000146715205374124021044 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8894.d(20): Error: no property `x` for `f` of type `diag8894.Foo` fail_compilation/diag8894.d(15): struct `Foo` defined here fail_compilation/diag8894.d(21): Error: no property `y` for `f` of type `diag8894.Foo` fail_compilation/diag8894.d(15): struct `Foo` defined here fail_compilation/diag8894.d(22): Error: no property `x` for `f` of type `diag8894.Foo` fail_compilation/diag8894.d(15): struct `Foo` defined here fail_compilation/diag8894.d(23): Error: no property `x` for `f` of type `diag8894.Foo` fail_compilation/diag8894.d(15): struct `Foo` defined here --- */ struct Foo { } void main() { Foo f; f.x; // UFCS getter1 f.y!int; // UFCS getter2 f.x = 10; // UFCS setter1 f.x!int = 10; // UFCS setter2 } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue11070.d0000644000175000017500000000040015205374124021306 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/issue11070.d(16): Error: undefined identifier `x` --- */ int get() { return 1; } void test() { import std.stdio : writeln; switch (auto x = get()) { default: auto z = x; } x = 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10481.d0000644000175000017500000000047215205374124021107 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10481.d(11): Error: undefined identifier `T1`, did you mean alias `T0`? fail_compilation/fail10481.d(15): Error: cannot infer type from template instance `get!(A)` --- */ struct A {} void get(T0 = T1.Req, Params...)(Params , T1) {} void main() { auto xxx = get!A; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9191.d0000644000175000017500000000163715205374124021032 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9191.d(16): Error: function `void diag9191.C1.aaa()` does not override any function, did you mean to override `void diag9191.B1.aa()`? fail_compilation/diag9191.d(22): Error: function `diag9191.C2.aaa` does not override any function fail_compilation/diag9191.d(33): Error: function `void diag9191.C3.foo()` does not override any function, did you mean to override `void diag9191.B2._foo()`? fail_compilation/diag9191.d(38): Error: function `void diag9191.C4.toStringa()` does not override any function, did you mean to override `string object.Object.toString()`? --- */ interface I1 { void a(); } class B1 { void aa(); } class C1 : B1, I1 { override void aaa(); void a() {} } class C2 : I1 { override void aaa(); void a() {} } class B2 { void _foo(){} } class C3 : B2 { override void foo(){} } class C4 { override void toStringa(){} } void main() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9765.d0000644000175000017500000000034115205374124021030 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9765.d(9): Error: cannot implicitly convert expression `'x'` of type `char` to `char[]` --- */ struct S9765 { char[] x; } const S9765 s9765 = S9765('x'); const char s9765b = s9765.x; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20023.d0000644000175000017500000000070315205374124021141 0ustar fabiofabio// REQUIRED_ARGS: -preview=dip1000 -preview=dip1008 -Ifail_compilation/extra-files // https://issues.dlang.org/show_bug.cgi?id=20023 /* TEST_OUTPUT: --- fail_compilation/imports/test20023b.d(8): Error: returning scope variable `e` is not allowed in a `@safe` function fail_compilation/test20023.d(15): Error: template instance `imports.test20023b.threw!()` error instantiating --- */ import imports.test20023b; @safe: void main() { threw!()(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19941.d0000644000175000017500000000206315205374124021117 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19941.d(8): Error: undefined identifier `dne` --- */ auto a = new Auto; class Auto { int field = &dne; } /* TEST_OUTPUT: --- fail_compilation/fail19941.d(17): Error: undefined identifier `dne` --- */ const c = new Const; class Const { int field = &dne; } /* TEST_OUTPUT: --- fail_compilation/fail19941.d(26): Error: undefined identifier `dne` --- */ enum e = new Enum; class Enum { int field = &dne; } /* TEST_OUTPUT: --- fail_compilation/fail19941.d(35): Error: undefined identifier `dne` --- */ __gshared g = new Gshared; class Gshared { int field = &dne; } /* TEST_OUTPUT: --- fail_compilation/fail19941.d(44): Error: undefined identifier `dne` --- */ immutable i = new Immutable; class Immutable { int field = &dne; } /* TEST_OUTPUT: --- fail_compilation/fail19941.d(53): Error: undefined identifier `dne` --- */ shared s = new Shared; class Shared { int field = &dne; } /* TEST_OUTPUT: --- fail_compilation/fail19941.d(62): Error: undefined identifier `dne` --- */ static t = new Static; class Static { int field = &dne; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail196.d0000644000175000017500000000534115205374124020751 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail196.d(38): Error: delimited string must end in `)"` fail_compilation/fail196.d(38): Error: implicit string concatenation is error-prone and disallowed in D fail_compilation/fail196.d(38): Use the explicit syntax instead (concatenating literals is `@nogc`): "foo(xxx)" ~ ";\n assert(s == " fail_compilation/fail196.d(39): Error: semicolon needed to end declaration of `s`, instead of `foo` fail_compilation/fail196.d(38): `s` declared here fail_compilation/fail196.d(39): Error: found `");\n\n s = q"` when expecting `;` following expression fail_compilation/fail196.d(39): expression: `foo(xxx)` fail_compilation/fail196.d(41): Error: found `";\n assert(s == "` when expecting `;` following expression fail_compilation/fail196.d(41): expression: `[foo[xxx]]` fail_compilation/fail196.d(42): Error: found `");\n\n s = q"` when expecting `;` following expression fail_compilation/fail196.d(42): expression: `foo[xxx]` fail_compilation/fail196.d(44): Error: found `{` when expecting `;` following expression fail_compilation/fail196.d(44): expression: `foo` fail_compilation/fail196.d(44): Error: found `}` when expecting `;` following expression fail_compilation/fail196.d(44): expression: `xxx` fail_compilation/fail196.d(45): Error: found `foo` when expecting `;` following expression fail_compilation/fail196.d(44): expression: `";\n assert(s == "` fail_compilation/fail196.d(45): Error: found `}` when expecting `;` following expression fail_compilation/fail196.d(45): expression: `xxx` fail_compilation/fail196.d(47): Error: found `<` when expecting `;` following expression fail_compilation/fail196.d(47): expression: `");\n\n s = q" < foo` fail_compilation/fail196.d(48): Error: found `foo` when expecting `;` following expression fail_compilation/fail196.d(47): expression: `xxx >> ";\n assert(s == "` fail_compilation/fail196.d(48): Error: found `<` instead of statement fail_compilation/fail196.d(54): Error: unterminated string constant starting at fail_compilation/fail196.d(54) fail_compilation/fail196.d(56): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/fail196.d(45): unmatched `{` fail_compilation/fail196.d(56): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/fail196.d(37): unmatched `{` --- */ void main() { string s = q"(foo(xxx)) "; assert(s == "foo(xxx)"); s = q"[foo[xxx]]"; assert(s == "foo[xxx]"); s = q"{foo{xxx}}"; assert(s == "foo{xxx}"); s = q">"; assert(s == "foo"); s = q"[foo(]"; assert(s == "foo("); s = q"/foo]/"; assert(s == "foo]"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13465a.d0000644000175000017500000000073415205374124021103 0ustar fabiofabio// REQUIRED_ARGS: -o- // EXTRA_SOURCES: imports/a13465.d /* TEST_OUTPUT: --- fail_compilation/imports/a13465.d(10): Error: cannot infer type from template instance `isMaskField!()` fail_compilation/ice13465a.d(17): Error: template instance `imports.a13465.isMatchingMaskField!()` error instantiating --- */ module ice13465a; import imports.a13465; auto createCheckpointMixins() { enum b = isMatchingMaskField!(); } immutable checkpointMixins = createCheckpointMixins; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375l.d0000644000175000017500000000052615205374124021210 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375l.d(14): Error: else is dangling, add { } after condition at fail_compilation/fail4375l.d(10) --- */ void main() { if (true) while (false) if (true) assert(70); else assert(71); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22344.c0000644000175000017500000000072615205374124021155 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test22344.c(103): Error: function `test22344.func` redeclaration with different type fail_compilation/test22344.c(203): Error: function `test22344.test` redeclaration with different type --- */ // https://issues.dlang.org/show_bug.cgi?id=22344 #line 100 int func(double a); int func(int b) { return 0; } // https://issues.dlang.org/show_bug.cgi?id=22761 #line 200 int test(int x); int test(int x, ...) { return x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23822.d0000644000175000017500000000046215205374124021111 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23822 // REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail23822.d(21): Deprecation: alias `fail23822.S.value` is deprecated --- */ alias Alias(alias A) = A; struct S { deprecated alias value = Alias!5; } void main() { auto a = S.value; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag12777.d0000644000175000017500000000105415205374124021107 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag12777.d(14): Error: cannot modify `this.v` in `const` function fail_compilation/diag12777.d(15): Error: cannot modify `this.v` in `immutable` function fail_compilation/diag12777.d(21): Error: cannot modify `this.v` in `const` function fail_compilation/diag12777.d(22): Error: cannot modify `this.v` in `immutable` function --- */ struct S { int v; void fun() const { v++; } void gun() immutable { v++; } } class C { int v; void fun() const { v++; } void gun() immutable { v++; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag1730.d0000644000175000017500000001150215205374124021011 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag1730.d(51): Error: mutable method `diag1730.S.func` is not callable using a `inout` object fail_compilation/diag1730.d(43): Consider adding `const` or `inout` here fail_compilation/diag1730.d(53): Error: `immutable` method `diag1730.S.iFunc` is not callable using a `inout` object fail_compilation/diag1730.d(54): Error: `shared` mutable method `diag1730.S.sFunc` is not callable using a non-shared `inout` object fail_compilation/diag1730.d(46): Consider adding `const` or `inout` here fail_compilation/diag1730.d(55): Error: `shared` `const` method `diag1730.S.scFunc` is not callable using a non-shared `inout` object fail_compilation/diag1730.d(70): Error: `immutable` method `diag1730.S.iFunc` is not callable using a mutable object fail_compilation/diag1730.d(71): Error: `shared` method `diag1730.S.sFunc` is not callable using a non-shared object fail_compilation/diag1730.d(72): Error: `shared` `const` method `diag1730.S.scFunc` is not callable using a non-shared mutable object fail_compilation/diag1730.d(75): Error: mutable method `diag1730.S.func` is not callable using a `const` object fail_compilation/diag1730.d(43): Consider adding `const` or `inout` here fail_compilation/diag1730.d(77): Error: `immutable` method `diag1730.S.iFunc` is not callable using a `const` object fail_compilation/diag1730.d(78): Error: `shared` mutable method `diag1730.S.sFunc` is not callable using a non-shared `const` object fail_compilation/diag1730.d(46): Consider adding `const` or `inout` here fail_compilation/diag1730.d(79): Error: `shared` `const` method `diag1730.S.scFunc` is not callable using a non-shared `const` object fail_compilation/diag1730.d(82): Error: mutable method `diag1730.S.func` is not callable using a `immutable` object fail_compilation/diag1730.d(43): Consider adding `const` or `inout` here fail_compilation/diag1730.d(85): Error: `shared` mutable method `diag1730.S.sFunc` is not callable using a `immutable` object fail_compilation/diag1730.d(46): Consider adding `const` or `inout` here fail_compilation/diag1730.d(89): Error: non-shared method `diag1730.S.func` is not callable using a `shared` object fail_compilation/diag1730.d(43): Consider adding `shared` here fail_compilation/diag1730.d(90): Error: non-shared `const` method `diag1730.S.cFunc` is not callable using a `shared` mutable object fail_compilation/diag1730.d(44): Consider adding `shared` here fail_compilation/diag1730.d(91): Error: `immutable` method `diag1730.S.iFunc` is not callable using a `shared` mutable object fail_compilation/diag1730.d(94): Error: non-shared `inout` method `diag1730.S.wFunc` is not callable using a `shared` mutable object fail_compilation/diag1730.d(48): Consider adding `shared` here fail_compilation/diag1730.d(96): Error: non-shared mutable method `diag1730.S.func` is not callable using a `shared` `const` object fail_compilation/diag1730.d(43): Consider adding `shared` here fail_compilation/diag1730.d(97): Error: non-shared `const` method `diag1730.S.cFunc` is not callable using a `shared` `const` object fail_compilation/diag1730.d(44): Consider adding `shared` here fail_compilation/diag1730.d(98): Error: `immutable` method `diag1730.S.iFunc` is not callable using a `shared` `const` object fail_compilation/diag1730.d(99): Error: `shared` mutable method `diag1730.S.sFunc` is not callable using a `shared` `const` object fail_compilation/diag1730.d(46): Consider adding `const` or `inout` here fail_compilation/diag1730.d(101): Error: non-shared `inout` method `diag1730.S.wFunc` is not callable using a `shared` `const` object fail_compilation/diag1730.d(48): Consider adding `shared` here --- */ struct S { void func() { } void cFunc() const { } void iFunc() immutable { } void sFunc() shared { } void scFunc() shared const { } void wFunc() inout { } static void test(inout(S) s) { s.func(); // ng s.cFunc(); s.iFunc(); // ng s.sFunc(); // ng s.scFunc(); // ng s.wFunc(); } } void main() { S obj; const(S) cObj; immutable(S) iObj; shared(S) sObj; shared(const(S)) scObj; obj.func(); obj.cFunc(); obj.iFunc(); // ng obj.sFunc(); // ng obj.scFunc(); // ng obj.wFunc(); cObj.func(); // ng cObj.cFunc(); cObj.iFunc(); // ng cObj.sFunc(); // ng cObj.scFunc(); // ng cObj.wFunc(); iObj.func(); // ng iObj.cFunc(); iObj.iFunc(); iObj.sFunc(); // ng iObj.scFunc(); iObj.wFunc(); sObj.func(); // ng sObj.cFunc(); // ng sObj.iFunc(); // ng sObj.sFunc(); sObj.scFunc(); sObj.wFunc(); // ng scObj.func(); // ng scObj.cFunc(); // ng scObj.iFunc(); // ng scObj.sFunc(); // ng scObj.scFunc(); scObj.wFunc(); // ng } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3731.d0000644000175000017500000000036715205374124021032 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail3731.d(13): Error: cannot implicitly convert expression `x` of type `immutable(D)` to `fail3731.main.C` --- */ void main() { class C {} class D : C {} auto x = new immutable(D); C y = x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23017.d0000644000175000017500000000102115205374124021141 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23017.d(16): Error: class `test23017.CppChildA` with C++ linkage cannot inherit from class `DClass` with D linkage --- */ // https://issues.dlang.org/show_bug.cgi?id=23017 // C++ class may not derive from D class extern(D) class DClass {} extern(C++) class CppClass { void foo(); } extern(C++) class CppChildA : DClass {} // error extern(C++) class CppChildB : CppClass {} extern(D) class DChildA : DClass {} extern(D) class DChildB : CppClass {} // automatically made extern(C++) ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4269g.d0000644000175000017500000000030715205374124021202 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail4269g.d(10): Error: alias `fail4269g.Xg` cannot alias an expression `d[1]` --- */ int[2] d; static if(is(typeof(Xg.init))) {} alias d[1] Xg; void main() {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test17096.d0000644000175000017500000000620615205374124021165 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test17096.d(29): Error: expected 1 arguments for `isPOD` but had 2 fail_compilation/test17096.d(30): Error: expected 1 arguments for `isNested` but had 2 fail_compilation/test17096.d(31): Deprecation: `traits(isVirtualFunction)` is deprecated. Use `traits(isVirtualMethod)` instead fail_compilation/test17096.d(31): Error: expected 1 arguments for `isVirtualFunction` but had 2 fail_compilation/test17096.d(32): Error: expected 1 arguments for `isVirtualMethod` but had 2 fail_compilation/test17096.d(33): Error: expected 1 arguments for `isAbstractFunction` but had 2 fail_compilation/test17096.d(34): Error: expected 1 arguments for `isFinalFunction` but had 2 fail_compilation/test17096.d(35): Error: expected 1 arguments for `isOverrideFunction` but had 2 fail_compilation/test17096.d(36): Error: expected 1 arguments for `isStaticFunction` but had 2 fail_compilation/test17096.d(37): Error: expected 1 arguments for `isRef` but had 2 fail_compilation/test17096.d(38): Error: expected 1 arguments for `isOut` but had 2 fail_compilation/test17096.d(39): Error: expected 1 arguments for `isLazy` but had 2 fail_compilation/test17096.d(40): Error: expected 1 arguments for `identifier` but had 2 fail_compilation/test17096.d(41): Error: expected 1 arguments for `getProtection` but had 2 fail_compilation/test17096.d(42): Error: expected 1 arguments for `parent` but had 2 fail_compilation/test17096.d(43): Error: expected 1 arguments for `classInstanceSize` but had 2 fail_compilation/test17096.d(44): Error: expected 1 arguments for `allMembers` but had 2 fail_compilation/test17096.d(45): Error: expected 1 arguments for `derivedMembers` but had 2 fail_compilation/test17096.d(46): Error: expected 1 arguments for `getAliasThis` but had 2 fail_compilation/test17096.d(47): Error: expected 1 arguments for `getAttributes` but had 2 fail_compilation/test17096.d(48): Error: expected 1 arguments for `getFunctionAttributes` but had 2 fail_compilation/test17096.d(49): Error: expected 1 arguments for `getUnitTests` but had 2 fail_compilation/test17096.d(50): Error: expected 1 arguments for `getVirtualIndex` but had 2 fail_compilation/test17096.d(51): Error: a single type expected for trait pointerBitmap --- */ enum b03 = __traits(isPOD, 1, 2); enum b04 = __traits(isNested, 1, 2); enum b05 = __traits(isVirtualFunction, 1, 2); enum b06 = __traits(isVirtualMethod, 1, 2); enum b07 = __traits(isAbstractFunction, 1, 2); enum b08 = __traits(isFinalFunction, 1, 2); enum b09 = __traits(isOverrideFunction, 1, 2); enum b10 = __traits(isStaticFunction, 1, 2); enum b11 = __traits(isRef, 1, 2); enum b12 = __traits(isOut, 1, 2); enum b13 = __traits(isLazy, 1, 2); enum b14 = __traits(identifier, 1, 2); enum b15 = __traits(getProtection, 1, 2); enum b16 = __traits(parent, 1, 2); enum b17 = __traits(classInstanceSize, 1, 2); enum b18 = __traits(allMembers, 1, 2); enum b19 = __traits(derivedMembers, 1, 2); enum b20 = __traits(getAliasThis, 1, 2); enum b21 = __traits(getAttributes, 1, 2); enum b22 = __traits(getFunctionAttributes, 1, 2); enum b23 = __traits(getUnitTests, 1, 2); enum b24 = __traits(getVirtualIndex, 1, 2); enum b25 = __traits(getPointerBitmap, 1, 2); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail337.d0000644000175000017500000000137115205374124020745 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail337.d(13): Error: static assert: `0` is false fail_compilation/fail337.d(26): instantiated from here: `bar!()` fail_compilation/fail337.d(33): 100 recursive instantiations from here: `foo!196` fail_compilation/fail337.d(41): 253 recursive instantiations from here: `baz!300` --- */ template bar() { static assert(0); } template foo(int N) { static if (N > 0) { static if (N & 1) alias foo!(N - 3) foo; else alias foo!(N - 1) foo; } else alias bar!() foo; } template baz(int M) { static if (M < 50) { alias foo!(M * 4) baz; } else alias baz!(M - 1) baz; } void main() { int x = baz!(300); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail238_m32.d0000644000175000017500000000161515205374124021427 0ustar fabiofabio// REQUIRED_ARGS: -m32 /* TEST_OUTPUT: --- fail_compilation/fail238_m32.d(21): Error: cannot implicitly convert expression `"a"` of type `string` to `uint` fail_compilation/fail238_m32.d(24): Error: cannot implicitly convert expression `X!()` of type `void` to `const(string)` fail_compilation/fail238_m32.d(29): Error: template instance `fail238_m32.A!"a"` error instantiating fail_compilation/fail238_m32.d(35): instantiated from here: `M!(q)` fail_compilation/fail238_m32.d(35): while evaluating `pragma(msg, M!(q))` --- */ // https://issues.dlang.org/show_bug.cgi?id=581 // Error message w/o line number in dot-instantiated template template X(){} template D(string str){} template A(string str) { static if (D!(str[str])) {} else const string A = .X!(); } template M(alias B) { const string M = A!("a"); } void main() { int q = 3; pragma(msg, M!(q)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail262.d0000644000175000017500000000105415205374124020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail262.d(23): Error: function `const void fail262.B.f()` does not override any function, did you mean to override `shared const void fail262.A.f()`? --- */ // https://issues.dlang.org/show_bug.cgi?id=1645 // can override base class' const method with non-const method import core.stdc.stdio; class A { int x; shared const void f() { printf("A\n"); } } class B : A { override const void f() { //x = 2; printf("B\n"); } } void main() { A y = new B; y.f; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail16772.d0000644000175000017500000000055615205374124021123 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16772 /* TEST_OUTPUT: --- fail_compilation/fail16772.d(8): Error: function `ice16772` cannot return type `ubyte[]` because its linkage is `extern(C++)` fail_compilation/fail16772.d(8): slices are specific to D and do not have a counterpart representation in C++ --- */ extern(C++) ubyte[] ice16772() { return []; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b20780.d0000644000175000017500000000046015205374124020415 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/b20780.d(10): Error: `@identifier` or `@(ArgumentList)` expected, not `@)` fail_compilation/b20780.d(11): Error: `@identifier` or `@(ArgumentList)` expected, not `@,` fail_compilation/b20780.d(11): Error: basic type expected, not `,` --- */ void f(@){} void g(@,){} ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag12432.d0000644000175000017500000000267215205374124021102 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag12432.d(55): Error: cannot infer argument types, expected 1 argument, not 2 fail_compilation/diag12432.d(56): Error: cannot infer argument types, expected 2 arguments, not 3 fail_compilation/diag12432.d(57): Error: cannot infer argument types, expected 1 argument, not 2 fail_compilation/diag12432.d(58): Error: cannot infer argument types, expected 1 argument, not 2 fail_compilation/diag12432.d(59): Error: cannot infer argument types, expected 2 arguments, not 3 fail_compilation/diag12432.d(60): Error: cannot infer argument types, expected 2 arguments, not 3 --- */ struct R1 { @property int front() { return 0; } enum bool empty = false; void popFront() { } } struct Tuple(T...) { T t; alias t this; } struct R2 { @property Tuple!(int, float) front() { return typeof(return).init; } enum bool empty = false; void popFront() { } } struct OpApply1Func { int opApply(int function(int)) { return 0; } } struct OpApply1Deleg { int opApply(int delegate(int)) { return 0; } } struct OpApply2Func { int opApply(int function(int, float)) { return 0; } } struct OpApply2Deleg { int opApply(int delegate(int, float)) { return 0; } } void main() { foreach (a, b; R1()) { } foreach (a, b, c; R2()) { } foreach (a, b; OpApply1Func()) { } foreach (a, b; OpApply1Deleg()) { } foreach (a, b, c; OpApply2Func()) { } foreach (a, b, c; OpApply2Deleg()) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag9148.d0000644000175000017500000000263015205374124021026 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag9148.d(19): Error: `pure` function `diag9148.test9148a.foo` cannot access mutable static data `g` fail_compilation/diag9148.d(23): Error: `pure` function `diag9148.test9148a.bar` cannot access mutable static data `g` fail_compilation/diag9148.d(24): Error: `immutable` function `diag9148.test9148a.bar` cannot access mutable data `x` fail_compilation/diag9148.d(31): Error: `pure` function `diag9148.test9148a.S.foo` cannot access mutable static data `g` fail_compilation/diag9148.d(35): Error: `pure` function `diag9148.test9148a.S.bar` cannot access mutable static data `g` fail_compilation/diag9148.d(36): Error: `immutable` function `diag9148.test9148a.S.bar` cannot access mutable data `x` --- */ void test9148a() pure { static int g; int x; void foo() /+pure+/ { g++; } void bar() immutable /+pure+/ { g++; x++; } struct S { void foo() /+pure+/ { g++; } void bar() immutable /+pure+/ { g++; x++; } } } /* TEST_OUTPUT: --- fail_compilation/diag9148.d(54): Error: `static` function `diag9148.test9148b.foo` cannot access variable `x` in frame of function `diag9148.test9148b` fail_compilation/diag9148.d(51): `x` declared here --- */ void test9148b() { int x; static void foo() pure { int y = x; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/testscopestatic.d0000644000175000017500000000112415205374124023012 0ustar fabiofabio /* TEST_OUTPUT: --- fail_compilation/testscopestatic.d(15): Error: variable `testscopestatic.foo.p` cannot be `scope` and `static` fail_compilation/testscopestatic.d(16): Error: variable `testscopestatic.foo.b` cannot be `scope` and `extern` fail_compilation/testscopestatic.d(17): Error: variable `testscopestatic.foo.c` cannot be `scope` and `__gshared` fail_compilation/testscopestatic.d(21): Error: field `x` cannot be `scope` --- */ void foo() { scope int a; static scope int* p; extern scope int b; scope __gshared int c; struct S { scope int x; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail12604.d0000644000175000017500000000500315205374124021101 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail12604.d(14): Error: mismatched array lengths, 1 and 3 fail_compilation/fail12604.d(15): Error: mismatched array lengths, 1 and 3 fail_compilation/fail12604.d(17): Error: mismatched array lengths, 1 and 3 fail_compilation/fail12604.d(18): Error: mismatched array lengths, 1 and 3 fail_compilation/fail12604.d(20): Error: cannot implicitly convert expression `[65536]` of type `int[]` to `short[]` fail_compilation/fail12604.d(21): Error: cannot implicitly convert expression `[65536, 2, 3]` of type `int[]` to `short[]` --- */ void main() { int[1] a1 = [1,2,3]; short[1] a2 = [1,2,3]; int[1] b1; b1 = [1,2,3]; short[1] b2; b2 = [1,2,3]; short[1] c = [65536]; short[1] d = [65536,2,3]; } /* TEST_OUTPUT: --- fail_compilation/fail12604.d(39): Error: mismatched array lengths, 2 and 3 fail_compilation/fail12604.d(40): Error: mismatched array lengths, 2 and 3 fail_compilation/fail12604.d(41): Error: mismatched array lengths, 2 and 3 fail_compilation/fail12604.d(42): Error: mismatched array lengths, 2 and 3 fail_compilation/fail12604.d(43): Error: mismatched array lengths, 2 and 3 fail_compilation/fail12604.d(44): Error: mismatched array lengths, 2 and 3 fail_compilation/fail12604.d(45): Error: mismatched array lengths, 2 and 3 fail_compilation/fail12604.d(46): Error: mismatched array lengths, 2 and 3 --- */ void test12606a() // AssignExp::semantic { uint[2] a1 = [1, 2, 3][]; ushort[2] a2 = [1, 2, 3][]; uint[2] a3 = [1, 2, 3][0 .. 3]; ushort[2] a4 = [1, 2, 3][0 .. 3]; a1 = [1, 2, 3][]; a2 = [1, 2, 3][]; a3 = [1, 2, 3][0 .. 3]; a4 = [1, 2, 3][0 .. 3]; } /* TEST_OUTPUT: --- fail_compilation/fail12604.d(60): Error: mismatched array lengths, 2 and 3 fail_compilation/fail12604.d(61): Error: mismatched array lengths, 2 and 3 fail_compilation/fail12604.d(62): Error: mismatched array lengths, 2 and 3 fail_compilation/fail12604.d(63): Error: mismatched array lengths, 2 and 3 --- */ void test12606b() // ExpInitializer::semantic { static uint[2] a1 = [1, 2, 3][]; static uint[2] a2 = [1, 2, 3][0 .. 3]; static ushort[2] a3 = [1, 2, 3][]; static ushort[2] a4 = [1, 2, 3][0 .. 3]; } /* TEST_OUTPUT: --- fail_compilation/fail12604.d(77): Error: mismatched array lengths 4 and 3 for assignment `sa1[0..4] = [1, 2, 3]` fail_compilation/fail12604.d(78): Error: mismatched array lengths 4 and 3 for assignment `sa1[0..4] = sa2` --- */ void testc() { int[4] sa1; int[3] sa2; sa1[0..4] = [1,2,3]; sa1[0..4] = sa2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail297.d0000644000175000017500000000157415205374124020757 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail297.d(31): Error: operator `+` is not defined for type `Bar` fail_compilation/fail297.d(25): perhaps overload the operator with `auto opBinary(string op : "+")(const(Bar) rhs) {}` --- */ // https://issues.dlang.org/show_bug.cgi?id=1969 // ICE(cod1.c) using undefined operator with one const operand // ICE or wrong-code. D2 only. Internal error: backend\cod1.c 1673 /* Root cause: BinExp::typeCombine() is checking for an _exact_ match, but typeMerge() will return success. PATCH: cast.c BinExp::typeCombine(). Compare the immutable versions of the types, instead of the types themselves. if (op == TOKmin || op == TOKadd) { if (t1->ito == t2->ito && (t1->ty == Tstruct || t1->ty == Tclass)) goto Lerror; } */ struct Bar {} const(Bar) baz() { return Bar(); } void foo() { Bar result = Bar() + baz(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice8309.d0000644000175000017500000000037715205374124020666 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice8309.d(10): Error: incompatible types for `(() => 1.0) : (() => 1)`: `double function() pure nothrow @nogc @safe` and `int function() pure nothrow @nogc @safe` --- */ void main() { auto x = [()=>1.0, ()=>1]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18417.d0000644000175000017500000000077015205374124021117 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail18417.d(11): Deprecation: `const` postblit is deprecated. Please use an unqualified postblit. fail_compilation/fail18417.d(12): Deprecation: `immutable` postblit is deprecated. Please use an unqualified postblit. fail_compilation/fail18417.d(13): Deprecation: `shared` postblit is deprecated. Please use an unqualified postblit. --- */ struct A { this(this) const {} } struct B { this(this) immutable {} } struct C { this(this) shared {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix19059.d0000644000175000017500000000112115205374124020764 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix19059.d(16): Error: octal digit expected, not `8` fail_compilation/fix19059.d(16): Error: octal literals larger than 7 are no longer supported fail_compilation/fix19059.d(17): Error: octal digit expected, not `9` fail_compilation/fix19059.d(17): Error: octal literals larger than 7 are no longer supported fail_compilation/fix19059.d(18): Error: octal literals `010` are no longer supported, use `std.conv.octal!"10"` instead --- */ // https://issues.dlang.org/show_bug.cgi?id=19059 void foo() { auto a = 08; auto b = 09; auto c = 010; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail136.d0000644000175000017500000000017615205374124020744 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail136.d(10): Error: `x"EFBBBF"` has no effect --- */ void main() { x"EF BB BF"; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22570.d0000644000175000017500000000054615205374124021113 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22570 /* TEST_OUTPUT: --- fail_compilation/fail22570.d(19): Error: too many initializers for `S` with 1 field fail_compilation/fail22570.d(20): Error: too many initializers for `S` with 1 field --- */ struct S { Object o1; } void main() @safe { S[] s; s = [S(null, null)]; s ~= S(null, null); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10115.d0000644000175000017500000000237715205374124021107 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10115.d(35): Error: cannot have `out` parameter of type `S` because the default construction is disabled fail_compilation/fail10115.d(35): Error: cannot have `out` parameter of type `E` because the default construction is disabled fail_compilation/fail10115.d(35): Error: cannot have `out` parameter of type `U` because the default construction is disabled fail_compilation/fail10115.d(40): Error: struct `fail10115.S` default construction is disabled fail_compilation/fail10115.d(41): Error: struct `fail10115.S` default construction is disabled fail_compilation/fail10115.d(42): Error: union `fail10115.U` default construction is disabled --- */ struct S { int a; @disable this(); //this(int) { a = 1; } //~this() { assert(a !is 0); } } enum E : S { A = S.init } union U { S s; //this(this) { assert (s.a !is 0); } //~this() { assert (s.a !is 0); } } void main() { void foo(out S s, out E e, out U u) { } S[] a; E[] e; U[] u; a.length = 5; // compiles -> NG e.length = 5; // compiles -> NG u.length = 5; // compiles -> NG S[1] x = (S[1]).init; foo(a[0], // compiles -> NG e[0], // compiles -> NG u[0]); // compiles -> NG } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9806.d0000644000175000017500000000346715205374124020674 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9806.d(12): Error: undefined identifier `undefined_expr` fail_compilation/ice9806.d(17): Error: template instance `ice9806.S1!()` error instantiating fail_compilation/ice9806.d(13): Error: undefined identifier `undefined_expr` fail_compilation/ice9806.d(19): Error: template instance `ice9806.C1!()` error instantiating fail_compilation/ice9806.d(14): Error: undefined identifier `undefined_expr` fail_compilation/ice9806.d(21): Error: template instance `ice9806.I1!()` error instantiating --- */ struct S1() { enum x = undefined_expr; } class C1() { enum x = undefined_expr; } class I1() { enum x = undefined_expr; } void test1() { static assert(!is(typeof(S1!().x))); auto sx = S1!().x; static assert(!is(typeof(C1!().x))); auto cx = C1!().x; static assert(!is(typeof(I1!().x))); auto ix = I1!().x; } // -------- /* TEST_OUTPUT: --- fail_compilation/ice9806.d(36): Error: undefined identifier `undefined_expr` fail_compilation/ice9806.d(44): Error: template instance `ice9806.S2!()` error instantiating fail_compilation/ice9806.d(37): Error: undefined identifier `undefined_expr` fail_compilation/ice9806.d(46): Error: template instance `ice9806.C2!()` error instantiating fail_compilation/ice9806.d(38): Error: undefined identifier `undefined_expr` fail_compilation/ice9806.d(48): Error: template instance `ice9806.I2!()` error instantiating --- */ int foo2()() { return undefined_expr; } int bar2()() { return undefined_expr; } int baz2()() { return undefined_expr; } struct S2() { enum x = foo2(); } class C2() { enum x = bar2(); } class I2() { enum x = baz2(); } void test2() { static assert(!is(typeof(S2!().x))); auto sx = S2!().x; static assert(!is(typeof(C2!().x))); auto cx = C2!().x; static assert(!is(typeof(I2!().x))); auto ix = I2!().x; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/depmsg.d0000644000175000017500000000720315205374124021054 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/depmsg.d(40): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message! fail_compilation/depmsg.d(40): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message! fail_compilation/depmsg.d(41): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message! fail_compilation/depmsg.d(41): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message! fail_compilation/depmsg.d(42): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message! fail_compilation/depmsg.d(42): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message! fail_compilation/depmsg.d(43): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message! fail_compilation/depmsg.d(43): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message! fail_compilation/depmsg.d(44): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message! fail_compilation/depmsg.d(44): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message! fail_compilation/depmsg.d(46): Deprecation: alias `depmsg.main.Inner.G` is deprecated - With message! fail_compilation/depmsg.d(47): Deprecation: variable `depmsg.main.Inner.H` is deprecated - With message! fail_compilation/depmsg.d(48): Deprecation: class `depmsg.main.Inner.I()` is deprecated - With message! --- */ void main() { class Inner { deprecated("With message!") { struct A { } class B { } interface C { } union D { } enum E { e }; //typedef int F; alias int G; static int H; template I() { class I {} } } } with(Inner) { A a; B b; C c; D d; E e; //F f; G g; auto h = H; I!() i; } } /* TEST_OUTPUT: --- fail_compilation/depmsg.d(94): Deprecation: function `depmsg.test12954.Foo.bar1` is deprecated - [C] Use Foo.bar42 instead fail_compilation/depmsg.d(95): Deprecation: function `depmsg.test12954.Foo.bar2` is deprecated - [E] Use Foo.bar42 instead fail_compilation/depmsg.d(96): Deprecation: function `depmsg.test12954.Foo.bar3` is deprecated - [S] Use Foo.bar42 instead fail_compilation/depmsg.d(97): Deprecation: function `depmsg.test12954.Foo.bar4` is deprecated - [F] Use Foo.bar42 instead fail_compilation/depmsg.d(98): Deprecation: variable `depmsg.test12954.Foo.v2` is deprecated - Forward reference fail_compilation/depmsg.d(105): Deprecation: class `depmsg.test12954.Obsolete` is deprecated fail_compilation/depmsg.d(105): Deprecation: function `depmsg.test12954.Obsolete.obs` is deprecated - Function is obsolete --- */ void test12954() { struct Foo { enum DeprecatedReasonEnum = "[E] Use Foo.bar42 instead"; static const DeprecatedReasonStatic = "[S] Use Foo.bar42 instead"; static immutable DeprecatedReasonFunc = reason("Foo.bar42"); static string reason (string name) { return "[F] Use " ~ name ~ " instead"; } deprecated("[C] Use " ~ `Foo.bar42 instead`) void bar1 () {} deprecated(DeprecatedReasonEnum) void bar2 () {} deprecated(DeprecatedReasonStatic) void bar3 () {} deprecated(DeprecatedReasonFunc) void bar4 () {} deprecated(Forward ~ Reference) int v2 = 2; enum Forward = "Forward ", Reference = "reference"; } Foo f; f.bar1; f.bar2; f.bar3; f.bar4; assert(f.v2 == 2); deprecated class Obsolete { deprecated("Function is obsolete") void obs() {} } (new Obsolete).obs(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail16.d0000644000175000017500000000070415205374124020656 0ustar fabiofabio// ICE(template.c) in DMD0.080 /* TEST_OUTPUT: --- fail_compilation/fail16.d(20): Error: function declaration without return type fail_compilation/fail16.d(20): Note that constructors are always named `this` fail_compilation/fail16.d(20): Error: variable name expected after type `bar!(typeof(X))(X)`, not `;` --- */ int i; template bar(T) { void bar(int x) {} } template foo(alias X) { bar!(typeof(X))(X); } void main() { foo!(i); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail232.d0000644000175000017500000000111615205374124020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail232.d(15): Error: shift by 33 is outside the range `0..31` fail_compilation/fail232.d(15): Error: shift by 33 is outside the range `0..31` fail_compilation/fail232.d(16): Error: shift by 33 is outside the range `0..31` fail_compilation/fail232.d(16): Error: shift by 33 is outside the range `0..31` fail_compilation/fail232.d(17): Error: shift by 33 is outside the range `0..31` fail_compilation/fail232.d(17): Error: shift by 33 is outside the range `0..31` --- */ void bug1601() { int i; i = i >> 33; i = i << 33; i = i >>> 33; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail18979.d0000644000175000017500000000046215205374124021132 0ustar fabiofabio// EXTRA_FILES: imports/imp18979.d /* TEST_OUTPUT: --- fail_compilation/fail18979.d(14): Error: no property `__ctor` for `Foo()` of type `imports.imp18979.Foo` fail_compilation/imports/imp18979.d(3): struct `Foo` defined here ---- */ import imports.imp18979; void main() { auto f = Foo(42); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail203.d0000644000175000017500000000035715205374124020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail203.d(10): Error: shift by 33 is outside the range `0..31` fail_compilation/fail203.d(10): Error: shift by 33 is outside the range `0..31` --- */ void main() { int c; c = c << 33; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bug8150b.d0000644000175000017500000000104115205374124021024 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=8150: nothrow check doesn't work for constructor /* TEST_OUTPUT: --- fail_compilation/bug8150b.d(15): Error: `object.Exception` is thrown but not caught fail_compilation/bug8150b.d(13): Error: constructor `bug8150b.Foo.this!().this` may throw but is marked as `nothrow` fail_compilation/bug8150b.d(20): Error: template instance `bug8150b.Foo.this!()` error instantiating --- */ struct Foo { this()(int) nothrow { throw new Exception("something"); } } void main() { Foo(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9284.d0000644000175000017500000000070615205374124020665 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice9284.d(14): Error: template `__ctor` is not callable using argument types `!()(int)` fail_compilation/ice9284.d(12): Candidate is: `this()(string)` fail_compilation/ice9284.d(20): Error: template instance `ice9284.C.this!()` error instantiating --- */ class C { this()(string) { this(10); // delegating to a constructor which not exists. } } void main() { new C("hello"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag16976.d0000644000175000017500000001126515205374124021121 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag16976.d(44): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(45): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(46): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(47): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(48): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(49): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(50): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(51): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(52): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(53): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(54): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(55): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(56): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(57): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(58): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(59): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(65): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(66): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(67): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(68): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(69): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(70): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(71): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(72): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(73): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(74): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(75): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(76): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(77): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(78): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(79): Error: foreach: index cannot be of non-integral type `float` fail_compilation/diag16976.d(80): Error: foreach: index cannot be of non-integral type `float` --- */ void main() { int[] dyn = [1,2,3,4,5]; int[5] sta = [1,2,3,4,5]; char[] str = ['1','2','3','4','5']; char[5] chr = ['1','2','3','4','5']; foreach(float f, i; dyn) {} foreach(float f, i; sta) {} foreach(float f, i; str) {} foreach(float f, i; chr) {} foreach(float f, dchar i; dyn) {} foreach(float f, dchar i; sta) {} foreach(float f, dchar i; str) {} foreach(float f, dchar i; chr) {} foreach_reverse(float f, i; dyn) {} foreach_reverse(float f, i; sta) {} foreach_reverse(float f, i; str) {} foreach_reverse(float f, i; chr) {} foreach_reverse(float f, dchar i; dyn) {} foreach_reverse(float f, dchar i; sta) {} foreach_reverse(float f, dchar i; str) {} foreach_reverse(float f, dchar i; chr) {} immutable int[] idyn = [1,2,3,4,5]; immutable int[5] ista = [1,2,3,4,5]; immutable char[] istr = ['1','2','3','4','5']; immutable char[5] ichr = ['1','2','3','4','5']; static foreach(float f, i; idyn) {} static foreach(float f, i; ista) {} static foreach(float f, i; istr) {} static foreach(float f, i; ichr) {} static foreach(float f, dchar i; idyn) {} static foreach(float f, dchar i; ista) {} static foreach(float f, dchar i; istr) {} static foreach(float f, dchar i; ichr) {} static foreach_reverse(float f, i; idyn) {} static foreach_reverse(float f, i; ista) {} static foreach_reverse(float f, i; istr) {} static foreach_reverse(float f, i; ichr) {} static foreach_reverse(float f, dchar i; idyn) {} static foreach_reverse(float f, dchar i; ista) {} static foreach_reverse(float f, dchar i; istr) {} static foreach_reverse(float f, dchar i; ichr) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8777.d0000644000175000017500000000164115205374124021036 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8777.d(12): Error: constructor `diag8777.Foo1.this` missing initializer for immutable field `x` fail_compilation/diag8777.d(12): Error: constructor `diag8777.Foo1.this` missing initializer for const field `y` --- */ class Foo1 { immutable int[5] x; const int[5] y; this() {} } /* TEST_OUTPUT: --- fail_compilation/diag8777.d(25): Error: cannot modify `immutable` expression `x` fail_compilation/diag8777.d(28): Error: cannot modify `const` expression `y` --- */ void test2() { immutable int x; x = 1; const int y; y = 1; } /* TEST_OUTPUT: --- fail_compilation/diag8777.d(42): Error: cannot remove key from `immutable` associative array `hashx` fail_compilation/diag8777.d(43): Error: cannot remove key from `const` associative array `hashy` --- */ immutable(int[int]) hashx; const(int[int]) hashy; void test3() { hashx.remove(1); hashy.remove(1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10221a.d0000644000175000017500000000027215205374124021227 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10221a.d(10): Error: cannot implicitly convert expression `257` of type `int` to `ubyte` --- */ void main() { foreach(ubyte i; 0..257) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10949.d0000644000175000017500000000131615205374124020743 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10949.d(12): Error: using the result of a comma expression is not allowed fail_compilation/ice10949.d(12): Error: array index 3 is out of bounds `[5, 5][0 .. 2]` fail_compilation/ice10949.d(12): Error: array index 17 is out of bounds `[2, 3][0 .. 2]` fail_compilation/ice10949.d(12): while evaluating: `static assert((((([5, 5][3] + global - global) * global / global % global >> global & global | global) ^ global) == 9 , [2, 3][17]) || [3, 3, 3][9] is 4 && [[1, 2, 3]][4].length)` --- */ int global; static assert((((((([5,5][3] + global - global)*global/global%global)>>global) &global|global)^global) == 9, [2,3][17]) || ([3,3,3][9] is 4) && ([[1,2,3]][4]).length); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6453.d0000644000175000017500000000127615205374124021036 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail6453.d(13): Error: struct `fail6453.S6453x` mixing invariants with different `shared`/`synchronized` qualifiers is not supported fail_compilation/fail6453.d(18): Error: class `fail6453.C6453y` mixing invariants with different `shared`/`synchronized` qualifiers is not supported fail_compilation/fail6453.d(23): Error: class `fail6453.C6453z` mixing invariants with different `shared`/`synchronized` qualifiers is not supported --- */ struct S6453x { invariant() {} shared invariant() {} } class C6453y { invariant() {} synchronized invariant() {} } class C6453z { shared invariant() {} synchronized invariant() {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail80_m32.d0000644000175000017500000000121715205374124021340 0ustar fabiofabio// REQUIRED_ARGS: -m32 /* TEST_OUTPUT: --- fail_compilation/fail80_m32.d(28): Error: cannot implicitly convert expression `"progress_rem"` of type `string` to `uint` fail_compilation/fail80_m32.d(29): Error: cannot implicitly convert expression `"redo"` of type `string` to `uint` --- */ module paintshop; class Image{} class ResourceManager { Image getImage(char[] name) { return null; } } class Test { static Image[] images; static void initIcons() { images["progress_rem"] = ResourceManager.getImage("progress_rem.gif"); // delete_obj_dis images["redo"] = ResourceManager.getImage("redo.gif"); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ufcs.d0000644000175000017500000000326115205374124020535 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ufcs.d(31): Error: no property `regularF` for `s` of type `S` fail_compilation/ufcs.d(31): the following error occured while looking for a UFCS match fail_compilation/ufcs.d(31): Error: function `regularF` is not callable using argument types `(S)` fail_compilation/ufcs.d(31): expected 0 argument(s), not 1 fail_compilation/ufcs.d(39): `ufcs.regularF()` declared here fail_compilation/ufcs.d(32): Error: no property `templateF` for `s` of type `S` fail_compilation/ufcs.d(32): the following error occured while looking for a UFCS match fail_compilation/ufcs.d(32): Error: template `templateF` is not callable using argument types `!()(S)` fail_compilation/ufcs.d(40): Candidate is: `templateF()()` fail_compilation/ufcs.d(33): Error: no property `templateO` for `s` of type `S` fail_compilation/ufcs.d(33): the following error occured while looking for a UFCS match fail_compilation/ufcs.d(33): Error: none of the overloads of template `ufcs.templateO` are callable using argument types `!()(S)` fail_compilation/ufcs.d(42): Candidates are: `templateO()(int x)` fail_compilation/ufcs.d(43): `templateO()(float y)` fail_compilation/ufcs.d(36): Error: no property `local` for `s` of type `ufcs.S` fail_compilation/ufcs.d(35): cannot call function `local` with UFCS because it is not declared at module scope fail_compilation/ufcs.d(26): struct `S` defined here --- */ struct S { } void f() { S s; s.regularF(); s.templateF(); s.templateO(); void local(S) {} s.local(); } void regularF(); void templateF()(); void templateO()(int x); void templateO()(float y); ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23536.d0000644000175000017500000000134115205374124021154 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23536.d(104): Error: function `test23536.S.nonctor` cannot be a non-static member function for `pragma(crt_constructor)` fail_compilation/test23536.d(106): Error: function `test23536.S.nondtor` cannot be a non-static member function for `pragma(crt_destructor)` --- */ // https://issues.dlang.org/show_bug.cgi?id=23536 #line 100 struct S { int x; extern (C) pragma(crt_constructor) void nonctor() { } // should not compile extern (C) pragma(crt_constructor) static void stactor() { } // should compile extern (C) pragma(crt_destructor) void nondtor() { } // should not compile extern (C) pragma(crt_destructor) static void stadtor() { } // should compile } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail8313.d0000644000175000017500000000072615205374124021032 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail8313.d(13): Error: `fail8313.bar` called with argument types `(int)` matches multiple overloads exactly: fail_compilation/fail8313.d(11): `fail8313.bar!().bar(int x)` and: fail_compilation/fail8313.d(12): `fail8313.bar!().bar(int x)` fail_compilation/fail8313.d(13): while evaluating: `static assert(bar()(int x)(1))` --- */ auto bar()(int x){return x;} auto bar()(int x = bar()){return x;} static assert(bar(1)); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail79.d0000644000175000017500000000030715205374124020666 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail79.d(13): Error: incompatible types for `(& a) + (& b)`: both operands are of type `int*` --- */ void main() { int a, b; int* p; p = &a + &b; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/b19691e.d0000644000175000017500000000100115205374124020563 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/b19691e.d(16): Error: forward reference to template `this` fail_compilation/b19691e.d(16): Error: constructor `b19691e.S2.this(int a, S1 s = "")` is not callable using argument types `(int, string)` fail_compilation/b19691e.d(16): Error: forward reference to template `this` --- */ // https://issues.dlang.org/show_bug.cgi?id=19691 module b19691e; struct S1 { this(T)(T) { S2(42, ""); } } struct S2 { this(int a, S1 s = ""){} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/depmsg15815.d0000644000175000017500000000057715205374124021467 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/depmsg15815.d(23): Deprecation: template `depmsg15815.Alias(T)` is deprecated - message Foo --- */ template Unqual(T) { static if (is(T U == const U)) alias Unqual = U; else alias Unqual = T; } deprecated("message") template Alias(T) { alias Alias = Unqual!T; } struct Foo {} pragma(msg, Alias!(const(Foo))); ./ldc-1.42.0-src/tests/dmd/fail_compilation/retscope.d0000644000175000017500000003672715205374124021436 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/retscope.d(22): Error: scope parameter `p` may not be returned fail_compilation/retscope.d(32): Error: escaping a reference to local variable `j` by returning `b ? nested1(& i) : nested2(& j)` is not allowed in a `@safe` function fail_compilation/retscope.d(45): Error: assigning scope variable `p` to global variable `q` is not allowed in a `@safe` function fail_compilation/retscope.d(47): Error: assigning address of variable `i` to `q` with longer lifetime is not allowed in a `@safe` function fail_compilation/retscope.d(48): Error: assigning scope variable `a` to global variable `b` is not allowed in a `@safe` function fail_compilation/retscope.d(49): Error: assigning address of expression temporary returned by `(*fp2)()` to `q` with longer lifetime is not allowed in a `@safe` function --- */ int* foo1(return scope int* p) @safe { return p; } // ok int* foo2()(scope int* p) @safe { return p; } // ok, 'return' is inferred alias foo2a = foo2!(); int* foo3(scope int* p) @safe { return p; } // error int* foo4(bool b) @safe { int i; int j; int* nested1(scope int* p) { return null; } int* nested2(return scope int* p) { return p; } return b ? nested1(&i) : nested2(&j); } /************************************************/ struct S2 { int a,b,c,d; } @safe S2 function() fp2; void test2(scope int* p, int[] a ...) @safe { static int* q; static int[] b; q = p; int i; q = &i; b = a; q = &fp2().d; } /**************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(75): Error: function `retscope.HTTP.Impl.onReceive` is `@nogc` yet allocates closure for `onReceive()` with the GC fail_compilation/retscope.d(77): delegate `() => this.x` closes over variable `this` --- */ struct Curl { int delegate() dg; } struct HTTP { struct Impl { Curl curl; int x; @nogc void onReceive() { auto dg = ( ) { return x; }; curl.dg = dg; } } } /***********************************************/ /* TEST_OUTPUT: --- --- */ // https://issues.dlang.org/show_bug.cgi?id=8838 int[] foo8() @safe { int[5] sa; return bar8(sa); } int[] bar8(int[] a) @safe { return a; } /*************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(95): Error: assigning reference to local variable `sa` to non-scope parameter `a` calling `bar8` is not allowed in a `@safe` function fail_compilation/retscope.d(123): Error: escaping a reference to local variable `tmp` by returning `foo9(cast(char[])tmp)` is not allowed in a `@safe` function --- */ char[] foo9(return char[] a) @safe pure nothrow @nogc { return a; } char[] bar9() @safe { char[20] tmp; foo9(tmp); // ok return foo9(tmp); // error } /*************************************************/ /* // // //fail_compilation/retscope.d(143): To enforce `@safe`, the compiler allocates a closure unless `opApply()` uses `scope` // */ struct S10 { static int opApply(int delegate(S10*) dg); } S10* test10() { foreach (S10* m; S10) return m; return null; } /************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(158): Error: scope parameter `this` may not be returned --- */ class C11 { @safe C11 foo() scope { return this; } } /****************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(177): Error: assigning address of variable `i` to `p` with longer lifetime is not allowed in a `@safe` function --- */ void foo11() @safe { int[] p; int[3] i; p = i[]; } /************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(197): Error: returning scope variable `e` is not allowed in a `@safe` function --- */ struct Escaper { void* DG; } void* escapeDg1(scope void* d) @safe { Escaper e; e.DG = d; return e.DG; } /*************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(212): Error: assigning scope variable `p` to non-scope `e.e` is not allowed in a `@safe` function --- */ struct Escaper3 { void* e; } void* escape3 (scope void* p) @safe { Escaper3 e; scope dg = () { return e.e; }; e.e = p; return dg(); } /**************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(229): Error: scope parameter `ptr` may not be returned --- */ alias dg_t = void* delegate () return scope @safe; void* funretscope(scope dg_t ptr) @safe { return ptr(); } /*****************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` --- */ void escape4() @safe { alias FunDG = void* delegate () scope @safe; int x = 42; scope FunDG f = () return { return &x; }; scope FunDG g = () { return &x; }; } /**************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(266): Error: taking address of `scope` variable `p` with pointers is not allowed in a `@safe` function --- */ void escape5() @safe { int* q; scope int* p; scope int** pp = &q; // ok pp = &p; // error } /***********************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(286): Error: escaping a reference to local variable `b` by returning `foo6(& b)` is not allowed in a `@safe` function --- */ @safe int* foo6()(int* arg) { return arg; } int* escape6() @safe { int b; return foo6(&b); } /***************************************************/ struct S7 { int[10] a; int[3] abc(int i) @safe { return a[0 .. 3]; // should not error } } /***************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(315): Error: scope parameter `p` may not be returned fail_compilation/retscope.d(316): Error: returning `p[]` escapes a reference to parameter `p` fail_compilation/retscope.d(319): Error: scope parameter `p` may not be returned --- */ int[3] escape8(scope int[] p) @safe { return p[0 .. 3]; } // should not error char*[3] escape9(scope char*[] p) @safe { return p[0 .. 3]; } // https://issues.dlang.org/show_bug.cgi?id=24663 int*[3] escape8b(scope int*[3] p) @safe { return p[]; } ref int*[3] escape9b( int*[3] p) @safe { return p[]; } ref int[3] asStatic(return scope int[] p) @safe { return p[0 .. 3]; } ref int[3] asStatic2( scope int[] p) @safe { return p[0 .. 3]; } /***************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(335): Error: assigning reference to local variable `i` to non-scope `f` is not allowed in a `@safe` function --- */ int* escape10() @safe { int i; int* f; scope int** x = &f; f = &i; return bar10(x); } int* bar10( scope int** ptr ) @safe { return *ptr; } /******************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(358): Error: taking address of `scope` variable `aa` with pointers is not allowed in a `@safe` function --- */ int* escape11() @safe { int i; int*[3] aa = [ &i, null, null ]; return bar11(&aa[0]); } int* bar11(scope int** x) @safe { return foo11(*x); } int* foo11(int* x) @safe { return x; } /******************************************/ void escape15() @safe { int arg; const(void)*[1] argsAddresses; argsAddresses[0] = // MUST be an array assignment (ref arg)@trusted{ return cast(const void*) &arg; }(arg); } /******************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(1003): Error: returning `f.foo()` escapes a reference to local variable `f` --- */ #line 1000 int* escape12() @safe { Foo12 f; return f.foo; } struct Foo12 { int* foo() return @safe; } /******************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(1103): Error: returning scope variable `f` is not allowed in a `@safe` function --- */ #line 1100 int* escape13() @safe { scope Foo13 f; return f.foo; } class Foo13 { int* foo() return @safe; } /******************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(1205): Error: scope variable `f14` calling non-scope member function `Foo14.foo()` is not allowed in a `@safe` function --- */ #line 1200 int* escape14() @safe { int i; Foo14 f14; f14.v = &i; return f14.foo; } struct Foo14 { int* v; int* foo () @safe { return this.v; } } /******************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(1311): Error: assigning scope variable `u2` to `ek` with longer lifetime is not allowed in a `@safe` function --- */ #line 1300 @safe struct U13 { int* k; int* get() return scope { return k; } static int* sget(return scope ref U13 u) { return u.k; } } @safe void foo13() { int* ek; int i; auto u2 = U13(&i); ek = U13.sget(u2); // Error: scope variable u2 assigned to ek with longer lifetime auto u1 = U13(new int); ek = u1.get(); // ok ek = U13.sget(u1); // ok } /************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(1405): Error: assigning reference to local variable `buf` to non-scope anonymous parameter calling `myprintf` is not allowed in a `@safe` function --- */ #line 1400 @trusted extern(C) int myprintf(const(char)*, ...); @safe void foo14() { char[4] buf = [ 'h', 'i', '\n', 0 ]; myprintf(&buf[0]); } /************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(1509): Error: assigning reference to stack allocated value returned by `(*fp15)()` to non-scope anonymous parameter is not allowed in a `@safe` function --- */ #line 1500 @safe void bar15(int*); struct S15 { int a,b,c,d; } @safe S15 function() fp15; void test15() @safe { bar15(&fp15().d); } /*************************************************/ void foo16() @nogc nothrow { alias dg_t = string delegate(string) @nogc nothrow; dg_t dg = (string s) => s; } /*************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(1701): Error: cannot implicitly convert expression `& func` of type `int* function(int* p)` to `int* function(scope int* p)` fail_compilation/retscope.d(1702): Error: cannot implicitly convert expression `& func` of type `int* function(int* p)` to `int* function(return int* p)` fail_compilation/retscope.d(1703): Error: cannot implicitly convert expression `& func` of type `int* function(int* p)` to `int* function(return scope int* p)` fail_compilation/retscope.d(1711): Error: cannot implicitly convert expression `& funcr` of type `int* function(return int* p)` to `int* function(scope int* p)` fail_compilation/retscope.d(1716): Error: cannot implicitly convert expression `& funcrs` of type `int* function(return scope int* p)` to `int* function(scope int* p)` --- */ int* func(int* p); int* funcs(scope int* p); int* funcr(return int* p); int* funcrs(return scope int* p); void foo17() { #line 1700 typeof(func) *fp1 = &func; typeof(funcs) *fp2 = &func; // error typeof(funcr) *fp3 = &func; // error typeof(funcrs) *fp4 = &func; // error typeof(func) *fq1 = &funcs; typeof(funcs) *fq2 = &funcs; typeof(funcr) *fq3 = &funcs; typeof(funcrs) *fq4 = &funcs; typeof(func) *fr1 = &funcr; typeof(funcs) *fr2 = &funcr; // error typeof(funcr) *fr3 = &funcr; typeof(funcrs) *fr4 = &funcr; typeof(func) *fs1 = &funcrs; typeof(funcs) *fs2 = &funcrs; // error typeof(funcr) *fs3 = &funcrs; typeof(funcrs) *fs4 = &funcrs; } /*************************************************/ /* TEST_OUTPUT: --- fail_compilation/retscope.d(1801): Error: cannot implicitly convert expression `&c.func` of type `int* delegate()` to `int* delegate() scope` fail_compilation/retscope.d(1802): Error: cannot implicitly convert expression `&c.func` of type `int* delegate()` to `int* delegate() return scope` fail_compilation/retscope.d(1803): Error: cannot implicitly convert expression `&c.func` of type `int* delegate()` to `int* delegate() return scope` fail_compilation/retscope.d(1811): Error: cannot implicitly convert expression `&c.funcr` of type `int* delegate() return scope` to `int* delegate() scope` fail_compilation/retscope.d(1816): Error: cannot implicitly convert expression `&c.funcrs` of type `int* delegate() return scope` to `int* delegate() scope` --- */ class C18 { int* func(); int* funcs() scope; int* funcr() return; int* funcrs() return scope; } void foo18() { C18 c; #line 1800 typeof(&c.func) fp1 = &c.func; typeof(&c.funcs) fp2 = &c.func; // error typeof(&c.funcr) fp3 = &c.func; // error typeof(&c.funcrs) fp4 = &c.func; // error typeof(&c.func) fq1 = &c.funcs; typeof(&c.funcs) fq2 = &c.funcs; typeof(&c.funcr) fq3 = &c.funcs; typeof(&c.funcrs) fq4 = &c.funcs; typeof(&c.func) fr1 = &c.funcr; typeof(&c.funcs) fr2 = &c.funcr; // error typeof(&c.funcr) fr3 = &c.funcr; typeof(&c.funcrs) fr4 = &c.funcr; typeof(&c.func) fs1 = &c.funcrs; typeof(&c.funcs) fs2 = &c.funcrs; // error typeof(&c.funcr) fs3 = &c.funcrs; typeof(&c.funcrs) fs4 = &c.funcrs; } /*********************************************/ @safe void foo19(C)(ref C[] str) // infer 'scope' for 'str' { str = str; str = str[1 .. str.length]; } @safe void test19() { char[10] s; char[] t = s[]; foo19(t); } /********************************************/ bool foo20(const string a) @safe pure nothrow @nogc { return !a.length; } struct Result(R) { R source; bool empty() // infer 'scope' for 'this' { return foo20(source); } } @safe void test20() { scope n = Result!string("abc"); n.empty(); } /************************************************/ // https://issues.dlang.org/show_bug.cgi?id=17117 ref int foo21(return ref int s) { return s; } int fail21() { int s; return foo21(s); // Error: escaping reference to local variable s } int test21() { int s; s = foo21(s); return s; } /**********************************************/ @safe void foo22()(ref char[] s) { char[] a = s; } @safe void test22(scope char[] s) { foo22(s); } /********************************************* TEST_OUTPUT: --- fail_compilation/retscope.d(1907): Error: assigning scope variable `x` to `ref` variable `this` with longer lifetime is not allowed in a `@safe` function fail_compilation/retscope.d(1913): Error: returning scope variable `x` is not allowed in a `@safe` function --- */ #line 1900 struct Constant { int* member; int* foo(scope Repeat!(int*) grid) @safe { foreach(ref x; grid) member = x; foreach(ref x; grid) x = member; foreach(ref x; grid) return x; return null; } alias Repeat(T...) = T; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23873.d0000644000175000017500000000065215205374124021164 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23873 /* TEST_OUTPUT: --- fail_compilation/imports/import23873.d(1): Error: (expression) expected following `static if` fail_compilation/imports/import23873.d(1): Error: declaration expected following attribute, not `;` fail_compilation/imports/import23873.d(3): Error: variable name expected after type `x`, not `End of File` --- */ struct Foo { import imports.import23873; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail5733.d0000644000175000017500000000032615205374124021031 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail5733.d(12): Error: `opDispatch!"foo"` isn't a template --- */ struct Test { struct opDispatch(string dummy) { enum opDispatch = 1; } } auto temp = Test().foo!(int); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13902.d0000644000175000017500000003276215205374124021117 0ustar fabiofabio// REQUIRED_ARGS: -o- -d -m64 struct S1 { int v; } struct S2 { int* p; } class C { int v; } #line 6 /* TEST_OUTPUT: --- fail_compilation/fail13902.d(45): Error: using the result of a comma expression is not allowed fail_compilation/fail13902.d(32): Error: returning `& x` escapes a reference to local variable `x` fail_compilation/fail13902.d(33): Error: returning `&s1.v` escapes a reference to local variable `s1` fail_compilation/fail13902.d(38): Error: returning `& sa1` escapes a reference to local variable `sa1` fail_compilation/fail13902.d(39): Error: returning `& sa2` escapes a reference to local variable `sa2` fail_compilation/fail13902.d(40): Error: returning `& x` escapes a reference to local variable `x` fail_compilation/fail13902.d(41): Error: returning `(& x + 4)` escapes a reference to local variable `x` fail_compilation/fail13902.d(42): Error: returning `& x + cast(long)x * 4L` escapes a reference to local variable `x` fail_compilation/fail13902.d(45): Error: returning `& y` escapes a reference to local variable `y` --- */ int* testEscape1() { int x, y; int[] da1; int[][] da2; int[1] sa1; int[1][1] sa2; int* ptr; S1 s1; S2 s2; C c; if (0) return &x; // VarExp if (0) return &s1.v; // DotVarExp if (0) return s2.p; // no error if (0) return &c.v; // no error if (0) return &da1[0]; // no error if (0) return &da2[0][0]; // no error if (0) return &sa1[0]; // IndexExp if (0) return &sa2[0][0]; // IndexExp if (0) return &x; if (0) return &x + 1; // optimized to SymOffExp == (& x+4) if (0) return &x + x; //if (0) return ptr += &x + 1; // semantic error if (0) ptr -= &x - &y; // no error if (0) return (&x, &y); // CommaExp return null; // ok } #line 49 /* TEST_OUTPUT: --- fail_compilation/fail13902.d(88): Error: using the result of a comma expression is not allowed fail_compilation/fail13902.d(75): Error: returning `& x` escapes a reference to parameter `x` fail_compilation/fail13902.d(76): Error: returning `&s1.v` escapes a reference to parameter `s1` fail_compilation/fail13902.d(81): Error: returning `& sa1` escapes a reference to parameter `sa1` fail_compilation/fail13902.d(82): Error: returning `& sa2` escapes a reference to parameter `sa2` fail_compilation/fail13902.d(83): Error: returning `& x` escapes a reference to parameter `x` fail_compilation/fail13902.d(84): Error: returning `(& x + 4)` escapes a reference to parameter `x` fail_compilation/fail13902.d(85): Error: returning `& x + cast(long)x * 4L` escapes a reference to parameter `x` fail_compilation/fail13902.d(88): Error: returning `& y` escapes a reference to parameter `y` --- */ int* testEscape2( int x, int y, int[] da1, int[][] da2, int[1] sa1, int[1][1] sa2, int* ptr, S1 s1, S2 s2, C c, ) { if (0) return &x; // VarExp if (0) return &s1.v; // DotVarExp if (0) return s2.p; // no error if (0) return &c.v; // no error if (0) return &da1[0]; // no error if (0) return &da2[0][0]; // no error if (0) return &sa1[0]; // IndexExp if (0) return &sa2[0][0]; // IndexExp if (0) return &x; if (0) return &x + 1; // optimized to SymOffExp == (& x+4) if (0) return &x + x; //if (0) return ptr += &x + 1; // semantic error if (0) ptr -= &x - &y; // no error if (0) return (&x, &y); // CommaExp return null; // ok } #line 92 /* TEST_OUTPUT: --- fail_compilation/fail13902.d(123): Error: using the result of a comma expression is not allowed --- */ int* testEscape3( return ref int x, return ref int y, ref int[] da1, ref int[][] da2, return ref int[1] sa1, return ref int[1][1] sa2, ref int* ptr, return ref S1 s1, ref S2 s2, ref C c, ) { if (0) return &x; // VarExp if (0) return &s1.v; // DotVarExp if (0) return s2.p; // no error if (0) return &c.v; // no error if (0) return &da1[0]; // no error if (0) return &da2[0][0]; // no error if (0) return &sa1[0]; // IndexExp if (0) return &sa2[0][0]; // IndexExp if (0) return ptr = &x; if (0) return ptr = &x + 1; // optimized to SymOffExp == (& x+4) if (0) return ptr = &x + x; //if (0) return ptr += &x + 1; // semantic error if (0) return ptr -= &x - &y; // no error if (0) return (&x, &y); // CommaExp return null; // ok } /* TEST_OUTPUT: --- fail_compilation/fail13902.d(150): Error: returning `cast(int[])sa1` escapes a reference to parameter `sa1` fail_compilation/fail13902.d(151): Error: returning `cast(int[])sa1` escapes a reference to parameter `sa1` fail_compilation/fail13902.d(152): Error: returning `sa1[]` escapes a reference to parameter `sa1` fail_compilation/fail13902.d(155): Error: returning `cast(int[])sa2` escapes a reference to local variable `sa2` fail_compilation/fail13902.d(156): Error: returning `cast(int[])sa2` escapes a reference to local variable `sa2` fail_compilation/fail13902.d(157): Error: returning `sa2[]` escapes a reference to local variable `sa2` fail_compilation/fail13902.d(161): Error: returning `cast(int[])s.sa` escapes a reference to local variable `s` fail_compilation/fail13902.d(162): Error: returning `cast(int[])s.sa` escapes a reference to local variable `s` fail_compilation/fail13902.d(163): Error: returning `s.sa[]` escapes a reference to local variable `s` fail_compilation/fail13902.d(166): Error: escaping reference to stack allocated value returned by `makeSA()` fail_compilation/fail13902.d(167): Error: escaping reference to stack allocated value returned by `makeSA()` fail_compilation/fail13902.d(168): Error: escaping reference to stack allocated value returned by `makeSA()` fail_compilation/fail13902.d(171): Error: escaping reference to stack allocated value returned by `makeS()` fail_compilation/fail13902.d(172): Error: escaping reference to stack allocated value returned by `makeS()` fail_compilation/fail13902.d(173): Error: escaping reference to stack allocated value returned by `makeS()` --- */ int[] testEscape4(int[3] sa1) // https://issues.dlang.org/show_bug.cgi?id=9279 { if (0) return sa1; // error <- no error if (0) return cast(int[])sa1; // error <- no error if (0) return sa1[]; // error int[3] sa2; if (0) return sa2; // error if (0) return cast(int[])sa2; // error if (0) return sa2[]; // error struct S { int[3] sa; } S s; if (0) return s.sa; // error <- no error if (0) return cast(int[])s.sa; // error <- no error if (0) return s.sa[]; // error int[3] makeSA() { int[3] ret; return ret; } if (0) return makeSA(); // error <- no error if (0) return cast(int[])makeSA(); // error <- no error if (0) return makeSA()[]; // error <- no error S makeS() { S s; return s; } if (0) return makeS().sa; // error <- no error if (0) return cast(int[])makeS().sa; // error <- no error if (0) return makeS().sa[]; // error <- no error return null; } /* TEST_OUTPUT: --- fail_compilation/fail13902.d(201): Error: returning `x` escapes a reference to local variable `x` fail_compilation/fail13902.d(202): Error: returning `s1.v` escapes a reference to local variable `s1` fail_compilation/fail13902.d(206): Error: returning `sa1[0]` escapes a reference to local variable `sa1` fail_compilation/fail13902.d(207): Error: returning `sa2[0][0]` escapes a reference to local variable `sa2` fail_compilation/fail13902.d(208): Error: returning `x = 1` escapes a reference to local variable `x` fail_compilation/fail13902.d(209): Error: returning `x += 1` escapes a reference to local variable `x` fail_compilation/fail13902.d(210): Error: returning `s1.v = 1` escapes a reference to local variable `s1` fail_compilation/fail13902.d(211): Error: returning `s1.v += 1` escapes a reference to local variable `s1` --- */ ref int testEscapeRef1() { int x; int[] da1; int[][] da2; int[1] sa1; int[1][1] sa2; S1 s1; C c; if (0) return x; // VarExp if (0) return s1.v; // DotVarExp if (0) return c.v; // no error if (0) return da1[0]; // no error if (0) return da2[0][0]; // no error if (0) return sa1[0]; // IndexExp if (0) return sa2[0][0]; // IndexExp if (0) return x = 1; // AssignExp if (0) return x += 1; // BinAssignExp if (0) return s1.v = 1; // AssignExp (e1 is DotVarExp) if (0) return s1.v += 1; // BinAssignExp (e1 is DotVarExp) static int g; return g; // ok } /* TEST_OUTPUT: --- fail_compilation/fail13902.d(240): Error: returning `x` escapes a reference to parameter `x` fail_compilation/fail13902.d(241): Error: returning `s1.v` escapes a reference to parameter `s1` fail_compilation/fail13902.d(245): Error: returning `sa1[0]` escapes a reference to parameter `sa1` fail_compilation/fail13902.d(246): Error: returning `sa2[0][0]` escapes a reference to parameter `sa2` fail_compilation/fail13902.d(247): Error: returning `x = 1` escapes a reference to parameter `x` fail_compilation/fail13902.d(248): Error: returning `x += 1` escapes a reference to parameter `x` fail_compilation/fail13902.d(249): Error: returning `s1.v = 1` escapes a reference to parameter `s1` fail_compilation/fail13902.d(250): Error: returning `s1.v += 1` escapes a reference to parameter `s1` --- */ ref int testEscapeRef2( int x, int[] da1, int[][] da2, int[1] sa1, int[1][1] sa2, S1 s1, C c, ) { if (0) return x; // VarExp if (0) return s1.v; // DotVarExp if (0) return c.v; // no error if (0) return da1[0]; // no error if (0) return da2[0][0]; // no error if (0) return sa1[0]; // IndexExp if (0) return sa2[0][0]; // IndexExp if (0) return x = 1; // AssignExp if (0) return x += 1; // BinAssignExp if (0) return s1.v = 1; // AssignExp (e1 is DotVarExp) if (0) return s1.v += 1; // BinAssignExp (e1 is DotVarExp) static int g; return g; // ok } /* TEST_OUTPUT: --- --- */ ref int testEscapeRef2( return ref int x, ref int[] da1, ref int[][] da2, return ref int[1] sa1, return ref int[1][1] sa2, return ref S1 s1, ref C c, ) { if (0) return x; // VarExp if (0) return s1.v; // DotVarExp if (0) return c.v; // no error if (0) return da1[0]; // no error if (0) return da2[0][0]; // no error if (0) return sa1[0]; // IndexExp if (0) return sa2[0][0]; // IndexExp if (0) return x = 1; // AssignExp if (0) return x += 1; // BinAssignExp if (0) return s1.v = 1; // AssignExp (e1 is DotVarExp) if (0) return s1.v += 1; // BinAssignExp (e1 is DotVarExp) static int g; return g; // ok } /* TEST_OUTPUT: --- fail_compilation/fail13902.d(294): Error: returning `[& x]` escapes a reference to local variable `x` fail_compilation/fail13902.d(295): Error: returning `[& x]` escapes a reference to local variable `x` --- */ int*[] testArrayLiteral1() { int x; return [&x]; } int*[1] testArrayLiteral2() { int x; return [&x]; } /* TEST_OUTPUT: --- fail_compilation/fail13902.d(304): Error: returning `S2(& x)` escapes a reference to local variable `x` fail_compilation/fail13902.d(305): Error: returning `new S2(& x)` escapes a reference to local variable `x` --- */ S2 testStructLiteral1() { int x; return S2(&x); } S2* testStructLiteral2() { int x; return new S2(&x); } /* TEST_OUTPUT: --- fail_compilation/fail13902.d(314): Error: returning `sa[]` escapes a reference to local variable `sa` fail_compilation/fail13902.d(315): Error: returning `sa[cast(ulong)n..2][1..2]` escapes a reference to local variable `sa` --- */ int[] testSlice1() { int[3] sa; return sa[]; } int[] testSlice2() { int[3] sa; int n; return sa[n..2][1..2]; } /* TEST_OUTPUT: --- fail_compilation/fail13902.d(324): Error: returning `vda[0]` escapes a reference to variadic parameter `vda` fail_compilation/fail13902.d(325): Error: returning `vda[]` escapes a reference to variadic parameter `vda` --- */ ref int testDynamicArrayVariadic1(int[] vda...) { return vda[0]; } @safe int[] testDynamicArrayVariadic2(int[] vda...) { return vda[]; } int[3] testDynamicArrayVariadic3(int[] vda...) { return vda[0..3]; } // no error /* TEST_OUTPUT: --- fail_compilation/fail13902.d(335): Error: returning `vsa[0]` escapes a reference to parameter `vsa` fail_compilation/fail13902.d(336): Error: returning `vsa[]` escapes a reference to parameter `vsa` --- */ ref int testStaticArrayVariadic1(int[3] vsa...) { return vsa[0]; } int[] testStaticArrayVariadic2(int[3] vsa...) { return vsa[]; } int[3] testStaticArrayVariadic3(int[3] vsa...) { return vsa[0..3]; } // no error /* TEST_OUTPUT: --- fail_compilation/fail13902.d(355): Error: returning `match(st)` escapes a reference to local variable `st` --- */ // This was reduced from a `static assert(!__traits(compiles, {...}))` test in `std.sumtype` // which was asserting that matchers couldn't escape sumtype members. // This should give an error even without `@safe` or `-preview=dip1000` int* match(return ref int i) { return &i; } int* escape() { int st; return match(st); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/nestedtempl2.d0000644000175000017500000000212715205374124022203 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/nestedtempl2.d(22): Deprecation: function `nestedtempl2.B.func!(n).func` function requires a dual-context, which is deprecated fail_compilation/nestedtempl2.d(34): instantiated from here: `func!(n)` fail_compilation/nestedtempl2.d(34): Error: `this` is only defined in non-static member functions, not `test` fail_compilation/nestedtempl2.d(34): Error: need `this` of type `B` to call function `func` fail_compilation/nestedtempl2.d(35): Error: `this` is only defined in non-static member functions, not `test` fail_compilation/nestedtempl2.d(35): Error: need `this` of type `B` to make delegate from function `func` fail_compilation/nestedtempl2.d(37): Error: `this` is only defined in non-static member functions, not `test` fail_compilation/nestedtempl2.d(37): Error: need `this` of type `B` needed to `new` nested class `N` --- */ class B { int n; } void test() { auto func(alias a)() { return a; } class N(alias a) { } auto b = new B(); b.n = 1; func!(b.n)(); auto dg = &func!(b.n); new N!(b.n)(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/templatethis.d0000644000175000017500000000133515205374124022300 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/templatethis.d(13): Error: cannot use `this` outside an aggregate type fail_compilation/templatethis.d(17): Error: cannot use `this` outside an aggregate type fail_compilation/templatethis.d(21): Error: cannot use `this` outside an aggregate type fail_compilation/templatethis.d(23): Error: cannot use `this` outside an aggregate type fail_compilation/templatethis.d(29): Error: cannot use `this` outside an aggregate type fail_compilation/templatethis.d(32): Error: mixin `templatethis.t2!()` error instantiating --- */ template t(this T) { } struct S(this T) { } enum e(this T) = 1; void f(this T)() { } mixin template t2() { int i(this T) = 1; } mixin t2; class C { mixin t2; // OK } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10528.d0000644000175000017500000000222515205374124021107 0ustar fabiofabio/* EXTRA_FILES: imports/a10528.d TEST_OUTPUT: --- fail_compilation/fail10528.d(24): Error: undefined identifier `a` fail_compilation/fail10528.d(25): Error: undefined identifier `a` in module `a10528` fail_compilation/fail10528.d(27): Error: undefined identifier `b` fail_compilation/fail10528.d(28): Error: undefined identifier `b` in module `a10528` fail_compilation/fail10528.d(30): Error: no property `c` for type `a10528.S` fail_compilation/imports/a10528.d(4): struct `S` defined here fail_compilation/fail10528.d(31): Error: no property `c` for type `a10528.S` fail_compilation/imports/a10528.d(4): struct `S` defined here fail_compilation/fail10528.d(33): Error: no property `d` for type `a10528.C` fail_compilation/imports/a10528.d(5): class `C` defined here fail_compilation/fail10528.d(34): Error: no property `d` for type `a10528.C` fail_compilation/imports/a10528.d(5): class `C` defined here --- */ import imports.a10528; void main() { auto a1 = a; auto a2 = imports.a10528.a; auto b1 = b; auto b2 = imports.a10528.b; auto c1 = S.c; with (S) auto c2 = c; auto d1 = C.d; with (C) auto d2 = d; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/template_function_oop.d0000644000175000017500000000060715205374124024173 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/template_function_oop.d(16): Deprecation: a function template is not virtual so cannot be marked `override` fail_compilation/template_function_oop.d(17): Deprecation: a function template is not virtual so cannot be marked `abstract` --- */ class C { void f(); } class D : C { override void f()() {} abstract void g()(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ob1.d0000644000175000017500000000077115205374124020261 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1021 TEST_OUTPUT: --- fail_compilation/ob1.d(23): Error: variable `ob1.mars.t` has undefined state and cannot be read --- https://issues.dlang.org/show_bug.cgi?id=21923 */ @live: struct Handle { private void* _handle; this(int n); ~this(); scope void bar(); static void fido(ref Handle); } void mars() { auto t = Handle(10); t.bar(); Handle.fido(t); // moves t to fido(), then destructor runs, causing error scope u = Handle(10); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag5450.d0000644000175000017500000000042615205374124021017 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag5450.d(18): Error: class `diag5450.C` cannot implicitly generate a default constructor when base class `diag5450.B` is missing a default constructor --- */ class A { this() { } } class B : A { this(int f) {} } class C : B { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail23151.d0000644000175000017500000000145015205374124021102 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail23151.d(30): Error: class `fail23151.makeDerivedObj.Derived` is nested within `makeDerivedObj`, but super class `Base` is nested within `makeBaseObj` --- */ interface I { void intfunc(int x); } auto makeBaseObj() { int realPrivateX; class Base : I { private int modulePrivateX; int publicX; override void intfunc(int x) { realPrivateX++; // expected OK } } return new Base; } auto makeDerivedObj() { int realPrivateY; class Derived : typeof(makeBaseObj()) { private int modulePrivateY; int publicY; override void intfunc(int x) { realPrivateX++; // expected NG modulePrivateX++; } } return new Derived; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test10.d0000644000175000017500000000030015205374124020704 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test10.d(10): Error: found `else` without a corresponding `if`, `version` or `debug` statement --- */ void test(int i) { ++i; else ++i; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail296.d0000644000175000017500000000027615205374124020754 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail296.d(10): Error: can only `*` a pointer, not a `int` --- */ // https://issues.dlang.org/show_bug.cgi?id=3117 // dmd crash by *1 void main(){ *1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/seq_assign.d0000644000175000017500000000253515205374124021734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/seq_assign.d(28): Error: cannot assign `int` to expression sequence `(int)` fail_compilation/seq_assign.d(29): Error: cannot implicitly convert expression `s` of type `string` to `int` fail_compilation/seq_assign.d(30): Error: cannot modify constant `2` fail_compilation/seq_assign.d(31): Error: mismatched sequence lengths, 1 and 2 fail_compilation/seq_assign.d(35): Error: mismatched sequence lengths, 1 and 2 fail_compilation/seq_assign.d(36): Error: cannot implicitly convert expression `__t_field_0` of type `string` to `int` fail_compilation/seq_assign.d(40): Error: cannot assign `IntString` to expression sequence `(string, int)` fail_compilation/seq_assign.d(42): Error: cannot implicitly convert expression `AliasSeq!(b, c)` of type `(int, int)` to `IntString` --- */ alias Seq(A...) = A; struct IntString { Seq!(int, string) expand; alias this = expand; } void main() { int b, c; string s; Seq!(b,) = 1; // RHS not seq Seq!(b,) = Seq!(s,); // b type error Seq!(2,) = Seq!(1,); // not lvalue Seq!(b,) = Seq!(1, 2); // too many auto t = Seq!("two", 3); Seq!(s, b) = t; // OK Seq!(b,) = t; // too many Seq!(b, c) = t; // b type error IntString t2; Seq!(b, s) = t2; // OK t = t2; // type mismatch t2 = Seq!(b, s); // OK t2 = Seq!(b, c); // c wrong type } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice8711.d0000644000175000017500000000023015205374124020647 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice8711.d(8): Error: cannot use array to initialize `int function(int)` --- */ int function(int) foos = [x => 0]; ./ldc-1.42.0-src/tests/dmd/fail_compilation/main.d0000644000175000017500000000037315205374124020522 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/main.d(9): Error: only one entry point `main`$?:windows=, `WinMain` or `DllMain`$ is allowed fail_compilation/main.d(8): previously found `void main()` here --- */ void main() {} void main(string[] args) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail114.d0000644000175000017500000000041415205374124020733 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail114.d(12): Error: forward reference to `funcA` --- */ // https://issues.dlang.org/show_bug.cgi?id=371 // ICE on mutual recursive typeof in function declarations void funcA(typeof(&funcB) p) {} void funcB(typeof(&funcA) p) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test11471.d0000644000175000017500000000042515205374124021151 0ustar fabiofabio// REQUIRED_ARGS: -profile /* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/test11471.d(10): Error: `asm` statement is assumed to throw - mark it with `nothrow` if it does not --- */ void main() nothrow { asm { nop; } } // Error: asm statements are assumed to throw ./ldc-1.42.0-src/tests/dmd/fail_compilation/test20569.d0000644000175000017500000000103415205374124021156 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test20569.d(19): Error: taking address of `scope` variable `s1` with pointers is not allowed in a `@safe` function fail_compilation/test20569.d(23): Error: taking address of `scope` variable `s2` with pointers is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=20569 struct S { int* pointer; } void main() @safe { scope S s1; scope int** p1 = &s1.pointer; int x; S s2 = S(&x); auto p2 = &s2.pointer; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20538.d0000644000175000017500000000051215205374124021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail20538.d(13): Error: found `=` when expecting `identifier` fail_compilation/fail20538.d(13): Error: found `1` when expecting `identifier` fail_compilation/fail20538.d(14): Error: named enum cannot declare member with type --- */ enum smth { a, = 1, int x = 1, @disable b } ./ldc-1.42.0-src/tests/dmd/fail_compilation/short_fn.d0000644000175000017500000000054315205374124021417 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/short_fn.d(13): Error: can only return void expression, `this` call or `super` call from constructor fail_compilation/short_fn.d(14): Error: can only return void expression, `this` call or `super` call from constructor --- */ struct Number { int x; this(int x) => this.x = x; this(byte x) => Number(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail343.d0000644000175000017500000000076315205374124020746 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail343.d(22): Error: function `fail343.TimedApp.run` cannot override `final` function `I.fail343.Timer.run` fail_compilation/fail343.d(22): Error: function `fail343.TimedApp.run` cannot override `final` function `Application.fail343.Application.run` --- */ interface Timer { final void run() { } } interface I : Timer { } interface Application { final void run() { } } class TimedApp : I, Application { // cannot define run() void run() { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9613.d0000644000175000017500000000043215205374124021030 0ustar fabiofabio// PERMUTE_ARGS: /* TEST_OUTPUT: --- fail_compilation/fail9613.d(12): Error: `(arguments)` expected following `const(byte)`, not `.` fail_compilation/fail9613.d(12): Error: semicolon expected following auto declaration, not `.` --- */ void main() { auto x = const byte.init; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail5953s1.d0000644000175000017500000000025415205374124021301 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail5953s1.d(10): Error: expression expected, not `,` --- */ void main() { struct S{} S s2 = {,}; // invalid, but compiles } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail188.d0000644000175000017500000000035115205374124020746 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail188.d(15): Error: function `fail188.Derived.foo` cannot override `final` function `fail188.Base.foo` --- */ class Base { final void foo() {} } class Derived : Base { void foo() {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail162.d0000644000175000017500000000124415205374124020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail162.d(25): Error: template `testHelper` is not callable using argument types `!()(string, string)` fail_compilation/fail162.d(10): Candidate is: `testHelper(A...)()` fail_compilation/fail162.d(30): Error: template instance `fail162.test!("hello", "world")` error instantiating --- */ template testHelper(A ...) { char[] testHelper() { char[] result; foreach (t; a) { result ~= "int " ~ t ~ ";\r\n"; } return result; } } template test(A...) { const char[] test = testHelper(A); } int main(char[][] args) { mixin(test!("hello", "world")); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/bug18743.d0000644000175000017500000000064215205374124020761 0ustar fabiofabio// REQUIRED_ARGS: /* TEST_OUTPUT: --- fail_compilation/bug18743.d(18): Error: `a ? a = 4 : a` must be surrounded by parentheses when next to operator `=` fail_compilation/bug18743.d(19): Error: `a ? --a : a` must be surrounded by parentheses when next to operator `+=` --- */ void main() { int a; // ok (a ? a = 4 : a) = 5; a ? a = 4 : (a = 5); a ? a = 4 : a = 5; a ? --a : a += 1; a ? a = 4 : a++; // ok } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18312.d0000644000175000017500000000047515205374124021157 0ustar fabiofabio/* REQUIRED_ARGS: -betterC TEST_OUTPUT: --- fail_compilation/test18312.d(14): Error: array concatenation of expression `"[" ~ s ~ "]"` requires the GC which is not available with -betterC --- */ // https://issues.dlang.org/show_bug.cgi?id=18312 extern (C) void main() { scope string s; s = "[" ~ s ~ "]"; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test11047.d0000644000175000017500000000056715205374124021157 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test11047.d(11): Error: value of `x` is not known at compile time fail_compilation/test11047.d(11): Error: value of `x` is not known at compile time --- */ // https://issues.dlang.org/show_bug.cgi?id=11047 int x; @(++x, ++x) void foo(){} @safe pure void test() { __traits(getAttributes, foo); __traits(getAttributes, foo)[0]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13775.d0000644000175000017500000000157215205374124021122 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: --- fail_compilation/fail13775.d(17): Error: cannot cast expression `ubytes[0..2]` of type `ubyte[2]` to `ubyte[1]` fail_compilation/fail13775.d(18): Error: cannot cast expression `ubytes[0..2]` of type `ubyte[2]` to `ubyte[3]` fail_compilation/fail13775.d(19): Error: cannot cast expression `ubytes[0..2]` of type `ubyte[2]` to `byte[1]` fail_compilation/fail13775.d(20): Error: cannot cast expression `ubytes[0..2]` of type `ubyte[2]` to `byte[3]` --- */ void main() { ubyte[4] ubytes = [1,2,3,4]; // CT-known slicing succeeds but sizes cannot match auto ng1 = cast(ubyte[1]) ubytes[0 .. 2]; // ubyte[2] to ubyte[1] auto ng2 = cast(ubyte[3]) ubytes[0 .. 2]; // ubyte[2] to ubyte[3] auto ng3 = cast( byte[1]) ubytes[0 .. 2]; // ubyte[2] to byte[1] auto ng4 = cast( byte[3]) ubytes[0 .. 2]; // ubyte[2] to byte[3] } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail325.d0000644000175000017500000000033015205374124020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail325.d(12): Error: template `fun(T = int)(int w, int z)` has no type --- */ void fun(T = int)(int w, int z) {} void main() { auto x = cast(void function(int, int))fun; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail4375t.d0000644000175000017500000000054115205374124021215 0ustar fabiofabio// REQUIRED_ARGS: -unittest // https://issues.dlang.org/show_bug.cgi?id=4375: Dangling else /* TEST_OUTPUT: --- fail_compilation/fail4375t.d(14): Error: else is dangling, add { } after condition at fail_compilation/fail4375t.d(11) --- */ unittest { // disallowed if (true) if (false) assert(52); else assert(53); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag14102.d0000644000175000017500000000147715205374124021100 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag14102.d(14): Error: cannot modify expression `-x` because it is not an lvalue fail_compilation/diag14102.d(15): Error: cannot modify expression `-(x -= 1)` because it is not an lvalue fail_compilation/diag14102.d(16): Error: cannot modify expression `-(x -= 1 -= 1)` because it is not an lvalue fail_compilation/diag14102.d(17): Error: cannot modify expression `-(x -= 1 -= 1 -= 1)` because it is not an lvalue --- */ int main() { int x; return -- -x; // error: -x is not an lvalue return -- - --x; // error: -(x -= 1) is not an lvalue return -- - -- --x; // error: -((x -= 1 , x) -= 1) is not an lvalue return -- - -- -- --x; // error: -((ref int __assignop1 = x -= 1 , __assignop1 = x; , __assignop1 -= 1 , __assignop1) -= 1) is not an lvalue } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11856_1.d0000644000175000017500000000110715205374124021157 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/ice11856_1.d(18): Error: no property `g` for `A()` of type `A` fail_compilation/ice11856_1.d(18): the following error occured while looking for a UFCS match fail_compilation/ice11856_1.d(18): Error: template `g` is not callable using argument types `!()(A)` fail_compilation/ice11856_1.d(16): Candidate is: `g(T)(T x)` with `T = A` must satisfy the following constraint: ` is(typeof(x.f()))` ---- */ struct A {} void f(T)(T x) if (is(typeof(x.g()))) {} void g(T)(T x) if (is(typeof(x.f()))) {} void main() { A().g(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag6743.d0000644000175000017500000000035515205374124021026 0ustar fabiofabio/* LDC: no additional output lines (`run `dmd` to print the compiler manual`, `run 'dmd -man' to open browser on manual`) REQUIRED_ARGS: -run test.exe TEST_OUTPUT: --- Error: -run must be followed by a source file, not 'test.exe' --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail356b.d0000644000175000017500000000041015205374124021101 0ustar fabiofabio/* EXTRA_FILES: imports/fail356.d TEST_OUTPUT: --- fail_compilation/fail356b.d(9): Error: variable `fail356b.bar` conflicts with alias `fail356b.bar` at fail_compilation/fail356b.d(8) --- */ import imports.fail356 : bar; int bar; // collides with selective import ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail1995.d0000644000175000017500000000112715205374124021037 0ustar fabiofabio/* REQUIRED_ARGS: -Jdoes_not_exists -Jfail_compilation/fail1995.d -Jfail_compilation/ TEST_OUTPUT: --- fail_compilation/fail1995.d(12): Error: file `"SomeFile.txt"` cannot be found or not in a path specified with `-J` fail_compilation/fail1995.d(12): Path(s) searched (as provided by `-J`): fail_compilation/fail1995.d(12): [0]: `does_not_exists` (path not found) fail_compilation/fail1995.d(12): [1]: `fail_compilation/fail1995.d` (not a directory) fail_compilation/fail1995.d(12): [2]: `fail_compilation$r:[/\\]$` --- */ immutable string Var = import("SomeFile.txt"); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail22133.d0000644000175000017500000000063215205374124021102 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22133 /* TEST_OUTPUT: --- fail_compilation/fail22133.d(16): Error: `s.popFront()()` has no effect fail_compilation/fail22133.d(17): Error: template `s.popFront()()` has no type --- */ struct Slice { void popFront()() {} } auto fail22133(const Slice s) { s.popFront; return s.popFront; } auto ok22133(Slice s) { s.popFront; return s.popFront; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8714.d0000644000175000017500000000064615205374124021031 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8714.d(9): Error: function `diag8714.foo` circular dependency. Functions cannot be interpreted while being compiled fail_compilation/diag8714.d(15): called from here: `foo("somestring")` --- */ string foo(string f) { if (f == "somestring") { return "got somestring"; } return bar!(foo("somestring")); } template bar(string s) { enum bar = s; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22910.d0000644000175000017500000000064315205374124021153 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test22910.d(17): Error: escaping a reference to parameter `this` by returning `&this.val` is not allowed in a `@safe` function fail_compilation/test22910.d(15): perhaps change the `return scope` into `scope return` --- */ @safe: struct S { int val; int* ptr; int* retScope() return scope { return &this.val; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failinout2.d0000644000175000017500000000051715205374124021652 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/failinout2.d(8): Error: variable `failinout2.x` - only parameters or stack-based variables can be `inout` fail_compilation/failinout2.d(12): Error: variable `failinout2.S3748.err8` - only parameters or stack-based variables can be `inout` --- */ inout int x; struct S3748 { inout(int) err8; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice20264.d0000644000175000017500000000044115205374124020730 0ustar fabiofabio/* DISABLED: freebsd32 openbsd32 linux32 osx32 win32 TEST_OUTPUT: --- fail_compilation/ice20264.d(12): Error: cannot modify expression `cast(__vector(float[4]))a` because it is not an lvalue --- */ void foo(float *a) { alias float4 = __vector(float[4]); cast(float4)(a) = 1.0f; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail8724.d0000644000175000017500000000051515205374124021034 0ustar fabiofabio// REQUIRED_ARGS: -w /* TEST_OUTPUT: --- fail_compilation/fail8724.d(14): Error: `object.Exception` is thrown but not caught fail_compilation/fail8724.d(12): Error: constructor `fail8724.Foo.this` may throw but is marked as `nothrow` --- */ struct Foo { this(int) nothrow { throw new Exception("something"); } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/array_bool.d0000644000175000017500000000121415205374124021722 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/array_bool.d(13): Deprecation: assert condition cannot be a string literal fail_compilation/array_bool.d(13): If intentional, use `"foo" !is null` instead to preserve behaviour fail_compilation/array_bool.d(14): Deprecation: static assert condition cannot be a string literal fail_compilation/array_bool.d(14): If intentional, use `"foo" !is null` instead to preserve behaviour --- */ void main() { assert("foo"); static assert("foo"); assert("foo".ptr); // OK static assert("foo".ptr); // OK enum e = "bar"; static assert(e); // OK assert(e); // OK } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice13921.d0000644000175000017500000000063215205374124020734 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice13921.d(13): Error: undefined identifier `undefined_identifier` fail_compilation/ice13921.d(25): Error: template instance `ice13921.S!string` error instantiating --- */ struct S(N) { void fun() { undefined_identifier; // or anything that makes the instantiation fail } } void test(T)(S!T) { } void main() { S!string g; test(g); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail17630.d0000644000175000017500000000047215205374124021112 0ustar fabiofabio// 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); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail169.d0000644000175000017500000000022715205374124020747 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail169.d(8): Error: cannot have `const out` parameter of type `const(int)` --- */ void foo(const out int x) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19881.d0000644000175000017500000000100115205374124021111 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 * TEST_OUTPUT: --- fail_compilation/fail19881.d(13): Error: assigning address of local variable `local` to return scope `input` is not allowed in a `@safe` function fail_compilation/fail19881.d(13): Error: assigning address of variable `local` to `input` with longer lifetime is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=19881 @safe int* test(return scope int* input) { int local = 42; input = &local; return input; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10783.d0000644000175000017500000000057015205374124021104 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10783.d(15): Error: no property `type` for `event` of type `diag10783.Event` fail_compilation/diag10783.d(10): struct `Event` defined here fail_compilation/diag10783.d(15): Error: undefined identifier `En` --- */ struct Event { } void main() { Event event; switch (event.type) with (En) { default: } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20779.d0000644000175000017500000000041415205374124021116 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20779 /* TEST_OUTPUT: --- fail_compilation/fail20779.d(12): Error: struct `fail20779.X` cannot have field `x` with same struct type --- */ module fail20779; struct X { X x; enum e = __traits(compiles, X.init); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag4528.d0000644000175000017500000000140715205374124021024 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag4528.d(14): Error: function `diag4528.Foo.pva` `private` functions cannot be `abstract` fail_compilation/diag4528.d(15): Error: function `diag4528.Foo.pka` `package` functions cannot be `abstract` fail_compilation/diag4528.d(16): Error: function `diag4528.Foo.pvsa` `static` functions cannot be `abstract` fail_compilation/diag4528.d(17): Error: function `diag4528.Foo.pksa` `static` functions cannot be `abstract` fail_compilation/diag4528.d(18): Error: function `diag4528.Foo.pbsa` `static` functions cannot be `abstract` --- */ class Foo { private abstract void pva(); package abstract void pka(); private static abstract void pvsa(); package static abstract void pksa(); public static abstract void pbsa(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19965.d0000644000175000017500000000103015205374124021116 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/fail19965.d(36): Error: assigning address of variable `f` to `a` with longer lifetime is not allowed in a `@safe` function --- */ // https://issues.dlang.org/show_bug.cgi?id=19965 struct Buffer { int[10] data; int[] getData() @safe return { return data[]; } } struct Foo() { Buffer buffer; int[] toArray() @safe return { return buffer.getData; } } int[] a; void main() @safe { Foo!() f; a = f.toArray; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10792.d0000644000175000017500000000023315205374124021100 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag10792.d(9): Error: semicolon expected following auto declaration, not `End of File` --- */ enum isPred(T) = asdf ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail20033.d0000644000175000017500000000246415205374124021104 0ustar fabiofabio// REQUIRED_ARGS: -de /* TEST_OUTPUT: --- fail_compilation/fail20033.d(38): Deprecation: `alias byKeyValue this` is deprecated - This was a bad idea fail_compilation/fail20033.d(39): Deprecation: `alias byKeyValue this` is deprecated fail_compilation/fail20033.d(41): Deprecation: `alias byKeyValue this` is deprecated - This was a bad idea fail_compilation/fail20033.d(42): Deprecation: `alias byKeyValue this` is deprecated --- */ #line 1 struct Tuple(T...) { T values; alias values this; } alias KVT = Tuple!(string, string); struct Test { struct Range { bool empty () { return false; } KVT front() { return KVT.init; } void popFront() {} } auto byKeyValue () { return Range.init; } deprecated("This was a bad idea") alias byKeyValue this; } struct Test2 { struct Range { bool empty () { return false; } KVT front() { return KVT.init; } void popFront() {} } auto byKeyValue () { return Range.init; } deprecated alias byKeyValue this; } void main () { foreach (k, v; Test.init.byKeyValue) {} // Fine foreach (k, v; Test2.init.byKeyValue) {} // Fine foreach (k, v; Test.init) {} // Fails foreach (k, v; Test2.init) {} // Fails auto f1 = Test.init.front(); // Fails auto f2 = Test2.init.front(); // Fails } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail317.d0000644000175000017500000000027415205374124020744 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail317.d(10): Error: function `fail317.I.f` has no function body with return type inference --- */ interface I { auto f() in {} out {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice23097.d0000644000175000017500000000141615205374124020742 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=23097 TEST_OUTPUT: --- fail_compilation/ice23097.d(13): Error: undefined identifier `ICE` fail_compilation/ice23097.d(28): Error: template instance `ice23097.ice23097!(S23097)` error instantiating fail_compilation/ice23097.d(28): Error: function `ice23097` is not callable using argument types `(S23097)` fail_compilation/ice23097.d(28): generating a copy constructor for `struct S23097` failed, therefore instances of it are uncopyable fail_compilation/ice23097.d(11): `ice23097.ice23097!(S23097).ice23097(S23097 __param_0)` declared here --- */ auto ice23097(I)(I) { ICE; } struct Cpctor23097 { this(ref typeof(this)) { } } struct S23097 { Cpctor23097 cpctor; } auto fail23097(S23097 s) { s.ice23097; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ctfe13612.d0000644000175000017500000000125715205374124021116 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ctfe13612.d(15): Error: function `ctfe13612.S.recurse` CTFE recursion limit exceeded fail_compilation/ctfe13612.d(20): called from here: `s.recurse()` fail_compilation/ctfe13612.d(15): 1000 recursive calls to function `recurse` fail_compilation/ctfe13612.d(23): called from here: `(new S).recurse()` fail_compilation/ctfe13612.d(23): while evaluating: `static assert((new S).recurse())` --- */ class S { int x; int recurse() { S s; assert(!x); // Error: class 'this' is null and cannot be dereferenced s = new S(); return s.recurse(); } } static assert(new S().recurse()); ./ldc-1.42.0-src/tests/dmd/fail_compilation/nestedtempl1.d0000644000175000017500000000113115205374124022174 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/nestedtempl1.d(14): Deprecation: function `nestedtempl1.main.bar!(a).bar` function requires a dual-context, which is deprecated fail_compilation/nestedtempl1.d(26): instantiated from here: `bar!(a)` fail_compilation/nestedtempl1.d(26): Error: modify `inout` to `mutable` is not allowed inside `inout` function --- */ auto foo(ref inout(int) x) { struct S { ref inout(int) bar(alias a)() inout { return x; } } return S(); } void main() { int a; auto o = foo(a); o.bar!a() = 1; // bad! } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22935.c0000644000175000017500000000127615205374124021164 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test22935.c(18): Error: array index 5 is out of bounds `[0..4]` --- */ // https://issues.dlang.org/show_bug.cgi?id=22935 typedef unsigned long size_t; struct S { char a; char text[4]; }; //int tmp = __builtin_offsetof(struct S, text[0]); int tmp = ((unsigned long)((char *)&((struct S *)0)->text[0] - (char *)0)); _Static_assert((unsigned long)((char *)&((struct S *)0)->text[0] - (char *)0) == 1, "1"); _Static_assert((unsigned long)((char *)&((struct S *)0)->text[2] - (char *)0) == 3, "2"); _Static_assert((unsigned long)((char *)&((struct S *)4)->text[2] - (char *)0) == 7, "3"); int tmp2 = ((unsigned long)((char *)&((struct S *)0)->text[5] - (char *)0)); ./ldc-1.42.0-src/tests/dmd/fail_compilation/testsemi.d0000644000175000017500000000241515205374124021432 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/testsemi.d(102): Error: found `int` when expecting `;` following static assert fail_compilation/testsemi.d(102): Error: variable name expected after type `x`, not `;` fail_compilation/testsemi.d(109): Error: found `alias` when expecting `;` following alias reassignment fail_compilation/testsemi.d(112): Error: found `}` when expecting `;` following invariant fail_compilation/testsemi.d(117): Error: found `int` when expecting `;` following `alias Identifier this` fail_compilation/testsemi.d(117): Error: variable name expected after type `x`, not `;` fail_compilation/testsemi.d(123): Error: found `int` when expecting `;` following mixin fail_compilation/testsemi.d(129): Error: found `int` when expecting `;` following `import` Expression fail_compilation/testsemi.d(131): Error: `}` expected following members in `class` declaration fail_compilation/testsemi.d(112): class `C` starts here --- */ #line 100 static assert(1) int x; template map(alias F, Args...) { alias A = AliasSeq!(); static foreach (Arg; Args) A = AliasSeq!(A, F!Arg) alias staticMap = A; } class C { invariant(3) } class D { alias x this int x; } void test1() { mixin("int x;") int y; } void test2() { import(1) int z; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test4682a.d0000644000175000017500000000051315205374124021236 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/test4682a.d(10): Error: divide by 0 fail_compilation/test4682a.d(11): Error: divide by 0 fail_compilation/test4682a.d(12): Error: divide by 0 fail_compilation/test4682a.d(13): Error: divide by 0 ---- */ auto a = int.min / 0; auto b = long.min / 0; auto c = int.min % 0; auto d = long.min % 0; ./ldc-1.42.0-src/tests/dmd/fail_compilation/call_function_type.d0000644000175000017500000000111715205374124023454 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/call_function_type.d(18): Error: missing argument for parameter #1: `int` fail_compilation/call_function_type.d(19): Error: cannot call `int(int)(3)` at compile time --- */ // This is a rare case where `dmd.expressionsem.functionParameters` catches a missing argument error, // which is usually caught earlier by `TypeFunction.callMatch`, and had no test coverage yet. // This was found while implementing named arguments and reduced from `vibe.internal.meta.traits`. int f(int); void m() { alias FT = typeof(f); enum X0 = FT(); enum X1 = FT(3); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail303.d0000644000175000017500000000172515205374124020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail303.d(18): Deprecation: use of imaginary type `ireal` is deprecated, use `real` instead fail_compilation/fail303.d(20): Error: `double /= cdouble` is undefined. Did you mean `double /= cdouble.re`? fail_compilation/fail303.d(21): Error: `ireal *= ireal` is an undefined operation fail_compilation/fail303.d(22): Error: `ireal *= creal` is undefined. Did you mean `ireal *= creal.im`? fail_compilation/fail303.d(23): Error: `ireal %= creal` is undefined. Did you mean `ireal %= creal.im`? fail_compilation/fail303.d(24): Error: `ireal += real` is undefined (result is complex) fail_compilation/fail303.d(25): Error: `ireal -= creal` is undefined (result is complex) fail_compilation/fail303.d(26): Error: `double -= idouble` is undefined (result is complex) --- */ void main() { ireal x = 3.0i; double y = 3; y /= 2.0 + 6i; x *= 7.0i; x *= 3.0i + 2; x %= (2 + 6.0i); x += 2.0; x -= 1 + 4i; y -= 3.0i; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/system_ptr_cast.d0000644000175000017500000000123415205374124023016 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 -de TEST_OUTPUT: --- fail_compilation/system_ptr_cast.d(20): Deprecation: cast from `S*` to `int*` will become `@system` in a future release fail_compilation/system_ptr_cast.d(20): Source element type has unsafe bit patterns and target element type is mutable fail_compilation/system_ptr_cast.d(24): Deprecation: cast from `int*` to `S*` will become `@system` in a future release fail_compilation/system_ptr_cast.d(24): Target element type has unsafe bit patterns --- */ struct S { @system int i; } void main() @safe { S s; auto p = cast(int*) &s; *p = 8; int i = 8; auto ps = cast(S*) &i; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21885.d0000644000175000017500000000050615205374124021117 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21885 /* TEST_OUTPUT: --- fail_compilation/fail21885.d(24): Error: struct `fail21885.Outer` is not copyable because field `i` is not copyable --- */ struct Outer { Inner i; } struct Inner { @disable this(this); } void main() { Outer o1; Outer o2; o1 = o2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue21378.d0000644000175000017500000000076115205374124021334 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/issue21378.d(13): Error: function `issue21378.fn` circular dependency. Functions cannot be interpreted while being compiled fail_compilation/issue21378.d(12): called from here: `fn()` fail_compilation/issue21378.d(12): Error: pragma(`inline`, `true` or `false`) expected, not `fn()` --- */ // Cannot call the same function linked to the pragma // Really hard to fix this limitation in the implementation pragma(inline, fn()) int fn() { return 1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test8509.d0000644000175000017500000000061215205374124021077 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test8509.d(13): Error: cannot implicitly convert expression `"hello world"` of type `string` to `E` fail_compilation/test8509.d(14): Error: cannot implicitly convert expression `"hello world"` of type `string` to `E` --- */ module test8509; enum E : string { a = "hello", b = "world" } void main() { E e1 = E.a ~ " world"; E e2 = "hello " ~ E.b; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail117.d0000644000175000017500000000120215205374124020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail117.d(35): Error: expression `foo.mixin MGettor!(a) geta;` is `void` and has no value fail_compilation/fail117.d(36): Error: expression `foo.mixin MGettor!(b) getb;` is `void` and has no value --- */ // https://issues.dlang.org/show_bug.cgi?id=420 // mixin make dmd break //import std.stdio; template MGettor(alias Fld) { typeof(Fld) opCall() { //writefln("getter"); return Fld; } } class Foo { int a = 1, b = 2; mixin MGettor!(a) geta; mixin MGettor!(b) getb; } void main() { auto foo = new Foo; int a = foo.geta; int b = foo.getb; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/retscope5.d0000644000175000017500000000065515205374124021512 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 */ /* TEST_OUTPUT: --- fail_compilation/retscope5.d(5010): Error: assigning address of variable `t` to `p` with longer lifetime is not allowed in a `@safe` function --- */ #line 5000 // https://issues.dlang.org/show_bug.cgi?id=17725 void test() @safe { int* p; struct T { int a; } void escape(ref T t) @safe { p = &t.a; // should not compile } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test21380.d0000644000175000017500000000255015205374124021152 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21380 /* TEST_OUTPUT: --- fail_compilation/test21380.d(39): Error: partial template instance `MySerializer().serializeSinkType!int` has no value fail_compilation/test21380.d(44): Error: template instance `test21380.SupportSinkTypeSer!(MySerializer!int)` error instantiating --- */ template isSomeFunction(T...) if (T.length == 1) { static if (is(typeof(& T[0]) U : U*) && is(U == function) || is(typeof(& T[0]) U == delegate)) { // T is a (nested) function symbol. enum bool isSomeFunction = true; } else static if (is(T[0] W) || is(typeof(T[0]) W)) { // T is an expression or a type. Take the type of it and examine. static if (is(W F : F*) && is(F == function)) enum bool isSomeFunction = true; // function pointer else enum bool isSomeFunction = is(W == function) || is(W == delegate); } else enum bool isSomeFunction = false; } struct MySerializer (T) { void serializeSinkType(T2) (scope auto ref T2 record) {} } template SupportSinkTypeSer(SerT) { /* Note: Partial template instance because it needs inference, in this case it cannot infer 'auto ref' parameter */ enum SupportSinkTypeSer = isSomeFunction!(SerT.init.serializeSinkType!int); } int main() { enum x = SupportSinkTypeSer!(MySerializer!int); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11086.d0000644000175000017500000000023415205374124020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11086.d(10): Error: template instance `foo!A` template `foo` is not defined --- */ struct A { foo!(A) l1,l2; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag10141.d0000644000175000017500000000047315205374124021072 0ustar fabiofabio/* EXTRA_FILES: imports/diag10141a.d imports/diag10141b.d TEST_OUTPUT: --- fail_compilation/diag10141.d(10): Error: module `imports.diag10141a` import `unexisting_symbol` not found --- */ import imports.diag10141a; import imports.diag10141a : unexisting_symbol; Tuple!(int) fun() { return Tuple!(int).init; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test16694.d0000644000175000017500000000024715205374124021167 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test16694.d(8): Error: cannot take address of imported symbol `bar` at compile time --- */ export void bar(); auto barptr = &bar; ./ldc-1.42.0-src/tests/dmd/fail_compilation/malformed_cmain.d0000644000175000017500000000166115205374124022714 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/malformed_cmain.d($n$): Error: function `malformed_cmain.main` parameters must match one of the following signatures fail_compilation/malformed_cmain.d($n$): `main()` fail_compilation/malformed_cmain.d($n$): `main(int argc, char** argv)` fail_compilation/malformed_cmain.d($n$): `main(int argc, char** argv, char** environ)` [POSIX extension] --- ARG_SETS: -version=A ARG_SETS: -version=B ARG_SETS: -version=C ARG_SETS: -version=D ARG_SETS: -version=E ARG_SETS: -version=F ARG_SETS: -version=G +/ extern(C): version (A) int main(char) { return 0; } else version (B) int main(int, char) { return 0; } else version (C) int main(int, char**, bool) { return 0; } else version (D) int main(int, char**...) { return 0; } else version (E) int main(int...) { return 0; } else version (F) int main(lazy int, char**) { return 0; } else version (G) int main(int, ref char**) { return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail177.d0000644000175000017500000000127415205374124020751 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail177.d(22): Error: cannot modify `immutable` expression `j` fail_compilation/fail177.d(24): Error: cannot modify `const` expression `i` fail_compilation/fail177.d(26): Error: cannot modify `const` expression `s1.x` fail_compilation/fail177.d(27): Error: cannot modify `const` expression `*s1.p` fail_compilation/fail177.d(29): Error: cannot modify `const` expression `s2.x` fail_compilation/fail177.d(30): Error: cannot modify `const` expression `*s2.p` --- */ struct S { int x; int* p; } void test(const(S) s1, const S s2, const(int) i) { immutable int j = 3; j = 4; i = 4; s1.x = 3; *s1.p = 4; s2.x = 3; *s2.p = 4; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail170.d0000644000175000017500000000024715205374124020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail170.d(8): Error: variable `fail170.foo.x` cannot be `final`, perhaps you meant `const`? --- */ void foo(final out int x) { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice17074.d0000644000175000017500000000053315205374124020737 0ustar fabiofabio/* */ extern(C++, std.__overloadset) void ice_std_keyword(); /* TEST_OUTPUT: --- fail_compilation/ice17074.d(13): Error: identifier expected for C++ namespace fail_compilation/ice17074.d(13): Error: found `*` when expecting `)` fail_compilation/ice17074.d(13): Error: declaration expected, not `)` --- */ extern(C++, std.*) void ice_std_token(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11974.d0000644000175000017500000000020615205374124020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11974.d(7): Error: cannot modify constant `0` --- */ void main() { 0 = __LINE__ ^^ [ 0 ] ; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12040.d0000644000175000017500000000017615205374124020726 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12040.d(8): Error: circular reference to `ice12040.lol` --- */ bool[lol.length] lol; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9301.d0000644000175000017500000000033315205374124021022 0ustar fabiofabio/* REQUIRED_ARGS: -m64 -o- TEST_OUTPUT: --- fail_compilation/fail9301.d(11): Error: cannot implicitly convert expression `0` of type `int` to `__vector(void[16])` --- */ void main() { __vector(void[16]) x = 0x0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test13786.d0000644000175000017500000000056615205374124021172 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test13786.d(12): Error: debug `abc` declaration must be at module level fail_compilation/test13786.d(13): Error: version `abc` declaration must be at module level fail_compilation/test13786.d(16): Error: template instance `test13786.T!()` error instantiating --- */ template T() { debug = abc; version = abc; } alias X = T!(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/failsafec.d0000644000175000017500000000036515205374124021514 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/failsafec.d(13): Error: `@safe` function `failsafec.callingsystem` cannot call `@system` delegate `sysdelegate` --- */ void delegate() @system sysdelegate; @safe void callingsystem() { sysdelegate(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test8556.d0000644000175000017500000000255415205374124021110 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test8556.d(24): Error: template instance `test8556.Grab!(Circle!(uint[]))` does not match template declaration `Grab(Range)` with `Range = Circle!(uint[])` must satisfy the following constraint: ` !isSliceable!Range` fail_compilation/test8556.d(55): Error: template instance `test8556.grab!(Circle!(uint[]))` error instantiating --- */ extern(C) int printf(const char*, ...); template isSliceable(R) { enum bool isSliceable = is(typeof( R.init[1 .. 2] )); } struct Grab(Range) if (!isSliceable!Range) { public Range source; } Grab!R grab(R)(R input) { return Grab!R(input); } // 3. evaluate isSliceable in template constraint auto grabExactly(R)(R range) if (!isSliceable!R) { return 0; } auto grabExactly(R)(R range) if ( isSliceable!R) { return 0; } struct Circle(Range) { // 2. auto return opSlice auto opSlice(size_t i, size_t j) { //pragma(msg, typeof(opSlice)); // prints "fwdref err" with B, but doesn't with A printf("%d %d\n", cast(int)i, cast(int)j); assert(j >= i); // 1. grabExactly curcular refers this opSlice. return grabExactly(typeof(this)()); // broken execution with A } } Circle!R circle(R)() { return Circle!R(); } void main() { auto t = grab(circle!(uint[])()); auto cx = circle!(uint[])(); auto slice = cx[23 .. 33]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/parse19277.d0000644000175000017500000000143615205374124021323 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/parse19277.d(13): Deprecation: storage class `ref` has no effect in type aliases fail_compilation/parse19277.d(14): Deprecation: storage class `__gshared` has no effect in type aliases fail_compilation/parse19277.d(15): Deprecation: storage class `static` has no effect in type aliases fail_compilation/parse19277.d(16): Deprecation: storage class `extern` has no effect in type aliases fail_compilation/parse19277.d(17): Deprecation: storage class `scope` has no effect in type aliases --- */ alias T = ref int; alias U = __gshared int; alias V = static int; alias W = extern int; alias Dg = scope void delegate(); alias F = ref pure nothrow @nogc @safe @live int function(); alias G = ref pure nothrow @nogc @system @live int delegate(); ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail249.d0000644000175000017500000000037615205374124020753 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail249.d(16): Error: invalid `foreach` aggregate `bar()` of type `void` --- */ module main; public void bar() { } void main() { foreach (Object o; bar()) { debug Object foo = null; //error } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fix19018.d0000644000175000017500000000121415205374124020762 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fix19018.d(16): Error: `0b` isn't a valid integer literal, use `0b0` instead fail_compilation/fix19018.d(17): Error: `0B` isn't a valid integer literal, use `0B0` instead fail_compilation/fix19018.d(18): Error: `0x` isn't a valid integer literal, use `0x0` instead fail_compilation/fix19018.d(19): Error: `0X` isn't a valid integer literal, use `0X0` instead fail_compilation/fix19018.d(20): Error: `0x_` isn't a valid integer literal, use `0x0` instead --- */ // https://issues.dlang.org/show_bug.cgi?id=19018 void foo() { auto a = 0b; auto b = 0B; auto c = 0x; auto d = 0X; auto e = 0x_; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail150.d0000644000175000017500000000041115205374124020730 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail150.d(22): Error: `.new` is only for allocating nested classes --- */ //import std.stdio; class Class1 { } class Foo { } int main(char[][] argv) { Class1 myclass = new Class1; myclass.new Foo(); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failexpression1.d0000644000175000017500000003472615205374124022723 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte += float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte -= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte *= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte /= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte %= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte += double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte -= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte *= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte /= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte %= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte += real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte -= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte *= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte /= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `byte %= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte += float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte -= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte *= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte /= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte %= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte += double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte -= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte *= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte /= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte %= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte += real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte -= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte *= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte /= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ubyte %= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short += float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short -= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short *= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short /= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short %= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short += double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short -= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short *= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short /= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short %= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short += real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short -= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short *= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short /= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `short %= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort += float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort -= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort *= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort /= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort %= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort += double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort -= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort *= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort /= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort %= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort += real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort -= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort *= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort /= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ushort %= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int += float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int -= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int *= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int /= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int %= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int += double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int -= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int *= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int /= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int %= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int += real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int -= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int *= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int /= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `int %= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint += float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint -= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint *= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint /= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint %= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint += double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint -= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint *= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint /= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint %= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint += real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint -= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint *= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint /= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `uint %= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long += float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long -= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long *= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long /= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long %= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long += double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long -= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long *= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long /= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long %= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long += real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long -= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long *= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long /= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `long %= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong += float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong -= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong *= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong /= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong %= float` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong += double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong -= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong *= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong /= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong %= double` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong += real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong -= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong *= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong /= real` is performing truncating conversion fail_compilation/failexpression1.d-mixin-138(138): Deprecation: `ulong %= real` is performing truncating conversion fail_compilation/failexpression1.d(148): Error: template instance `failexpression1.X!(integral, floating, arith)` error instantiating fail_compilation/failexpression1.d(153): instantiated from here: `OpAssignCases!(TestOpAssign)` --- */ template TT(T...) { alias T TT; } void TestOpAssign(Tx, Ux, ops)() { foreach(T; Tx.x) foreach(U; Ux.x) foreach(op; ops.x) { T a = cast(T)1; mixin("a " ~ op ~ " cast(U)1;"); } } struct integral { alias TT!(byte, ubyte, short, ushort, int, uint, long, ulong) x; } struct floating { alias TT!(float, double, real) x; } struct arith { alias TT!("+=", "-=", "*=", "/=", "%=") x; } void OpAssignCases(alias X)() { X!(integral, floating, arith)(); } void main() { OpAssignCases!TestOpAssign(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/warn7444.d0000644000175000017500000000254015205374124021066 0ustar fabiofabio// REQUIRED_ARGS: -w /* TEST_OUTPUT: --- fail_compilation/warn7444.d(22): Error: cannot implicitly convert expression `e` of type `int` to `int[]` --- */ void test7444() { int[2] sa; int[] da; int e; { // X: Changed accepts-invalid to rejects-invalid by this issue // a: slice assignment // b: element-wise assignment sa = e; // X sa[] = e; // b da = e; da[] = e; // b // lhs is static array sa = sa; // b == identity assign sa = sa[]; // X sa[] = sa; // X sa[] = sa[]; // b sa = da; // X sa = da[]; // X sa[] = da; // X sa[] = da[]; // b // lhs is dynamic array da = sa; // X da = sa[]; // a da[] = sa; // X da[] = sa[]; // b da = da; // a == identity assign da = da[]; // a da[] = da; // X da[] = da[]; // b } } /* TEST_OUTPUT: --- No warning --- */ void test10214() { bool[1] arr; arr = 0; pragma(msg, "No warning"); } /* TEST_OUTPUT: --- No warning --- */ struct S11228 { int[2] ii; alias ii this; } void test11228() { S11228 s; int[2] ii; ii = s.ii; // OK ii = s; // OK <- Warning pragma(msg, "No warning"); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail72.d0000644000175000017500000000022215205374124020653 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail72.d(10): Error: undefined identifier `foo` --- */ void main() { synchronized( foo ) { } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7861.d0000644000175000017500000000042415205374124021034 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7861.d(18): Error: no property `nonexistent` for type `test.B` fail_compilation/fail7861.d(14): struct `B` defined here --- */ module test; mixin template A() { import test; } struct B { mixin A!(); } enum C = B.nonexistent; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11850.d0000644000175000017500000000066615205374124020742 0ustar fabiofabio/* EXTRA_FILES: imports/a11850.d TEST_OUTPUT: --- fail_compilation/ice11850.d(15): Error: incompatible types for `(a) < ([0])`: `uint[]` and `int[]` fail_compilation/imports/a11850.d(9): instantiated from here: `FilterResult!(__lambda_L15_C13, uint[][])` fail_compilation/ice11850.d(15): instantiated from here: `filter!(uint[][])` --- */ import imports.a11850 : filter; void main() { filter!(a => a < [0])([[0u]]); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23056.c0000644000175000017500000000060615205374124021153 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23056.c(101): Error: function `test23056.test` no return value from function fail_compilation/test23056.c(102): called from here: `test()` fail_compilation/test23056.c(102): while evaluating: `static assert(test())` --- */ /* https://issues.dlang.org/show_bug.cgi?id=23056 */ #line 100 int test(void){} _Static_assert(test(), ""); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice11793.d0000644000175000017500000000025515205374124020742 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice11793.d(11): Error: circular reference to `ice11793.Outer.outer` --- */ class Outer { int foo; Outer outer = new Outer(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6334.d0000644000175000017500000000062315205374124021027 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail6334.d(13): Error: static assert: `0` is false fail_compilation/fail6334.d(11): instantiated from here: `mixin T2!();` --- */ mixin template T1() { mixin T2; //compiles if these lines mixin T2!(a, bb, ccc, dddd); //are before T2 declaration mixin template T2() { static assert(0); } } void main() { mixin T1; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail101.d0000644000175000017500000000042115205374124020725 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail101.d(9): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead fail_compilation/fail101.d(9): Error: cannot implicitly convert expression `1` of type `int` to `creal` --- */ creal c = 1; ./ldc-1.42.0-src/tests/dmd/fail_compilation/test18480.d0000644000175000017500000000072015205374124021156 0ustar fabiofabio// REQUIRED_ARGS: -i /* TEST_OUTPUT: --- fail_compilation/imports/test18480a.d(2): Error: `alias TestTemplate = TestTemplate;` cannot alias itself, use a qualified name to create an overload set fail_compilation/imports/test18480a.d(2): Error: alias `test18480a.TestTemplate` conflicts with alias `test18480a.TestTemplate` at fail_compilation/imports/test18480a.d(1) --- https://issues.dlang.org/show_bug.cgi?id=18480 */ import imports.test18480a : TestTemplate; ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag6717.d0000644000175000017500000000027115205374124021024 0ustar fabiofabio/* DISABLED: LDC_not_x86 TEST_OUTPUT: --- fail_compilation/diag6717.d(12): Error: end of instruction expected, not `h` --- */ void main() { asm { mov AX, 12h ; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail223.d0000644000175000017500000000051715205374124020740 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail223.d(14): Error: cannot modify `this.x` in `const` function --- */ //import std.stdio; class A { public: int x = 0; void setX(int nx) const { x = nx; } } void foo(const A a) { a.setX(1); } int main(char[][] args) { A a = new A; foo(a); //writefln(a.x); return 0; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail66.d0000644000175000017500000000225615205374124020667 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail66.d(11): Error: constructor `fail66.C1.this` missing initializer for const field `y` --- */ class C1 { const int y; this() {} } /* TEST_OUTPUT: --- fail_compilation/fail66.d(28): Error: cannot modify `const` expression `c.y` --- */ class C2 { const int y; this() { y = 7; } } void test2() { C2 c = new C2(); c.y = 3; } /* TEST_OUTPUT: --- fail_compilation/fail66.d(43): Error: cannot modify `const` expression `this.y` --- */ class C3 { const int y; this() { y = 7; } void foo() { y = 6; } } /* TEST_OUTPUT: --- fail_compilation/fail66.d(59): Error: cannot modify `const` expression `x` --- */ class C4 { static const int x; shared static this() { x = 5; } void foo() { x = 4; } } /* TEST_OUTPUT: --- fail_compilation/fail66.d(73): Error: cannot modify `const` expression `z5` --- */ const int z5; shared static this() { z5 = 3; } void test5() { z5 = 4; } /* TEST_OUTPUT: --- fail_compilation/fail66.d(89): Error: cannot modify `const` expression `c.y` --- */ class C6 { const int y; this() { C6 c = this; y = 7; c.y = 8; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail5153.d0000644000175000017500000000071415205374124021026 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=5153 /* TEST_OUTPUT: --- fail_compilation/fail5153.d(26): Error: cannot implicitly convert expression `new Foo(0)` of type `Foo*` to `Foo` fail_compilation/fail5153.d(26): Perhaps remove the `new` keyword? --- */ class Foo2 { this(int) {} } struct Foo { int x; this(int x_) { this.x = x_; } this(Foo2) {} } void main() { Foo f = new Foo(0); Foo f2 = new Foo2(0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9865.d0000644000175000017500000000042615205374124020671 0ustar fabiofabio/* EXTRA_FILES: imports/ice9865b.d TEST_OUTPUT: --- fail_compilation/ice9865.d(10): Error: alias `ice9865.Baz` recursive alias declaration fail_compilation/ice9865.d(11): error on member `ice9865.Foo.f` --- */ public import imports.ice9865b : Baz; struct Foo { Baz f; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail19336.d0000644000175000017500000000062115205374124021113 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail19336.d(14): Error: template instance `Template!()` template `Template` is not defined fail_compilation/fail19336.d(14): Error: circular reference to `fail19336.Foo.a` fail_compilation/fail19336.d(17): Error: circular reference to `fail19336.b` --- */ // https://issues.dlang.org/show_bug.cgi?id=19336 struct Foo { Template!() a(a.x); } int b(b.x); ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice10713.d0000644000175000017500000000036415205374124020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice10713.d(11): Error: no property `nonExistingField` for type `ice10713.S` fail_compilation/ice10713.d(9): struct `S` defined here --- */ struct S { void f(typeof(this.nonExistingField) a) {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/issue20627.d0000644000175000017500000000373115205374124021330 0ustar fabiofabio/** REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/issue20627.d(38): Deprecation: `shared static` constructor can only be of D linkage fail_compilation/issue20627.d(39): Deprecation: `shared static` destructor can only be of D linkage fail_compilation/issue20627.d(40): Deprecation: `static` constructor can only be of D linkage fail_compilation/issue20627.d(41): Deprecation: `static` destructor can only be of D linkage fail_compilation/issue20627.d(55): Deprecation: `shared static` constructor can only be of D linkage fail_compilation/issue20627.d(56): Deprecation: `shared static` destructor can only be of D linkage fail_compilation/issue20627.d(57): Deprecation: `static` constructor can only be of D linkage fail_compilation/issue20627.d(58): Deprecation: `static` destructor can only be of D linkage fail_compilation/issue20627.d(63): Deprecation: `shared static` constructor can only be of D linkage fail_compilation/issue20627.d(64): Deprecation: `shared static` destructor can only be of D linkage fail_compilation/issue20627.d(65): Deprecation: `static` constructor can only be of D linkage fail_compilation/issue20627.d(66): Deprecation: `static` destructor can only be of D linkage --- */ // OK, default linkage shared static this () {} shared static ~this () {} static this () {} static ~this () {} // Still okay extern(D) { shared static this () {} shared static ~this () {} static this () {} static ~this () {} } // No! extern(C) { shared static this () {} shared static ~this () {} static this () {} static ~this () {} } // Disabled because platform specific version (none) extern(Objective-C) { shared static this () {} shared static ~this () {} static this () {} static ~this () {} } extern(C++) { shared static this () {} shared static ~this () {} static this () {} static ~this () {} } extern(System) { shared static this () {} shared static ~this () {} static this () {} static ~this () {} } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice19762.d0000644000175000017500000000057715205374124020755 0ustar fabiofabio// This bug wasn't fixed properly, so I've reopened https://issues.dlang.org/show_bug.cgi?id=19762. // DISABLED: LDC // EXTRA_FILES: imports/b19762.d imports/c19762.d // PERMUTE_ARGS: -g /* TEST_OUTPUT: --- fail_compilation/ice19762.d(13): Error: struct `ice19762.X` had semantic errors when compiling --- */ module ice19762; struct X { import imports.b19762 : Baz; Err err; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test22102.c0000644000175000017500000000100615205374124021135 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test22102.c(254): Error: expected identifier for declarator fail_compilation/test22102.c(255): Error: no type-specifier for parameter fail_compilation/test22102.c(255): Error: found `0` when expecting `,` fail_compilation/test22102.c(255): Error: expected identifier for declarator --- */ /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22102 #line 250 typedef int int22102; void test22102() { int22102(); int22102(0); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test15525.d0000644000175000017500000000105115205374124021151 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=15525 /* TEST_OUTPUT: --- fail_compilation/imports/import15525.d(3): Error: parenthesized template parameter list expected following template identifier fail_compilation/imports/import15525.d(3): Error: (expression) expected following `static if` fail_compilation/imports/import15525.d(3): Error: declaration expected, not `}` fail_compilation/test15525.d(16): Error: template instance `Tuple!()` template `Tuple` is not defined --- */ struct CrashMe { import imports.import15525; Tuple!() crash; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail7173.d0000644000175000017500000000046515205374124021035 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail7173.d(23): Error: expression `b1._a.opBinary(b2._a).fun()` is `void` and has no value --- */ struct A{ A opBinary(string op)(A a){ A rt; return rt; } void fun(){ } } struct B{ A _a; alias _a this; } void main(){ B b1, b2, b3; b3 = (b1 - b2).fun(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag8928.d0000644000175000017500000000042515205374124021033 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag8928.d(18): Error: class `diag8928.Z` cannot implicitly generate a default constructor when base class `diag8928.X` is missing a default constructor --- */ class X { this(int n) {} } class Y : X { this() {} } class Z : X { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail6795.d0000644000175000017500000000211215205374124021035 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=6795 /* TEST_OUTPUT: --- fail_compilation/fail6795.d(19): Error: cannot modify expression `[0][0]` because it is not an lvalue fail_compilation/fail6795.d(20): Error: cannot modify expression `[0:0][0]` because it is not an lvalue fail_compilation/fail6795.d(22): Error: cannot modify expression `[0][0]` because it is not an lvalue fail_compilation/fail6795.d(23): Error: cannot modify expression `[0:0][0]` because it is not an lvalue fail_compilation/fail6795.d(25): Error: cannot take address of expression `[0][0]` because it is not an lvalue fail_compilation/fail6795.d(30): Error: cannot modify expression `Some["zz"]` because it is not an lvalue --- */ void test_wrong_line_num() { enum int[1] sa = [0]; enum int[int] aa = [0:0]; sa[0]++; --aa[0]; sa[0] *= 3; aa[0] /= 3; auto ps = &sa[0]; auto pa = &aa[0]; // ok with AA lowering, just as `pa = 0 in aa` // https://issues.dlang.org/show_bug.cgi?id=24845 enum Maps : int[string] { Some = ["aa" : 12], Other = ["bb" : 24] } Maps.Some["zz"] = 44; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/must_use_opunary.d0000644000175000017500000000047715205374124023224 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/must_use_opunary.d(20): Error: ignored value of `@mustuse` type `must_use_opunary.S`; prepend a `cast(void)` if intentional --- +/ import core.attribute; @mustuse struct S { ref S opUnary(string op)() return { return this; } } void test() { S s; -s; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice14923.d0000644000175000017500000000123215205374124020734 0ustar fabiofabio/* TEST_OUTPUT: ---- fail_compilation/ice14923.d(23): Error: function `parse` is not callable using argument types `(A)` fail_compilation/ice14923.d(23): cannot pass argument `b` of type `ice14923.A` to parameter `C a` fail_compilation/ice14923.d(21): `ice14923.parse(C a)` declared here fail_compilation/ice14923.d(23): instantiated from here: `bar!((b) => parse(b))` ---- */ auto bar(alias fun)() { size_t counter; scope(exit) counter++; Object a2; if (auto ai = cast(A)a2) return fun(ai); if (auto ai = cast(B)a2) return fun(ai); } void parse(C a) { bar!(b => parse(b))(); } class A {} class C {} class B : C {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/test23170.d0000644000175000017500000000051515205374124021150 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/test23170.d(10): Error: this array literal causes a GC allocation in `@nogc` delegate `__lambda_L10_C15` --- */ // https://issues.dlang.org/show_bug.cgi?id=23170 @nogc: enum lambda = () => badAlias([1, 2, 3]); alias badAlias = (int[] array) => id(array); int[] id(int[] array) { return array; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail9665a.d0000644000175000017500000001042615205374124021204 0ustar fabiofabio/+ TEST_OUTPUT: --- fail_compilation/fail9665a.d(43): Error: immutable field `v` initialized multiple times fail_compilation/fail9665a.d(42): Previous initialization is here. fail_compilation/fail9665a.d(53): Error: immutable field `v` initialized multiple times fail_compilation/fail9665a.d(52): Previous initialization is here. fail_compilation/fail9665a.d(58): Error: immutable field `v` initialized multiple times fail_compilation/fail9665a.d(57): Previous initialization is here. fail_compilation/fail9665a.d(63): Error: immutable field `v` initialized multiple times fail_compilation/fail9665a.d(62): Previous initialization is here. fail_compilation/fail9665a.d(73): Error: immutable field `v` initialized multiple times fail_compilation/fail9665a.d(72): Previous initialization is here. fail_compilation/fail9665a.d(78): Error: immutable field `v` initialized multiple times fail_compilation/fail9665a.d(77): Previous initialization is here. fail_compilation/fail9665a.d(83): Error: immutable field `v` initialized multiple times fail_compilation/fail9665a.d(82): Previous initialization is here. fail_compilation/fail9665a.d(96): Error: immutable field `v` initialization is not allowed in loops or after labels fail_compilation/fail9665a.d(101): Error: immutable field `v` initialization is not allowed in loops or after labels fail_compilation/fail9665a.d(106): Error: immutable field `v` initialized multiple times fail_compilation/fail9665a.d(105): Previous initialization is here. fail_compilation/fail9665a.d(111): Error: immutable field `v` initialized multiple times fail_compilation/fail9665a.d(110): Previous initialization is here. fail_compilation/fail9665a.d(116): Error: immutable field `v` initialized multiple times fail_compilation/fail9665a.d(115): Previous initialization is here. fail_compilation/fail9665a.d(130): Error: immutable field `v` initialized multiple times fail_compilation/fail9665a.d(129): Previous initialization is here. fail_compilation/fail9665a.d(134): Error: immutable field `w` initialized multiple times fail_compilation/fail9665a.d(133): Previous initialization is here. fail_compilation/fail9665a.d(148): Error: static assert: `__traits(compiles, this.v = 1)` is false --- +/ /***************************************************/ // immutable field struct S1A { immutable int v; this(int) { v = 1; v = 2; // multiple initialization } } struct S1B { immutable int v; this(int) { if (true) v = 1; else v = 2; v = 3; // multiple initialization } this(long) { if (true) v = 1; v = 3; // multiple initialization } this(string) { if (true) {} else v = 2; v = 3; // multiple initialization } } struct S1C { immutable int v; this(int) { true ? (v = 1) : (v = 2); v = 3; // multiple initialization } this(long) { auto x = true ? (v = 1) : 2; v = 3; // multiple initialization } this(string) { auto x = true ? 1 : (v = 2); v = 3; // multiple initialization } } /***************************************************/ // with control flow struct S2 { immutable int v; this(int) { L: v = 1; // after labels } this(long) { foreach (i; 0..1) v = 1; // in loops } this(string) { v = 1; // initialization L: v = 2; // assignment after labels } this(wstring) { v = 1; // initialization foreach (i; 0..1) v = 2; // assignment in loops } this(dstring) { v = 1; return; v = 2; // multiple initialization } } /***************************************************/ // with immutable constructor struct S3 { int v; int w; this(int) immutable { v = 1; v = 2; // multiple initialization if (true) w = 1; w = 2; // multiple initialization } } /***************************************************/ // in __traits(compiles) struct S4 { immutable int v; this(int) { static assert(__traits(compiles, v = 1)); v = 1; static assert(__traits(compiles, v = 1)); // multiple initialization } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/discard_value.d0000644000175000017500000000246315205374124022405 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/discard_value.d(24): Error: the result of the equality expression `3 is 3` is discarded fail_compilation/discard_value.d(25): Error: the result of the equality expression `null !is null` is discarded fail_compilation/discard_value.d(26): Error: the result of the equality expression `v == 0` is discarded fail_compilation/discard_value.d(27): Error: the result of the equality expression `v == 0` is discarded fail_compilation/discard_value.d(28): Error: the result of the equality expression `"" != ""` is discarded fail_compilation/discard_value.d(29): Error: the result of the equality expression `"" == ""` is discarded fail_compilation/discard_value.d(30): Error: the result of the equality expression `fun().i == 4` is discarded fail_compilation/discard_value.d(30): note that `fun().i` may have a side effect fail_compilation/discard_value.d(33): Error: the result of the equality expression `slice == slice[0..0]` is discarded --- */ struct S { int i; } S fun() { return S(42); } int v; void main() { 3 is 3; null !is null; true && v == 0; true || v == 0; "" != ""; "" == ""; // https://issues.dlang.org/show_bug.cgi?id=24359 fun().i == 4; // https://issues.dlang.org/show_bug.cgi?id=12390 int[] slice = [0, 1]; slice == slice[0 .. 0]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail13064.d0000644000175000017500000000025715205374124021110 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail13064.d(8): Error: function `fail13064.f` storage class `auto` has no effect if return type is not inferred --- */ auto void f() { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21091b.d0000644000175000017500000000055515205374124021252 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21091 /* TRANSFORM_OUTPUT: remove_lines("^import path") TEST_OUTPUT: ---- fail_compilation/fail21091b.d(14): Error: unable to read module `Tid` fail_compilation/fail21091b.d(14): Expected 'Tid.d' or 'Tid/package.d' in one of the following import paths: ---- */ class Logger { import Tid; Tid threadId; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/powinline.d0000644000175000017500000000144115205374124021577 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/powinline.d(25): Error: cannot implicitly convert expression `(a + 5.0) ^^ 2L` of type `double` to `int` fail_compilation/powinline.d(26): Error: cannot implicitly convert expression `(1.0 / foo()) ^^ 2L` of type `double` to `int` fail_compilation/powinline.d(31): Error: void has no value fail_compilation/powinline.d(31): Error: incompatible types for `(5.0) * (bar())`: `double` and `void` fail_compilation/powinline.d(37): Error: cannot modify `immutable` expression `a` --- */ double foo() { return 5.0; } void bar() { return; } void test1() { double a = 2.0; int b = (a + 5.0) ^^ 2.0; b = (1 / foo()) ^^ 2.0; } void test2() { double a = (5.0 * bar()) ^^ 2.0; } void test3() { immutable double a = 3.0; (a ^^= 2.0) = 6; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail302.d0000644000175000017500000000113415205374124020732 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail302.d(23): Error: cannot implicitly convert expression `1` of type `int` to `Bar` fail_compilation/fail302.d(23): `bar = 1` is the first assignment of `bar` therefore it represents its initialization fail_compilation/fail302.d(23): `opAssign` methods are not used for initialization, but for subsequent assignments --- */ struct Bar { uint num; Bar opAssign(uint otherNum) { num = otherNum; return this; } } void main() { Bar bar = 1; // disallow because construction is not assignment auto x = bar.num; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/var_func_attr.d0000644000175000017500000000174415205374124022436 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/var_func_attr.d(19): Error: cannot implicitly convert expression `() { static int g; g++; }` of type `void function() nothrow @nogc @safe` to `void function() pure` --- */ // Test the effect of function attributes on variables // See: // https://issues.dlang.org/show_bug.cgi?id=7432 // https://github.com/dlang/dmd/pull/14199 // Usually it's a no-op, but the attribute can apply to the function/delegate type of the variable // The current behavior is weird, so this is a test of the current behavior, not necessarily the desired behavior // No-op pure int x; // Applies to function type (existing code in dmd and Phobos relies on this) pure void function() pf = () { static int g; g++; }; // Function attributes currently don't apply to inferred types (somewhat surprisingly) nothrow nf = () { throw new Exception(""); }; // Neither do they apply to indirections alias F = void function(); pure F pf2 = () { static int g; g++; }; ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail10947.d0000644000175000017500000000230015205374124021106 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail10947.d(21): Error: cannot have `immutable out` parameter of type `immutable(S)` fail_compilation/fail10947.d(22): Error: cannot have `immutable out` parameter of type `immutable(S)` fail_compilation/fail10947.d(23): Error: cannot have `immutable out` parameter of type `immutable(S)` fail_compilation/fail10947.d(25): Error: cannot have `const out` parameter of type `const(S)` fail_compilation/fail10947.d(26): Error: cannot have `const out` parameter of type `const(S)` fail_compilation/fail10947.d(27): Error: cannot have `const out` parameter of type `const(S)` fail_compilation/fail10947.d(29): Error: cannot have `inout out` parameter of type `inout(S)` fail_compilation/fail10947.d(30): Error: cannot have `inout out` parameter of type `inout(S)` fail_compilation/fail10947.d(31): Error: cannot have `inout out` parameter of type `inout(S)` --- */ struct S {} alias SI = immutable S; alias SC = const S; alias SW = inout S; void fooi1(out SI) {} void fooi2(out immutable(S)) {} void fooi3(out immutable S) {} void fooc1(out SC) {} void fooc2(out const(S)) {} void fooc3(out const S) {} void foow1(out SW) {} void foow2(out inout(S)) {} void foow3(out inout S) {} ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail24422.c0000644000175000017500000000020715205374124021102 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail24422.c(7): Error: type-specifier missing for declaration of `a` --- */ void f24422(a) a; { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice12581.d0000644000175000017500000000034615205374124020737 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ice12581.d(21): Error: undefined identifier `undef` --- */ struct S { int[3] a; alias a this; } struct T { S s; alias s this; } void main() { T x; x[] = (undef = 1); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/diag13215.d0000644000175000017500000000037415205374124021077 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/diag13215.d(11): Error: cannot implicitly convert expression `[1, 2, 3]` of type `int[]` to `immutable(uint[2])[]` --- */ enum uint N = 10; immutable uint[2][3] arr2; shared static this() { arr2 = [1, 2, 3]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail124.d0000644000175000017500000000106715205374124020741 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail124.d(17): Error: class `fail124.CC` inherits from duplicate interface `C` fail_compilation/fail124.d(31): Error: class `fail124.D` inherits from duplicate interface `T` fail_compilation/fail124.d(31): Error: class `fail124.D` inherits from duplicate interface `T` --- */ //import std.stdio; interface C { void f(); } class CC : C, C { void f() { /*writefln("hello");*/ } } void main() { CC cc = new CC(); cc.f(); } // https://issues.dlang.org/show_bug.cgi?id=20830 interface T { } class D : T, T, T { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/jsonBadField1.d0000644000175000017500000000050515205374124022200 0ustar fabiofabio/* LDC: just a different error msg DISABLED: LDC REQUIRED_ARGS: -Xi=UNKNOWN_FIELD_NAME TEST_OUTPUT: --- Error: unknown JSON field `-Xi=UNKNOWN_FIELD_NAME`, expected one of `compilerInfo`, `buildInfo`, `modules`, `semantics` run `dmd` to print the compiler manual run `dmd -man` to open browser on manual --- */ ./ldc-1.42.0-src/tests/dmd/fail_compilation/ice9545.d0000644000175000017500000000042115205374124020657 0ustar fabiofabio// REQUIRED_ARGS: -o- /* TEST_OUTPUT: ---- fail_compilation/ice9545.d(14): Error: type `int` has no value fail_compilation/ice9545.d(14): perhaps use `int.init` ---- */ struct S { template T(X) { alias T = X; } } void main() { auto x1 = S.init.T!int; // ICE } ./ldc-1.42.0-src/tests/dmd/fail_compilation/mixintype2.d0000644000175000017500000000114515205374124021704 0ustar fabiofabio /* TEST_OUTPUT: --- fail_compilation/mixintype2.d(13): Error: alias `mixintype2.Foo.T` recursive alias declaration fail_compilation/mixintype2.d(19): Error: `mixin(0)` does not give a valid type fail_compilation/mixintype2.d(20): Error: unexpected token `{` after type `int()` fail_compilation/mixintype2.d(20): while parsing string mixin type `int() {}` fail_compilation/mixintype2.d(20): Error: `mixin(_error_)` 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; mixin("int() {}") f; ./ldc-1.42.0-src/tests/dmd/fail_compilation/ctfeblock.d0000644000175000017500000000105215205374124021525 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/ctfeblock.d(112): Error: cannot `goto` into `if (__ctfe)` block --- */ /*******************************************/ // https://issues.dlang.org/show_bug.cgi?id=18472 // https://github.com/dlang/dmd/pull/14676 #line 100 struct T { } @nogc void test1() { int a; if (__ctfe) { L1: new T(); a = 3; } goto L1; } @nogc void test2() { if (__ctfe) { new T(); } } @nogc void test3() { if (!__ctfe) { } else { int* p = new int; } } ./ldc-1.42.0-src/tests/dmd/fail_compilation/impconv.d0000644000175000017500000000342415205374124021251 0ustar fabiofabio/* FIXME: DMD host compilers < 2.073 with faulty optimization lead to unfortunate test failures, see https://github.com/dlang/dmd/pull/6831#issuecomment-304495842. DISABLED: win32 win64 linux osx freebsd openbsd */ /* TEST_OUTPUT: --- fail_compilation/impconv.d(30): Error: function `impconv.foo_float(float)` is not callable using argument types `(int)` fail_compilation/impconv.d(30): cannot pass argument `-2147483647` of type `int` to parameter `float` fail_compilation/impconv.d(31): Error: function `impconv.foo_float(float)` is not callable using argument types `(uint)` fail_compilation/impconv.d(31): cannot pass argument `4294967295u` of type `uint` to parameter `float` fail_compilation/impconv.d(34): Error: function `impconv.foo_double(double)` is not callable using argument types `(long)` fail_compilation/impconv.d(34): cannot pass argument `-9223372036854775807L` of type `long` to parameter `double` fail_compilation/impconv.d(35): Error: function `impconv.foo_double(double)` is not callable using argument types `(ulong)` fail_compilation/impconv.d(35): cannot pass argument `18446744073709551615LU` of type `ulong` to parameter `double` --- */ void foo_float(float); void foo_double(double); void foo_real(real); void main() { foo_float(1); // implicitly convertible to float foo_float(-int.max); // -(2^31 - 1) foo_float(uint.max); // 2^32 - 1 foo_double(int.max); // implicitly convertible to double foo_double(-long.max); // -(2^63 - 1) foo_double(ulong.max); // 2^64 - 1 foo_real(0xffff_ffff_ffffL); // 2^48 - 1, implicitly convertible to real static assert(__traits(compiles, foo_real(-long.max)) == (real.mant_dig >= 63)); static assert(__traits(compiles, foo_real(ulong.max)) == (real.mant_dig >= 64)); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail21508_2.d0000644000175000017500000000037215205374124021331 0ustar fabiofabio/* REQUIRED_ARGS: -Ifail_compilation/imports/ EXTRA_FILES: imports/import21508.d TEST_OUTPUT: --- fail_compilation/fail21508_2.d(11): Error: import `fail21508_2.import21508` is used as a type --- */ import import21508; class Other : import21508 { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/test19107.d0000644000175000017500000000114615205374124021156 0ustar fabiofabio/* EXTRA_FILES: imports/imp19661.d imports/test19107a.d imports/test19107b.d TEST_OUTPUT: --- fail_compilation/test19107.d(24): Error: template `all` is not callable using argument types `!((c) => c)(string[])` fail_compilation/test19107.d(18): Candidate is: `all(alias pred, T)(T t)` with `pred = (c) => c, T = string[]` must satisfy the following constraint: ` 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); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/failexpression4.d0000644000175000017500000004424515205374124022723 0ustar fabiofabio/* REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a + 1.0F` of type `float` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a - 1.0F` of type `float` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a * 1.0F` of type `float` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a / 1.0F` of type `float` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a % 1.0F` of type `float` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a + 1.0` of type `double` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a - 1.0` of type `double` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a * 1.0` of type `double` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a / 1.0` of type `double` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a % 1.0` of type `double` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a + 1.0L` of type `real` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a - 1.0L` of type `real` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a * 1.0L` of type `real` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a / 1.0L` of type `real` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a % 1.0L` of type `real` to `byte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a + 1.0F` of type `float` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a - 1.0F` of type `float` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a * 1.0F` of type `float` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a / 1.0F` of type `float` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a % 1.0F` of type `float` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a + 1.0` of type `double` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a - 1.0` of type `double` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a * 1.0` of type `double` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a / 1.0` of type `double` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a % 1.0` of type `double` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a + 1.0L` of type `real` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a - 1.0L` of type `real` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a * 1.0L` of type `real` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a / 1.0L` of type `real` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a % 1.0L` of type `real` to `ubyte` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a + 1.0F` of type `float` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a - 1.0F` of type `float` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a * 1.0F` of type `float` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a / 1.0F` of type `float` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a % 1.0F` of type `float` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a + 1.0` of type `double` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a - 1.0` of type `double` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a * 1.0` of type `double` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a / 1.0` of type `double` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a % 1.0` of type `double` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a + 1.0L` of type `real` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a - 1.0L` of type `real` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a * 1.0L` of type `real` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a / 1.0L` of type `real` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a % 1.0L` of type `real` to `short` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a + 1.0F` of type `float` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a - 1.0F` of type `float` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a * 1.0F` of type `float` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a / 1.0F` of type `float` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)cast(int)a % 1.0F` of type `float` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a + 1.0` of type `double` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a - 1.0` of type `double` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a * 1.0` of type `double` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a / 1.0` of type `double` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)cast(int)a % 1.0` of type `double` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a + 1.0L` of type `real` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a - 1.0L` of type `real` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a * 1.0L` of type `real` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a / 1.0L` of type `real` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)cast(int)a % 1.0L` of type `real` to `ushort` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a + 1.0F` of type `float` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a - 1.0F` of type `float` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a * 1.0F` of type `float` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a / 1.0F` of type `float` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a % 1.0F` of type `float` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a + 1.0` of type `double` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a - 1.0` of type `double` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a * 1.0` of type `double` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a / 1.0` of type `double` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a % 1.0` of type `double` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a + 1.0L` of type `real` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a - 1.0L` of type `real` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a * 1.0L` of type `real` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a / 1.0L` of type `real` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a % 1.0L` of type `real` to `int` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a + 1.0F` of type `float` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a - 1.0F` of type `float` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a * 1.0F` of type `float` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a / 1.0F` of type `float` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a % 1.0F` of type `float` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a + 1.0` of type `double` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a - 1.0` of type `double` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a * 1.0` of type `double` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a / 1.0` of type `double` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a % 1.0` of type `double` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a + 1.0L` of type `real` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a - 1.0L` of type `real` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a * 1.0L` of type `real` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a / 1.0L` of type `real` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a % 1.0L` of type `real` to `uint` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a + 1.0F` of type `float` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a - 1.0F` of type `float` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a * 1.0F` of type `float` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a / 1.0F` of type `float` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a % 1.0F` of type `float` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a + 1.0` of type `double` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a - 1.0` of type `double` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a * 1.0` of type `double` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a / 1.0` of type `double` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a % 1.0` of type `double` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a + 1.0L` of type `real` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a - 1.0L` of type `real` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a * 1.0L` of type `real` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a / 1.0L` of type `real` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a % 1.0L` of type `real` to `long` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a + 1.0F` of type `float` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a - 1.0F` of type `float` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a * 1.0F` of type `float` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a / 1.0F` of type `float` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(float)a % 1.0F` of type `float` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a + 1.0` of type `double` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a - 1.0` of type `double` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a * 1.0` of type `double` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a / 1.0` of type `double` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(double)a % 1.0` of type `double` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a + 1.0L` of type `real` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a - 1.0L` of type `real` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a * 1.0L` of type `real` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a / 1.0L` of type `real` to `ulong` fail_compilation/failexpression4.d-mixin-139(139): Error: cannot implicitly convert expression `cast(real)a % 1.0L` of type `real` to `ulong` fail_compilation/failexpression4.d(149): Error: template instance `failexpression4.X!(integral, floating, arith)` error instantiating fail_compilation/failexpression4.d(154): instantiated from here: `OpReAssignCases!(TestOpAndAssign)` --- */ template TT(T...) { alias T TT; } void TestOpAndAssign(Tx, Ux, ops)() { foreach(T; Tx.x) foreach(U; Ux.x) foreach(op; ops.x) { T a = cast(T)1; U b = cast(U)1; mixin("a = a " ~ op[0..$-1] ~ " cast(U)1;"); } } struct integral { alias TT!(byte, ubyte, short, ushort, int, uint, long, ulong) x; } struct floating { alias TT!(float, double, real) x; } struct arith { alias TT!("+=", "-=", "*=", "/=", "%=") x; } void OpReAssignCases(alias X)() { X!(integral, floating, arith)(); } void main() { OpReAssignCases!TestOpAndAssign(); } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail15.d0000644000175000017500000000055715205374124020663 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail15.d(24): Error: cannot use `[]` operator on expression of type `void` --- */ /* Segfault on DMD 0.095 https://www.digitalmars.com/d/archives/digitalmars/D/bugs/926.html */ module test; template Test() { bool opIndex(bool x) { return !x; } } void main() { mixin Test!() xs; bool x = xs[false]; } ./ldc-1.42.0-src/tests/dmd/fail_compilation/fail3673b.d0000644000175000017500000000072315205374124021175 0ustar fabiofabio/* TEST_OUTPUT: --- fail_compilation/fail3673b.d(12): Error: basic type expected, not `if` fail_compilation/fail3673b.d(12): Error: template constraints only allowed for templates fail_compilation/fail3673b.d(12): Error: { } expected following `class` declaration fail_compilation/fail3673b.d(12): Error: variable name expected after type `A`, not `{` fail_compilation/fail3673b.d(12): Error: declaration expected, not `{` --- */ class A {} class B : if(false) A { } ./ldc-1.42.0-src/tests/dmd/fail_compilation/needspkgmod2.d0000644000175000017500000000040015205374124022147 0ustar fabiofabio/* DISABLED: LDC // `-i=` is equivalent to `-i` for LDC REQUIRED_ARGS: -i= TEST_OUTPUT: ---- Error: invalid option '-i=', module patterns cannot be empty run `dmd` to print the compiler manual run `dmd -man` to open browser on manual ---- */ ./ldc-1.42.0-src/tests/dmd/dshell/0000755000175000017500000000000015205374124015370 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/dshell/imports/0000755000175000017500000000000015205374124017065 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/dshell/imports/issue22804_2.d0000644000175000017500000000010515205374124021177 0ustar fabiofabiomodule issue22804_2; string[] foo(string str) { return [str]; } ./ldc-1.42.0-src/tests/dmd/dshell/imports/depsprot_public.d0000644000175000017500000000001615205374124022425 0ustar fabiofabiovoid pub() {} ./ldc-1.42.0-src/tests/dmd/dshell/imports/depsprot_private.d0000644000175000017500000000001715205374124022622 0ustar fabiofabiovoid priv() {} ./ldc-1.42.0-src/tests/dmd/dshell/imports/depsprot_default.d0000644000175000017500000000001715205374124022574 0ustar fabiofabiovoid pack() {} ./ldc-1.42.0-src/tests/dmd/dshell/imports/issue22804_1.d0000644000175000017500000000002515205374124021177 0ustar fabiofabiomodule issue22804_1; ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/0000755000175000017500000000000015205374124017613 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/dshell/extra-files/defaults/0000755000175000017500000000000015205374124021422 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/dshell/extra-files/defaults/hello.d0000644000175000017500000000020215205374124022664 0ustar fabiofabio// A common yet underrated D program module defaults.hello; import std.stdio; void main() { writeln("Hello, World from D!"); } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dll/0000755000175000017500000000000015205374124020366 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dll/mydll.d0000644000175000017500000000233615205374124021660 0ustar fabiofabiomodule mydll; export: __gshared int saved_var; int multiply10(int x) { saved_var = x; return x * 10; } struct S { int i; export int add(int j) { return i += j; } } // https://issues.dlang.org/show_bug.cgi?id=9729 interface I9729 { C9729 foo(I9729); export static C9729 create() { return new C9729(); } } class C9729 : I9729 { int x, y; export C9729 foo(I9729 i) { return cast(C9729) i; } } // https://issues.dlang.org/show_bug.cgi?id=10462 void call10462(int delegate() dg) { assert(dg() == 7); } interface I10462 { int opCall(); } class C10462 : I10462 { int opCall() { return 7; } } void test10462_dll() { I10462 i = new C10462; call10462(&i.opCall); } // https://issues.dlang.org/show_bug.cgi?id=19660 extern (C) { __gshared int someValue19660 = 0xF1234; void setSomeValue19660(int v) { someValue19660 = v; } int getSomeValue19660() { return someValue19660; } } extern (C++) { __gshared int someValueCPP19660 = 0xF1234; void setSomeValueCPP19660(int v) { someValueCPP19660 = v; } int getSomeValueCPP19660() { return someValueCPP19660; } } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dll/dllmain.d0000644000175000017500000000126715205374124022161 0ustar fabiofabiomodule dllmain; import core.sys.windows.windows; import core.sys.windows.dll; __gshared HINSTANCE g_hInst; extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { switch (ulReason) { case DLL_PROCESS_ATTACH: g_hInst = hInstance; dll_process_attach(hInstance, true); break; case DLL_PROCESS_DETACH: dll_process_detach(hInstance, true); break; case DLL_THREAD_ATTACH: dll_thread_attach(true, true); break; case DLL_THREAD_DETACH: dll_thread_detach(true, true); break; default: } return true; } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dll/testdll.d0000644000175000017500000000311115205374124022202 0ustar fabiofabioimport mydll; void test1() { int n1 = mydll.multiply10(2); assert(mydll.saved_var == 2); assert(n1 == 20); } void test2() { auto pvar = &mydll.saved_var; auto funcptr = &mydll.multiply10; int n2 = funcptr(4); assert(mydll.saved_var == 4); assert(*pvar == 4); assert(n2 == 40); } void test3() { S s; assert(s.add(2) == 2); assert(s.add(2) == 4); } void test9729() { I9729 i = I9729.create(); C9729 c = i.foo(i); assert(c is i); } void test10462() { test10462_dll(); } // https://issues.dlang.org/show_bug.cgi?id=19660 extern (C) { export extern __gshared int someValue19660; export void setSomeValue19660(int v); export int getSomeValue19660(); } extern (C++) { export extern __gshared int someValueCPP19660; export void setSomeValueCPP19660(int v); export int getSomeValueCPP19660(); } void test19660() { assert(someValue19660 == 0xF1234); assert(getSomeValue19660() == 0xF1234); setSomeValue19660(100); assert(someValue19660 == 100); assert(getSomeValue19660() == 100); someValue19660 = 200; assert(someValue19660 == 200); assert(getSomeValue19660() == 200); assert(someValueCPP19660 == 0xF1234); assert(getSomeValueCPP19660() == 0xF1234); setSomeValueCPP19660(100); assert(someValueCPP19660 == 100); assert(getSomeValueCPP19660() == 100); someValueCPP19660 = 200; assert(someValueCPP19660 == 200); assert(getSomeValueCPP19660() == 200); } void main() { test1(); test2(); test3(); test9729(); test10462(); test19660(); } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/cpp_header_gen/0000755000175000017500000000000015205374124022536 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/dshell/extra-files/cpp_header_gen/app.cpp0000644000175000017500000000343315205374124024025 0ustar fabiofabio#include "library.h" #include int main() { char name[] = "Header"; const int length = sizeof(name) - 1; C* c = C::create(name, length); assert(c); assert(c->s.i == length); assert(!c->s.b); assert(c->name.ptr == name); assert(c->name.length == length); assert(c->name[1] == 'e'); assert(const_cast(c)->name[2] == 'a'); c->verify(); assert(foo(c->s) == bar(c)); c->s.multiply(c->s); assert(c->s.i == length * length); assert(c->s.b); U u; u.b = false; toggle(u); assert(u.b); assert(3 <= PI && PI <= 4); assert(counter = 42); assert(Weather::Sun != Weather::Rain); assert(Weather::Rain != Weather::Storm); S2 s2; s2.s = c->s; WithTuple wt = createTuple(); // printf("\n(%d, %f)\n\n", wt.__memberTuple_field_0, wt.__memberTuple_field_1); assert(wt.__memberTuple_field_0_ == 1); assert(wt.__memberTuple_field_1_ == 2.0); // printf("\n(%d, %f)\n\n", __globalTuple_field_0, __globalTuple_field_1); // Omitted because a leading __ implies a reserved name // assert(__globalTuple_field_0 == 3); // assert(__globalTuple_field_1 == 4.0); tupleFunction(5, 6.0); assert(vtable->callable_2() == 2); assert(vtable->callable_4() == 4); assert(vtable->callable_6() == 6); #if !defined(_WIN64) // The call segfaults on Win64, probably an unrelated (ABI?) bug assert(templated(Templated(4)).t == 4); #endif int i; assert(&i == inoutFunc(&i)); InvalidNames invalidNames; invalidNames.register_ = Pass::inline_; invalidNames.foo(Pass::inline_); { // Disallowed, would skip the dtor // RequiresDummy dummy; acceptDummy(nullptr); } assert(fromMixin(2, 4) == 8); return 0; } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/cpp_header_gen/library.d0000644000175000017500000000505615205374124024355 0ustar fabiofabiomodule library; version (D_ObjectiveC) import core.attribute : selector; extern (C++): int foo(ref const S s) { return s.i; } int bar(const C c) { return c.s.i; } /* // TODO: Seems not implemented yet interface I { void verify(); } */ class C // : I { S s; char[] name; extern(D) this(ref S s, char[] name) { this.s = s; this.name = name; } static C create(char* name, const int length) { auto s = S(length, length & 1); return new C(s, name[0 .. length]); } void verify() { assert(s.i == 6); assert(!s.b); assert(name == "Header"); } } struct S { int i; bool b = true; void multiply(ref const S other) { i *= other.i; b = b || !other.b; } } union U { int a; bool b; } void toggle(ref U u) { u.b = !u.b; } // FIXME: Generates non-existant global // enum PI = 3.141; // extern _d_double PI; __gshared const PI = 3.141; __gshared int counter = 42; enum Weather { Sun, Rain, Storm } static if (true) { struct S2 { S s; } } alias AliasSeq(T...) = T; __gshared AliasSeq!(int, double) globalTuple = AliasSeq!(3, 4.0); void tupleFunction(AliasSeq!(int, double) argTuple) { assert(argTuple[0] == 5); assert(argTuple[1] == 6.0); } struct WithTuple { AliasSeq!(int, double) memberTuple; } WithTuple createTuple() { return WithTuple(1, 2.0); } extern(C++) class VTable { extern(D) int hidden_1() { return 1; } int callable_2() { return 2; } version (D_ObjectiveC) extern(Objective-C) int hidden_3() @selector("hidden_3") { return 3; } int callable_4() { return 4; } extern(D) final int hidden_5() { return 5; } int callable_6() { return 6; } } extern(C++) __gshared VTable vtable = new VTable(); extern(C++) struct TemplatedStruct(T) { T t; this(T t) { this.t = t; } } alias Templated = TemplatedStruct; extern(C++) Templated!int templated(Templated!(Templated!int) i) { return typeof(return)(i.t.t); } inout(int)* inoutFunc(inout int* ptr) { return ptr; } enum Pass { inline = 10 } struct InvalidNames(typename) { typename register; void foo(typename and) { assert(register == and); } } void useInvalid(InvalidNames!Pass) {} struct RequiresDummy { extern(D): ~this() {} } ref RequiresDummy acceptDummy(RequiresDummy* dummy) { return *dummy; } mixin template CreateModuleMembers() { int fromMixin(int a, int b) { return a * b; } } mixin CreateModuleMembers!(); ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/test6952/0000755000175000017500000000000015205374124021120 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/dshell/extra-files/test6952/main.d0000644000175000017500000000010415205374124022204 0ustar fabiofabiomodule main; extern(C) void _start() {} extern(C) void main() { } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/test6952/object.d0000644000175000017500000000001715205374124022531 0ustar fabiofabiomodule object; ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dll_cxx/0000755000175000017500000000000015205374124021250 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dll_cxx/external/0000755000175000017500000000000015205374124023072 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dll_cxx/external/binding.d0000644000175000017500000000036715205374124024657 0ustar fabiofabiomodule binding; version (LDC) // automatic dllimport for *extern(D)* globals only { pragma(mangle, "testExternalImportVar") __gshared extern int testExternalImportVar; } else { extern (C) __gshared extern int testExternalImportVar; } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dll_cxx/mydll.cpp0000644000175000017500000000217415205374124023101 0ustar fabiofabio#ifdef _WIN32 #define EXPORT __declspec(dllexport) #else #define EXPORT #endif class EXPORT C22323 { public: C22323(); virtual ~C22323(); static int ctorCount; static int dtorCount; }; int C22323::ctorCount; int C22323::dtorCount; C22323::C22323() { ctorCount++; } C22323::~C22323() { dtorCount++; } struct EXPORT S22323 { public: S22323(int dummy); ~S22323(); static int ctorCount; static int dtorCount; }; int S22323::ctorCount; int S22323::dtorCount; S22323::S22323(int dummy) { ctorCount++; } S22323::~S22323() { dtorCount++; } // https://issues.dlang.org/show_bug.cgi?id=19660 extern "C" { EXPORT int someValue19660 = 0xF1234; EXPORT void setSomeValue19660(int v) { someValue19660 = v; } EXPORT int getSomeValue19660(void) { return someValue19660; } } EXPORT int someValueCPP19660 = 0xF1234; EXPORT void setSomeValueCPP19660(int v) { someValueCPP19660 = v; } EXPORT int getSomeValueCPP19660(void) { return someValueCPP19660; } extern "C" { // tests -extI switch for variables EXPORT int testExternalImportVar = 0xF1234; } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dll_cxx/testdll.d0000644000175000017500000000522515205374124023074 0ustar fabiofabioversion(Windows) enum EXPORT = "export "; else enum EXPORT = ""; // https://issues.dlang.org/show_bug.cgi?id=22323 extern(C++) class C22323 { this(); ~this(); mixin(EXPORT ~ q{static extern __gshared int ctorCount;}); mixin(EXPORT ~ q{static extern __gshared int dtorCount;}); } extern(C++) struct S22323 { this(int dummy); ~this(); mixin(EXPORT ~ q{static extern __gshared int ctorCount;}); mixin(EXPORT ~ q{static extern __gshared int dtorCount;}); } void test22323() { import core.stdcpp.new_; assert(C22323.ctorCount == 0); assert(C22323.dtorCount == 0); C22323 o = cpp_new!C22323; assert(C22323.ctorCount == 1); assert(C22323.dtorCount == 0); cpp_delete(o); assert(C22323.ctorCount == 1); assert(C22323.dtorCount == 1); o = new C22323; assert(C22323.ctorCount == 2); assert(C22323.dtorCount == 1); o.destroy; assert(C22323.ctorCount == 2); assert(C22323.dtorCount == 2); assert(S22323.ctorCount == 0); assert(S22323.dtorCount == 0); { S22323 s = S22323(0); assert(S22323.ctorCount == 1); assert(S22323.dtorCount == 0); } assert(S22323.ctorCount == 1); assert(S22323.dtorCount == 1); S22323 *s = cpp_new!S22323(0); assert(S22323.ctorCount == 2); assert(S22323.dtorCount == 1); cpp_delete(s); assert(S22323.ctorCount == 2); assert(S22323.dtorCount == 2); s = new S22323(0); assert(S22323.ctorCount == 3); assert(S22323.dtorCount == 2); (*s).destroy(); assert(S22323.ctorCount == 3); assert(S22323.dtorCount == 3); } // https://issues.dlang.org/show_bug.cgi?id=19660 extern (C) { export extern __gshared int someValue19660; export void setSomeValue19660(int v); export int getSomeValue19660(); } extern (C++) { export extern __gshared int someValueCPP19660; export void setSomeValueCPP19660(int v); export int getSomeValueCPP19660(); } void test19660() { assert(someValue19660 == 0xF1234); assert(getSomeValue19660() == 0xF1234); setSomeValue19660(100); assert(someValue19660 == 100); assert(getSomeValue19660() == 100); someValue19660 = 200; assert(someValue19660 == 200); assert(getSomeValue19660() == 200); assert(someValueCPP19660 == 0xF1234); assert(getSomeValueCPP19660() == 0xF1234); setSomeValueCPP19660(100); assert(someValueCPP19660 == 100); assert(getSomeValueCPP19660() == 100); someValueCPP19660 = 200; assert(someValueCPP19660 == 200); assert(getSomeValueCPP19660() == 200); } void main() { test22323(); test19660(); import binding; assert(testExternalImportVar == 0xF1234); } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/0000755000175000017500000000000015205374124020716 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/0000755000175000017500000000000015205374124024300 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/fix22508.txt0000644000175000017500000000030715205374124026230 0ustar fabiofabioDW_AT_name : fix22508.istr_a DW_AT_name : int[string] DW_AT_name : fix22508.stri_a DW_AT_name : string[int] DW_AT_name : fix22508.ii_a DW_AT_name : int[int] ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/fix21154.txt0000755000175000017500000000002315205374124026222 0ustar fabiofabioDW_TAG_shared_type ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/fix21663.txt0000644000175000017500000000073415205374124026235 0ustar fabiofabioDW_AT_name : a1 DW_AT_bit_size : 6 DW_AT_data_bit_offset: 0x20 DW_AT_name : b1 DW_AT_bit_size : 7 DW_AT_data_bit_offset: 0x26 DW_AT_name : c1 DW_AT_bit_size : 14 DW_AT_data_bit_offset: 0x2d DW_AT_name : d1 DW_AT_bit_size : 5 DW_AT_data_bit_offset: 0x3b DW_AT_name : a2 DW_AT_bit_size : 31 DW_AT_name : b2 DW_AT_bit_size : 1 DW_AT_name : c2 DW_AT_bit_size : 19 DW_AT_name : d2 DW_AT_bit_size : 13 ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/immutable.txt0000644000175000017500000000002615205374124027016 0ustar fabiofabioDW_TAG_immutable_type ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/fix21157.txt0000644000175000017500000000013715205374124026230 0ustar fabiofabioDW_AT_decl_line : 1002 DW_AT_decl_column : 17 DW_AT_decl_line : 1003 DW_AT_decl_column : 9 ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/fix22468.txt0000644000175000017500000000017615205374124026241 0ustar fabiofabioDW_AT_name : fix22468.dcharVar DW_AT_name : dchar DW_AT_byte_size : 4 DW_AT_encoding : 16 (unicode string) ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/fix22426.txt0000644000175000017500000000001715205374124026225 0ustar fabiofabioDW_AT_noreturn ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/fix22352.txt0000755000175000017500000000017515205374124026233 0ustar fabiofabioDW_AT_name : fix22352.Foo DW_AT_name : foo DW_AT_name : fix22352.Foo[] D main fix22352._d_cmain!().main ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/issue22423.txt0000644000175000017500000000032015205374124026561 0ustar fabiofabioDW_AT_name : issue22423 DW_AT_name : issue22423.issue22423func DW_AT_decl_line : 1000 DW_AT_decl_column : 10 DW_AT_decl_line : 2000 DW_AT_decl_column : 20 D main issue22423._d_cmain!().main ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/fix22469.txt0000644000175000017500000000104215205374124026233 0ustar fabiofabioDW_AT_name : char DW_AT_name : wchar DW_AT_name : dchar DW_AT_name : float DW_AT_name : double DW_AT_name : real DW_AT_name : bool DW_AT_name : byte DW_AT_name : ubyte DW_AT_name : short DW_AT_name : ushort DW_AT_name : int DW_AT_name : uint DW_AT_name : long DW_AT_name : ulong DW_AT_name : ifloat DW_AT_name : idouble DW_AT_name : ireal DW_AT_name : cfloat DW_AT_name : cdouble DW_AT_name : creal ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/immutableVoid.txt0000644000175000017500000000002615205374124027640 0ustar fabiofabioDW_TAG_immutable_type ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/fix21159.txt0000755000175000017500000000001315205374124026226 0ustar fabiofabioDW_AT_pure ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/fix21153.txt0000755000175000017500000000010015205374124026215 0ustar fabiofabioDW_AT_name : fix21153.i D main fix21153._d_cmain!().main ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/delegates.txt0000644000175000017500000000060215205374124026774 0ustar fabiofabioDW_AT_name : dg DW_AT_name : void delegate() pure nothrow @nogc @safe DW_AT_name : dg_gc_sys DW_AT_name : void delegate() pure nothrow @system DW_AT_name : dg_lazy DW_AT_name : void delegate(lazy void f) pure nothrow @nogc @safe DW_AT_name : pure nothrow @nogc @safe void(lazy void f) DW_AT_name : ptr DW_AT_name : funcptr ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/testVersion.txt0000755000175000017500000000002115205374124027362 0ustar fabiofabioVersion: 5 ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/fix22471.txt0000644000175000017500000000013515205374124026226 0ustar fabiofabioDW_AT_artificial : 1 DW_AT_name : D main DW_AT_name : __main._d_cmain!().main ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/excepted_results/fix21160.txt0000644000175000017500000000002615205374124026217 0ustar fabiofabioDW_AT_main_subprogram ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/fix22508.d0000644000175000017500000000026015205374124022250 0ustar fabiofabio/* EXTRA_ARGS: -g -defaultlib= -main -c // Issue https://issues.dlang.org/show_bug.cgi?id=22856 DWARF_VERIFY: false */ int[string] istr_a; string[int] stri_a; int[int] ii_a; ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/immutableVoid.d0000644000175000017500000000025715205374124023670 0ustar fabiofabio/* EXTRA_ARGS: -gdwarf=5 MIN_OBJDUMP_VERSION: 2.30 // Issue https://issues.dlang.org/show_bug.cgi?id=22855 DWARF_VERIFY: false */ void main() { immutable(void)[] arr; } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/fix22426.d0000755000175000017500000000022115205374124022247 0ustar fabiofabio/* EXTRA_ARGS: -gdwarf=5 -main // Issue https://issues.dlang.org/show_bug.cgi?id=22855 DWARF_VERIFY: false */ noreturn noret() { assert(0); } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/testVersion.d0000755000175000017500000000017115205374124023412 0ustar fabiofabio/* EXTRA_ARGS: -gdwarf=5 // Issue https://issues.dlang.org/show_bug.cgi?id=22855 DWARF_VERIFY: false */ void main() {} ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/fix21159.d0000755000175000017500000000004715205374124022257 0ustar fabiofabiovoid main() { } void foo() pure { } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/fix22471.d0000644000175000017500000000017015205374124022247 0ustar fabiofabio/* EXTRA_ARGS: -g -defaultlib= -main -c // Issue https://issues.dlang.org/show_bug.cgi?id=22856 DWARF_VERIFY: false */ ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/fix21154.d0000755000175000017500000000004015205374124022243 0ustar fabiofabioshared int i; void main() { } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/fix21153.d0000755000175000017500000000003115205374124022242 0ustar fabiofabioint i; void main() { } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/delegates.d0000644000175000017500000000033215205374124023016 0ustar fabiofabio/* EXTRA_ARGS: -defaultlib= */ void main() { auto dg = delegate() @safe pure nothrow @nogc {}; auto dg_gc_sys = delegate() @system pure nothrow { new int[10]; }; auto dg_lazy = delegate(lazy void f) {}; } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/fix21157.d0000644000175000017500000000025315205374124022251 0ustar fabiofabio/* EXTRA_ARGS: -main */ #line 1000 void foo() { int var1; // col: 9 (4 spaces + 3 chars + 1 space) float var2; // col: 17 (10 spaces + 5 chars + 1 space) } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/fix22352.d0000644000175000017500000000005415205374124022246 0ustar fabiofabiostruct Foo {} void main() { Foo[] foo; } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/fix21663.d0000644000175000017500000000043115205374124022251 0ustar fabiofabio/* EXTRA_ARGS: -preview=bitfields -main */ struct S { uint first; uint a1 : 6; uint b1 : 7; uint c1 : 14; uint d1 : 5; uint last; } S s; class C { uint first; uint a2 : 31; uint b2 : 1; uint c2 : 19; uint d2 : 13; uint last; } C c; ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/fix22469.d0000644000175000017500000000045515205374124022264 0ustar fabiofabio/* EXTRA_ARGS: -g -defaultlib= -betterC -c */ extern(C) void main() { char c; wchar wc; dchar dc; float f; double d; real r; bool b; byte sb; ubyte ub; short s; ushort us; int i; uint ui; long l; ulong ul; ifloat if_; idouble id; ireal ir; cfloat cf; cdouble cd; creal cr; } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/immutable.d0000644000175000017500000000032515205374124023042 0ustar fabiofabio/* EXTRA_ARGS: -gdwarf=5 MIN_OBJDUMP_VERSION: 2.30 // Issue https://issues.dlang.org/show_bug.cgi?id=22855 DWARF_VERIFY: false */ void main() { immutable int I = 3; } immutable(int) foo() { return 2; } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/issue22423.d0000755000175000017500000000016015205374124022610 0ustar fabiofabio#line 1000 void main() // col: 10 { } #line 2000 void issue22423func() pure // col: 20 { } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/fix22468.d0000644000175000017500000000007715205374124022263 0ustar fabiofabio/* EXTRA_ARGS: -g -defaultlib= -betterC -c */ dchar dcharVar; ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/dwarf/fix21160.d0000644000175000017500000000017115205374124022242 0ustar fabiofabio/* EXTRA_ARGS: -gdwarf=4 // Issue https://issues.dlang.org/show_bug.cgi?id=22855 DWARF_VERIFY: false */ void main() {} ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/linker_flag_with_spaces_b.d0000644000175000017500000000001415205374124025122 0ustar fabiofabiovoid b() {} ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/multi9377.d0000644000175000017500000000025315205374124021444 0ustar fabiofabioimport core.stdc.stdio; import mul9377a, mul9377b; int main() { printf("main\n"); abc(); def!().mem(); pragma(msg, def!().mem.mangleof); return 0; } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/mul9377b.d0000644000175000017500000000067515205374124021261 0ustar fabiofabiomodule mul9377b; import core.stdc.stdio; int j; int foo()() { printf("foo()\n"); static int z = 7; assert(z != 10); return ++z; } void bar() { assert(j == 7); foo(); printf("bar\n"); } template def() { alias int defint; static this() { printf("def.static this()\n"); j = 7; } //void mem(int){} void mem() { printf("def().mem()\n"); } } def!().defint x; ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/source_date_epoch.d0000644000175000017500000000031215205374124023427 0ustar fabiofabiomodule source_date_epoch; static immutable Date = __DATE__; static immutable Time = __TIME__; static immutable TimeStamp = __TIMESTAMP__; pragma(msg, Date); pragma(msg, Time); pragma(msg, TimeStamp); ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/test_shared.d0000644000175000017500000000002015205374124022255 0ustar fabiofabiovoid main() { } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/linker_flag_with_spaces_a.d0000644000175000017500000000007015205374124025123 0ustar fabiofabioimport linker_flag_with_spaces_b; void main() { b(); } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/printenv.d0000644000175000017500000000076415205374124021634 0ustar fabiofabioimport std.array, std.stdio, std.process, std.algorithm; auto filterEnv(T)(T env) { // Windows shell output is not in UTF-8 // https://github.com/dlang/phobos/pull/7342#issuecomment-571154708 return env.filter!(e => !e.key.among("BUILD_SOURCEVERSIONAUTHOR")); } void main() { foreach (varPair; environment.toAA().byKeyValue.filterEnv.array.sort!"a.key < b.key") { if (varPair.key != "_") { writeln(varPair.key, "=", varPair.value); } } } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/depsprot.d0000644000175000017500000000013115205374124021613 0ustar fabiofabioimport depsprot_default; private import depsprot_private; public import depsprot_public; ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/mul9377a.d0000644000175000017500000000016015205374124021245 0ustar fabiofabioimport core.stdc.stdio; import mul9377b; void abc() { printf("mul9377b.abc()\n"); foo(); bar(); } ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/issue22816.d0000644000175000017500000000002315205374124021506 0ustar fabiofabiomodule issue22816; ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/issue24111.c0000644000175000017500000000002315205374124021473 0ustar fabiofabio#include ./ldc-1.42.0-src/tests/dmd/dshell/extra-files/issue22804.d0000644000175000017500000000012015205374124021501 0ustar fabiofabioimport issue22804_2; void main(string[] args) { auto arr = foo(args[0]); } ./ldc-1.42.0-src/tests/dmd/dshell/dll.d0000644000175000017500000000240615205374124016312 0ustar fabiofabioimport dshell; int main() { version (LDC) { if (Vars.BUILD_SHARED_LIBS == "OFF") return DISABLED; } version (DigitalMars) { // Disable DM Dlls for now, need to redesign it // version (OSX) // Shared libraries are not yet supported on OSX return DISABLED; } Vars.set(`SRC`, `$EXTRA_FILES/dll`); Vars.set(`EXE_NAME`, `$OUTPUT_BASE/testdll$EXE`); Vars.set(`DLL`, `$OUTPUT_BASE/mydll$SOEXT`); version (Windows) { enum dllExtra = `$SRC/dllmain.d`; enum mainExtra = `$OUTPUT_BASE/mydll$LIBEXT`; } else { // Segfaults without PIC - using hardcoded -fPIC and not $PIC_FLAG as // the latter can be set to an empty string. enum dllExtra = `-fPIC`; version (LDC) // shared default libs for the executable too enum mainExtra = `-fPIC -L-L$OUTPUT_BASE -L$DLL -link-defaultlib-shared`; else enum mainExtra = `-fPIC -L-L$OUTPUT_BASE -L$DLL`; } run(`$DMD -m$MODEL -shared -od=$OUTPUT_BASE -of=$DLL $SRC/mydll.d ` ~ dllExtra); run(`$DMD -m$MODEL -I$SRC -od=$OUTPUT_BASE -of=$EXE_NAME $SRC/testdll.d ` ~ mainExtra); run(`$EXE_NAME`, stdout, stderr, [`LD_LIBRARY_PATH`: Vars.OUTPUT_BASE]); return 0; } ./ldc-1.42.0-src/tests/dmd/dshell/cpp_header_gen.d0000644000175000017500000000344415205374124020465 0ustar fabiofabiomodule test.dshell.cpp_header_gen; import dshell; int main() { if (!CXX.length) { writeln("CPP header generation test was skipped because $CXX is empty!"); return DISABLED; } Vars.set("SOURCE_DIR", "$EXTRA_FILES/cpp_header_gen"); Vars.set("LIB", "$OUTPUT_BASE/library$LIBEXT"); Vars.set("CPP_OBJ", "$OUTPUT_BASE/cpp$OBJ"); Vars.set("HEADER_EXE", "$OUTPUT_BASE/test$EXE"); run("$DMD -m$MODEL -c -lib -of=$LIB -HC=verbose -HCf=$OUTPUT_BASE/library.h $SOURCE_DIR/library.d"); // Dump header if any of the following step fails scope (failure) { const file = buildPath(Vars.OUTPUT_BASE, "library.h"); const header = (cast(string) read(file)).ifThrown("\n"); stderr.flush(); writeln("========================= library.h ==================================\n"); write(header); writeln("======================================================================\n"); stdout.flush(); } // LDC: don't specify -m for C compiler for non-x86 targets, it's mostly unsupported. version (X86) enum X86_Any = true; else version (X86_64) enum X86_Any = true; else enum X86_Any = false; version (Windows) run([CXX, "/c", "/Fo" ~ Vars.CPP_OBJ, "/I" ~ OUTPUT_BASE, "/I" ~ EXTRA_FILES ~"/../../../../../dmd/root", Vars.SOURCE_DIR ~ "/app.cpp"]); else static if (X86_Any) run("$CXX -std=c++11 -m$MODEL -c -o $CPP_OBJ -I$OUTPUT_BASE -I$EXTRA_FILES/../../../../../dmd/root $SOURCE_DIR/app.cpp"); else run("$CXX -std=c++11 -c -o $CPP_OBJ -I$OUTPUT_BASE -I$EXTRA_FILES/../../../../../dmd/root $SOURCE_DIR/app.cpp"); run("$DMD -m$MODEL -of=$HEADER_EXE $LIB $CPP_OBJ"); run("$HEADER_EXE"); return 0; } ./ldc-1.42.0-src/tests/dmd/dshell/defaults.d0000644000175000017500000000301515205374124017343 0ustar fabiofabio/// Verifies that DMD using default settings work as expected /// when using the default configuration + some example programs module defaults; import std.algorithm; import std.file; import std.path; import std.stdio; import dshell; int main(const string[] args) { // dshellPrebuiltInit("dshell", "defaults"); try { testConfigurations(); return 0; } catch (Throwable t) { writeln(t.msg); return 1; } } void testConfigurations() { // Compilation targets const string[] targets = [ MODEL ]; // Configuration file version (Windows) const string config = `bin\sc.ini`; else version (OSX) const string config = `bin/dmd.conf`; else const string config = `bin` ~ MODEL ~ `/dmd.conf`; // Static configuration file for the final release string configPath = buildNormalizedPath(dirName(__FILE_FULL_PATH__), "..", "..", "ini", OS, config); // Flag sets to test string[] extraFlags = [ // Minimal configuration generated by build.d "", // Predefined, full configuration located in ini "-conf=" ~ configPath ]; foreach (const target; targets) { foreach (const flags; extraFlags) { run( `$DMD ` ~ flags ~ ` -g -m` ~ target ~ ` -I$EXTRA_FILES/defaults ` ~ DFLAGS ~ ` $EXTRA_FILES/defaults/hello.d ` ~ ` -of=$OUTPUT_BASE/hello$EXE `, ); auto pipe = std.process.pipe(); run(`$OUTPUT_BASE/hello$EXE`, pipe.writeEnd, stderr); const output = cast(string) pipe.readEnd.byChunk(4096).join(); stdout.writeln(output); assert(output.canFind("Hello, World from D!")); } } } ./ldc-1.42.0-src/tests/dmd/dshell/linker_flag_with_spaces.d0000644000175000017500000000045415205374124022406 0ustar fabiofabioimport dshell; int main() { Vars.set("lib", "$OUTPUT_BASE/dir with spaces/b$LIBEXT"); run("$DMD -m$MODEL -of$lib -lib $EXTRA_FILES/linker_flag_with_spaces_b.d"); run("$DMD -m$MODEL -I$EXTRA_FILES -of$OUTPUT_BASE/a$EXE $EXTRA_FILES/linker_flag_with_spaces_a.d -L$lib"); return 0; } ./ldc-1.42.0-src/tests/dmd/dshell/README.md0000644000175000017500000000233215205374124016647 0ustar fabiofabio# Scripted tests Each D file is treated like a shell scripts which executes one or multiple complex tests. The test result is indicated by the scripts exit code, ``` 0 the test was successful dshell.DISABLED the test was skipped based on the environment * the test failed ``` ## Purpose These scripts are intended to supports tests which cannot be implemented in any other test category. For example, [this test](sameenv.d) verifies that the process environment is propagated correctly to an executable run by `dmd -run`. This can also be used to aggregate several such test cases into a new category (e.g. as done for [DWARF debug info generation](dwarf.d)). ## Remarks Scripts should prefer the following wrappers defined in the [`dshell` module](../tools/dshell_prebuilt/dshell_prebuilt.d) instead of the plain Phobos functions s.t. the test runner can issue a proper log on failure. Note that `dshell` tests require additional code and linking another executable, so they should be the last resort if a the test setup cannot be represented in any other test category. Refer to [test/README.md](../README.md) for general information and the [test guidelines](../README.md#test-coding-practices). ./ldc-1.42.0-src/tests/dmd/dshell/test_shared.d0000644000175000017500000000077615205374124020054 0ustar fabiofabioimport dshell; int main() { version (LDC) return DISABLED; // requires shared libs and a patched cmdline below; hardly worth it if (OS != "linux") { writefln("Skipping shared library test on %s.", OS); return DISABLED; } run("$DMD -m$MODEL -of$OUTPUT_BASE/a$EXE -defaultlib=libphobos2.so $EXTRA_FILES/test_shared.d"); run("$OUTPUT_BASE/a$EXE", stdout, stderr, [ "LD_LIBRARY_PATH" : "../../../phobos/generated/"~OS~'/'~BUILD~'/'~MODEL ]); return 0; } ./ldc-1.42.0-src/tests/dmd/dshell/issue22817.d0000644000175000017500000000125615205374124017275 0ustar fabiofabioimport dshell; int main() { auto stderr_file = shellExpand("$OUTPUT_BASE/issue22817.err"); auto stderr = File(stderr_file, "w"); string cmd = "$DMD -m$MODEL -c $EXTRA_FILES/issue22817.d"; string expected = shellExpand("^Error: cannot find input file `$EXTRA_FILES" ~ SEP ~ "issue22817.d`"); version (Windows) expected = expected.replace(`\`, `\\`); // Replace \ => \\ for regex const exitCode = tryRun(cmd, std.stdio.stdout, stderr); assert(exitCode == 1, "DMD should've failed!"); Vars.set("stderr", stderr_file); Vars.stderr .grep(expected) .enforceMatches("Expected 'Error: cannot find input file'"); return 0; } ./ldc-1.42.0-src/tests/dmd/dshell/issue24111.d0000644000175000017500000000054415205374124017261 0ustar fabiofabioimport dshell; int main() { version (Windows) { auto cmd = "$DMD -m$MODEL -c $EXTRA_FILES" ~ SEP ~ "issue24111.c"; run(cmd); import std.process: environment; version (LDC) { // if VSINSTALLDIR is set, LDC assumes INCLUDE is set up too environment.remove("VSINSTALLDIR"); } environment.remove("INCLUDE"); run(cmd); } return 0; } ./ldc-1.42.0-src/tests/dmd/dshell/depsprot.d0000644000175000017500000000134115205374124017374 0ustar fabiofabioimport dshell; void main() { Vars.set("deps_file", "$OUTPUT_BASE/compile.deps"); run("$DMD -m$MODEL -deps=$deps_file -Idshell/imports -o- $EXTRA_FILES/$TEST_NAME.d"); Vars.deps_file .grep("^$TEST_NAME.*${TEST_NAME}_default") .grep("private") .enforceMatches("Default import protection in dependency file should be 'private'"); Vars.deps_file .grep("^$TEST_NAME.*${TEST_NAME}_public") .grep("public") .enforceMatches("Public import protection in dependency file should be 'public'"); Vars.deps_file .grep("^$TEST_NAME.*${TEST_NAME}_private") .grep("private") .enforceMatches("Private import protection in dependency file should be 'private'"); } ./ldc-1.42.0-src/tests/dmd/dshell/sameenv.d0000644000175000017500000000141215205374124017171 0ustar fabiofabioimport dshell; void main() { const envFromExe = shellExpand("$OUTPUT_BASE/envFromExe.txt"); const envFromRun = shellExpand("$OUTPUT_BASE/envFromRun.txt"); run("$DMD -m$MODEL -of$OUTPUT_BASE/printenv$EXE $EXTRA_FILES/printenv.d"); run("$OUTPUT_BASE/printenv$EXE", File(envFromExe, "wb")); run("$DMD -m$MODEL -run $EXTRA_FILES/printenv.d", File(envFromRun, "wb")); const fromExe = readText(envFromExe).filterCompilerOutput; const fromRun = readText(envFromRun).filterCompilerOutput; if (fromExe != fromRun) { writefln("FromExe:"); writeln("-----------"); writeln(fromExe); writefln("FromRun:"); writeln("-----------"); writeln(fromRun); assert(0, "output from exe/run differ"); } } ./ldc-1.42.0-src/tests/dmd/dshell/dwarf.d0000755000175000017500000001106515205374124016646 0ustar fabiofabioimport dshell; import std.algorithm; import std.file; import std.process; import std.regex; import std.conv; int main() { version(DigitalMars) { } else { writeln("Skipping dwarf.d for non-DMD compilers."); return DISABLED; } version(Windows) { writeln("Skipping dwarf.d for Windows."); return DISABLED; } version(OSX) { writeln("Skipping dwarf.d for MacOS X."); return DISABLED; } version(Windows) immutable slash = "\\"; else immutable slash = "/"; // If the Unix system doesn't have objdump, disable the tests auto sysObjdump = executeShell("objdump --version"); if (sysObjdump.status) return DISABLED; double objdumpVersion; try { // output examples : // GNU objdump 2.15 // GNU objdump 2.17.50 [FreeBSD] 2007-07-03 // GNU objdump (GNU Binutils) 2.36.1 string strVer = sysObjdump.output.split("\n")[0]; writeln("Objdump version of the machine : ", strVer); auto cap = matchFirst(strVer, `[0-9]+\.[0-9]+`); assert(cap); objdumpVersion = cap.hit.to!double; } catch (ConvException ce) { // The conversion failed return DISABLED; } writeln("Parsed objdump version of the machine : ", objdumpVersion); // DWARF 3 (and 4) support has been implemented in version 2.20 (2.20.51.0.1) if(objdumpVersion < 2.20) return DISABLED; immutable extra_dwarf_dir = EXTRA_FILES ~ slash ~ "dwarf" ~ slash; bool failed; // test them all foreach (string path; dirEntries(extra_dwarf_dir, SpanMode.shallow)) { if (!isFile(path) || extension(path) != ".d") continue; // retrieve the filename without the extension auto filename = baseName(stripExtension(path)); string[string] requirements = getRequirements(path); try { if (objdumpVersion < requirements["MIN_OBJDUMP_VERSION"].to!double) { writeln("Warning: test " ~ path ~ " skipped."); continue ; } } catch(Exception e) { } string exe = OUTPUT_BASE ~ slash ~ filename; run("$DMD -m$MODEL -of" ~ exe ~ "$EXE -conf= -fPIE -g " ~ requirements["EXTRA_ARGS"] ~ " -I" ~ extra_dwarf_dir ~ " " ~ path); // Write objdump result to a file auto objdump = exe ~ ".objdump"; auto objdump_file = File(objdump, "w"); run("objdump -W " ~ exe, objdump_file); objdump_file.close(); auto llvmDwarfdump = executeShell("llvm-dwarfdump --version"); try { if (!llvmDwarfdump.status && requirements["DWARF_VERIFY"].to!bool) run("llvm-dwarfdump --verify " ~ exe); } catch (ConvException e) { } // Objdump excepted results string excepted_results_file = extra_dwarf_dir ~ "excepted_results" ~ slash ~ filename ~ ".txt"; if (!exists(excepted_results_file)) assert(0, "DWARF tests must have a .txt file in the `excepted_results`" ~ " folder which contains the DWARF dump info"); // Read file result as a string auto result = cast(string)readText(objdump); string failmsg; foreach (line; File(excepted_results_file).byLine) { if (!canFind(result, line)) { failmsg ~= filename ~ ": Couln't find `" ~ line ~ "` in the DWARF dump info.\n"; failed = true; } } if (failmsg) { // Writes the result into stdout for the CI machines. writeln(result); write(failmsg); } } return failed; } string[string] getRequirements(string dfile) { string[string] result; // Initialize to an empty string to prevent RangeViolation exceptions. foreach (req; ["EXTRA_ARGS", "MIN_OBJDUMP_VERSION"]) result[req] = ""; result["DWARF_VERIFY"] = "true"; bool begin; auto f = File(dfile, "r"); foreach (line; f.byLine) { if (line.length < 2) continue; if (line.startsWith("/*")) { begin = true; } if (begin) { string[] args = line.split(":").to!(string[]); if (args.length == 2) { result[args[0]] = args[1].strip(); } if (line.indexOf("*/") != -1) { break; } } } f.close(); return result; } ./ldc-1.42.0-src/tests/dmd/dshell/issue22816.d0000644000175000017500000000125615205374124017274 0ustar fabiofabioimport dshell; int main() { auto stderr_file = shellExpand("$OUTPUT_BASE/issue22816.err"); auto stderr = File(stderr_file, "w"); string cmd = "$DMD -m$MODEL -c $EXTRA_FILES/issue22816.c"; string expected = shellExpand("^Error: cannot find input file `$EXTRA_FILES" ~ SEP ~ "issue22816.c`"); version (Windows) expected = expected.replace(`\`, `\\`); // Replace \ => \\ for regex const exitCode = tryRun(cmd, std.stdio.stdout, stderr); assert(exitCode == 1, "DMD should've failed!"); Vars.set("stderr", stderr_file); Vars.stderr .grep(expected) .enforceMatches("Expected 'Error: cannot find input file'"); return 0; } ./ldc-1.42.0-src/tests/dmd/dshell/dll_cxx.d0000644000175000017500000000314615205374124017176 0ustar fabiofabioimport dshell; import std.stdio; int main() { // Only run this test, if CXX has been set. if (Vars.CXX.empty) return DISABLED; version (Windows) if (environment.get("C_RUNTIME", "") == "mingw") return DISABLED; version (FreeBSD) if (Vars.MODEL == "32") return DISABLED; Vars.set(`SRC`, `$EXTRA_FILES${SEP}dll_cxx`); Vars.set(`EXE_NAME`, `$OUTPUT_BASE${SEP}testdll$EXE`); Vars.set(`DLL`, `$OUTPUT_BASE${SEP}mydll$SOEXT`); string[] dllCmd = [Vars.CXX]; string mainExtra; version (Windows) { Vars.set(`DLL_LIB`, `$OUTPUT_BASE${SEP}mydll.lib`); // CXX should be cl dllCmd ~= [`/LD`, `/nologo`, `/Fe` ~ Vars.DLL]; mainExtra = `$DLL_LIB -dllimport=externalOnly`; } else version(OSX) { dllCmd ~= [`-dynamiclib`, `-fPIC`, `-o`, Vars.DLL, `-lstdc++`]; mainExtra = `-fPIC -L-L$OUTPUT_BASE -L$DLL -L-lstdc++ -L--no-demangle`; } else { dllCmd ~= [ `-shared`, `-fPIC`, `-o`, Vars.DLL ]; mainExtra = `-fPIC -L-L$OUTPUT_BASE -L$DLL -L-lstdc++ -L--no-demangle`; if (environment.get("NO_ARCH_VARIANT", "") != "1") dllCmd ~= `-m` ~ Vars.MODEL; } dllCmd ~= Vars.SRC ~ Vars.SEP ~ `mydll.cpp`; // The arguments have to be passed as an array, because run would replace '/' with '\\' otherwise. run(dllCmd); run(`$DMD -m$MODEL -g -od=$OUTPUT_BASE -of=$EXE_NAME -extI=$EXTRA_FILES${SEP}dll_cxx${SEP}external $SRC/testdll.d ` ~ mainExtra); run(`$EXE_NAME`, stdout, stderr, [`LD_LIBRARY_PATH`: Vars.OUTPUT_BASE]); return 0; } ./ldc-1.42.0-src/tests/dmd/dshell/test9377.d0000644000175000017500000000044015205374124017044 0ustar fabiofabioimport dshell; void main() { Vars.set("libname", "$OUTPUT_BASE/a$LIBEXT"); run("$DMD -m$MODEL -I$EXTRA_FILES -of$libname -c $EXTRA_FILES/mul9377a.d $EXTRA_FILES/mul9377b.d -lib"); run("$DMD -m$MODEL -I$EXTRA_FILES -of$OUTPUT_BASE/a$EXE $EXTRA_FILES/multi9377.d $libname"); } ./ldc-1.42.0-src/tests/dmd/dshell/issue22804.d0000644000175000017500000000045315205374124017267 0ustar fabiofabioimport dshell; int main() { run("$DMD -m$MODEL -od$OUTPUT_BASE -c $IMPORT_FILES/issue22804_1.d $IMPORT_FILES/issue22804_2.d"); run("$DMD -m$MODEL -I$IMPORT_FILES -of$OUTPUT_BASE/a$EXE $EXTRA_FILES/issue22804.d $OUTPUT_BASE/issue22804_1$OBJ $OUTPUT_BASE/issue22804_2$OBJ"); return 0; } ./ldc-1.42.0-src/tests/dmd/dshell/issue20444_SOURCE_DATE_EPOCH.d0000644000175000017500000000076415205374124022065 0ustar fabiofabioimport dshell; immutable string expected = `Apr 24 1992 14:14:00 Fri Apr 24 14:14:00 1992 `; void main () { string[string] env = [ "SOURCE_DATE_EPOCH": "704124840", "TZ": "UTC", "LC_ALL": "C", ]; const output = shellExpand("$OUTPUT_BASE/source_date_epoch.txt"); run("$DMD -m$MODEL -o- -c $EXTRA_FILES/source_date_epoch.d", stdout, File(output, "wb"), env); const result = readText(output).filterCompilerOutput; assert(result == expected, result); } ./ldc-1.42.0-src/tests/dmd/dshell/test6952.d0000644000175000017500000000373515205374124017052 0ustar fabiofabioimport dshell; import std.algorithm : canFind, find; int main() { if (OS == "windows") { writefln("Skipping test6952.d for %s.", OS); return DISABLED; } auto cmd = shellExpand("$DMD" ~ " -m$MODEL -of$OUTPUT_BASE/main$EXE -conf= -fPIC -g -v" ~ " -I$EXTRA_FILES/test6952/ -defaultlib=" ~ " -Xcc=-nostartfiles -Xcc=-nostdlib -Xcc=-nodefaultlibs $EXTRA_FILES/test6952/main.d"); // Remove DFLAGS environment variable. Everything we need is explicitly stated in // the command line above. string[string] e; e["DFLAGS"] = ""; // Use our custom linker wrapper in order not to depend on the platform's CC const ccWrapper = shellExpand("$OUTPUT_BASE/test6952.fakeLinker.sh"); e["CC"] = ccWrapper; // And make this explicit const outputFile = shellExpand("$OUTPUT_BASE/test6952.last_test_output.txt"); // Write the wrapper script... std.file.write(ccWrapper, "#!/usr/bin/env bash\nset -e\necho \"$@\" > " ~ outputFile ~ "\n"); run("chmod +x " ~ ccWrapper); // Compile the D code run(cmd, std.stdio.stdout, std.stdio.stderr, e); // This test used to parse the compiler output (using `-v`), // but that turned out to be quite brittle. // Instead, just provide a wrapper script via CC and write the arguments // to a file, and inspect what has been written. const result = readText(outputFile); immutable lines = result.split("\n"); if (!lines.length || !lines[0].length) assert(0, "The CC wrapper didn't write to " ~ outputFile ~ ":\n" ~ result); auto line = lines[0]; // The arguments prefixed with `-Xcc` should not have an // additional `-Xlinker` prepended to them assert(line.find("-Xlinker -nostartfiles") == ""); assert(line.find("-Xlinker -nostdlib") == ""); assert(line.find("-Xlinker -nodefaultlibs") == ""); // This is the way it should look assert(line.find("-nostartfiles -nostdlib -nodefaultlibs") != ""); return 0; } ./ldc-1.42.0-src/tests/dmd/compilable/0000755000175000017500000000000015205374126016226 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/0000755000175000017500000000000015205374125017722 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test18651/0000755000175000017500000000000015205374125021306 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test18651/c.d0000644000175000017500000000014215205374125021672 0ustar fabiofabiomodule imports.test18651.c; import imports.test18651.algorithm; const var = sort(string[].init); ./ldc-1.42.0-src/tests/dmd/compilable/imports/test18651/algorithm.d0000644000175000017500000000025215205374125023440 0ustar fabiofabiostruct SortedRange(Range) { Range _input; } auto sort(Range)(Range) { return SortedRange!Range(); } auto uniq(Range)(Range) { return SortedRange!Range(); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test18651/b.d0000644000175000017500000000003415205374125021671 0ustar fabiofabioimport imports.test18651.c; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test18651/datetime.d0000644000175000017500000000016015205374125023244 0ustar fabiofabiovoid parseTZConversions() { import imports.test18651.algorithm; string[] value; value.sort.uniq; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg16701/0000755000175000017500000000000015205374125021102 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg16701/Package.d0000644000175000017500000000002115205374125022573 0ustar fabiofabiomodule pkg16701; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test21227/0000755000175000017500000000000015205374125021277 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test21227/..foo/0000755000175000017500000000000015205374125022216 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test21227/..foo/a.txt0000644000175000017500000000000615205374125023173 0ustar fabiofabiohello ./ldc-1.42.0-src/tests/dmd/compilable/imports/test21227/a.txt0000644000175000017500000000000615205374125022254 0ustar fabiofabiohello ./ldc-1.42.0-src/tests/dmd/compilable/imports/test21227/a..b.txt0000644000175000017500000000000615205374125022552 0ustar fabiofabiohello ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg11847/0000755000175000017500000000000015205374125021110 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg11847/package.d0000644000175000017500000000005315205374125022646 0ustar fabiofabiomodule pkg11847; int func() { return 1; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg11847/mod11847.d0000644000175000017500000000006415205374125022441 0ustar fabiofabiomodule pkg11847.mod11847; int func() { return 2; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/format23327/0000755000175000017500000000000015205374125021613 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/format23327/write.d0000644000175000017500000000000015205374125023100 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg20008/0000755000175000017500000000000015205374125021075 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg20008/subpkg/0000755000175000017500000000000015205374125022370 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg20008/subpkg/subsubmod.d0000644000175000017500000000044715205374125024545 0ustar fabiofabiomodule pkg20008.subpkg.subsubmod; import pkg20008.subpkg; import pkg20008.subpkg.subsubmod; enum T8 { x } static assert([__traits(allMembers, pkg20008.subpkg)] == ["object", "pkg20008", "T9"]); static assert([__traits(allMembers, pkg20008.subpkg.subsubmod)] == ["object", "pkg20008", "T8"]); ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg20008/subpkg/package.d0000644000175000017500000000024315205374125024127 0ustar fabiofabiomodule pkg20008.subpkg; import pkg20008.subpkg.subsubmod; enum T9 { x } static assert([__traits(allMembers, pkg20008.subpkg)] == ["object", "pkg20008", "T9"]); ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg20008/submod.d0000644000175000017500000000004615205374125022533 0ustar fabiofabiomodule pkg20008.submod; enum T1 { x } ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg20008/package.d0000644000175000017500000000035315205374125022636 0ustar fabiofabiomodule pkg20008; import pkg20008.submod; enum T2 { y } enum T3 { z } static assert([__traits(allMembers, pkg20008)] == ["object", "pkg20008", "T2", "T3"]); static assert([__traits(allMembers, pkg20008.submod)] == ["object", "T1"]); ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg22952/0000755000175000017500000000000015205374125021107 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg22952/package.d0000644000175000017500000000001415205374125022642 0ustar fabiofabiomodule lib; ./ldc-1.42.0-src/tests/dmd/compilable/imports/cpkg/0000755000175000017500000000000015205374125020646 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/cpkg/cmodule.c0000644000175000017500000000041115205374125022436 0ustar fabiofabio// D module declaration #if __IMPORTC__ __module imports.cpkg.cmodule; // Only the first module statement is used, // subsequent __module declarations are assumed to come from #included other files __module some.header; #endif int sqr(int i) { return i * i; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg16044/0000755000175000017500000000000015205374125021102 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg16044/sub/0000755000175000017500000000000015205374125021673 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg16044/sub/package.d0000644000175000017500000000005415205374125023432 0ustar fabiofabiomodule pkg16044.sub; int test3; int test4; ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg16044/package.d0000644000175000017500000000005015205374125022635 0ustar fabiofabiomodule pkg16044; int test1; int test2; ./ldc-1.42.0-src/tests/dmd/compilable/imports/include_unittest/0000755000175000017500000000000015205374125023304 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/include_unittest/compiled_unittest_lib.d0000644000175000017500000000044315205374125030033 0ustar fabiofabiomodule lib.with_.unittests; void someFunction() { // This should trigger because this is a root module pragma(msg, "Compiling lib.with_.unittests.someFunction"); } unittest { // This should trigger because this is a root module pragma(msg, "Compiling lib.with_.unittests.unittest"); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/include_unittest/compiled_lib.d0000644000175000017500000000037215205374125026075 0ustar fabiofabio unittest { // This should trigger because this is a root module pragma(msg, "Compiling compiled_lib.unittests"); } void someFunction() { // This should trigger because this is a root module pragma(msg, "Compiling compiled_lib.someFunction"); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/include_unittest/skipped_unittest_lib.d0000644000175000017500000000062415205374125027677 0ustar fabiofabiomodule lib.ignores.unittests; pragma(msg, "Found module with skipped unittests"); unittest { // Shouldn't be parsed because we're in a non-root module static assert(false, "Semantic on unittest in non-root module!"); } void someFunction() { // This shouldn't be evaluated, no semantic for the body in non-root modules static assert(false, "Semantic on function body in non-root module!"); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test17991a/0000755000175000017500000000000015205374125021455 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test17991a/package.d0000644000175000017500000000000015205374125023203 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test17991a/a.d0000644000175000017500000000000015205374125022030 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg20537/0000755000175000017500000000000015205374125021104 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg20537/package.d0000644000175000017500000000000015205374125022632 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg313/0000755000175000017500000000000015205374125020732 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkg313/c313.d0000644000175000017500000000005415205374125021547 0ustar fabiofabiomodule imports.pkg313.c313; void bug() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test20151a/0000755000175000017500000000000015151104326021425 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test20151a/b/0000755000175000017500000000000015151104326021646 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test20151a/b/c/0000755000175000017500000000000015205374125022076 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test20151a/b/c/c.d0000644000175000017500000000000015205374125022453 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test21299/0000755000175000017500000000000015205374125021310 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test21299/rootstringtable.d0000644000175000017500000000301615205374125024677 0ustar fabiofabiomodule imports.test21299.rootstringtable; struct StringValue(T) { char* lstring() { return cast(char*)&this; } } struct StringTable(T) { StringValue!T* insert() { allocValue; return getValue; } uint allocValue() { StringValue!(T) sv; sv.lstring[0] = 0; return 0; } StringValue!T* getValue() { return cast(StringValue!T*)&this; } } // Other tests are the same as the original issue, but use other kinds of // nesting Dsymbols that need to be handled by templateInstanceSemantic(). struct StringValue2(T) { char* lstring() { return cast(char*)&this; } } struct StringTable2(T) { @nogc // AttribDeclaration (also covers pragma, extern(), static foreach, ...) { StringValue2!T* insert() { allocValue; return getValue; } uint allocValue() { StringValue2!(T) sv; sv.lstring[0] = 0; return 0; } StringValue2!T* getValue() { return cast(StringValue2!T*)&this; } } } // struct StringValue3(T) { char* lstring() { return cast(char*)&this; } } struct StringTable3(T) { static if (true) // ConditionalDeclaration (static if) { StringValue3!T* insert() { allocValue; return getValue; } uint allocValue() { StringValue3!(T) sv; sv.lstring[0] = 0; return 0; } StringValue3!T* getValue() { return cast(StringValue3!T*)&this; } } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test21299/func.d0000644000175000017500000000035515205374125022413 0ustar fabiofabiomodule imports.test21299.func; import imports.test21299.mtype; import imports.test21299.rootstringtable; class FuncDeclaration { StringTable!Type stringtable; StringTable2!Type stringtable2; StringTable3!Type stringtable3; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test21299/mtype.d0000644000175000017500000000034215205374125022612 0ustar fabiofabiomodule imports.test21299.mtype; import imports.test21299.func; import imports.test21299.rootstringtable; class Type { StringTable!Type stringtable; StringTable2!Type stringtable2; StringTable3!Type stringtable3; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkgmod313/0000755000175000017500000000000015205374125021432 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkgmod313/package.d0000644000175000017500000000011715205374125023171 0ustar fabiofabiomodule imports.pkgmod313; public import imports.pkgmod313.mod; void foo() {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkgmod313/mod.d0000644000175000017500000000005515205374125022356 0ustar fabiofabiomodule imports.pkgmod313.mod; void bar() {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/plainpackage/0000755000175000017500000000000015205374125022341 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/plainpackage/plainmodule.d0000644000175000017500000000011315205374125025012 0ustar fabiofabio/// Used to test is(x == module) module imports.plainpackage.plainmodule; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test17441foo/0000755000175000017500000000000015205374125022006 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test17441foo/bar.d0000644000175000017500000000004115205374125022712 0ustar fabiofabiomodule imports.test17441foo.bar; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test17441foo/package.d0000644000175000017500000000003515205374125023544 0ustar fabiofabiomodule imports.test17441foo; ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkgmodule/0000755000175000017500000000000015205374125021711 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/pkgmodule/package.d0000644000175000017500000000012115205374125023443 0ustar fabiofabio/// Used to test is(x == package) and is(x == module) module imports.pkgmodule; ./ldc-1.42.0-src/tests/dmd/compilable/imports/pkgmodule/plainmodule.d0000644000175000017500000000010715205374125024365 0ustar fabiofabio/// Used to test is(x == module) module imports.pkgmodule.plainmodule; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test15150a.d0000644000175000017500000000005315205374125021601 0ustar fabiofabiomodule imports.test15150a; enum { x } ./ldc-1.42.0-src/tests/dmd/compilable/imports/fwdref2_test17548.d0000644000175000017500000000021715205374125023076 0ustar fabiofabiomodule fwdref2_test17548; import test17548; struct S2 { void bar(int arg = .test17548.cnst) {} S1 s; import fwdref2_test17548; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19657g.d0000644000175000017500000000004715205374125021632 0ustar fabiofabioimport test19657d; class Seq: Trump {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/ldc_github_1698a.d0000644000175000017500000000027315205374125023025 0ustar fabiofabioimport std.variant; class C { Algebraic!int[string][] W; auto foo() { auto d = { foreach (w; W) w["path"].get!string; }; } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/udamodule1.d0000644000175000017500000000014015205374125022122 0ustar fabiofabio@(1) deprecated("This module will be removed.") @(2) module imports.udamodule1; void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test24390b.d0000644000175000017500000000037415205374125021616 0ustar fabiofabiomodule imports.test24390b; static if (__traits(compiles, __vector(int[4])) && __traits(compiles, __vector(byte[16]))) { __vector(int[4]) _mm_set1_epi8 (byte a) { __vector(byte[16]) b = a; return cast(__vector(int[4]))b; } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test72c.d0000644000175000017500000000005015205374125021355 0ustar fabiofabiomodule imports.test72c; void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/dip22e.d0000644000175000017500000000010515205374125021150 0ustar fabiofabiomodule imports.dip22e; public struct Foo {} public void bar(int) {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9692b.d0000644000175000017500000000004115205374125021535 0ustar fabiofabiomodule imports.test9692b; int k; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test1754b.d0000644000175000017500000000005215205374125021526 0ustar fabiofabiomodule imports.test1754b; void bar() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp12242b1.d0000644000175000017500000000021715205374125021472 0ustar fabiofabiomodule imports.imp12242b1; // std.string.strip int stripB(C)(C[] str) @safe pure if (is(immutable C == immutable char)) { return 1; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp15490b.d0000644000175000017500000000016615205374125021424 0ustar fabiofabiomodule imports.imp15490b; int regex() { return regexImpl(); } auto regexImpl() { int r = 0; return r; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp23662.c0000644000175000017500000000014515205374125021256 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23662 typedef enum {A} E; E func(E v) { return v; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp17434a.d0000644000175000017500000000003015205374125021411 0ustar fabiofabiomodule imp17434a.test1; ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp16460.d0000644000175000017500000000006015205374125021251 0ustar fabiofabiomodule imports.imp16460; package enum val = 0; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test67a.d0000644000175000017500000000026615205374125021370 0ustar fabiofabiomodule imports.test67a; import test67; class Base { I create() { return null; } } class Derived : Base { override SubI create() { return null; } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19657d.d0000644000175000017500000000004715205374125021627 0ustar fabiofabioimport test19657a; class Trump: Foo {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/ice13403a.d0000644000175000017500000000012115205374125021355 0ustar fabiofabiomodule imports.ice13403a; package(imports): template BacktrackingMatcher() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9919c.d0000644000175000017500000000010715205374125021543 0ustar fabiofabiomodule imports.test9919c; import test9919; MouseEvent.Action action; ./ldc-1.42.0-src/tests/dmd/compilable/imports/a313templatemixin2.d0000644000175000017500000000001715205374125023417 0ustar fabiofabiovoid bug() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp12242a1.d0000644000175000017500000000021715205374125021471 0ustar fabiofabiomodule imports.imp12242a1; // std.string.strip int stripA(C)(C[] str) @safe pure if (is(immutable C == immutable char)) { return 1; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19750a.d0000644000175000017500000000004015205374125021607 0ustar fabiofabioimport test19750c; class Bar {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/cimports2a.i0000644000175000017500000000023015205374125022152 0ustar fabiofabioextern int xx; typedef struct Foo *FooRef; FooRef make_foo(void); typedef struct Foo2 *FooRef2; struct Foo2 { int x; }; FooRef2 make_foo2(void); ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp23548.c0000644000175000017500000000003115205374125021253 0ustar fabiofabio#define issue23548 false ./ldc-1.42.0-src/tests/dmd/compilable/imports/depsOutput21238_baz_stringimport.d0000644000175000017500000000017215205374125026320 0ustar fabiofabiomodule imports.depsOutput21238_baz_stringimport; template t_stringimport() { enum x = import("depsOutput21238_qux.d"); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test72b.d0000644000175000017500000000007615205374125021364 0ustar fabiofabiomodule imports.test72b; private import imports.test72c : foo; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test21501c.d0000644000175000017500000000007015205374125021577 0ustar fabiofabiomodule imports.test21501c; alias C = int; const D = 1; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9276util.d0000644000175000017500000000026715205374125022301 0ustar fabiofabiomodule imports.test9276util; string _dgliteral(T...)() { foreach (t; T) return t.stringof; assert(0); } template DownCastMethods(T...) { enum x = _dgliteral!T; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test10375a.d0000644000175000017500000000011715205374125021606 0ustar fabiofabiomodule imports.test10375a; private template Pack(T...) { alias T tuple; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test16709a.d0000644000175000017500000000007015205374125021613 0ustar fabiofabiomodule test16709a; public import imports.test16709b:to; ./ldc-1.42.0-src/tests/dmd/compilable/imports/f313.d0000644000175000017500000000013315205374125020540 0ustar fabiofabio // different module declaration not used for access check module foo.bar; void bug() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/art4769a.d0000644000175000017500000000031215205374125021344 0ustar fabiofabiomodule imports.art4769a; import core.stdc.stdio; template DataStreamability(T) { const int isStreamable = true; alias T footype; void write() { printf("hallo\n"); } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test11563std_array.d0000644000175000017500000000020415205374125023353 0ustar fabiofabiomodule imports.test11563std_array; void popFront(S)(ref S str)// @trusted pure nothrow { import imports.test11563core_bitop; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test11225b.d0000644000175000017500000000053115205374125021602 0ustar fabiofabiomodule imports.test11225b; import test11225a; interface J : I {} // remove this line to make it work static assert(is(typeof({ import imports.test11225c; }))); // OK pragma(msg, B!().result); // just instantiates the template template B() { static assert(is(typeof({ import imports.test11225c; }))); // FAILS enum result = "WORKS"; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/b3682.d0000644000175000017500000000007515205374125020635 0ustar fabiofabiomodule imports.b3682; import a3682; alias Tuple!(int) tint; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test11563std_range.d0000644000175000017500000000031515205374125023334 0ustar fabiofabiomodule imports.test11563std_range; public import imports.test11563std_array; template isInputRange(R) { enum bool isInputRange = is(typeof( { R r = void; r.popFront(); })); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/a12511.d0000644000175000017500000000014715205374125020703 0ustar fabiofabiomodule a12511; public class A { private static void foo() {} public static void foo(int) {} } ./ldc-1.42.0-src/tests/dmd/compilable/imports/udamodule2.d0000644000175000017500000000013015205374125022122 0ustar fabiofabio@UDA(1) @UDA(2) module imports.udamodule2; import imports.udamodule2a; void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19746a.d0000644000175000017500000000004515205374125021621 0ustar fabiofabioimport test19746; class Bar: Foo { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp15907.d0000644000175000017500000000055715205374125021271 0ustar fabiofabiomodule imports.imp15907; void process(T)(T t) { foreach (member; __traits(allMembers, T)) { static if (__traits(getProtection, __traits(getMember, t, member)) != "private") { } } } enum allMembers(T) = [__traits(allMembers, T)]; struct PublicStruct { private struct S {} } private: struct PrivateStruct {} int privateVar; ./ldc-1.42.0-src/tests/dmd/compilable/imports/g313public.d0000644000175000017500000000001715205374125021741 0ustar fabiofabiovoid bug() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/a14528.d0000644000175000017500000000007115205374125020711 0ustar fabiofabiomodule imports.a14528; void foo(alias f)() { f(); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/a15856.d0000644000175000017500000000005215205374125020715 0ustar fabiofabiomodule imports.a15856; alias int c_long; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19187.d0000644000175000017500000000012015205374125021451 0ustar fabiofabiomodule imports.test19187; void test()() { } alias foo = test; alias foo = test; ./ldc-1.42.0-src/tests/dmd/compilable/imports/dip22.d0000644000175000017500000000046715205374125021016 0ustar fabiofabiomodule imports.dip22; interface Base1 { private ubyte bar() { return 1; } private enum baz = 1; private alias T = byte; } interface Base2 { final short bar() { return 2; } enum baz = 2; alias T = short; } private void bar() {} void bar(int) {} void baz(int) {} private void baz() {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/checkimports3b.d0000644000175000017500000000003115205374125023001 0ustar fabiofabioprivate void foo(int) {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/stdio4003.d0000644000175000017500000000007015205374125021515 0ustar fabiofabiomodule imports.stdio4003; import imports.typecons4003; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test24390a.d0000644000175000017500000000007515205374125021613 0ustar fabiofabiomodule imports.test24390a; public import imports.test24390b; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test18771d.d0000644000175000017500000000013515205374125021621 0ustar fabiofabiomodule imports.test18771d; import imports.test18771b, imports.test18771a; alias fooD = foo; ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp22122.d0000644000175000017500000000006615205374125021247 0ustar fabiofabiomodule imports.imp22122; package struct Imp22122 { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/typecons4003.d0000644000175000017500000000100415205374125022235 0ustar fabiofabiomodule imports.typecons4003; struct Tuple(T...) { alias T Types; Types field; ref Tuple!(Types[from .. to]) slice(uint from, uint to)() { return *cast(typeof(return) *) &(field[from]); } void test() //unittest { .Tuple!(int, string, float, double) a; a.field[1] = "abc"; a.field[2] = 4.5; auto s = a.slice!(1, 3); static assert(is(typeof(s) == Tuple!(string, float))); //assert(s.field[0] == "abc" && s.field[1] == 4.5); } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/foofunc2.d0000644000175000017500000000011015205374125021600 0ustar fabiofabiomodule imports.foofunc2; void foo2() { import imports.foofunc; foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test1imp.d0000644000175000017500000000002715205374125021634 0ustar fabiofabio alias uint DWORD; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9436aggr.d0000644000175000017500000000015015205374125022231 0ustar fabiofabiomodule imports.test9436aggr; import imports.test9436type; class Aggregate : Type { } class Class { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/g313stringmixin.d0000644000175000017500000000001715205374125023036 0ustar fabiofabiovoid bug() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/ldc_github_821a.d0000755000175000017500000000005515205374125022731 0ustar fabiofabiomodule imports.ldc_github_821a; struct S {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/vcg_ast_import.d0000644000175000017500000000004015205374125023101 0ustar fabiofabiostruct O { invariant() {} } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test18771b.d0000644000175000017500000000006015205374125021614 0ustar fabiofabiomodule imports.test18771b; void foo(string) {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9276expr.d0000644000175000017500000000025715205374125022301 0ustar fabiofabiomodule imports.test9276expr; import imports.test9276parser; import imports.test9276util; class Node { mixin DownCastMethods!Declaration; } class Expression : Node { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/diag12598a.d0000644000175000017500000000005515205374125021545 0ustar fabiofabiomodule imports.diag12598a; struct lines { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp15490a.d0000644000175000017500000000014115205374125021414 0ustar fabiofabiomodule imports.imp15490a; import imports.imp15490b; void listenTCP() { enum r = regex(); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/depsOutput21238_baz_pragmalib.d0000644000175000017500000000013615205374125025515 0ustar fabiofabiomodule imports.depsOutput21238_baz_pragmalib; template t_pragmalib() { pragma(lib, "qux"); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/ice11300a.d0000644000175000017500000000011715205374125021354 0ustar fabiofabiomodule imports.ice11300a; static import ice11300; enum value = ice11300.value; ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp12242a.d0000644000175000017500000000043715205374125021414 0ustar fabiofabiomodule imports.imp12242a; public: import imports.imp12242a1; // std.string import imports.imp12242a2; // std.algorithm private mixin template MixTmp(T, int x) { template foo(U) if (is(U == T)) { enum foo = x; } } mixin MixTmp!(int, 1); mixin MixTmp!(long, 2); ./ldc-1.42.0-src/tests/dmd/compilable/imports/dip22d.d0000644000175000017500000000013215205374125021147 0ustar fabiofabiomodule imports.dip22d; private struct Foo {} private void foo() {} private void bar() {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/test59b.d0000644000175000017500000000005415205374125021365 0ustar fabiofabiomodule imports.test59b; alias int HRESULT; ./ldc-1.42.0-src/tests/dmd/compilable/imports/cimports2b.i0000644000175000017500000000027715205374125022166 0ustar fabiofabioextern int xx; typedef struct Foo *FooRef; void free_foo(FooRef foo); /****************************/ typedef struct Foo2 *FooRef2; struct Foo2 { int x; }; void free_foo2(FooRef2 foo); ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19609b.d0000644000175000017500000000007515205374125021623 0ustar fabiofabiodeprecated(['h','e','l','l','o']) module imports.test19609b; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test1754a.d0000644000175000017500000000006215205374125021526 0ustar fabiofabiomodule imports.test1754a; private void bar() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/a12567.d0000644000175000017500000000014315205374125020712 0ustar fabiofabiodeprecated("This module will be removed in future release.") module imports.a12567; void foo() {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/file23499.d0000644000175000017500000000035515205374125021424 0ustar fabiofabio ///---- file.d struct TempCStringBuffer(To ) { ~this() { } To* _ptr; } auto tempCString(To, From)(From) { return TempCStringBuffer!To(); } bool exists(R)(R name) { return name.tempCString!wchar._ptr != null; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9276visitors.d0000644000175000017500000000034415205374125023202 0ustar fabiofabiomodule imports.test9276visitors; template Visitors() { mixin Semantic!(typeof(this)); mixin DeepDup!(typeof(this)); } import imports.test9276type; template DeepDup(T) if (is(T : BasicType)) {} template DeepDup(T) {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/fwdref9514.d0000644000175000017500000000007315205374125021667 0ustar fabiofabiobool find9514(alias pred, R)(R range) { return true; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test21464a.d0000644000175000017500000000007515205374125021612 0ustar fabiofabiostruct Mallocator { static shared Mallocator instance; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp18127a.c0000644000175000017500000000166715205374125021431 0ustar fabiofabio// https://github.com/dlang/dmd/issues/18127 union struct_or_union { int x; }; struct S_n_fields { int x, y; }; struct S_types { float x; }; struct S_names { float x; }; struct B { int x; }; struct S_b { struct B b; }; struct S_contains_anon_named { struct { int x; } a; }; struct S_contains_anon_unnamed { struct { int x; }; }; struct S_bitfields_mismatch1 { unsigned x: 3; unsigned y: 1; }; struct S_bitfields_mismatch2 { unsigned x; unsigned y: 1; }; struct S_bitfields_widths { unsigned x: 3; unsigned y: 1; }; struct S_bitfields_anon { unsigned x: 3; unsigned : 1; }; struct S_alignas { _Alignas(8) float x; }; struct S_aligned { float x; }__attribute__((aligned(8))); struct __attribute__((packed)) S_pack_1 { float x; char c; }; #pragma pack(push) #pragma pack(1) struct S_pack_2 { float x; char c; }; #pragma pack(pop) ./ldc-1.42.0-src/tests/dmd/compilable/imports/ldc_github_739a.d0000644000175000017500000000007615205374125022741 0ustar fabiofabiomodule imports.ldc_github_739a; void array(Range)(Range r) {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/test55a.d0000644000175000017500000000025515205374125021363 0ustar fabiofabiomodule imports.test55a; import test55; class Arm { alias int ListHead; MessageQueue.ListHead mqueue; } class Arm2 { alias int ListHead; Queue2.ListHead mqueue; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test13582.d0000644000175000017500000000004515205374125021450 0ustar fabiofabiodeprecated module imports.test13582; ./ldc-1.42.0-src/tests/dmd/compilable/imports/h20184.h0000644000175000017500000000002215205374125020713 0ustar fabiofabioint f20184(void); ./ldc-1.42.0-src/tests/dmd/compilable/imports/test18771a.d0000644000175000017500000000005515205374125021617 0ustar fabiofabiomodule imports.test18771a; void foo(int) {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp17434b.d0000644000175000017500000000007215205374125021420 0ustar fabiofabiomodule imp.imports17434b; void testing() { return; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/pr9471b.d0000644000175000017500000000013715205374125021200 0ustar fabiofabioimport imports.pr9471a; class ClassDeclaration : AggregateDeclaration { void isBaseOf(); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp20344.c0000644000175000017500000000007315205374125021250 0ustar fabiofabio// https://github.com/dlang/dmd/issues/20334 #define X "X" ./ldc-1.42.0-src/tests/dmd/compilable/imports/test15785.d0000644000175000017500000000026715205374125021465 0ustar fabiofabiomodule imports.test15785; interface IBase2 { final protected void faz() {} } class Base { protected void foo() {} protected void bar() {} protected alias T = int; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19657f.d0000644000175000017500000000004315205374125021625 0ustar fabiofabioclass Baz { import test19657d; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/library.c0000644000175000017500000000010315205374125021524 0ustar fabiofabiotypedef enum SomeEnum { foo = 0, bar = -10000, } SomeEnum; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9436interp.d0000644000175000017500000000037315205374125022621 0ustar fabiofabiomodule imports.test9436interp; import imports.test9436type; import imports.test9436aggr; class ReferenceValueT(T) { void doCast() { auto x = Type.ConversionFlags.kAllowBaseClass; } } class ClassValue : ReferenceValueT!Class { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/depsOutput21238_baz_moduleimport.d0000644000175000017500000000016415205374125026300 0ustar fabiofabiomodule imports.depsOutput21238_baz_moduleimport; template t_moduleimport() { import imports.depsOutput21238_qux; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test17541_3.d0000644000175000017500000000035215205374125021672 0ustar fabiofabiomodule three; void aaa() @nogc { } struct TT(T) { void insertabcdefg(T) // @nogc <-- deduction problem { //static assert(insertabcdefg.mangleof == "_D5three__T2TTTiZQg13insertabcdefgMFiZv"); aaa(); } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test50a.d0000644000175000017500000000010015205374125021343 0ustar fabiofabiomodule imports.test50a; class Foo { protected int a; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/format23327.d0000644000175000017500000000022015205374125021752 0ustar fabiofabiomodule imports.format23327; import imports.format23327.write; immutable(string) format23327() { } import imports.format23327.internal.write; ./ldc-1.42.0-src/tests/dmd/compilable/imports/b33a.d0000644000175000017500000000053315205374125020620 0ustar fabiofabiomodule imports.b33a; struct IsEqual( T ) { bool opCall( char p1, char p2 ) { return p1 == p2; } } template find_( Elem, Pred = IsEqual!(Elem) ) { size_t fn( char[] buf, Pred pred = Pred.init ) { return 3; } } template find() { size_t find( char[3] buf ) { return find_!(char).fn( buf ); } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19657b.d0000644000175000017500000000020615205374125021622 0ustar fabiofabioimport test19657g; import test19657a; import test19657e; class Frop: Seq { override bool func(Foo rhs, Bar bee) { return false; } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test22714a.d0000644000175000017500000000011115205374125021600 0ustar fabiofabiomodule imports.test22714a; import imports.test22714b; class Statement {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/test66a.d0000644000175000017500000000007515205374125021365 0ustar fabiofabiomodule imports.test66a; import test66; class A : Lexer { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test15150b.d0000644000175000017500000000007315205374125021604 0ustar fabiofabiomodule imports.test15150b; import imports.test15150a : x; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test14954_implementation.d0000644000175000017500000000013515205374125024561 0ustar fabiofabioextern(C) struct UndeclaredStruct { int i; } extern(C) __gshared UndeclaredStruct blah; ./ldc-1.42.0-src/tests/dmd/compilable/imports/u20958.d0000644000175000017500000000006615205374125020745 0ustar fabiofabiostruct W() { int[] J; } typeof(typeid(W!())) OB; ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp16798.d0000644000175000017500000000010715205374125021271 0ustar fabiofabio module its.a.dessert.topping; pragma(msg, "it's a dessert topping"); ./ldc-1.42.0-src/tests/dmd/compilable/imports/depsOutput21238_qux.d0000644000175000017500000000004415205374125023536 0ustar fabiofabiomodule imports.depsOutput21238_qux; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test16709c.d0000644000175000017500000000004315205374125021615 0ustar fabiofabiovoid to(string units, D)(D td) { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/asmmerge.c0000644000175000017500000000013015205374125021660 0ustar fabiofabiovoid fun22() asm ("test1"); void fun22() { } extern int xs[] asm("test2"); int xs[1]; ./ldc-1.42.0-src/tests/dmd/compilable/imports/bug8922.d0000644000175000017500000000003015205374125021162 0ustar fabiofabiomodule imports.bug8922; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test11563std_traits.d0000644000175000017500000000054415205374125023552 0ustar fabiofabiomodule imports.test11563std_traits; import imports.test11563std_range; bool startsWith(R1, R2)(R1 doesThisStart, R2 withThis) if (isInputRange!R1) { return true; } template moduleName(alias T) { static if (T.stringof.startsWith("module ")) { enum moduleName = "b"; } else { enum moduleName = "--error--"; } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test23490zoo.d0000644000175000017500000000055615205374125022206 0ustar fabiofabiomodule imports.test23490zoo; import imports.test23490pop; import imports.test23490frop; class Foo23490() : Pop23490 { override void frop(Frop23490 f) { f.frolick; } } class Baz23490 { Foo23490!() foo; Frop23490 frop; } class Bar23490 { static instance() { return new Baz23490; } auto ss = __traits(getAttributes, instance.frop); } class Zoo23490 { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test25b.d0000644000175000017500000000013215205374125021353 0ustar fabiofabiomodule imports.test25b; import imports.test25a; import core.stdc.stdio; class Bfoo { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/pr9471a.d0000644000175000017500000000010615205374125021173 0ustar fabiofabioimport imports.pr9471c; class AggregateDeclaration : ScopeDsymbol { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/jsonimport2.d0000644000175000017500000000006315205374125022354 0ustar fabiofabiomodule imports.jsonimport2; int target1, target2; ./ldc-1.42.0-src/tests/dmd/compilable/imports/a313.d0000644000175000017500000000032315205374125020534 0ustar fabiofabiomodule imports.a313; // adds private package imports private import imports.b313; // adds private package core private import core.stdc.stdio; // adds public alias cstdio public alias cstdio = core.stdc.stdio; ./ldc-1.42.0-src/tests/dmd/compilable/imports/testcontracts.d0000644000175000017500000000072015205374125022766 0ustar fabiofabiomodule imports.testcontracts; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=3602 class Base3602 { void method(int x, int y) in { assert(x > 0); assert(y > 0); } do { } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=5230 class Base5230 { int method() out (res) { } do { return 42; } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test22685c.d0000644000175000017500000000006415205374125021620 0ustar fabiofabiomodule imports.test22685c; void overloaded()() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19750b.d0000644000175000017500000000004115205374125021611 0ustar fabiofabioimport test19750d; class Frop {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/a8392.d0000644000175000017500000000022215205374125020631 0ustar fabiofabiomodule imports.a8392; import ice8392; class B { this(B); } void foob(A a, B b) { a.fooa!((arg){ return new B(b); }); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test62a.d0000644000175000017500000000017115205374125021356 0ustar fabiofabiomodule imports.test62a; import test62; struct T() { struct Nested { S member; } } alias T!() instance; ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp16085b.d0000644000175000017500000000041015205374125021415 0ustar fabiofabioimport imp16085 : S; struct Fail { } Fail functionAndFunction(ref S) { return Fail(); } Fail staticFunctionAndFunction(int) { return Fail(); } Fail functionAndTemplate(T)(T) { return Fail(); } Fail templateAndTemplate(T)(T) { return Fail(); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test16214b.d0000644000175000017500000000026215205374125021606 0ustar fabiofabiomodule test16214b; import test16214a; struct Appender() { int[] arr; } struct Tuple() { alias A = Appender!(); } class EventLoop { auto f() { auto x = [Tuple!().init]; } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19609a.d0000644000175000017500000000005215205374125021615 0ustar fabiofabiodeprecated([]) module imports.test19609a; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test15371.d0000644000175000017500000000022315205374125021444 0ustar fabiofabiomodule imports.test15371; struct A { private int a; private void fun() {} private void fun(int, int) {} public void fun(int) {} } ./ldc-1.42.0-src/tests/dmd/compilable/imports/jsonimport4.d0000644000175000017500000000003415205374125022354 0ustar fabiofabiomodule imports.jsonimport4; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test10752.d0000644000175000017500000000005415205374125021444 0ustar fabiofabiomodule imports.test10752; private int priv; ./ldc-1.42.0-src/tests/dmd/compilable/imports/a314.d0000644000175000017500000000026215205374125020537 0ustar fabiofabiomodule imports.pkg.a314; // sub package package(imports) static import imports.c314; package(imports) import renamed = imports.c314; package(imports) import imports.c314 : bug; ./ldc-1.42.0-src/tests/dmd/compilable/imports/testlambda1.d0000644000175000017500000000006515205374125022271 0ustar fabiofabiomodule imports.testlambda1; int bar() { return 7; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp23548.d0000644000175000017500000000003015205374125021253 0ustar fabiofabioenum issue23548 = true; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9919b.d0000644000175000017500000000034315205374125021544 0ustar fabiofabiomodule imports.test9919b; class Event { mixin genToString; // @BUG@ } class MouseEvent : Event { enum Action { A, B } } mixin template genToString() { override string toString() { return ""; } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test68a.d0000644000175000017500000000014515205374125021365 0ustar fabiofabiomodule imports.test68a; class OtherModuleClass { protected void foo() { } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9276decl.d0000644000175000017500000000035015205374125022224 0ustar fabiofabiomodule imports.test9276decl; import imports.test9276sem, imports.test9276visitors, imports.test9276util; class Declaration { mixin DownCastMethods!TemplateDecl; } class TemplateDecl : OverloadableDecl { mixin Visitors; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/testcov1b.d0000644000175000017500000000044015205374125021777 0ustar fabiofabiomodule testcov1b; class ArraySet(Key, int div = 1) { private Key[][div] polje; public this(in ArraySet a) { foreach(Key k, uint i; a) this.add(k); } public void add(Key elem) { } int opApply(int delegate(ref Key x, ref uint y) dg) const { return 0; } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test4003a.d0000644000175000017500000000011315205374125021511 0ustar fabiofabiomodule imports.test4003a; import imports.typecons4003; Tuple!(string) t; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19656b.d0000644000175000017500000000016615205374125021626 0ustar fabiofabioimport test19656; class Bar { } class Qux(T): Foo { override void thunk() { } } class Fred { Qux!Bar _q; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test22480b.d0000644000175000017500000000030715205374125021610 0ustar fabiofabiomodule immports.test22480b; auto parseAA() { bool[string] aa; aa["key"] = true; assert("key" in aa); assert(aa["key"]); assert(aa.length == 1); assert(aa == aa); aa.rehash(); return true; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test16709b.d0000644000175000017500000000012215205374125021612 0ustar fabiofabiomodule test16709b; public: import imports.test16709c; import imports.test16709d; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test11225c.d0000644000175000017500000000004415205374125021602 0ustar fabiofabiomodule imports.test11225c; // empty ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19746d.d0000644000175000017500000000017515205374125021630 0ustar fabiofabioimport test19746; class Baz(T): Foo { } class Dap(T): Baz!T { override void thunk() {} } class Zoo { Dap!int _dap; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test70.d0000644000175000017500000000004715205374125021216 0ustar fabiofabiomodule imports.test70; void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9276parser.d0000644000175000017500000000013215205374125022607 0ustar fabiofabiomodule imports.test9276parser; public import imports.test9276expr, imports.test9276decl; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test21501b.d0000644000175000017500000000011015205374125021571 0ustar fabiofabiomodule imports.test21501b; import test21501a; struct B { A data; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/depsOutput21238_bar.d0000644000175000017500000000056315205374125023473 0ustar fabiofabiomodule imports.depsOutput21238_bar; import imports.depsOutput21238_baz_moduleimport; alias x_moduleimport = t_moduleimport!(); import imports.depsOutput21238_baz_stringimport; alias x_stringimport = t_stringimport!(); import imports.depsOutput21238_baz_cond; alias x_cond = t_cond!(); import imports.depsOutput21238_baz_pragmalib; alias x_pragmalib = t_pragmalib!(); ./ldc-1.42.0-src/tests/dmd/compilable/imports/a313templatemixin1.d0000644000175000017500000000001715205374125023416 0ustar fabiofabiovoid bug() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/ldc_github_739b.d0000644000175000017500000000036015205374125022736 0ustar fabiofabiomodule imports.ldc_github_739b; import ldc_github_739; import imports.ldc_github_739a; struct MatchTree { struct TerminalTag {} TerminalTag[] m_terminalTags; void print() { m_terminalTags.map!(t => "").array; } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp22625.c0000644000175000017500000000003715205374125021254 0ustar fabiofabiotypedef struct S { int x; } T; ./ldc-1.42.0-src/tests/dmd/compilable/imports/fwdref12201a.d0000644000175000017500000000002015205374125022063 0ustar fabiofabioalias int FILE; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test22685b.d0000644000175000017500000000013515205374125021616 0ustar fabiofabiomodule imports.test22685b; import imports.test22685c : overloaded; void overloaded()() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp12242a2.d0000644000175000017500000000024115205374125021467 0ustar fabiofabiomodule imports.imp12242a2; // std.algorithm.strip auto stripA(R, E)(R range, E element) { return 2; } auto stripA(alias pred, R)(R range) { return 3; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19750c.d0000644000175000017500000000010215205374125021610 0ustar fabiofabioimport test19750d; class Qux: Thud { override void thunk() {} } ./ldc-1.42.0-src/tests/dmd/compilable/imports/checkimports3c.d0000644000175000017500000000002415205374125023004 0ustar fabiofabiovoid foo(string) {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/test23034b.c0000644000175000017500000000013315205374125021600 0ustar fabiofabiostruct S2 { int field2; }; void fn() { struct S2 *const s; int x = s->field2; // here } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test18771c.d0000644000175000017500000000013515205374125021620 0ustar fabiofabiomodule imports.test18771c; import imports.test18771a, imports.test18771b; alias fooC = foo; ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp20499.c0000644000175000017500000000017315205374125021264 0ustar fabiofabio// https://github.com/dlang/dmd/issues/20499 typedef struct Foo { int x; } *pFoo; struct Bar { struct Foo foo; }; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test15857c.d0000644000175000017500000000003115205374125021615 0ustar fabiofabiovoid bar15857(string) {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp18127b.c0000644000175000017500000000166715205374125021432 0ustar fabiofabio// https://github.com/dlang/dmd/issues/18127 union struct_or_union { int x; }; struct S_n_fields { int x, y; }; struct S_types { float x; }; struct S_names { float x; }; struct B { int x; }; struct S_b { struct B b; }; struct S_contains_anon_named { struct { int x; } a; }; struct S_contains_anon_unnamed { struct { int x; }; }; struct S_bitfields_mismatch1 { unsigned x: 3; unsigned y: 1; }; struct S_bitfields_mismatch2 { unsigned x; unsigned y: 1; }; struct S_bitfields_widths { unsigned x: 3; unsigned y: 1; }; struct S_bitfields_anon { unsigned x: 3; unsigned : 1; }; struct S_alignas { _Alignas(8) float x; }; struct S_aligned { float x; }__attribute__((aligned(8))); struct __attribute__((packed)) S_pack_1 { float x; char c; }; #pragma pack(push) #pragma pack(1) struct S_pack_2 { float x; char c; }; #pragma pack(pop) ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp16085.d0000644000175000017500000000072415205374125021263 0ustar fabiofabiostruct Pass { } struct S { import imports.imp16085b : functionAndFunction, staticFunctionAndFunction, functionAndTemplate, templateAndTemplate; //<- private // public Pass functionAndFunction() { return Pass(); } static Pass staticFunctionAndFunction() { return Pass(); } Pass functionAndTemplate() { return Pass(); } Pass templateAndTemplate()() { return Pass(); } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test2991.d0000644000175000017500000000006115205374125021370 0ustar fabiofabiomodule imports.test2991; private void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/wax16798.d0000644000175000017500000000010215205374125021276 0ustar fabiofabiomodule its.a.floorwax.wax16798; pragma(msg, "it's a floor wax"); ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19609c.d0000644000175000017500000000005415205374125021621 0ustar fabiofabiodeprecated(null) module imports.test19609c; ./ldc-1.42.0-src/tests/dmd/compilable/imports/art4769b.d0000644000175000017500000000017315205374125021352 0ustar fabiofabioprivate import imports.art4769a; private import art4769; int main(char [][] args) { Vector!(wchar) str; return 0; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test1238b.d0000644000175000017500000000005515205374125021526 0ustar fabiofabiomodule imports.test1238b; public int zuiop; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19746b.d0000644000175000017500000000004215205374125021617 0ustar fabiofabioimport test19746d; class Frop { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp21832.d0000644000175000017500000000040415205374125021252 0ustar fabiofabiomodule imports.imp21832; static if(1) { int fun(int a) { return a; } int tpl()(int a) { return a; } } deprecated { int fun(char a) { return a; } int tpl()(char a) { return a; } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp24022.c0000644000175000017500000000013015205374125021237 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24022 typedef enum { A = 1, B, } E; ./ldc-1.42.0-src/tests/dmd/compilable/imports/defab.d0000644000175000017500000000017515205374125021133 0ustar fabiofabio module imports.defab; private import defa; public class B : A { private import imports.defad; D parent; this() {} } ./ldc-1.42.0-src/tests/dmd/compilable/imports/checkimports3a.d0000644000175000017500000000001615205374125023003 0ustar fabiofabiovoid foo() {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/test59a.d0000644000175000017500000000006415205374125021365 0ustar fabiofabiomodule imports.test59a; import test59; HRESULT h; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test13242b.d0000644000175000017500000000040015205374125021576 0ustar fabiofabiomodule imports.test13242b; template expensiveArgs(alias v) { pragma(msg, "b.expensiveArgs: ", v); } template expensiveTemplate(Args...) { pragma(msg, "b.expensiveTemplate: ", Args[0]); } alias apiSym3 = expensiveTemplate!(3, expensiveArgs!(3)); ./ldc-1.42.0-src/tests/dmd/compilable/imports/issue21614a.d0000644000175000017500000000042515205374125021757 0ustar fabiofabiomodule 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)(); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19657e.d0000644000175000017500000000004115205374125021622 0ustar fabiofabioimport test19657f; class Bar { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp22665.c0000644000175000017500000000001615205374125021255 0ustar fabiofabioenum E { A }; ./ldc-1.42.0-src/tests/dmd/compilable/imports/g313templatemixin.d0000644000175000017500000000001715205374125023343 0ustar fabiofabiovoid bug() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test71.d0000644000175000017500000000010015205374125021205 0ustar fabiofabiomodule imports_test71; import imports = object; void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/impfieldwise.d0000644000175000017500000000007315205374125022550 0ustar fabiofabio@safe: struct S { private: @safe: int a, b; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/cstuff3.c0000644000175000017500000000137315205374125021447 0ustar fabiofabio// check bugs in importing C files int squared(int a) { return a * a; } /* test case for issue #21094 */ typedef enum upng_error { UPNG_EOK = 0, /* success (no error) */ UPNG_ENOMEM = 1, /* memory allocation failed */ UPNG_ENOTFOUND = 2, /* resource not found (file missing) */ UPNG_ENOTPNG = 3, /* image data does not have a PNG header */ UPNG_EMALFORMED = 4, /* image data is not a valid PNG image */ UPNG_EUNSUPPORTED = 5, /* critical PNG chunk type is not supported */ UPNG_EUNINTERLACED = 6, /* image interlacing is not supported */ UPNG_EUNFORMAT = 7, /* image color format is not supported */ UPNG_EPARAM = 8 /* invalid parameter to method call */ } upng_error; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19656c.d0000644000175000017500000000005315205374125021622 0ustar fabiofabioimport imports.test19656b; class Thud { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9399a.d0000644000175000017500000000007515205374125021547 0ustar fabiofabiomodule imports.test9399a; void call(alias n)() { n(); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp12242b2.d0000644000175000017500000000024115205374125021470 0ustar fabiofabiomodule imports.imp12242b2; // std.algorithm.strip auto stripB(R, E)(R range, E element) { return 2; } auto stripB(alias pred, R)(R range) { return 3; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/jsonimport3.d0000644000175000017500000000007415205374125022357 0ustar fabiofabiomodule imports.jsonimport3; int target1, target2, target3; ./ldc-1.42.0-src/tests/dmd/compilable/imports/jsonimport1.d0000644000175000017500000000006315205374125022353 0ustar fabiofabiomodule imports.jsonimport1; int target1, target2; ./ldc-1.42.0-src/tests/dmd/compilable/imports/testlambda2.d0000644000175000017500000000006515205374125022272 0ustar fabiofabiomodule imports.testlambda2; int bar() { return 7; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/defac.d0000644000175000017500000000024115205374125021126 0ustar fabiofabio module imports.defac; private import imports.defab; public abstract class C : B { private import imports.defad; this() {} this(D parent, int style) {} } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test13242a.d0000644000175000017500000000057515205374125021612 0ustar fabiofabiomodule imports.test13242a; template expensiveArgs(alias v) { pragma(msg, "a.expensiveArgs: ", v); } template expensiveTemplate(Args...) { pragma(msg, "a.expensiveTemplate: ", Args[0]); } alias apiSym1 = expensiveTemplate!(1, expensiveArgs!(1)); alias apiSym2 = expensiveTemplate!(2, expensiveArgs!(2)); public import imports.test13242b : apiSym3; void cheapFunc() {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/test22714b.d0000644000175000017500000000027015205374125021607 0ustar fabiofabiomodule imports.test22714b; import imports.test22714a; struct Array(T) { T[] data; T[1] smallarray; } struct Ensure { Statement ensure; Array!Ensure* arraySyntaxCopy; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test6013.d0000644000175000017500000000044615205374125021364 0ustar fabiofabiomodule imports.test6013; int value; int func() { return 0; }; public alias value public_alias_value; private alias value private_alias_value; public alias func public_alias_func; private alias func private_alias_func; public alias int public_alias_type; private alias int private_alias_type; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test23597.di0000644000175000017500000000005315205374125021627 0ustar fabiofabiomodule imports.test23597; void fun()() {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/foofunc.d0000644000175000017500000000004715205374125021527 0ustar fabiofabiomodule imports.foofunc; void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test1238a.d0000644000175000017500000000005615205374125021526 0ustar fabiofabiomodule imports.test1238a; private int zuiop; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test17541_2.d0000644000175000017500000000030015205374125021662 0ustar fabiofabiomodule two; import one; struct ET(bool a) { enum e = BB.MAX_NUM_FIBERS; } alias Event = ET!false; struct TWOR(size_t M) { Event e; void open() { bb.foo(); } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test16348.d0000644000175000017500000000010015205374125021443 0ustar fabiofabiomodule mypackage.bar; package bool bar() { return false; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/g313staticif.d0000644000175000017500000000001715205374125022271 0ustar fabiofabiovoid bug() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp23812.c0000644000175000017500000000124515205374125021255 0ustar fabiofabio void funcDefault(void); #pragma attribute(push, nothrow) void funcNothrow(void); #pragma attribute(pop) #pragma attribute(push, nogc) void funcNogc(void); #pragma attribute(pop) #pragma attribute(push, pure) void funcPure(void); #pragma attribute(pop) #pragma attribute(push, nothrow, nogc) void funcNothrowNogc(void); #pragma attribute(pop) void funcDefault2(void); #pragma attribute(push, nothrow) #pragma attribute(push, nogc) void funcNothrowNogc2(void); #pragma attribute(pop) void funcNothrow2(void); #pragma attribute(pop) #pragma attribute(push, nothrow) void funcWithCallback(void (*f)(void)); struct Callbacks { void (*f)(void); }; #pragma attribute(pop) ./ldc-1.42.0-src/tests/dmd/compilable/imports/test25a.d0000644000175000017500000000021415205374125021353 0ustar fabiofabiomodule imports.test25a; import imports.test25b; import core.stdc.stdio; class Afoo { static this() { printf("Afoo()\n"); } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9276sem.d0000644000175000017500000000036515205374125022107 0ustar fabiofabiomodule imports.test9276sem; class Declaration { mixin Visitors; } template Semantic(T) { private: struct { import imports.test9276hash; } } import imports.test9276visitors; class OverloadableDecl : Declaration { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test24511_c.c0000644000175000017500000000070315205374125021744 0ustar fabiofabiotypedef void (*CFunctionPointer)(); typedef void (__stdcall *StdCallFunctionPointer)(); void cFunction() {} void __stdcall stdcallFunction() {} void __stdcall takesCFunctionPointer(CFunctionPointer f) {} void takesStdCallFunctionPointer(StdCallFunctionPointer f) {} typedef void (__stdcall *StdCallFunctionPointerTakingCFunctionPointer)(CFunctionPointer f); typedef void (*CFunctionPointerTakingStdCallFunctionPointer)(StdCallFunctionPointer f); ./ldc-1.42.0-src/tests/dmd/compilable/imports/test15857a.d0000644000175000017500000000010415205374125021614 0ustar fabiofabiopublic import imports.test15857b; public import imports.test15857c; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19344.d0000644000175000017500000000020415205374125021447 0ustar fabiofabiomodule imports.test19344; template getUDAs(alias symbol, alias attribute) { alias getUDAs = __traits(getAttributes, symbol); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19746c.d0000644000175000017500000000004615205374125021624 0ustar fabiofabioimport test19746a; class Qux: Bar { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test24280b.i0000644000175000017500000000064115205374125021616 0ustar fabiofabiostruct S; struct timespec { int s; }; typedef struct timespec Clock; Clock now() { Clock result; return result; } struct S { Clock clock; }; /* https://issues.dlang.org/show_bug.cgi?id=24303 */ typedef struct {} Slice; struct Lang { Slice *slices; }; void langmap(struct Lang *self) { Slice slice = *self->slices; } /* https://issues.dlang.org/show_bug.cgi?id=24306 */ struct T { }; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test23490frop.d0000644000175000017500000000027715205374125022345 0ustar fabiofabiomodule imports.test23490frop; import imports.test23490pop; class Mu23490 : Pop23490 { } class Frop23490 : Pop23490 { // final // does not fail if declared final void frolick() {} } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test72a.d0000644000175000017500000000006715205374125021363 0ustar fabiofabiomodule imports.test72a; public import imports.test72b; ./ldc-1.42.0-src/tests/dmd/compilable/imports/defines.c0000644000175000017500000000245115205374125021505 0ustar fabiofabio/* */ #define CC 'c' _Static_assert(CC == 'c', "1"); #define I32 3 _Static_assert(I32 == 3, "3"); #define U32 4U _Static_assert(U32 == 4U, "4"); #define I64 5L _Static_assert(I64 == 5U, "5"); #define U64 6UL _Static_assert(U64 == 6UL, "6"); #define F32 7.0f _Static_assert(F32 == 7.0f, "7"); #define F64 8.0f _Static_assert(F64 == 8.0, "8"); #define F80 9.0f _Static_assert(F80 == 9.0L, "9"); #define SSS "hello" _Static_assert(SSS[0] == 'h', "10"); #define ABC 12 #define GHI (size) abbadabba #define DEF (ABC + 5) #define ADD(a, b) a + b #define SUB() 3 - 2 #define NO_BODY() #define NO_BODY_PARAMS(a, b) #define DO_WHILE() do { } while(0) #define pr16199_trigger(cond,func,args) _Generic (cond, default: func args) #define pr16199_skipped1(a) (1) #define pr16199_skipped2(b) (2) #define pr16199_ice 0x3 #define M16199Ea(TYPE) (TYPE __x;) #define M16199E(X,S,M) ({ M16199Ea(S *); }) #define M16199Da(TYPE,VAR) ((TYPE)(VAR)) #define M16199D(X,S,M) ({ int *__x = (X); M16199Da(S *, __x); }) int pr16199d() { return 7; } #define M16199C(X,S,M) ({ int __x; }) int pr16199c() { return 8; } // https://issues.dlang.org/show_bug.cgi?id=24639 #define NEGATIVE_I32 -1 #define NEGATIVE_U32 -2U #define NEGATIVE_I64 -3LL #define NEGATIVE_U64 -4LLU #define NEGATIVE_F32 -5.0f #define NEGATIVE_F64 -6.0 ./ldc-1.42.0-src/tests/dmd/compilable/imports/defaa.d0000644000175000017500000000015115205374125021124 0ustar fabiofabio module imports.defaa; class Display { private import imports.defab; B lastHittestB; this() { } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9672a.d0000644000175000017500000000070615205374125021542 0ustar fabiofabiomodule imports.test9672a; // interpret import test9672; // node class Type { mixin ForwardCtor!(); } //BasicType only created for standard types associated with tokens class BasicType : Type { static Type createType() { return null; } } class ValueT(T) { Type getType() { return BasicType.createType(); } } class CharValue : ValueT!char { string toStr() { return null; } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/c23789.i0000644000175000017500000000067715205374125020745 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23789 struct __declspec(align(64)) M128A { char c; }; typedef struct __declspec(align(32)) _M128B { int x; } M128B, *PM128A; void testpl(p) struct __declspec(align(2)) S *p; { } ///// struct __attribute__((aligned(64))) N128A { char c; }; typedef struct __attribute__((aligned(32))) _N128B { int x; } N128B, *PN128A; void testpl2(p) struct __attribute__((aligned(2))) S *p; { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test63a.d0000644000175000017500000000012215205374125021353 0ustar fabiofabiomodule imports.test63a; private import test63; struct s { char[SIZE] a; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/a15760.d0000644000175000017500000000010415205374125020705 0ustar fabiofabiomodule imports.a15760; import ice15760; struct Foo { Bar a; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9436node.d0000644000175000017500000000012715205374125022242 0ustar fabiofabiomodule imports.test9436node; import imports.test9436aggr; template ForwardCtor() { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/ice11054a.d0000644000175000017500000000051115205374125021360 0ustar fabiofabiotemplate Tuple() { string injectNamedFields() { formatNthX(); return ""; } } Tuple!T tuple(T...)() { } void formatNthX(A...)(A) { static gencode(size_t count)() { result ~= ""; // comment out this line will remove the ICE return ""; } mixin(gencode!(A.length)()); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test14666a.d0000644000175000017500000000016615205374125021621 0ustar fabiofabiomodule imports.test14666a; auto getNames() { import imports.test14666b; return ""; } enum Names = getNames; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test11563core_bitop.d0000644000175000017500000000003415205374125023511 0ustar fabiofabiomodule test11563core_bitop; ./ldc-1.42.0-src/tests/dmd/compilable/imports/b313.d0000644000175000017500000000015015205374125020533 0ustar fabiofabiomodule imports.b313; void bug() { // scope has access to it's own module imports.b313.bug(); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9276hash.d0000644000175000017500000000003515205374125022240 0ustar fabiofabiomodule imports.test9276hash; ./ldc-1.42.0-src/tests/dmd/compilable/imports/ldc_github_247a.d0000644000175000017500000000050415205374125022727 0ustar fabiofabiomodule imports.ldc_github_247a; class ReadValue(T = int){ void get_value(){ if( ctrl.active ){} } } class Value(T) : ReadValue!(T) { auto opAssign(T value){ // <<<=== change to Value!T to solve the ice return this; } } static Controller ctrl; class Controller { bool active; Value!(int) pulse; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test16709d.d0000644000175000017500000000003015205374125021612 0ustar fabiofabiovoid to(T, D)(D td) { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19750d.d0000644000175000017500000000013115205374125021613 0ustar fabiofabioimport test19750; class Dap(T) {} class Thud: Foo { Dap!int _dap; void thunk() { } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/defad.d0000644000175000017500000000024615205374125021134 0ustar fabiofabio module imports.defad; private import imports.defac; private import imports.defab; public class D : C { B [] tabList; this() {} this(D parent, int style){ } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp16080.d0000644000175000017500000000004615205374125021253 0ustar fabiofabiostruct A() { static immutable A a; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test61a.d0000644000175000017500000000010115205374125021346 0ustar fabiofabiomodule imports.test61a; enum FooA { fooA }; void bar(FooA x) {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/test21098b.d0000644000175000017500000000033415205374125021614 0ustar fabiofabioimport imports.test21098_phobos : Appender, Nullable; struct Type { Nullable!(Type[]) templateArgs; } Type[] parseDeclarations() { Appender!(Type[]) members; return null; } enum ast = parseDeclarations(); ./ldc-1.42.0-src/tests/dmd/compilable/imports/test14666b.d0000644000175000017500000000012715205374125021617 0ustar fabiofabiomodule imports.test14666b; import test14666; struct Token { Location location; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/g313.d0000644000175000017500000000112315205374125020541 0ustar fabiofabiomodule imports.g313; // adds public package imports (see https://issues.dlang.org/show_bug.cgi?id=15900) public import imports.g313public; // same w/ deferred semantics static if (true) public import imports.g313staticif; mixin("public import imports.g313stringmixin;"); template impD() { public import imports.g313templatemixin; } mixin impD!(); void test15900() { // publically imported modules should obviously be available in here as well imports.g313public.bug(); imports.g313staticif.bug(); imports.g313stringmixin.bug(); imports.g313templatemixin.bug(); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/protectionimp.d0000644000175000017500000000111415205374125022760 0ustar fabiofabioprivate { void privF() {} class privC {} struct privS {} union privU {} interface privI {} enum privE { foo } mixin template privMT() {} void privTF(T)() {} class privTC(T) {} struct privTS(T) {} union privTU(T) {} interface privTI(T) {} } void publF(T)() {} void publFA(alias A)() {} private alias privC privA; public mixin template publMT() {} /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=14169 template GetName14169(TemplateParam) { enum GetName14169 = TemplateParam.Name; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/aliasdump.d0000644000175000017500000000006015205374125022042 0ustar fabiofabioalias iainBuclaw = ulong; /// enum aaa : int; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9919a.d0000644000175000017500000000006515205374125021544 0ustar fabiofabiomodule imports.test9919a; import imports.test9919c; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9276type.d0000644000175000017500000000022015205374125022272 0ustar fabiofabiomodule imports.test9276type; import imports.test9276parser; class Type : Expression // <- note to Walter. { } class BasicType : Type { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/depsOutput21238_baz_cond.d0000644000175000017500000000012115205374125024474 0ustar fabiofabiomodule imports.depsOutput21238_baz_cond; template t_cond() { version (qux) {} } ./ldc-1.42.0-src/tests/dmd/compilable/imports/a15333.d0000644000175000017500000000026715205374125020713 0ustar fabiofabiomodule imports.a15333; import ice15333; struct StatementVisitor { void visit() { int location; alias IR = IdentifierResolver!((e){ location = 0; }); } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/test7491b.d0000644000175000017500000000003215205374125021530 0ustar fabiofabiomodule imports.test7491b; ./ldc-1.42.0-src/tests/dmd/compilable/imports/pr9471d.d0000644000175000017500000000005715205374125021203 0ustar fabiofabio// Module needs to be imported to trigger bug. ./ldc-1.42.0-src/tests/dmd/compilable/imports/ldc_github_662c.d0000644000175000017500000000007015205374125022730 0ustar fabiofabiomodule imports.ldc_github_662c; import ldc_github_662; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test20530a.d0000644000175000017500000000000015205374125021567 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/imports/test19656a.d0000644000175000017500000000005015205374125021615 0ustar fabiofabioimport test19656; class Corge: Foo { } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp22734.c0000644000175000017500000000004215205374125021251 0ustar fabiofabiotypedef enum { C } E; int a = C; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test7491a.d0000644000175000017500000000003215205374125021527 0ustar fabiofabiomodule imports.test7491a; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test19657c.d0000644000175000017500000000004515205374125021624 0ustar fabiofabioimport test19657a; class Pol: Foo {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/test9436type.d0000644000175000017500000000024715205374125022301 0ustar fabiofabiomodule imports.test9436type; import imports.test9436node; class Type { mixin ForwardCtor!(); enum ConversionFlags { kAllowBaseClass = 0 } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/a18911.d0000644000175000017500000000010615205374125020710 0ustar fabiofabioenum A_FILE = __FILE_FULL_PATH__; enum suffix_a = "imports/a18911.d"; ./ldc-1.42.0-src/tests/dmd/compilable/imports/a12506.d0000644000175000017500000000010415205374125020700 0ustar fabiofabiomodule imports.a12506; auto f12506(alias fun)() { return fun(1); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/a13226.d0000644000175000017500000000054315205374125020707 0ustar fabiofabiomodule imports.a13226; enum isFunction(alias f) = is(typeof(f) == function); enum isIntField(alias f) = is(typeof(f) == int); string t(alias cls, string method)() { static if (isFunction!(mixin("cls."~method))) {} return ""; } string u(alias cls, string member)() { static if (isIntField!(mixin("cls."~member))) {} return ""; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/testcov1a.d0000644000175000017500000000011115205374125021771 0ustar fabiofabiomodule testcov1a; import testcov1b; alias ArraySet!(int,3) IntegerSet; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test15857b.d0000644000175000017500000000002615205374125021620 0ustar fabiofabiovoid bar15857(int) {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/makedeps_a.d0000644000175000017500000000005515205374125022160 0ustar fabiofabiomodule imports.makedeps_a; void a_func() {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/test21098_phobos.d0000644000175000017500000000230315205374125023022 0ustar fabiofabiostruct Nullable(T) { static struct DontCallDestructorT { T payload; } DontCallDestructorT _value; string toString() const { Appender!string app; formatValueImpl(app, _value); return null; } } struct Appender(A) { InPlaceAppender!A impl; } struct InPlaceAppender(T) { static void toStringImpl(const T[] data) { string app; formatValue(app, data); } } void formatValueImpl(Writer, T)(Writer, const(T)) {} void formatValueImpl(Writer, T)(Writer w, T obj) if (is(T == U[], U)) { formatValue(w, obj[0]); } enum HasToStringResult { none, bla } template hasToString(T) { static if (is(typeof( (T val) { val.toString(s); }))) enum hasToString = HasToStringResult.bla; else enum hasToString = HasToStringResult.none; } void formatValueImpl(Writer, T)(ref Writer w, T val) if (is(T == struct) || is(T == union)) { static if (hasToString!T) int dummy; formatElement(w, val.tupleof); } void formatElement(Writer, T)(Writer w, T val) { formatValueImpl(w, val); } void formatValue(Writer, T)(Writer w, T val) { formatValueImpl(w, val); } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp12242b.d0000644000175000017500000000044115205374125021410 0ustar fabiofabiomodule imports.imp12242b; public: import imports.imp12242b1; // std.string import imports.imp12242b2; // std.algorithm private mixin template MixTmp(T, int x) { template foo(U) if (is(U == T)) { enum foo = x; } } mixin MixTmp!(float, 3); mixin MixTmp!(real, 4); ./ldc-1.42.0-src/tests/dmd/compilable/imports/impcimport.c0000644000175000017500000000002315205374125022244 0ustar fabiofabio enum E { A = 3 }; ./ldc-1.42.0-src/tests/dmd/compilable/imports/test23490pop.d0000644000175000017500000000025215205374125022166 0ustar fabiofabiomodule imports.test23490pop; import imports.test23490frop; import imports.test23490zoo : Zoo23490; class Pop23490 { void frop(Frop23490) { } void zoo(Zoo23490) { } } ./ldc-1.42.0-src/tests/dmd/compilable/imports/ldc_github_662d.d0000644000175000017500000000024015205374125022730 0ustar fabiofabiomodule imports.ldc_github_662d; template RCounted() { void release() { this.destroy; } } struct RC(T) { ~this() { _rc_ptr.release; } T _rc_ptr; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/imp16088.d0000644000175000017500000000003115205374125021255 0ustar fabiofabiomodule imports.imp16088; ./ldc-1.42.0-src/tests/dmd/compilable/imports/ldc_github_662b.d0000644000175000017500000000045215205374125022733 0ustar fabiofabiomodule imports.ldc_github_662b; import imports.ldc_github_662c; import imports.ldc_github_662d; import std.range; class Font { mixin RCounted; auto makeTextData(string s) { // split text by spaces auto arr = s.splitter.array; } } class Engine { RC!Font font; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/c314.d0000644000175000017500000000005415205374125020540 0ustar fabiofabiomodule imports.c314; void bug(string s) {} ./ldc-1.42.0-src/tests/dmd/compilable/imports/udamodule2a.d0000644000175000017500000000006715205374125022274 0ustar fabiofabiomodule imports.udamodule2a; struct UDA { int a; } ./ldc-1.42.0-src/tests/dmd/compilable/imports/pr9471c.d0000644000175000017500000000043415205374125021201 0ustar fabiofabioimport imports.pr9471b; struct Array(T) { static if (is(typeof(T.opCmp))) { } } alias ClassDeclarations = Array!ClassDeclaration; class Dsymbol { void addObjcSymbols(ClassDeclarations); } class ScopeDsymbol : Dsymbol { import imports.pr9471d; void importScope(); } ./ldc-1.42.0-src/tests/dmd/compilable/test22294.i0000644000175000017500000000051415151104326017753 0ustar fabiofabio/*********************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22294 #pragma whatever enum { Ax, Bx, Cx }; #pragma _Static_assert(Ax == 0 && Bx == 1 && Cx == 2, "in"); int array22924[Cx]; // Note that ^Z means end of file, this file ends with one #pragma  this should never be parsed ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/0000755000175000017500000000000015205374125020450 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10421/0000755000175000017500000000000015205374125022467 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10421/algo/0000755000175000017500000000000015205374125023411 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10421/algo/package.d0000644000175000017500000000022515205374125025150 0ustar fabiofabiomodule pkgDIP37_10421.algo; public import pkgDIP37_10421.algo.mod; package { void foo() {} void bar() { foo(); } // should be accessible } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10421/algo/mod.d0000644000175000017500000000030615205374125024334 0ustar fabiofabiomodule pkgDIP37_10421.algo.mod; import pkgDIP37_10421.algo; // foo import pkgDIP37_10421.except; // baz void test() { foo(); // should be accessible baz(); // should be accessible } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10421/except.d0000644000175000017500000000006515205374125024125 0ustar fabiofabiomodule pkgDIP37_10421.except; package void baz() {} ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10302/0000755000175000017500000000000015205374125022465 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10302/libb.d0000644000175000017500000000031115205374125023535 0ustar fabiofabiomodule pkgDIP37_10302.libb; import pkgDIP37_10302.liba; void bar() { foo(); // should be error, but unfortunately this works by bug 314 now. //lib.foo(); pkgDIP37_10302.liba.foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10302/package.d0000644000175000017500000000007215205374125024224 0ustar fabiofabiomodule pkgDIP37_10302; public import pkgDIP37_10302.liba; ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10302/liba.d0000644000175000017500000000005215205374125023536 0ustar fabiofabiomodule pkgDIP37_10302.liba; void foo() {} ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ldc_output_filenames/0000755000175000017500000000000015205374125024655 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ldc_output_filenames/imp/0000755000175000017500000000000015205374125025442 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ldc_output_filenames/imp/foo.d0000644000175000017500000000005115205374125026366 0ustar fabiofabiomodule imp.foo; int bar() { return 0; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ldc_output_filenames/foo.d0000644000175000017500000000004415205374125025603 0ustar fabiofabiomodule foo; public import imp.foo; ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ldc_output_filenames/main.d0000644000175000017500000000011015205374125025736 0ustar fabiofabiomodule ldc_output_filenames; import foo; int main() { return bar(); } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test6461/0000755000175000017500000000000015205374125021750 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test6461/b.d0000644000175000017500000000010715205374125022334 0ustar fabiofabiomodule b; import tmpl; TypeInfo fun() { return typeid(Tmpl!long()); } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test6461/tmpl.d0000644000175000017500000000004715205374125023072 0ustar fabiofabiomodule tmpl; struct Tmpl(T) { T a; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test6461/a.d0000644000175000017500000000010615205374125022332 0ustar fabiofabiomodule a; import tmpl; TypeInfo fun() { return typeid(Tmpl!int()); } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test6461/main.d0000644000175000017500000000013215205374125023035 0ustar fabiofabioimport a, b; void main() { auto t1 = a.fun(); auto t2 = b.fun(); assert(t1 != t2); }./ldc-1.42.0-src/tests/dmd/compilable/extra-files/example7190/0000755000175000017500000000000015151104326022416 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/example7190/models/0000755000175000017500000000000015205374125023707 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/example7190/models/HomeModel.d0000644000175000017500000000026315205374125025726 0ustar fabiofabiomodule example7190.models.HomeModel; import serenity7190.core.Model; struct Article { ulong id; } class HomeModel : Model { private SqlitePersister!Article mArticles; }./ldc-1.42.0-src/tests/dmd/compilable/extra-files/example7190/controllers/0000755000175000017500000000000015205374125024772 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/example7190/controllers/HomeController.d0000644000175000017500000000024115205374125030070 0ustar fabiofabiomodule example7190.controllers.HomeController; import serenity7190.core.Controller; class HomeController : Controller { mixin register!(HomeController); } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/serenity7190/0000755000175000017500000000000015151104326022625 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/serenity7190/core/0000755000175000017500000000000015205374125023563 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/serenity7190/core/Controller.d0000644000175000017500000000121515205374125026052 0ustar fabiofabioclass Controller { mixin template register(T : 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);}); } } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/serenity7190/core/Model.d0000644000175000017500000000023715205374125024772 0ustar fabiofabioclass SqlitePersister(T) { static assert(T.tupleof.length > 0, T.stringof ~ `(` ~ (T.tupleof.length + '0') ~ `): ` ~ T.tupleof.stringof); } class Model {}./ldc-1.42.0-src/tests/dmd/compilable/extra-files/minimal/0000755000175000017500000000000015205374125022076 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/minimal/verify_symbols.sh0000755000175000017500000000050215205374125025506 0ustar fabiofabio#!/usr/bin/env bash # ensure no ModuleInfo or TypeInfo related code was generated if ! nm "$1" | grep -q 'ModuleInfo\|_d_dso_registry\__start_minfo\|__stop_minfo\|TypeInfo' ; then # ensure no exception handling code was generated if ! objdump -h "$1" | grep -q ".eh_frame" ; then exit 0 fi fi exit 1 ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/minimal/object.d0000644000175000017500000000001715205374125023507 0ustar fabiofabiomodule object; ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10354/0000755000175000017500000000000015205374125022474 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10354/package.d0000644000175000017500000000013515205374125024233 0ustar fabiofabiomodule pkgDIP37_10354; public import pkgDIP37_10354.mfoo; public import pkgDIP37_10354.mbar; ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10354/mfoo.d0000644000175000017500000000005515205374125023601 0ustar fabiofabiomodule pkgDIP37_10354.mfoo; void foo(T)() {} ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37_10354/mbar.d0000644000175000017500000000005515205374125023562 0ustar fabiofabiomodule pkgDIP37_10354.mbar; void bar(T)() {} ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37/0000755000175000017500000000000015151104326021732 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37/test17629/0000755000175000017500000000000015205374125023330 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37/test17629/common.di0000644000175000017500000000006415205374125025136 0ustar fabiofabiomodule pkgDIP37.test17629.common; void foo17629(); ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37/test17629/package.di0000644000175000017500000000010415205374125025234 0ustar fabiofabiomodule pkgDIP37.test17629; public import pkgDIP37.test17629.common; ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37/datetime/0000755000175000017500000000000015205374125023534 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37/datetime/common.d0000644000175000017500000000005615205374125025172 0ustar fabiofabiomodule pkgDIP37.datetime.common; void def(); ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/pkgDIP37/datetime/package.d0000644000175000017500000000014715205374125025276 0ustar fabiofabiomodule pkgDIP37.datetime; public import pkgDIP37.datetime.common; //alias std.datetime.common.def def; ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_quote.html0000644000175000017500000003352315205374125025374 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/ddoc_markdown_quote.html test.compilable.ddoc_markdown_code

test.compilable.ddoc_markdown_code

Quote Blocks

Discussion

“It seems to me that most of the ‘new’ programming languages fall into one of two categories: Those from academia with radical new paradigms and those from large corporations with a focus on RAD and the web. Maybe it’s time for a new language born out of practical experience implementing compilers.” -- Michael


Great, just what I need.. another D in programming. -- Segfault


To D, or not to D. -- Willeam NerdSpeare


"What I am going to tell you about is what we teach our programming students in the third or fourth year of graduate school... It is my task to convince you not to turn away because you don't understand it. You see my programming students don't understand it... That is because I don't understand it. Nobody does." -- Richard Deeman


Here's a bit of text between quotes.

This is a quote
And this is a nested quote


This is a quote with a > symbol in it


This is a quote with a continuation


This quote
  • is ended by this list
This quote

is ended by this heading

This quote is ended by a thematic break:

This quote
  1. is ended by this code
    

Some things inside a quote block:


  1. Some code
    
  • a list

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9155.html0000644000175000017500000003624015205374125022600 0ustar fabiofabio ddoc9155

ddoc9155

  • foo

    Declaration

    void foo();

    Note: test document note 2nd line

    Example:

    1. import std.stdio;   //&
      writeln("Hello world!");
      if (test) {
        writefln("D programming language");
      }
      
          algorithm;
      
      xxx;    //comment
          yyy;
      /* test
       * comment
       */
      
      // Create MIME Base64 with CRLF, per line 76.
      File f = File("./text.txt", "r");
      uint line = 0;
      // The ElementType of data is not aggregation type
      foreach (encoded; Base64.encoder(data))
      


    1. wstring ws;
      transcode("hello world",ws);
          // transcode from UTF-8 to UTF-16
      

    Example:

    1. import std.stdio;   //&
      writeln("Hello world!");
      if (test) {
        writefln("D programming language");
      }
      
          algorithm;
      
      xxx;    //comment
          yyy;
      /+ test
       + comment
       +/
      


    1. #!/usr/bin/env rdmd
      // Computes average line length for standard input.
      import std.stdio;
      


    1. writefln(q"EOS
      This
      is a multi-line
      heredoc string
      EOS"
      );
      

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc11823.html0000644000175000017500000003073515205374125022656 0ustar fabiofabio ddoc11823

ddoc11823

  • Declaration

    void file(string arg);

    file function name is file, arg defaults to __FILE__ but not _something__

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc5446.html0000644000175000017500000005536715205374125022612 0ustar fabiofabio ddoc5446

ddoc5446

  • Declaration

    alias This_Foo = ddoc5446a.A_Foo;

  • Declaration

    alias This_Foo_Alias = ddoc5446a.A_Foo;

  • Declaration

    alias This_Int = int;

  • Declaration

    alias This_Enum = ddoc5446a.A_Enum;

  • Declaration

    deprecated alias A_Enum_New = ddoc5446b.A_Enum_New;

  • Bar

    Declaration

    struct Bar;

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test21359a.d0000644000175000017500000000005615205374125022342 0ustar fabiofabiovoid registerAll() { import test21359b; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9369.html0000644000175000017500000003115115205374125022603 0ustar fabiofabio ddoc9369

ddoc9369

  • foo

    Declaration

    void foo();

    Sample:

    1. a=1;
      writeln(AddressOf!a);
      Exclamation
      QuestionMark
      

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc10.html0000644000175000017500000010132215205374125022407 0ustar fabiofabio ddoc10

ddoc10

  • Foo

    Declaration

    struct Foo(T);
    struct Foo(T, U);

    The foo

  • Declaration

    int func1(T)(T x);

    This basic case doesn't work very well. The template signature is documented twice, but the function signature (argument names and return type) is not documented at all. This comment is also repeated twice.

  • Declaration

    int func2(T, U)(T x, U y);
    int func2(T)(T x);

    This comment is also repeated twice, and the second function signature is not very well documented.

  • Declaration

    int func2()();

    Separate overload item.

  • Declaration

    int func3(T, U)(T x, U y);
    int func3(T, U = int, V : long)(T x);

    This used to work adequately and documented both func3 templates simultaneously. Now, it documents the first template twice and no longer documents the function argument and return types.

  • map

    Declaration

    void map(char rs);
    void map(int rs);

    blah

  • Declaration

    void map2()(char rs);
    void map2()(int rs);

    blah

  • Declaration

    void map3(char rs);

  • Declaration

    void map4(string s)(char rs);

  • Declaration

    template map5(string s)

  • Declaration

    struct bar6;

    blah

  • Declaration

    struct Foo7(T);

    template bodies

    • bar

      Declaration

      void bar();

      Attempt two: Inside.

      Discussion

      Attempt one: Doc outside static if.

    • abc

      Declaration

      static void abc();

      the abc function should be static

  • Declaration

    abstract class Foo8;

    show abstract

  • Declaration

    void bug4878(string a = ")");

    a stray ) mustn't foul the macros

  • S

    Declaration

    struct S;

    • Declaration

      pure nothrow this(long ticks) const;

    • foo

      Declaration

      pure nothrow void foo(long ticks) const;

  • f10

    Declaration

    float f10(float a, float b);

    Produces something in (a;b]

  • h10

    Declaration

    float h10(float a, float b);

    Produces something in [a;b)

  • Declaration

    void bug6090(string f = "$(B b)", char g = ')')(string h = "$(", string i = "$)");

  • T

    Declaration

    struct T;

    • Declaration

      this(A...)(A args);

    • Declaration

      this(int);

  • Declaration

    int x14547;
    enum int y14547;

    doc-comment

  • Declaration

    enum auto isInt14547(T);
    enum bool isString14547(T);
    static immutable typeName14547(T);
    int storageFor14547(T);

    doc-comment

  • Declaration

    enum int foo14547(T);
    template bar14547(T) if (is(T == int))

    doc-comment

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_code_verbose.html0000644000175000017500000003011215205374125026665 0ustar fabiofabiocompilable/ddoc_markdown_code_verbose.d(13): Ddoc: adding code block for language 'ruby' === ${RESULTS_DIR}/compilable/ddoc_markdown_code_verbose.html test.compilable.ddoc_markdown_code_verbose

test.compilable.ddoc_markdown_code_verbose

Code:

  1. RWBY

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9.html0000644000175000017500000004024115205374125022341 0ustar fabiofabio ddoc9

ddoc9

  • Declaration

    template Template(T)

    Template Documentation (OK)

  • Declaration

    void Function(T)(T x);

    Function Documentation (Not included at all by DDoc)

  • Declaration

    class Class(T);

    Class Documentation (OK)

  • Declaration

    struct Struct(T);

    Struct Documentation

  • Declaration

    union Union(T);

    Union Documentation

  • Declaration

    template TemplateWithAnonEnum(T)

    Template documentation with anonymous enum

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test21359b.d0000644000175000017500000000031115205374125022335 0ustar fabiofabiostruct SumType(Types...) { static foreach (T; Types) T values_; } SumType!(string[int]) convertObserver; void hackAroundLinkerError() { auto t = typeid(const(immutable(char)[][])); } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9789.html0000644000175000017500000003134515205374125022616 0ustar fabiofabio ddoc9789

ddoc9789

  • S

    Declaration

    struct S;

  • A

    Declaration

    alias A = S;

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc19814.html0000644000175000017500000003016115205374125022657 0ustar fabiofabio test.compilable.ddoc_markdown_nested_code

test.compilable.ddoc_markdown_nested_code

Nested Code

Discussion

  1. /**
     * Examples:
     * --------------------
     * writeln("3"); // writes '3' to stdout
     * --------------------
     */
    

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test19266.d0000644000175000017500000000005215205374125022201 0ustar fabiofabiomodule test19266; pragma(msg, __FILE__); ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_escapes.html0000644000175000017500000003036715205374125025665 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/ddoc_markdown_escapes.html ddoc_markdown_escapes

ddoc_markdown_escapes

Backslash Escapes:

Discussion

!"#$%&'()*+,-./:;<=>?@[\]^_`{|}

But not in code:

  1. \{\}
    


\{\}

Nor in HTML:



Nor before things that aren't punctuation:

C:\dlang\dmd

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/makedeps-import-codemixin.txt0000644000175000017500000000005415205374125026266 0ustar fabiofabioenum text2 = import("makedeps-import.txt"); ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_code.html0000644000175000017500000003412515205374125025150 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/ddoc_markdown_code.html test.compilable.ddoc_markdown_code

test.compilable.ddoc_markdown_code

Code Blocks

Discussion

  1. A regular ol' code block (note the uneven delimiter lengths)
    


  1. A backtick-fenced code block
    


  1. A tilde-fenced code block
    


  1. A hyphen-fenced D code block
    


  1. A backtick-fenced D code block
    


  1. A tilde-fenced D code block
    


  1. A hyphen-fenced ruby code block
    


  1. A backtick-fenced ruby code block
    


  1. A tilde-fenced ruby code block
    

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_breaks.html0000644000175000017500000003035515205374125025506 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/ddoc_markdown_breaks.html ddoc_markdown_lists

ddoc_markdown_lists

Thematic Breaks

Discussion

Some text before


Some text in between
Some text after

  1. This is a code block
    


But this is a thematic break:

Not Thematic Breaks

_ **

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc2.html0000644000175000017500000003655615205374125022350 0ustar fabiofabio std.test

std.test

Summary

Discussion

Description1

Description2

Description3

See Also

Things to see also.

And more things.

  • Declaration

    class StreamException: object.Exception;

    A base class for stream exceptions.

    • Declaration

      this(string msg, int foo);

      Construct a StreamException with given error message msg.

      Parameters

      string msg

      the red blue green yellow.

      int foo

      next parameter which is a much longer message spanning multiple lines.

    • Declaration

      int stars;

      stars

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc3.html0000644000175000017500000003775715205374125022355 0ustar fabiofabio std.test

std.test

Summary

Discussion

Description1

Description2

Description3

See Also

Things to see also.

And more things
'arg1, arg2, arg3' : arg1, arg2, arg3.
'arg2, arg3' : arg2, arg3.
'arg1' : arg1.
'arg2' : arg2.
'arg3' : arg3.


Things to see also world.

1 2 3
4 5 6


  1.       pragma( name );
          pragma( name , option [ option ] );
          (
      

  • Declaration

    class StreamException: object.Exception;

    A base class for stream exceptions.

    • Declaration

      this(string msg, int foo);

      Construct a StreamException with given error message msg.

      Parameters

      string msg

      the red blue green yellow.

      int foo

      next parameter which is a much longer message spanning multiple lines.

    • Declaration

      int stars;

      stars

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc18361.html0000644000175000017500000000062715205374125022657 0ustar fabiofabio void main(string[] arguments);

The main thing this program does is nothing, and I do HALPIMBEINGSUPPRESSED not want to hear any false arguments about that!

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test19376.di0000644000175000017500000000006615205374125022361 0ustar fabiofabiomodule test19376; int x = 5; // any old declaration ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc10366.html0000644000175000017500000003402715205374125022655 0ustar fabiofabio ddoc10366

ddoc10366

  • S

    Declaration

    struct S(T);

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/dtoh_imports.d0000644000175000017500000000025315205374125023330 0ustar fabiofabioextern(C++): public import dtoh_imports2 : MyStdcInt = customInt; class ImportsC {} void importFunc() {} private struct HiddenData {} enum : int { IgnoreErrors } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc1.html0000644000175000017500000006165015205374125022340 0ustar fabiofabio abc

abc

This module is for ABC

  • Declaration

    alias myint = int;

  • f

    Declaration

    myint f;

    windy city

    Discussion

    paragraph 2 about of F

    1. #include <stdio.h>
      void main()
      {
      	printf("hello\n");
      }
      

  • E

    Declaration

    enum E: int;

    comment1

  • g

    Declaration

    int g;

    comment2

  • LS

    Declaration

    wchar LS;

    UTF line separator

  • PS

    Declaration

    wchar PS;
    wchar _XX;
    wchar YY;

    UTF paragraph separator

  • foo

    Declaration

    int foo(char c, int argulid, char u = '\'', wchar v = '\u7233', dchar y = '\U00017233');

    Function foo takes argument c and adds it to argulid.

    Discussion

    Then it munges argulid, u underline.

    Parameters

    char c

    the character which adds c to argulid

    int argulid

    the argument

    char u

    the other argument

  • Declaration

    int barr();

    doc for barr()

  • Bar

    Declaration

    class Bar;

    The Class Bar

    • x

      Declaration

      int x;

      member X

    • y

      Declaration

      int y;

      member Y

    • z

      Declaration

      protected int z;

      member Z

  • Declaration

    enum Easy: int;

    The Enum Easy

    • red

      Declaration

      red

      the Red

    • Declaration

      blue

      the Blue

    • Declaration

      green

      the Green

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9497a.html0000644000175000017500000003074415205374125022755 0ustar fabiofabio ddoc9497a

ddoc9497a

  • foo

    Declaration

    void foo();

    foo function.

    Args:

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test23626a.d0000644000175000017500000000156615205374125022350 0ustar fabiofabiotemplate fullyQualifiedName(T...) { enum fullyQualifiedName = !T[0]; } void __trace_maybeDumpTupleToFile(Args...)(auto ref const Args args) nothrow @nogc { } int getStructInfoEx(T)() { enum Ctx = fullyQualifiedName!T; return 0; } auto as(Func)(Func) {} @nogc void foo() { } void assertOp(string OPERATION, LHS, RHS)(LHS lhs, RHS) { as({ try { try as(lhs); catch(Throwable) foo(); } catch(Throwable) assert(false); }); } struct FixedArray(T, size_t capacity_) { int a = getStructInfoEx!FixedArray; T* some_function() { assertOp !""(1, 1); return null; } alias some_function this; } struct ReclamationBatch { FixedArray !(uint,1) dummy; @nogc nothrow void some_inout_func() inout { } void func_2(Dlg)(Dlg dlg) { __trace_maybeDumpTupleToFile(dlg); } void _reclaimBatch() { func_2({ some_inout_func; }); } } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/dtoh_imports2.d0000644000175000017500000000004515205374125023411 0ustar fabiofabioextern(C++): alias customInt = int; ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddocYear.html0000644000175000017500000003047715205374125023103 0ustar fabiofabio ddocYear

ddocYear

  • Declaration

    int year;

    __YEAR__

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9676b.html0000644000175000017500000003031415205374125022746 0ustar fabiofabio ddoc9676b

ddoc9676b

  • foo

    Declaration

    deprecated void foo();

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9037.html0000644000175000017500000003146515205374125022603 0ustar fabiofabio ddoc9037

ddoc9037

  • Declaration

    void test9037();

    Example:

    1. D d = d;
      
    1. D d = d;
      

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/imp9057.d0000644000175000017500000000010515205374125021723 0ustar fabiofabiostruct BugInt { uint[] data = ZEROX; } enum uint [] ZEROX = [0]; ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_tables_22285.html0000644000175000017500000003117215205374125026251 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/ddoc_markdown_tables_22285.html test.compilable.ddoc_markdown_tables_22285

test.compilable.ddoc_markdown_tables_22285

  • _

    Declaration

    enum int _;

    ABC
    a0
    b1 1 1
    c2

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9369.ddoc0000644000175000017500000000011615205374125022545 0ustar fabiofabioESCAPES = /&/AddressOf!/ /!/Exclamation/ /?/QuestionMark/ ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/header1.d0000644000175000017500000002435715205374125022141 0ustar fabiofabio// REQUIRED_ARGS: -ignore module foo.bar; import core.vararg; // Only compilable, declare inline void writeln(T...)(T) {} pragma(lib, "test"); pragma(msg, "Hello World"); pragma(linkerDirective, "/DEFAULTLIB:test2"); static assert(true, "message"); alias double mydbl; alias fl1 = function () in {} in (true) out (; true) out (r; true) out { } out (r) { } do { return 2; }; alias fl2 = function () in (true) out(; true) out(r; true) { return 2; }; int testmain() in { assert(1+(2+3) == -(1 - 2*3)); } out (result) { assert(result == 0); } do { float f = float.infinity; int i = cast(int) f; writeln(i,1,2); writeln(cast(int)float.max); assert(i == cast(int)float.max); assert(i == 0x80000000); return 0; } struct S { int m, n; } template Foo(T, int V) { void foo(...) { static if (is(Object _ : X!TL, alias X, TL...)) {} // https://issues.dlang.org/show_bug.cgi?id=10044 auto x = __traits(hasMember, Object, "noMember"); auto y = is(Object : X!TL, alias X, TL...); assert(!x && !y, "message"); S s = { 1,2 }; auto a = [1, 2, 3]; auto aa = [1:1, 2:2, 3:3]; int n,m; } int bar(double d, int x) { if (d) { d++; } else d--; asm { naked ; mov EAX, 3; } for (;;) { d = d + 1; } for (int i = 0; i < 10; i++) { d = i ? d + 1 : 5; } char[] s; foreach (char c; s) { d *= 2; if (d) break; else continue; } switch (V) { case 1: case 2: break; case 3: goto case 1; case 4: goto default; default: d /= 8; break; } enum Label { A, B, C } void fswitch(Label l) { final switch (l) { case A: break; case B: break; case C: break; } } loop: while (x) { x--; if (x) break loop; else continue loop; } do { x++; } while (x < 10); try { bar(1, 2); } catch (Object o) { x++; } finally { x--; } try bar(1, 2); catch(Object o) x++; finally x--; Object o; synchronized (o) { x = ~x; } synchronized { x = x < 3; } with (o) { toString(); } } } static this() { } static ~this() { } pure nothrow @safe @nogc static this() {} pure nothrow @safe @nogc static ~this() {} static this() pure nothrow @safe @nogc {} static ~this() pure nothrow @safe @nogc {} pure nothrow @safe @nogc shared static this() {} pure nothrow @safe @nogc shared static ~this() {} shared static this() pure nothrow @safe @nogc {} shared static ~this() pure nothrow @safe @nogc {} interface iFoo{} class xFoo: iFoo{} interface iFoo2{} class xFoo2: iFoo, iFoo2{} class Foo3 { this(int a, ...){} this(int* a){} } alias int myint; static notquit = 1; class Test { void a() {} void b() {} void c() {} void d() {} void e() {} void f() {} void g() {} void h() {} void i() {} void j() {} void k() {} void l() {} void m() {} void n() {} void o() {} void p() {} void q() {} void r() {} void s() {} void t() {} void u() {} void v() {} void w() {} void x() {} void y() {} void z() {} void aa() {} void bb() {} void cc() {} void dd() {} void ee() {} // Try adding or removing some functions here to see the effect. template A(T) { } alias A!(uint) getHUint; alias A!(int) getHInt; alias A!(float) getHFloat; alias A!(ulong) getHUlong; alias A!(long) getHLong; alias A!(double) getHDouble; alias A!(byte) getHByte; alias A!(ubyte) getHUbyte; alias A!(short) getHShort; alias A!(ushort) getHUShort; alias A!(real) getHReal; alias void F(); pure nothrow @safe @nogc unittest {} pure nothrow @safe @nogc invariant {} pure nothrow @safe @nogc invariant (true); } template templ( T ) { void templ( T val ) { pragma( msg, "Invalid destination type." ); } } static char[] charArray = [ '\"', '\'' ]; class Point { auto x = 10; uint y = 20; } template Foo2(bool bar) { void test() { static if(bar) { int i; } else { } static if(!bar) { } else { } } } template Foo4() { void bar() { } } template Foo4x( T... ) {} class Baz4 { mixin Foo4 foo; mixin Foo4x!(int, "str") foox; alias foo.bar baz; } int test(T)(T t) { if (auto o = cast(Object)t) return 1; return 0; } enum x6 = 1; bool foo6(int a, int b, int c, int d) { return (a < b) != (c < d); } auto foo7(int x) { return 5; } class D8{} void func8() { scope a= new D8(); } T func9(T)() if (true) { T i; scope(exit) i= 1; scope(success) i = 2; scope(failure) i = 3; return i; } template V10(T) { void func() { for(int i,j=4; i<3;i++) { } } } int foo11(int function() fn) { return fn(); } int bar11(T)() { return foo11(function int (){ return 0; }); } struct S6360 { @property long weeks1() const pure nothrow { return 0; } @property const pure nothrow long weeks2() { return 0; } } struct S12 { /// postfix storage class and constructor this(int n) nothrow{} /// prefix storage class (==StorageClassDeclaration) and constructor nothrow this(string s){} } /// dummy struct T12 { /// postfix storage class and template constructor this()(int args) immutable { } /// prefix storage class (==StorageClassDeclaration) and template constructor immutable this(A...)(A args){ } } // https://issues.dlang.org/show_bug.cgi?id=6591 import core.stdc.stdio : printf, F = FILE; void foo6591()() { import core.stdc.stdio : printf, F = FILE; } // https://issues.dlang.org/show_bug.cgi?id=8081 version(unittest) { pure nothrow unittest {} pure nothrow unittest {} public unittest {} extern(C) unittest {} align unittest {} } // https://issues.dlang.org/show_bug.cgi?id=10334 template Foo10334(T) if (Bar10334!()) {} /// template Foo10334(T) if (Bar10334!100) {} /// template Foo10334(T) if (Bar10334!3.14) {} /// template Foo10334(T) if (Bar10334!"str") {} /// template Foo10334(T) if (Bar10334!1.4i) {} /// template Foo10334(T) if (Bar10334!null) {} /// template Foo10334(T) if (Bar10334!true) {} /// template Foo10334(T) if (Bar10334!false) {} /// template Foo10334(T) if (Bar10334!'A') {} /// template Foo10334(T) if (Bar10334!int) {} /// template Foo10334(T) if (Bar10334!string) {} /// template Foo10334(T) if (Bar10334!wstring) {} /// template Foo10334(T) if (Bar10334!dstring) {} /// template Foo10334(T) if (Bar10334!this) {} /// template Foo10334(T) if (Bar10334!([1,2,3])) {} /// template Foo10334(T) if (Bar10334!(Baz10334!())) {} /// template Foo10334(T) if (Bar10334!(Baz10334!T)) {} /// template Foo10334(T) if (Bar10334!(Baz10334!100)) {} /// template Foo10334(T) if (Bar10334!(.foo)) {} /// template Foo10334(T) if (Bar10334!(const int)) {} /// template Foo10334(T) if (Bar10334!(shared T)) {} /// template Test10334(T...) {} /// mixin Test10334!int a; /// mixin Test10334!(int,long) b; /// mixin Test10334!"str" c; /// // https://issues.dlang.org/show_bug.cgi?id=12266 auto clamp12266a(T1, T2, T3)(T1 x, T2 min_val, T3 max_val) { return 0; } pure clamp12266b(T1, T2, T3)(T1 x, T2 min_val, T3 max_val) { return 0; } @disable pure clamp12266c(T1, T2, T3)(T1 x, T2 min_val, T3 max_val) { return 0; } // https://issues.dlang.org/show_bug.cgi?id=13832 alias Dg13832 = ref int delegate(); // https://issues.dlang.org/show_bug.cgi?id=16590 class TestClass { int aa; int b1, b2; this(int b1, int b2) { this.b1 = b1; this.b2 = b2; } ref foo() { return aa; } ref retFunc() return { return aa; } ~this() @trusted @disable @nogc { } } class FooA { protected void method42() { } ~this() @safe { } } class Bar : FooA { override void method42() { } } double foo() @trusted { int a = 5; return a; } struct Foo1(size_t Size = 42 / magic()) { } size_t magic() { return 42; } class Foo2A { immutable(FooA) Dummy = new immutable(FooA); private immutable pure nothrow @nogc @safe this() { } } // https://issues.dlang.org/show_bug.cgi?id=15676 struct Foo3A(T) { @disable this(this); @disable this(); } // return ref, return scope, return ref scope ref int foo(return ref int a) @safe { return a; } int* foo(return scope int* a) @safe { return a; } ref int* foo(scope return ref int* a) @safe { return a; } struct SafeS { this(int[1] x) scope {} this(int[2] x) return scope {} this(int[3] x) return ref scope {} this(int[4] x) return {} @safe: ref SafeS foo() return { return this; } SafeS foo2() return scope { return this; } ref SafeS foo3() scope { static SafeS s; return s; } ref SafeS foo4() scope return { return this; } int* p; } void test13x(@(10) int a, @(20) int, @(30) @(40) int[] arr...) {} enum Test14UDA1; struct Test14UDA2 { string str; } Test14UDA2 test14uda3(string name) { return Test14UDA2(name); } struct Test14UDA4(string v){} void test14x(@Test14UDA1 int, @Test14UDA2("1") int, @test14uda3("2") int, @Test14UDA4!"3" int) {} void test15x(@(20) void delegate(int) @safe dg){} T throwStuff(T)(T t) { if (false) test13x(1, throw new Exception(""), 2); return t ? t : throw new Exception("Bad stuff happens!"); } class C12344 { abstract int c12344(int x) in(x > 0) out(result) {assert(result > 0);}; } interface I12344 { int i12344(int x) in(x > 0) out(result) {assert(result > 0);}; } debug enum issue21406 = 1; ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc14.html0000644000175000017500000010311015205374125022410 0ustar fabiofabio ddoc14

ddoc14

  • Declaration

    struct Structure;

    -1

    • Declaration

      P variable;

      0

    • Declaration

      V mNone(lazy P p);

      1

    • Declaration

      pure nothrow V mPrefix(lazy P p);

      2

    • Declaration

      pure nothrow V mSuffix(lazy P p);

      3

    • Declaration

      pure nothrow V mSuffixTemplate(T)(lazy P p, T[] t...);

      5

    • Declaration

      pure nothrow V mScoped(lazy P p);

      6

    • Declaration

      pure nothrow auto mAutoPrefix(ref P p);

      7

    • Declaration

      pure nothrow auto mAutoTemplateSuffix(alias T)(ref T t);

      9

    • Declaration

      pure nothrow V mColon(lazy P p);

      10

  • Declaration

    class Class;

    -1

    • Declaration

      P variable;

      0

    • Declaration

      V mNone(lazy P p);

      1

    • Declaration

      pure nothrow V mPrefix(lazy P p);

      2

    • Declaration

      pure nothrow V mSuffix(lazy P p);

      3

    • Declaration

      pure nothrow V mSuffixTemplate(T)(lazy P p, T[] t...);

      5

    • Declaration

      pure nothrow V mScoped(lazy P p);

      6

    • Declaration

      pure nothrow auto mAutoPrefix(ref P p);

      7

    • Declaration

      pure nothrow auto mAutoTemplateSuffix(alias T)(ref T t);

      9

    • Declaration

      pure nothrow V mColon(lazy P p);

      10

  • Declaration

    P variable;

    0

  • Declaration

    V mNone(lazy P p);

    1

  • Declaration

    pure nothrow V mPrefix(lazy P p);

    2

  • Declaration

    pure nothrow V mSuffix(lazy P p);

    3

  • Declaration

    pure nothrow V mSuffixTemplate(T)(lazy P p, T[] t...);

    5

  • Declaration

    pure nothrow V mScoped(lazy P p);

    6

  • Declaration

    pure nothrow auto mAutoPrefix(ref P p);

    7

  • Declaration

    pure nothrow auto mAutoTemplateSuffix(alias T)(ref T t);

    9

  • Declaration

    pure nothrow V mColon(lazy P p);

    10

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9497a.ddoc0000644000175000017500000000005615205374125022713 0ustar fabiofabioDDOC_UNDEFINED_MACRO=./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc12706.html0000644000175000017500000003042615205374125022654 0ustar fabiofabio ddoc12706

ddoc12706

  • Declaration

    void test()(string[] args) if (args[$]);

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9497c.html0000644000175000017500000003072415205374125022755 0ustar fabiofabio ddoc9497c

ddoc9497c

  • foo

    Declaration

    void foo();

    foo function.

    Args: arg1, arg2

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9497b.ddoc0000644000175000017500000000004615205374125022713 0ustar fabiofabioDDOC_UNDEFINED_MACRO=$(DOLLAR)($1 $+) ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/c6395.d0000644000175000017500000000051315205374125021365 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=6395 template map(alias fun) { auto map(Range)(Range r) { struct Result { @property auto ref front() { return fun("a"); } } return Result(); } } Range find(alias pred, Range)(Range haystack) { pred(haystack.front); return haystack; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_links_verbose.html0000644000175000017500000003147215205374125027105 0ustar fabiofabiocompilable/ddoc_markdown_links_verbose.d(17): Ddoc: found link reference 'dub' to 'https://code.dlang.org' compilable/ddoc_markdown_links_verbose.d(17): Ddoc: linking '[Object]' to '$(DOC_ROOT_object)object$(DOC_EXTENSION)#.Object' compilable/ddoc_markdown_links_verbose.d(17): Ddoc: linking '[the D homepage](https://dlang.org)' to 'https://dlang.org' compilable/ddoc_markdown_links_verbose.d(17): Ddoc: linking '[dub]' to 'https://code.dlang.org' compilable/ddoc_markdown_links_verbose.d(17): Ddoc: linking '[dub][]' to 'https://code.dlang.org' compilable/ddoc_markdown_links_verbose.d(17): Ddoc: linking '![D-Man](https://dlang.org/images/d3.png)' to 'https://dlang.org/images/d3.png' === ${RESULTS_DIR}/compilable/ddoc_markdown_links_verbose.html test.compilable.ddoc_markdown_links_verbose

test.compilable.ddoc_markdown_links_verbose

Links: A link to Object. An inline link to the D homepage. A simple link to dub. A slightly less simple link to dub. An image: D-Man

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_lists_verbose.html0000644000175000017500000002747315205374125027131 0ustar fabiofabiocompilable/ddoc_markdown_lists_verbose.d(9): Ddoc: starting list item 'list item' === ${RESULTS_DIR}/compilable/ddoc_markdown_lists_verbose.html ddoc_markdown_lists_verbose

ddoc_markdown_lists_verbose

  • list item

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_links.html0000644000175000017500000003142615205374125025357 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/ddoc_markdown_links.html test.compilable.ddoc_markdown_links

test.compilable.ddoc_markdown_links

Links

Discussion

A link to printf.

A link to the base object.

Not a link because it's an associative array: int[Object].

An inline link to the D homepage.

A reference link to the D homepage.

Not a reference link because it [links to nothing][nonexistent].

A simple link to dub.

A slightly less simple link to dub.

An image: D-Man Another image: D-Man again

Here's a reference to the tour inside a macro.

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_emphasis.html0000644000175000017500000003103415205374125026043 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/ddoc_markdown_emphasis.html ddoc_markdown_emphasis

ddoc_markdown_emphasis

Markdown Emphasis:

Discussion

emphasized text

emphasized text on more than one line

strongly emphasized text

inseperable

tricky emphasis

more tricky emphasis

trickyunspaced

moretrickyunspaced

highly nested emphasis in this line

inside a macro

outside a macro

The following aren't Markdown emphasis:

a * not emphasis*

a*"not either"*

*nor this *

*jumping into a macro*

*jumping out of a macro*

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test9680winmain.d0000644000175000017500000000023315205374125023504 0ustar fabiofabioimport core.sys.windows.windef; extern(Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { return 0; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc4.html0000644000175000017500000002675515205374125022352 0ustar fabiofabio ddoc4

ddoc4

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/jsonCompilerInfo.json0000644000175000017500000000076515205374125024633 0ustar fabiofabio{ "compilerInfo": { "__VERSION__": 0, "architectures": [ "VALUES_REMOVED_FOR_TEST" ], "interface": "dmd", "platforms": [ "VALUES_REMOVED_FOR_TEST" ], "predefinedVersions": [ "VALUES_REMOVED_FOR_TEST" ], "size_t": 0, "supportedFeatures": { "includeImports": true }, "vendor": "VALUE_REMOVED_FOR_TEST", "version": "VALUE_REMOVED_FOR_TEST" } } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_tables_verbose.html0000644000175000017500000002774615205374125027250 0ustar fabiofabiocompilable/ddoc_markdown_tables_verbose.d(13): Ddoc: formatting table '| this | that |' === ${RESULTS_DIR}/compilable/ddoc_markdown_tables_verbose.html test.compilable.ddoc_markdown_tables_verbose

test.compilable.ddoc_markdown_tables_verbose

Table:
thisthat
cellcell

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/json.json0000644000175000017500000011577015205374125022327 0ustar fabiofabio[ { "file": "VALUE_REMOVED_FOR_TEST", "kind": "module", "members": [ { "char": 1, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 23, "endline": 8, "kind": "shared static constructor", "line": 8, "name": "_sharedStaticCtor_L8_C1", "protection": "public", "storageClass": [ "static" ] }, { "char": 1, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 16, "endline": 9, "kind": "static constructor", "line": 9, "name": "static this", "protection": "public", "storageClass": [ "static" ] }, { "char": 1, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 24, "endline": 10, "kind": "shared static destructor", "line": 10, "name": "_sharedStaticDtor_L10_C1", "protection": "public", "storageClass": [ "static" ] }, { "char": 1, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 17, "endline": 11, "kind": "static destructor", "line": 11, "name": "static ~this", "protection": "public", "storageClass": [ "static" ] }, { "char": 1, "kind": "template", "line": 13, "members": [ { "char": 5, "endchar": 27, "endline": 15, "kind": "shared static constructor", "line": 15, "name": "_sharedStaticCtor_L15_C5", "storageClass": [ "static" ] }, { "char": 5, "endchar": 20, "endline": 16, "kind": "static constructor", "line": 16, "name": "static this", "storageClass": [ "static" ] }, { "char": 5, "endchar": 28, "endline": 17, "kind": "shared static destructor", "line": 17, "name": "_sharedStaticDtor_L17_C5", "storageClass": [ "static" ] }, { "char": 5, "endchar": 21, "endline": 18, "kind": "static destructor", "line": 18, "name": "static ~this", "storageClass": [ "static" ] } ], "name": "X", "parameters": [ { "kind": "type", "name": "T" } ], "protection": "public" }, { "char": 1, "kind": "alias", "line": 21, "name": "SSCDX", "originalType": "X!int", "protection": "public" }, { "char": 1, "kind": "class", "line": 23, "members": [ { "char": 5, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 27, "endline": 25, "kind": "shared static constructor", "line": 25, "name": "_sharedStaticCtor_L25_C5", "protection": "public", "storageClass": [ "static" ] }, { "char": 5, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 20, "endline": 26, "kind": "static constructor", "line": 26, "name": "static this", "protection": "public", "storageClass": [ "static" ] }, { "char": 5, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 28, "endline": 27, "kind": "shared static destructor", "line": 27, "name": "_sharedStaticDtor_L27_C5", "protection": "public", "storageClass": [ "static" ] }, { "char": 5, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 21, "endline": 28, "kind": "static destructor", "line": 28, "name": "static ~this", "protection": "public", "storageClass": [ "static" ] } ], "name": "SSCDClass", "protection": "public" }, { "char": 1, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "alias", "line": 18, "name": "myInt", "protection": "public" }, { "char": 7, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 19, "name": "x", "originalType": "myInt", "protection": "public" }, { "char": 1, "kind": "template", "line": 21, "members": [ { "char": 1, "kind": "struct", "line": 21, "members": [ { "char": 19, "kind": "variable", "line": 21, "name": "t", "type": "T" } ], "name": "Foo", "protection": "public" } ], "name": "Foo", "parameters": [ { "kind": "type", "name": "T" } ], "protection": "public" }, { "char": 1, "kind": "template", "line": 22, "members": [ { "char": 1, "kind": "class", "line": 22, "members": [ { "char": 25, "deco": "VALUE_REMOVED_FOR_TEST", "init": "T", "kind": "variable", "line": 22, "name": "t" } ], "name": "Bar", "protection": "public" } ], "name": "Bar", "parameters": [ { "deco": "VALUE_REMOVED_FOR_TEST", "kind": "value", "name": "T" } ], "protection": "public" }, { "char": 1, "kind": "template", "line": 23, "members": [ { "char": 1, "kind": "interface", "line": 23, "members": [ { "char": 28, "kind": "function", "line": 23, "name": "t", "type": "const T[0]()" } ], "name": "Baz", "protection": "public" } ], "name": "Baz", "parameters": [ { "kind": "tuple", "name": "T" } ], "protection": "public" }, { "char": 1, "kind": "template", "line": 25, "members": [], "name": "P", "parameters": [ { "kind": "alias", "name": "T" } ], "protection": "public" }, { "base": "json.Bar!1.Bar", "char": 1, "interfaces": [ "json.Baz!(int, 2, null).Baz" ], "kind": "class", "line": 27, "members": [ { "char": 5, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 13, "endline": 28, "kind": "constructor", "line": 28, "name": "this", "originalType": "()", "protection": "public" }, { "char": 5, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 14, "endline": 29, "kind": "destructor", "line": 29, "name": "~this", "protection": "public", "storageClass": [ "scope" ] }, { "char": 12, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 19, "endline": 31, "kind": "function", "line": 31, "name": "foo", "originalType": "()", "protection": "public", "storageClass": [ "static" ] }, { "char": 32, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "function", "line": 32, "name": "baz", "protection": "protected", "storageClass": [ "abstract" ] }, { "char": 18, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 40, "endline": 33, "kind": "function", "line": 33, "name": "t", "overrides": [ "json.Baz!(int, 2, null).Baz.t" ], "protection": "public", "storageClass": [ "override" ] }, { "kind": "alias", "name": "~this", "protection": "public" } ], "name": "Bar2", "protection": "public" }, { "base": "json.Bar2", "char": 1, "kind": "class", "line": 36, "members": [ { "char": 17, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 37, "name": "val", "offset": 0, "protection": "private" }, { "char": 5, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 28, "endline": 38, "kind": "constructor", "line": 38, "name": "this", "originalType": "(int i)", "parameters": [ { "deco": "VALUE_REMOVED_FOR_TEST", "name": "i" } ], "protection": "public" }, { "char": 32, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 61, "endline": 40, "kind": "function", "line": 40, "name": "baz", "overrides": [ "json.Bar2.baz" ], "protection": "protected", "storageClass": [ "override" ] } ], "name": "Bar3", "protection": "public" }, { "char": 1, "kind": "struct", "line": 43, "members": [ { "char": 10, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 44, "name": "bar2", "offset": 0, "originalType": "Bar2", "protection": "public" }, { "char": 5, "kind": "union", "line": 45, "members": [ { "char": 19, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 47, "name": "s", "offset": 0, "protection": "public" }, { "char": 17, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 48, "name": "i", "offset": 0, "protection": "public" }, { "char": 16, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 50, "name": "o", "offset": 0, "originalType": "Object", "protection": "public" } ], "name": "U", "protection": "public" } ], "name": "Foo2", "protection": "public" }, { "char": 1, "kind": "template", "line": 54, "members": [ { "char": 1, "kind": "struct", "line": 54, "members": [ { "char": 14, "kind": "function", "line": 57, "name": "method1", "type": "void()" }, { "char": 14, "kind": "function", "line": 61, "name": "method2", "type": "void()" }, { "char": 10, "kind": "function", "line": 68, "name": "method4", "type": "void()" } ], "name": "Foo3", "protection": "public" } ], "name": "Foo3", "parameters": [ { "deco": "VALUE_REMOVED_FOR_TEST", "kind": "value", "name": "b" } ], "protection": "public" }, { "char": 16, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 1, "endline": 77, "kind": "function", "line": 74, "name": "bar", "originalType": "@trusted myInt(ref uint blah, Bar2 foo = new Bar3(7))", "parameters": [ { "deco": "VALUE_REMOVED_FOR_TEST", "name": "blah", "storageClass": [ "ref" ] }, { "deco": "VALUE_REMOVED_FOR_TEST", "default": "new Bar3(7)", "name": "foo" } ], "protection": "public" }, { "char": 15, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 1, "endline": 96, "kind": "function", "line": 79, "name": "outer", "protection": "public" }, { "char": 8, "kind": "import", "line": 99, "name": "imports.jsonimport1", "protection": "private", "selective": [ "target1", "target2" ] }, { "char": 8, "kind": "import", "line": 100, "name": "imports.jsonimport2", "protection": "private", "renamed": { "alias1": "target1", "alias2": "target2" } }, { "char": 8, "kind": "import", "line": 101, "name": "imports.jsonimport3", "protection": "private", "renamed": { "alias3": "target1", "alias4": "target2" }, "selective": [ "target3" ] }, { "char": 8, "kind": "import", "line": 102, "name": "imports.jsonimport4", "protection": "private" }, { "char": 1, "kind": "struct", "line": 104, "members": [ { "char": 5, "kind": "template", "line": 107, "members": [ { "char": 5, "endchar": 20, "endline": 107, "kind": "constructor", "line": 107, "name": "this", "parameters": [ { "name": "t", "type": "T" } ], "type": "(T t)" } ], "name": "this", "parameters": [ { "kind": "type", "name": "T" } ], "protection": "public" } ], "name": "S", "protection": "public" }, { "char": 9, "kind": "template", "line": 111, "members": [ { "char": 9, "kind": "struct", "line": 111, "members": [], "name": "S1_9755", "protection": "public" } ], "name": "S1_9755", "parameters": [ { "kind": "type", "name": "T" } ], "protection": "private" }, { "char": 9, "kind": "template", "line": 112, "members": [ { "char": 9, "kind": "struct", "line": 112, "members": [], "name": "S2_9755", "protection": "public" } ], "name": "S2_9755", "parameters": [ { "kind": "type", "name": "T" } ], "protection": "package" }, { "char": 1, "kind": "class", "line": 114, "members": [ { "char": 22, "kind": "template", "line": 116, "members": [ { "char": 22, "kind": "class", "line": 116, "members": [], "name": "CI_9755", "protection": "public" } ], "name": "CI_9755", "parameters": [ { "kind": "type", "name": "T" } ], "protection": "protected" } ], "name": "C_9755", "protection": "public" }, { "char": 14, "deco": "VALUE_REMOVED_FOR_TEST", "init": "Object()", "kind": "variable", "line": 120, "name": "c_10011", "originalType": "Object", "protection": "public", "storageClass": [ "const" ] }, { "baseDeco": "i", "char": 1, "kind": "enum", "line": 123, "members": [ { "char": 5, "kind": "enum member", "line": 125, "name": "unspecified1", "protection": "public", "value": "0" }, { "char": 5, "kind": "enum member", "line": 126, "name": "one", "protection": "public", "value": "2" }, { "char": 5, "kind": "enum member", "line": 127, "name": "two", "protection": "public", "value": "3" }, { "char": 5, "kind": "enum member", "line": 128, "name": "FILE_NOT_FOUND", "protection": "public", "value": "101" }, { "char": 5, "kind": "enum member", "line": 129, "name": "unspecified3", "protection": "public", "value": "102" }, { "char": 5, "kind": "enum member", "line": 130, "name": "unspecified4", "protection": "public", "value": "103" }, { "char": 5, "kind": "enum member", "line": 131, "name": "four", "protection": "public", "value": "4" } ], "name": "Numbers", "protection": "public" }, { "char": 1, "constraint": "T == string", "kind": "template", "line": 134, "members": [], "name": "IncludeConstraint", "parameters": [ { "kind": "type", "name": "T" } ], "protection": "public" }, { "char": 5, "deco": "VALUE_REMOVED_FOR_TEST", "file": "VALUE_REMOVED_FOR_TEST", "init": "1", "kind": "variable", "line": 138, "name": "a0", "protection": "public" }, { "char": 5, "deco": "VALUE_REMOVED_FOR_TEST", "init": "1", "kind": "variable", "line": 138, "name": "a1", "protection": "public" }, { "char": 5, "deco": "VALUE_REMOVED_FOR_TEST", "init": "1", "kind": "variable", "line": 138, "name": "a2", "protection": "public" }, { "char": 1, "file": "VALUE_REMOVED_FOR_TEST", "kind": "template", "line": 141, "members": [ { "char": 1, "kind": "alias", "line": 141, "name": "Seq", "type": "T" } ], "name": "Seq", "parameters": [ { "kind": "tuple", "name": "T" } ], "protection": "public" }, {}, { "char": 1, "file": "VALUE_REMOVED_FOR_TEST", "kind": "alias", "line": 145, "name": "b0", "originalType": "a", "protection": "public" }, {}, { "char": 1, "kind": "alias", "line": 145, "name": "b1", "originalType": "a", "protection": "public" }, {}, { "char": 1, "kind": "alias", "line": 145, "name": "b2", "originalType": "a", "protection": "public" }, { "char": 9, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 1, "endline": 152, "file": "VALUE_REMOVED_FOR_TEST", "kind": "function", "line": 149, "name": "foo", "parameters": [ { "deco": "VALUE_REMOVED_FOR_TEST", "name": "a", "storageClass": [ "ref", "return" ] } ], "protection": "public" }, { "char": 6, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 1, "endline": 157, "kind": "function", "line": 154, "name": "foo", "parameters": [ { "deco": "VALUE_REMOVED_FOR_TEST", "name": "a", "storageClass": [ "scope", "return" ] } ], "protection": "public" }, { "char": 10, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 1, "endline": 162, "kind": "function", "line": 159, "name": "foo", "parameters": [ { "deco": "VALUE_REMOVED_FOR_TEST", "name": "a", "storageClass": [ "scope", "ref", "return" ] } ], "protection": "public" }, { "char": 1, "kind": "struct", "line": 164, "members": [ { "char": 15, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 5, "endline": 170, "kind": "function", "line": 167, "name": "foo", "protection": "public" }, { "char": 11, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 5, "endline": 175, "kind": "function", "line": 172, "name": "foo2", "protection": "public" }, { "char": 15, "deco": "VALUE_REMOVED_FOR_TEST", "endchar": 5, "endline": 180, "kind": "function", "line": 177, "name": "foo3", "protection": "public" }, { "char": 7, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 182, "name": "p", "offset": 0, "protection": "public", "storageClass": [ "@safe" ] } ], "name": "SafeS", "protection": "public" }, { "char": 12, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 185, "name": "vlinkageDefault", "protection": "public", "storageClass": [ "extern" ] }, { "char": 15, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 186, "name": "vlinkageD", "protection": "public" }, { "char": 15, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 187, "linkage": "c", "name": "vlinakgeC", "protection": "public" }, { "char": 27, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 188, "linkage": "cpp", "name": "vlinkageCpp", "protection": "public", "storageClass": [ "__gshared" ] }, { "char": 21, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 189, "linkage": "windows", "name": "vlinkageWindows", "protection": "public" }, { "char": 25, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 190, "linkage": "objc", "name": "vlinkageObjc", "protection": "public" }, { "char": 20, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "variable", "line": 191, "linkage": "system", "name": "vlinkageSystem", "protection": "public" }, { "char": 12, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "function", "line": 192, "name": "flinkageDefault", "protection": "public", "storageClass": [ "extern" ] }, { "char": 15, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "function", "line": 193, "name": "flinkageD", "protection": "public" }, { "char": 15, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "function", "line": 194, "linkage": "c", "name": "linakgeC", "protection": "public" }, { "char": 17, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "function", "line": 195, "linkage": "cpp", "name": "flinkageCpp", "protection": "public" }, { "char": 21, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "function", "line": 196, "linkage": "windows", "name": "flinkageWindows", "protection": "public" }, { "char": 25, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "function", "line": 197, "linkage": "objc", "name": "flinkageObjc", "protection": "public" }, { "char": 20, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "function", "line": 198, "linkage": "system", "name": "flinkageSystem", "originalType": "extern (System) int()", "protection": "public" }, { "char": 7, "kind": "template", "line": 199, "members": [], "name": "test18211", "parameters": [ { "deco": "VALUE_REMOVED_FOR_TEST", "kind": "value", "name": "n" } ], "protection": "public" }, { "char": 1, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "alias", "line": 208, "name": "F", "originalType": "size_t function(size_t a)", "protection": "public" } ], "name": "json" } ]./ldc-1.42.0-src/tests/dmd/compilable/extra-files/header1i.di0000644000175000017500000002051315205374125022451 0ustar fabiofabioHello World === ${RESULTS_DIR}/compilable/testheader1i.di // D import file generated from 'compilable/extra-files/header1.d' module foo.bar; import core.vararg; void writeln(T...)(T) { } pragma (lib, "test"); pragma (msg, "Hello World"); pragma (linkerDirective, "/DEFAULTLIB:test2"); static assert(true, "message"); alias mydbl = double; alias fl1 = function () in { } in (true) out (; true) out (r; true) out { } out(r) { } do { return 2; } ; alias fl2 = function () in (true) out (; true) out (r; true) { return 2; } ; int testmain() in { assert(1 + (2 + 3) == -(1 - 2 * 3)); } out(result) { assert(result == 0); } do { float f = (float).infinity; int i = cast(int)f; writeln(i, 1, 2); writeln(cast(int)(float).max); assert(i == cast(int)(float).max); assert(i == 2147483648u); return 0; } struct S { int m; int n; } template Foo(T, int V) { void foo(...) { static if (is(Object _ : X!TL, alias X, TL...)) { } auto x = __traits(hasMember, Object, "noMember"); auto y = is(Object : X!TL, alias X, TL...); assert(!x && !y, "message"); S s = {1, 2}; auto a = [1, 2, 3]; auto aa = [1:1, 2:2, 3:3]; int n, m; } int bar(double d, int x) { if (d) { d++; } else d--; asm { naked; } asm { mov EAX,3; } for (;;) { { d = d + 1; } } for (int i = 0; i < 10; i++) { { d = i ? d + 1 : 5; } } char[] s; foreach (char c; s) { d *= 2; if (d) break; else continue; } switch (V) { case 1: { } case 2: { break; } case 3: { goto case 1; } case 4: { goto default; } default: { d /= 8; break; } } enum Label { A, B, C, } void fswitch(Label l) { final switch (l) { case A: { break; } case B: { break; } case C: { break; } } } loop: while (x) { x--; if (x) break loop; else continue loop; } do { x++; } while (x < 10); try { try { bar(1, 2); } catch(Object o) { x++; } } finally { x--; } try { try bar(1, 2); catch(Object o) { x++; } } finally x--; Object o; synchronized(o) { x = ~x; } synchronized { x = x < 3; } with (o) { toString(); } } } static this(); static ~this(); nothrow pure @nogc @safe static this(); nothrow pure @nogc @safe static ~this(); nothrow pure @nogc @safe static this(); nothrow pure @nogc @safe static ~this(); nothrow pure @nogc @safe shared static this(); nothrow pure @nogc @safe shared static ~this(); nothrow pure @nogc @safe shared static this(); nothrow pure @nogc @safe shared static ~this(); interface iFoo { } class xFoo : iFoo { } interface iFoo2 { } class xFoo2 : iFoo, iFoo2 { } class Foo3 { this(int a, ...) { } this(int* a) { } } alias myint = int; static extern typeof(1) notquit; class Test { void a() { } void b() { } void c() { } void d() { } void e() { } void f() { } void g() { } void h() { } void i() { } void j() { } void k() { } void l() { } void m() { } void n() { } void o() { } void p() { } void q() { } void r() { } void s() { } void t() { } void u() { } void v() { } void w() { } void x() { } void y() { } void z() { } void aa() { } void bb() { } void cc() { } void dd() { } void ee() { } template A(T) { } alias getHUint = A!uint; alias getHInt = A!int; alias getHFloat = A!float; alias getHUlong = A!ulong; alias getHLong = A!long; alias getHDouble = A!double; alias getHByte = A!byte; alias getHUbyte = A!ubyte; alias getHShort = A!short; alias getHUShort = A!ushort; alias getHReal = A!real; alias void F(); } void templ(T)(T val) { pragma (msg, "Invalid destination type."); } static extern char[] charArray; class Point { auto x = 10; uint y = 20; } template Foo2(bool bar) { void test() { static if (bar) { int i; } else { } static if (!bar) { } else { } } } template Foo4() { void bar() { } } template Foo4x(T...) { } class Baz4 { mixin Foo4!() foo; mixin Foo4x!(int, "str") foox; alias baz = foo.bar; } int test(T)(T t) { if (auto o = cast(Object)t) return 1; return 0; } enum x6 = 1; bool foo6(int a, int b, int c, int d) { return (a < b) != (c < d); } auto foo7(int x) { return 5; } class D8 { } void func8() { scope a = new D8; } T func9(T)() if (true) { T i; scope(exit) i = 1; scope(success) i = 2; scope(failure) i = 3; return i; } template V10(T) { void func() { for (int i, j = 4; i < 3; i++) { { } } } } int foo11(int function() fn) { return fn(); } int bar11(T)() { return foo11(function int() { return 0; } ); } struct S6360 { pure nothrow @property long weeks1() const { return 0; } pure nothrow @property long weeks2() const { return 0; } } struct S12 { nothrow this(int n) { } nothrow this(string s) { } } struct T12 { this()(int args) immutable { } this(A...)(A args) immutable { } } import core.stdc.stdio : printf, F = FILE; void foo6591()() { import core.stdc.stdio : printf, F = FILE; } version (unittest) { public {} extern (C) {} align {} } template Foo10334(T) if (Bar10334!()) { } template Foo10334(T) if (Bar10334!100) { } template Foo10334(T) if (Bar10334!3.14) { } template Foo10334(T) if (Bar10334!"str") { } template Foo10334(T) if (Bar10334!1.4i) { } template Foo10334(T) if (Bar10334!null) { } template Foo10334(T) if (Bar10334!true) { } template Foo10334(T) if (Bar10334!false) { } template Foo10334(T) if (Bar10334!'A') { } template Foo10334(T) if (Bar10334!int) { } template Foo10334(T) if (Bar10334!string) { } template Foo10334(T) if (Bar10334!wstring) { } template Foo10334(T) if (Bar10334!dstring) { } template Foo10334(T) if (Bar10334!this) { } template Foo10334(T) if (Bar10334!([1, 2, 3])) { } template Foo10334(T) if (Bar10334!(Baz10334!())) { } template Foo10334(T) if (Bar10334!(Baz10334!T)) { } template Foo10334(T) if (Bar10334!(Baz10334!100)) { } template Foo10334(T) if (Bar10334!(.foo)) { } template Foo10334(T) if (Bar10334!(const(int))) { } template Foo10334(T) if (Bar10334!(shared(T))) { } template Test10334(T...) { } mixin Test10334!int a; mixin Test10334!(int, long) b; mixin Test10334!"str" c; auto clamp12266a(T1, T2, T3)(T1 x, T2 min_val, T3 max_val) { return 0; } pure clamp12266b(T1, T2, T3)(T1 x, T2 min_val, T3 max_val) { return 0; } @disable pure clamp12266c(T1, T2, T3)(T1 x, T2 min_val, T3 max_val) { return 0; } alias Dg13832 = ref int delegate(); class TestClass { int aa; int b1; int b2; this(int b1, int b2) { this.b1 = b1; this.b2 = b2; } ref foo() { return aa; } ref retFunc() return { return aa; } @nogc @trusted @disable ~this() { } } class FooA { protected void method42() { } @safe ~this() { } } class Bar : FooA { override void method42() { } } @trusted double foo() { int a = 5; return a; } struct Foo1(size_t Size = 42 / magic()) { } size_t magic() { return 42; } class Foo2A { immutable(FooA) Dummy = new immutable(FooA); private pure nothrow @nogc @safe this() immutable { } } struct Foo3A(T) { @disable this(this); @disable this(); } ref @safe int foo(return ref int a) { return a; } @safe int* foo(return scope int* a) { return a; } ref @safe int* foo(return ref scope int* a) { return a; } struct SafeS { this(int[1] x) scope { } this(int[2] x) return scope { } this(int[3] x) scope return { } this(int[4] x) return { } @safe { ref SafeS foo() return { return this; } SafeS foo2() return scope { return this; } ref SafeS foo3() scope { static SafeS s; return s; } ref SafeS foo4() scope return { return this; } int* p; } } void test13x(@(10) int a, @(20) int, @(AliasSeq!(30), AliasSeq!(40)) int[] arr...) { } enum Test14UDA1; struct Test14UDA2 { string str; } Test14UDA2 test14uda3(string name) { return Test14UDA2(name); } struct Test14UDA4(string v) { } void test14x(@(Test14UDA1) int, @Test14UDA2("1") int, @test14uda3("2") int, @(Test14UDA4!"3") int) { } void test15x(@(20) void delegate(int) @safe dg) { } T throwStuff(T)(T t) { if (false) test13x(1, throw new Exception(""), 2); return t ? t : throw new Exception("Bad stuff happens!"); } class C12344 { abstract int c12344(int x) in (x > 0) out(result) { assert(result > 0); } ; } interface I12344 { int i12344(int x) in (x > 0) out(result) { assert(result > 0); } ; } debug { enum issue21406 = 1; }./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9497b.html0000644000175000017500000003073315205374125022754 0ustar fabiofabio ddoc9497b

ddoc9497b

  • foo

    Declaration

    void foo();

    foo function.

    Args: $(XYZ arg1, arg2)

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/cdcmp.out0000644000175000017500000006177415205374125022306 0ustar fabiofabio Disassembly of section .text._D5cdcmp8test_ltzFhZb: 0000000000000000 <_D5cdcmp8test_ltzFhZb>: 0: 31 c0 xor eax,eax 2: c3 ret ... Disassembly of section .text._D5cdcmp8test_lezFhZb: 0000000000000000 <_D5cdcmp8test_lezFhZb>: 0: 40 84 ff test dil,dil 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_eqzFhZb: 0000000000000000 <_D5cdcmp8test_eqzFhZb>: 0: 40 84 ff test dil,dil 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_nezFhZb: 0000000000000000 <_D5cdcmp8test_nezFhZb>: 0: 40 84 ff test dil,dil 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_gezFhZb: 0000000000000000 <_D5cdcmp8test_gezFhZb>: 0: b8 01 00 00 00 mov eax,0x1 5: c3 ret ... Disassembly of section .text._D5cdcmp8test_gtzFhZb: 0000000000000000 <_D5cdcmp8test_gtzFhZb>: 0: 40 84 ff test dil,dil 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_ltzFgZb: 0000000000000000 <_D5cdcmp8test_ltzFgZb>: 0: 40 84 ff test dil,dil 3: 0f 98 c0 sets al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_lezFgZb: 0000000000000000 <_D5cdcmp8test_lezFgZb>: 0: 40 84 ff test dil,dil 3: 0f 9e c0 setle al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_eqzFgZb: 0000000000000000 <_D5cdcmp8test_eqzFgZb>: 0: 40 84 ff test dil,dil 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_nezFgZb: 0000000000000000 <_D5cdcmp8test_nezFgZb>: 0: 40 84 ff test dil,dil 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_gezFgZb: 0000000000000000 <_D5cdcmp8test_gezFgZb>: 0: 40 84 ff test dil,dil 3: 0f 99 c0 setns al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_gtzFgZb: 0000000000000000 <_D5cdcmp8test_gtzFgZb>: 0: 40 84 ff test dil,dil 3: 0f 9f c0 setg al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_ltzFtZb: 0000000000000000 <_D5cdcmp8test_ltzFtZb>: 0: 31 c0 xor eax,eax 2: c3 ret ... Disassembly of section .text._D5cdcmp8test_lezFtZb: 0000000000000000 <_D5cdcmp8test_lezFtZb>: 0: 66 85 ff test di,di 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_eqzFtZb: 0000000000000000 <_D5cdcmp8test_eqzFtZb>: 0: 66 85 ff test di,di 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_nezFtZb: 0000000000000000 <_D5cdcmp8test_nezFtZb>: 0: 66 85 ff test di,di 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_gezFtZb: 0000000000000000 <_D5cdcmp8test_gezFtZb>: 0: b8 01 00 00 00 mov eax,0x1 5: c3 ret ... Disassembly of section .text._D5cdcmp8test_gtzFtZb: 0000000000000000 <_D5cdcmp8test_gtzFtZb>: 0: 66 85 ff test di,di 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_ltzFsZb: 0000000000000000 <_D5cdcmp8test_ltzFsZb>: 0: 66 85 ff test di,di 3: 0f 98 c0 sets al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_lezFsZb: 0000000000000000 <_D5cdcmp8test_lezFsZb>: 0: 66 85 ff test di,di 3: 0f 9e c0 setle al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_eqzFsZb: 0000000000000000 <_D5cdcmp8test_eqzFsZb>: 0: 66 85 ff test di,di 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_nezFsZb: 0000000000000000 <_D5cdcmp8test_nezFsZb>: 0: 66 85 ff test di,di 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_gezFsZb: 0000000000000000 <_D5cdcmp8test_gezFsZb>: 0: 66 85 ff test di,di 3: 0f 99 c0 setns al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_gtzFsZb: 0000000000000000 <_D5cdcmp8test_gtzFsZb>: 0: 66 85 ff test di,di 3: 0f 9f c0 setg al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_ltzFkZb: 0000000000000000 <_D5cdcmp8test_ltzFkZb>: 0: 31 c0 xor eax,eax 2: c3 ret ... Disassembly of section .text._D5cdcmp8test_lezFkZb: 0000000000000000 <_D5cdcmp8test_lezFkZb>: 0: 85 ff test edi,edi 2: 0f 94 c0 sete al 5: c3 ret ... Disassembly of section .text._D5cdcmp8test_eqzFkZb: 0000000000000000 <_D5cdcmp8test_eqzFkZb>: 0: 85 ff test edi,edi 2: 0f 94 c0 sete al 5: c3 ret ... Disassembly of section .text._D5cdcmp8test_nezFkZb: 0000000000000000 <_D5cdcmp8test_nezFkZb>: 0: 85 ff test edi,edi 2: 0f 95 c0 setne al 5: c3 ret ... Disassembly of section .text._D5cdcmp8test_gezFkZb: 0000000000000000 <_D5cdcmp8test_gezFkZb>: 0: b8 01 00 00 00 mov eax,0x1 5: c3 ret ... Disassembly of section .text._D5cdcmp8test_gtzFkZb: 0000000000000000 <_D5cdcmp8test_gtzFkZb>: 0: 85 ff test edi,edi 2: 0f 95 c0 setne al 5: c3 ret ... Disassembly of section .text._D5cdcmp8test_ltzFiZb: 0000000000000000 <_D5cdcmp8test_ltzFiZb>: 0: 8b c7 mov eax,edi 2: c1 e8 1f shr eax,0x1f 5: c3 ret ... Disassembly of section .text._D5cdcmp8test_lezFiZb: 0000000000000000 <_D5cdcmp8test_lezFiZb>: 0: 8b c7 mov eax,edi 2: 83 c0 ff add eax,0xffffffff 5: 83 d0 00 adc eax,0x0 8: c1 e8 1f shr eax,0x1f b: c3 ret Disassembly of section .text._D5cdcmp8test_eqzFiZb: 0000000000000000 <_D5cdcmp8test_eqzFiZb>: 0: 85 ff test edi,edi 2: 0f 94 c0 sete al 5: c3 ret ... Disassembly of section .text._D5cdcmp8test_nezFiZb: 0000000000000000 <_D5cdcmp8test_nezFiZb>: 0: 85 ff test edi,edi 2: 0f 95 c0 setne al 5: c3 ret ... Disassembly of section .text._D5cdcmp8test_gezFiZb: 0000000000000000 <_D5cdcmp8test_gezFiZb>: 0: 8b c7 mov eax,edi 2: 01 c0 add eax,eax 4: 19 c0 sbb eax,eax 6: ff c0 inc eax 8: c3 ret 9: 00 00 add BYTE PTR [rax],al ... Disassembly of section .text._D5cdcmp8test_gtzFiZb: 0000000000000000 <_D5cdcmp8test_gtzFiZb>: 0: 8b c7 mov eax,edi 2: f7 d8 neg eax 4: 83 d8 00 sbb eax,0x0 7: c1 e8 1f shr eax,0x1f a: c3 ret ... Disassembly of section .text._D5cdcmp8test_ltzFmZb: 0000000000000000 <_D5cdcmp8test_ltzFmZb>: 0: 31 c0 xor eax,eax 2: c3 ret ... Disassembly of section .text._D5cdcmp8test_lezFmZb: 0000000000000000 <_D5cdcmp8test_lezFmZb>: 0: 48 85 ff test rdi,rdi 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_eqzFmZb: 0000000000000000 <_D5cdcmp8test_eqzFmZb>: 0: 48 85 ff test rdi,rdi 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_nezFmZb: 0000000000000000 <_D5cdcmp8test_nezFmZb>: 0: 48 85 ff test rdi,rdi 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_gezFmZb: 0000000000000000 <_D5cdcmp8test_gezFmZb>: 0: b8 01 00 00 00 mov eax,0x1 5: c3 ret ... Disassembly of section .text._D5cdcmp8test_gtzFmZb: 0000000000000000 <_D5cdcmp8test_gtzFmZb>: 0: 48 85 ff test rdi,rdi 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_ltzFlZb: 0000000000000000 <_D5cdcmp8test_ltzFlZb>: 0: 48 8b c7 mov rax,rdi 3: 48 c1 e8 3f shr rax,0x3f 7: c3 ret Disassembly of section .text._D5cdcmp8test_lezFlZb: 0000000000000000 <_D5cdcmp8test_lezFlZb>: 0: 48 8b c7 mov rax,rdi 3: 48 83 c0 ff add rax,0xffffffffffffffff 7: 48 83 d0 00 adc rax,0x0 b: 48 c1 e8 3f shr rax,0x3f f: c3 ret Disassembly of section .text._D5cdcmp8test_eqzFlZb: 0000000000000000 <_D5cdcmp8test_eqzFlZb>: 0: 48 85 ff test rdi,rdi 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_nezFlZb: 0000000000000000 <_D5cdcmp8test_nezFlZb>: 0: 48 85 ff test rdi,rdi 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp8test_gezFlZb: 0000000000000000 <_D5cdcmp8test_gezFlZb>: 0: 48 8b c7 mov rax,rdi 3: 48 01 c0 add rax,rax 6: 48 19 c0 sbb rax,rax 9: 48 ff c0 inc rax c: c3 ret d: 00 00 add BYTE PTR [rax],al ... Disassembly of section .text._D5cdcmp8test_gtzFlZb: 0000000000000000 <_D5cdcmp8test_gtzFlZb>: 0: 48 8b c7 mov rax,rdi 3: 48 f7 d8 neg rax 6: 48 83 d8 00 sbb rax,0x0 a: 48 c1 e8 3f shr rax,0x3f e: c3 ret ... Disassembly of section .text._D5cdcmp7test_ltFhhZb: 0000000000000000 <_D5cdcmp7test_ltFhhZb>: 0: 40 38 fe cmp sil,dil 3: 0f 92 c0 setb al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_leFhhZb: 0000000000000000 <_D5cdcmp7test_leFhhZb>: 0: 40 3a fe cmp dil,sil 3: 0f 93 c0 setae al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_eqFhhZb: 0000000000000000 <_D5cdcmp7test_eqFhhZb>: 0: 40 38 fe cmp sil,dil 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_neFhhZb: 0000000000000000 <_D5cdcmp7test_neFhhZb>: 0: 40 38 fe cmp sil,dil 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_geFhhZb: 0000000000000000 <_D5cdcmp7test_geFhhZb>: 0: 40 38 fe cmp sil,dil 3: 0f 93 c0 setae al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_gtFhhZb: 0000000000000000 <_D5cdcmp7test_gtFhhZb>: 0: 40 3a fe cmp dil,sil 3: 0f 92 c0 setb al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_ltFggZb: 0000000000000000 <_D5cdcmp7test_ltFggZb>: 0: 40 38 fe cmp sil,dil 3: 0f 9c c0 setl al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_leFggZb: 0000000000000000 <_D5cdcmp7test_leFggZb>: 0: 40 38 fe cmp sil,dil 3: 0f 9e c0 setle al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_eqFggZb: 0000000000000000 <_D5cdcmp7test_eqFggZb>: 0: 40 38 fe cmp sil,dil 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_neFggZb: 0000000000000000 <_D5cdcmp7test_neFggZb>: 0: 40 38 fe cmp sil,dil 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_geFggZb: 0000000000000000 <_D5cdcmp7test_geFggZb>: 0: 40 38 fe cmp sil,dil 3: 0f 9d c0 setge al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_gtFggZb: 0000000000000000 <_D5cdcmp7test_gtFggZb>: 0: 40 38 fe cmp sil,dil 3: 0f 9f c0 setg al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_ltFttZb: 0000000000000000 <_D5cdcmp7test_ltFttZb>: 0: 66 39 fe cmp si,di 3: 0f 92 c0 setb al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_leFttZb: 0000000000000000 <_D5cdcmp7test_leFttZb>: 0: 66 3b fe cmp di,si 3: 0f 93 c0 setae al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_eqFttZb: 0000000000000000 <_D5cdcmp7test_eqFttZb>: 0: 66 39 fe cmp si,di 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_neFttZb: 0000000000000000 <_D5cdcmp7test_neFttZb>: 0: 66 39 fe cmp si,di 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_geFttZb: 0000000000000000 <_D5cdcmp7test_geFttZb>: 0: 66 39 fe cmp si,di 3: 0f 93 c0 setae al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_gtFttZb: 0000000000000000 <_D5cdcmp7test_gtFttZb>: 0: 66 3b fe cmp di,si 3: 0f 92 c0 setb al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_ltFssZb: 0000000000000000 <_D5cdcmp7test_ltFssZb>: 0: 66 39 fe cmp si,di 3: 0f 9c c0 setl al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_leFssZb: 0000000000000000 <_D5cdcmp7test_leFssZb>: 0: 66 39 fe cmp si,di 3: 0f 9e c0 setle al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_eqFssZb: 0000000000000000 <_D5cdcmp7test_eqFssZb>: 0: 66 39 fe cmp si,di 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_neFssZb: 0000000000000000 <_D5cdcmp7test_neFssZb>: 0: 66 39 fe cmp si,di 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_geFssZb: 0000000000000000 <_D5cdcmp7test_geFssZb>: 0: 66 39 fe cmp si,di 3: 0f 9d c0 setge al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_gtFssZb: 0000000000000000 <_D5cdcmp7test_gtFssZb>: 0: 66 39 fe cmp si,di 3: 0f 9f c0 setg al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_ltFkkZb: 0000000000000000 <_D5cdcmp7test_ltFkkZb>: 0: 39 fe cmp esi,edi 2: 0f 92 c0 setb al 5: c3 ret ... Disassembly of section .text._D5cdcmp7test_leFkkZb: 0000000000000000 <_D5cdcmp7test_leFkkZb>: 0: 3b fe cmp edi,esi 2: 0f 93 c0 setae al 5: c3 ret ... Disassembly of section .text._D5cdcmp7test_eqFkkZb: 0000000000000000 <_D5cdcmp7test_eqFkkZb>: 0: 39 fe cmp esi,edi 2: 0f 94 c0 sete al 5: c3 ret ... Disassembly of section .text._D5cdcmp7test_neFkkZb: 0000000000000000 <_D5cdcmp7test_neFkkZb>: 0: 39 fe cmp esi,edi 2: 0f 95 c0 setne al 5: c3 ret ... Disassembly of section .text._D5cdcmp7test_geFkkZb: 0000000000000000 <_D5cdcmp7test_geFkkZb>: 0: 39 fe cmp esi,edi 2: 0f 93 c0 setae al 5: c3 ret ... Disassembly of section .text._D5cdcmp7test_gtFkkZb: 0000000000000000 <_D5cdcmp7test_gtFkkZb>: 0: 3b fe cmp edi,esi 2: 0f 92 c0 setb al 5: c3 ret ... Disassembly of section .text._D5cdcmp7test_ltFiiZb: 0000000000000000 <_D5cdcmp7test_ltFiiZb>: 0: 39 fe cmp esi,edi 2: 0f 9c c0 setl al 5: c3 ret ... Disassembly of section .text._D5cdcmp7test_leFiiZb: 0000000000000000 <_D5cdcmp7test_leFiiZb>: 0: 39 fe cmp esi,edi 2: 0f 9e c0 setle al 5: c3 ret ... Disassembly of section .text._D5cdcmp7test_eqFiiZb: 0000000000000000 <_D5cdcmp7test_eqFiiZb>: 0: 39 fe cmp esi,edi 2: 0f 94 c0 sete al 5: c3 ret ... Disassembly of section .text._D5cdcmp7test_neFiiZb: 0000000000000000 <_D5cdcmp7test_neFiiZb>: 0: 39 fe cmp esi,edi 2: 0f 95 c0 setne al 5: c3 ret ... Disassembly of section .text._D5cdcmp7test_geFiiZb: 0000000000000000 <_D5cdcmp7test_geFiiZb>: 0: 39 fe cmp esi,edi 2: 0f 9d c0 setge al 5: c3 ret ... Disassembly of section .text._D5cdcmp7test_gtFiiZb: 0000000000000000 <_D5cdcmp7test_gtFiiZb>: 0: 39 fe cmp esi,edi 2: 0f 9f c0 setg al 5: c3 ret ... Disassembly of section .text._D5cdcmp7test_ltFmmZb: 0000000000000000 <_D5cdcmp7test_ltFmmZb>: 0: 48 39 fe cmp rsi,rdi 3: 0f 92 c0 setb al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_leFmmZb: 0000000000000000 <_D5cdcmp7test_leFmmZb>: 0: 48 3b fe cmp rdi,rsi 3: 0f 93 c0 setae al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_eqFmmZb: 0000000000000000 <_D5cdcmp7test_eqFmmZb>: 0: 48 39 fe cmp rsi,rdi 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_neFmmZb: 0000000000000000 <_D5cdcmp7test_neFmmZb>: 0: 48 39 fe cmp rsi,rdi 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_geFmmZb: 0000000000000000 <_D5cdcmp7test_geFmmZb>: 0: 48 39 fe cmp rsi,rdi 3: 0f 93 c0 setae al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_gtFmmZb: 0000000000000000 <_D5cdcmp7test_gtFmmZb>: 0: 48 3b fe cmp rdi,rsi 3: 0f 92 c0 setb al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_ltFllZb: 0000000000000000 <_D5cdcmp7test_ltFllZb>: 0: 48 39 fe cmp rsi,rdi 3: 0f 9c c0 setl al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_leFllZb: 0000000000000000 <_D5cdcmp7test_leFllZb>: 0: 48 39 fe cmp rsi,rdi 3: 0f 9e c0 setle al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_eqFllZb: 0000000000000000 <_D5cdcmp7test_eqFllZb>: 0: 48 39 fe cmp rsi,rdi 3: 0f 94 c0 sete al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_neFllZb: 0000000000000000 <_D5cdcmp7test_neFllZb>: 0: 48 39 fe cmp rsi,rdi 3: 0f 95 c0 setne al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_geFllZb: 0000000000000000 <_D5cdcmp7test_geFllZb>: 0: 48 39 fe cmp rsi,rdi 3: 0f 9d c0 setge al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_gtFllZb: 0000000000000000 <_D5cdcmp7test_gtFllZb>: 0: 48 39 fe cmp rsi,rdi 3: 0f 9f c0 setg al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_ltFffZb: 0000000000000000 <_D5cdcmp7test_ltFffZb>: 0: 0f 2e c1 ucomiss xmm0,xmm1 3: 0f 97 c0 seta al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_leFffZb: 0000000000000000 <_D5cdcmp7test_leFffZb>: 0: 0f 2e c1 ucomiss xmm0,xmm1 3: 0f 93 c0 setae al 6: c3 ret ... Disassembly of section .text._D5cdcmp7test_eqFffZb: 0000000000000000 <_D5cdcmp7test_eqFffZb>: 0: 0f 2e c1 ucomiss xmm0,xmm1 3: b8 01 00 00 00 mov eax,0x1 8: 7a 02 jp c <_D5cdcmp7test_eqFffZb+0xc> a: 74 02 je e <_D5cdcmp7test_eqFffZb+0xe> c: 31 c0 xor eax,eax e: c3 ret ... Disassembly of section .text._D5cdcmp7test_neFffZb: 0000000000000000 <_D5cdcmp7test_neFffZb>: 0: 0f 2e c1 ucomiss xmm0,xmm1 3: b8 01 00 00 00 mov eax,0x1 8: 75 04 jne e <_D5cdcmp7test_neFffZb+0xe> a: 7a 02 jp e <_D5cdcmp7test_neFffZb+0xe> c: 31 c0 xor eax,eax e: c3 ret ... Disassembly of section .text._D5cdcmp7test_geFffZb: 0000000000000000 <_D5cdcmp7test_geFffZb>: 0: 0f 2e c1 ucomiss xmm0,xmm1 3: b8 01 00 00 00 mov eax,0x1 8: 7a 02 jp c <_D5cdcmp7test_geFffZb+0xc> a: 76 02 jbe e <_D5cdcmp7test_geFffZb+0xe> c: 31 c0 xor eax,eax e: c3 ret ... Disassembly of section .text._D5cdcmp7test_gtFffZb: 0000000000000000 <_D5cdcmp7test_gtFffZb>: 0: 0f 2e c1 ucomiss xmm0,xmm1 3: b8 01 00 00 00 mov eax,0x1 8: 7a 02 jp c <_D5cdcmp7test_gtFffZb+0xc> a: 72 02 jb e <_D5cdcmp7test_gtFffZb+0xe> c: 31 c0 xor eax,eax e: c3 ret ... Disassembly of section .text._D5cdcmp7test_ltFddZb: 0000000000000000 <_D5cdcmp7test_ltFddZb>: 0: 66 0f 2e c1 ucomisd xmm0,xmm1 4: 0f 97 c0 seta al 7: c3 ret Disassembly of section .text._D5cdcmp7test_leFddZb: 0000000000000000 <_D5cdcmp7test_leFddZb>: 0: 66 0f 2e c1 ucomisd xmm0,xmm1 4: 0f 93 c0 setae al 7: c3 ret Disassembly of section .text._D5cdcmp7test_eqFddZb: 0000000000000000 <_D5cdcmp7test_eqFddZb>: 0: 66 0f 2e c1 ucomisd xmm0,xmm1 4: b8 01 00 00 00 mov eax,0x1 9: 7a 02 jp d <_D5cdcmp7test_eqFddZb+0xd> b: 74 02 je f <_D5cdcmp7test_eqFddZb+0xf> d: 31 c0 xor eax,eax f: c3 ret Disassembly of section .text._D5cdcmp7test_neFddZb: 0000000000000000 <_D5cdcmp7test_neFddZb>: 0: 66 0f 2e c1 ucomisd xmm0,xmm1 4: b8 01 00 00 00 mov eax,0x1 9: 75 04 jne f <_D5cdcmp7test_neFddZb+0xf> b: 7a 02 jp f <_D5cdcmp7test_neFddZb+0xf> d: 31 c0 xor eax,eax f: c3 ret Disassembly of section .text._D5cdcmp7test_geFddZb: 0000000000000000 <_D5cdcmp7test_geFddZb>: 0: 66 0f 2e c1 ucomisd xmm0,xmm1 4: b8 01 00 00 00 mov eax,0x1 9: 7a 02 jp d <_D5cdcmp7test_geFddZb+0xd> b: 76 02 jbe f <_D5cdcmp7test_geFddZb+0xf> d: 31 c0 xor eax,eax f: c3 ret Disassembly of section .text._D5cdcmp7test_gtFddZb: 0000000000000000 <_D5cdcmp7test_gtFddZb>: 0: 66 0f 2e c1 ucomisd xmm0,xmm1 4: b8 01 00 00 00 mov eax,0x1 9: 7a 02 jp d <_D5cdcmp7test_gtFddZb+0xd> b: 72 02 jb f <_D5cdcmp7test_gtFddZb+0xf> d: 31 c0 xor eax,eax f: c3 ret Disassembly of section .text.d_dso_init: 0000000000000000 <.text.d_dso_init>: 0: 55 push rbp 1: 48 8b ec mov rbp,rsp 4: 48 8d 05 00 00 00 00 lea rax,[rip+0x0] # b <.text.d_dso_init+0xb> b: 50 push rax c: 48 8d 05 00 00 00 00 lea rax,[rip+0x0] # 13 <.text.d_dso_init+0x13> 13: 50 push rax 14: 48 8d 05 00 00 00 00 lea rax,[rip+0x0] # 1b <.text.d_dso_init+0x1b> 1b: 50 push rax 1c: 6a 01 push 0x1 1e: 48 8b fc mov rdi,rsp 21: e8 00 00 00 00 call 26 <.text.d_dso_init+0x26> 26: c9 leave 27: c3 ret ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc3.ddoc0000644000175000017500000000003415205374125022274 0ustar fabiofabioHELLO = world UNUSED=unused./ldc-1.42.0-src/tests/dmd/compilable/extra-files/json-postscript.sh0000755000175000017500000000044015205374125024166 0ustar fabiofabio#!/usr/bin/env bash source tools/common_funcs.sh echo SANITIZING JSON... ${RESULTS_DIR}/sanitize_json ${OUTPUT_BASE}.out > ${OUTPUT_BASE}.out.sanitized diff -up --strip-trailing-cr ${EXTRA_FILES}/${TEST_NAME}.json ${OUTPUT_BASE}.out.sanitized rm_retry ${OUTPUT_BASE}.out{,.sanitized} ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/testcdefines.i.cg0000644000175000017500000000011115205374125023663 0ustar fabiofabio=== compilable/testcdefines.i.cg extern (C) enum int _ATFILE_SOURCE = 1; ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc2273.html0000644000175000017500000004003215205374125022564 0ustar fabiofabio ddoc2273

ddoc2273

  • B

    Declaration

    interface B: ddoc2273.C, ddoc2273.D;

  • Foo

    Declaration

    class Foo: ddoc2273.A, ddoc2273.B;

  • min

    Declaration

    MinType!(T1, T2, T) min(T1, T2, T...)(T1 a, T2 b, T xs);

  • max

    Declaration

    Templ!([1, 2, 3]) max(T...)();

  • Declaration

    template Base64Impl(char Map62th, char Map63th, char Padding)

  • Declaration

    int sqlite3_config(int, ...);

  • Declaration

    alias IndexOf = staticIndexOf(T, TList...);

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9497c.ddoc0000644000175000017500000000003015205374125022705 0ustar fabiofabioDDOC_UNDEFINED_MACRO=$+ ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_headings.html0000644000175000017500000003075515205374125026025 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/ddoc_markdown_headings.html ddoc_markdown_headings

ddoc_markdown_headings

ATX-Style Headings

Discussion

H1

H2

H3

H4

H5
H6

headings

with initial

spaces

heading with emphasis

heading with trailing #'s

heading with trailing literal ##'s

heading with another trailing literal#

heading with backslash-escaped trailing ###

Some empty headers:

Not Headings

#hashtag not a heading because there's no space after the #

####### Not a heading because it has more than 6 #'s

## Not a heading because of the preceeding backslash

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_emphasis_verbose.html0000644000175000017500000003007215205374125027571 0ustar fabiofabiocompilable/ddoc_markdown_emphasis_verbose.d(13): Ddoc: emphasized text 'emphasized text' compilable/ddoc_markdown_emphasis_verbose.d(13): Ddoc: emphasized text 'strongly emphasized text' === ${RESULTS_DIR}/compilable/ddoc_markdown_emphasis_verbose.html ddoc_markdown_emphasis

ddoc_markdown_emphasis

Markdown Emphasis:

Discussion

emphasized text

strongly emphasized text

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9764.dd0000644000175000017500000000012015205374125022215 0ustar fabiofabioDdoc Check ddoc9764 document. ---- // Check ddoc9764 comment. ddoc9764(); ---- ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/rdeps7016a.d0000644000175000017500000000010515205374125022405 0ustar fabiofabiomodule rdeps7016a; int f() { import rdeps7016b; return i; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/objdump-postscript.sh0000644000175000017500000000114415205374125024654 0ustar fabiofabio#!/usr/bin/env bash source tools/common_funcs.sh expect_file=${EXTRA_FILES}/${TEST_NAME}.out # We are only used by cdcmp, which is a D test, # otherwise we could use ${OUTPUT_BASE} and then figure out language. obj_file=${RESULTS_TEST_DIR}/d/${TEST_NAME}_0.o echo Creating objdump objdump --disassemble --disassembler-options=intel "${obj_file}" > "${obj_file}.dump" echo SANITIZING Objdump... < "${obj_file}.dump" \ tail -n+3 | sed 's/[ \t]\s*$//' > "${obj_file}.dump.sanitized" diff -up --strip-trailing-cr "${expect_file}" "${obj_file}.dump.sanitized" rm_retry ${obj_file}{,.dump,.dump,.sanitized} ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9903.html0000644000175000017500000004170215205374125022600 0ustar fabiofabio ddoc9903

ddoc9903

  • Declaration

    struct S9903X;
    struct S9903Y;

    sss

  • Declaration

    class C9903X;
    class C9903Y;

    ccc

  • Declaration

    union U9903X;
    union U9903Y;

    uuu

  • Declaration

    interface I9903X;
    interface I9903Y;

    iii

  • Declaration

    enum E9903X: int;
    enum E9903Y: int;

    eee

  • Declaration

    a9903
    b9903

    ea

  • Declaration

    c9903

    ec

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/empty.conf0000644000175000017500000000000015205374125022443 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc14383.html0000644000175000017500000002775115205374125022666 0ustar fabiofabio ddoc14383

ddoc14383

Module docs.

Examples

Ddoc'd unittest

  1. int iShouldAppearInTheDocs;
    

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc10367.html0000644000175000017500000004377115205374125022664 0ustar fabiofabio ddoc10367

ddoc10367

  • A

    Declaration

    enum A: int;

    A

    • a

      Declaration

      a

      a

    • b

      Declaration

      b

      b

  • B

    Declaration

    enum B: long;

    B

    • a

      Declaration

      a

      a

    • b

      Declaration

      b

      b

  • C

    Declaration

    enum C: string;

    C

    • a

      Declaration

      a

      a

    • b

      Declaration

      b

      b

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/e6815.d0000644000175000017500000000010515205374125021361 0ustar fabiofabiobool e(T)(T) { f(true); return true; } void f(lazy bool) {} ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc6.html0000644000175000017500000003032515205374125022340 0ustar fabiofabio ddoc6

ddoc6

  • Declaration

    struct MyStruct(T);

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_lists.html0000644000175000017500000003161515205374125025375 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/ddoc_markdown_lists.html ddoc_markdown_lists

ddoc_markdown_lists

Lists

Discussion

Unordered

  • item one

    part of item one

    1. // code in item one
      
not part of item one
  • three
  • different
  • lists
  • list with
  • empty item
  • parent item
    • child item
  • sibling item
  • sibling item
After text:
  • heading

  • and item

Ordered

  1. zero
  2. one
List separator text
  1. list that starts with three
  2. parent item
    1. child item
  3. sibling item
  4. sibling item

Not Lists

-no initial space

2.no initial space

1234567890. too many numbers

-1. negative

New lists must start with 1, not 6. So this isn't a list.

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc10870.html0000644000175000017500000003143115205374125022651 0ustar fabiofabio ddoc10870

ddoc10870

  • I

    Declaration

    interface I;

    • f

      Declaration

      abstract void f();

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ucn_vars.i0000644000175000017500000000030315205374125022436 0ustar fabiofabiostruct Vars { int x²; int \u2160; int \u2182; int \u00C0; int \u00C1; int \U000000C2; int wh\u00ff; int a\u00c4b\u0441\U000003b4e; int b\u3021𗘰\u3023e; }; ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc7656.html0000644000175000017500000003356415205374125022612 0ustar fabiofabio ddoc7656

ddoc7656

  • Declaration

    void main();

    1. int x; // This is a $ comment (and here is some
      int y; // more information about that comment)
      

  • add

    Declaration

    int add(int a, int b);

    (Regression check)

    Example:

    1. assert(add(1, 1) == 2);
      

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/header18365.d0000644000175000017500000000020215205374125022446 0ustar fabiofabiomodule foo.bar.ba; nothrow pure @nogc @safe package(foo) { void foo(); nothrow pure @nogc @safe package(foo.bar) void foo2(); } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc8739.html0000644000175000017500000003363215205374125022611 0ustar fabiofabio ddoc8739

ddoc8739

  • dg

    Declaration

    void delegate(int a) dg;

  • dg2

    Declaration

    void delegate(int b) dg2;

  • dg3

    Declaration

    void delegate(int c)[] dg3;

  • dg4

    Declaration

    void delegate(int d)* dg4;

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddocunittest.html0000644000175000017500000020225015205374125024050 0ustar fabiofabio ddocunittest

ddocunittest

  • foo

    Declaration

    int foo(int a, int b);

    foo function - 1 example

    Examples

    1. assert(foo(1, 1) == 2);
      

  • bar

    Declaration

    bool bar();

    bar function - 1 example

    Examples

    1. // documented
      assert(bar());
      

    Examples

    placeholder

  • doo

    Declaration

    void doo();

    doo function - no examples

  • add

    Declaration

    int add(int a, int b);

    add function - 3 examples

    Examples

    1. assert(add(1, 1) == 2);
      

    Examples

    1. // documented
      assert(add(3, 3) == 6);
      assert(add(4, 4) == 8);
      

    Examples

    1. // documented
      assert(add(5, 5) == 10);
      assert(add(6, 6) == 12);
      

  • Foo

    Declaration

    class Foo;

    class Foo

    Examples

    1. Foo foo = new Foo;
      

  • Declaration

    class SomeClass;

    some class - 1 example

    Examples

    1. SomeClass sc = new SomeClass;
      

  • Declaration

    class Outer;

    Outer - 1 example

    Examples

    1. Outer outer = new Outer;
      

    • Declaration

      class Inner;

      Inner

      Examples

      1. Inner inner = new Inner;
        

  • Declaration

    void foobar();

    foobar - no examples

  • foo

    Declaration

    void foo(int x);

    func - 4 examples

    Examples

    1. foo(1);
      

    Examples

    1. foo(2);
      

    Examples

    1. foo(2);
      

    Examples

    1. foo(4);
      

  • Declaration

    void fooImport();

    Examples

    test

    1. fooImport();
      

  • Declaration

    void fooStaticImport();

    Examples

    test

    1. fooStaticImport();
      

  • Declaration

    void fooSelectiveImport();

    Examples

    test

    1. fooSelectiveImport();
      

  • Declaration

    void fooRenamedImport();

    Examples

    test

    1. fooRenamedImport();
      

  • Declaration

    public import core.stdc.string;

    This is a public import

  • Declaration

    public import core.stdc.stdarg;

    This is a mutiple public import

  • Declaration

    public import core.stdc.stdlib;

    This is a mutiple public import

  • Declaration

    public import core.stdc.string : memcpy;

    This is a public selective import

  • Declaration

    public import core.stdc.string : copy = memcpy;

    This is a public selective renamed import

  • Declaration

    public import core.stdc.string : memcpy, memcmp;

    This is a public multiple selective import

  • Declaration

    public import core.stdc.string : copy = memcpy, compare = memcmp;

    This is a public multiple selective renamed import

  • str

    Declaration

    public import str = core.stdc.string;

    This is a public renamed import

  • Declaration

    void fooConditionalDecl1a();

    Examples

    1. int x1a;
      

  • Declaration

    void fooConditionalDecl1b();

    Examples

    1. int x1b;
      

  • Declaration

    void fooConditionalDecl3a();

  • Declaration

    void fooConditionalDecl3b();

  • Declaration

    void barConditionalDecl4a();

    Examples

    1. int x4a;
      

  • Declaration

    void barConditionalDecl4b();

    Examples

    1. int x4b;
      

  • Declaration

    void barConditionalDecl6a();

    Examples

    1. int x6a;
      

  • Declaration

    void barConditionalDecl6b();

    Examples

    1. int x6b;
      

  • Declaration

    void foo9474();

    Examples

    Example

    1. foo9474();
      

  • Declaration

    void bar9474();

    doc

    Examples

    Example

    1. bar9474();
      

  • Declaration

    struct S9474;

    Examples

    1. S9474 s;
      

  • Declaration

    int autovar9474;

    Examples

    1. int v = autovar9474;
      

  • Declaration

    auto autofun9474();

    Examples

    1. int n = autofun9474();
      

  • Declaration

    template Template9474()

    Examples

    1. alias Template9474!() T;
      

    • foo

      Declaration

      void foo();

      Shouldn't link following unittest to here

  • Declaration

    void fooNoDescription();

    Examples

    1. fooNoDescription();
      

    Examples

    1. if (true) {fooNoDescription(); } /* comment */
      

  • Declaration

    void foo9757();
    void bar9757();
    void baz9757();

    Examples

    1. foo9757(); bar9757();
      

    Examples

    1. bar9757(); foo9757();
      

  • Declaration

    auto redBlackTree(E)(E[] elems...);
    auto redBlackTree(bool allowDuplicates, E)(E[] elems...);
    auto redBlackTree(alias less, E)(E[] elems...) if (__traits(compiles, (E a, E b) => mixin(less)));

    with template functions

    Examples

    1. auto rbt1 = redBlackTree(0, 1, 5, 7);
      auto rbt2 = redBlackTree!string("hello", "world");
      auto rbt3 = redBlackTree!true(0, 1, 5, 7, 5);
      auto rbt4 = redBlackTree!"a > b"(0, 1, 5, 7);
      

  • foo

    Declaration

    void foo();

    test

    Examples

  • Declaration

    bool balancedParens10519(string, char, char);

    Examples

    1. auto s = "1 + (2 * (3 + 1 / 2)";
      assert(!balancedParens10519(s, '(', ')'));
      

  • Declaration

    struct S12097;
    void f12097();
    struct T12097(T);

    declaration

    Examples

    ddoc code 1

    1. int a = 1;
      

    Examples

    ddoc code 2

    1. int[] arr;
      

    • foo

      Declaration

      void foo();

      method

  • Declaration

    void fun14594a()();

    testA

    Examples

    1. fun14594a();
      

  • Declaration

    void fun14594b()();
    void fun14594b(T)(T);

    testB

    Examples

    1. fun14594b(); fun14594b(1);
      

  • Declaration

    void fun14594c()();
    void fun14594c(T)(T);

    testC

    Examples

    1. fun14594c(); fun14594c(1);
      

  • Declaration

    void fun14594d()();
    void fun14594d(T)(T);

    testD

    Examples

    1. fun14594d();
      

    Examples

    1. fun14594d(1);
      

  • Declaration

    void fun14594e()();

    testE

    Discussion

    concatenated doc-comment fun14594e

    Examples

    doc-unittest fun14594e

    1. fun14594e();
      

  • Declaration

    void fun14594f()();
    void fun14594f(T)(T);

    testF

    Discussion

    concatenated doc-comment fun14594f

    Examples

    doc-unittest fun14594f

    1. fun14594f();
      

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/d6815.d0000644000175000017500000000007515205374125021366 0ustar fabiofabiovoid d() { import e6815 : e; static if (e("")) { } } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test9680main.d0000644000175000017500000000002015205374125022760 0ustar fabiofabiovoid main() { } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc10367.ddoc0000644000175000017500000000003715205374125022615 0ustar fabiofabioDDOC_ENUM_BASETYPE = $(RED $0) ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc11479.html0000644000175000017500000004776615205374125022701 0ustar fabiofabio ddoc11479

ddoc11479

  • S1

    Declaration

    struct S1(T);

    • a

      Declaration

      int a;

    • b

      Declaration

      int b;

    • c

      Declaration

      int c;

  • S2

    Declaration

    struct S2(T);

    • a

      Declaration

      int a;

    • b

      Declaration

      int b;

    • c

      Declaration

      int c;

    • d

      Declaration

      int d;

  • S3

    Declaration

    struct S3(T);

    • a

      Declaration

      int a;

    • b

      Declaration

      int b;

    • c

      Declaration

      int c;

    • d

      Declaration

      int d;

    • e

      Declaration

      int e;

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc8271.html0000644000175000017500000003052415205374125022575 0ustar fabiofabio ddoc8271

ddoc8271

  • Declaration

    void ddoc8271();

    Macro

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/header2.d0000644000175000017500000001044115205374125022127 0ustar fabiofabio// for D 2.0 only class C { } void foo(const C c, const(char)[] s, const int* q, const (int*) p) { } void bar(in void *p) { } void f(void function() f2); class C2; void foo2(const C2 c); struct Foo3 { int k; ~this() @trusted @disable @nogc @live { k = 1; } this(this) { k = 2; } } class C3 { @property int get() { return 0; } } T foo3(T)() {} struct S4A(T) { T x; ~this() @safe {} } struct S4B(T) if (1) { T x; } union U4A(T) { T x; } union U4B(T) if (2*4 == 8) { T x; } class C4A(T) { T x; } class C4B(T) if (true) { T x; } class C4C(T) : C4A!int if (!false) { T x; } class C4D(T) if (!false) : C4B!long, C4C!(int[]) { T x; } interface I4(T) if ((int[1]).length == 1) { T x; } // eponymous template case template MyClass4(T) if (is(typeof(T.subtype))) { alias HelperSymbol = T.subtype; class MyClass4 {} } enum isInt(T) = is(T == int); enum bool isString(T) = is(T == string); static immutable typeName(T) = T.stringof; int storageFor(T) = 0; template templateVariableFoo(T) { enum int templateVariableFoo = T.stringof.length; } template templateVariableBar(T) if (is(T == int)) { enum int templateVariableBar = T.stringof.length; } auto flit = 3 / 2.0; // https://issues.dlang.org/show_bug.cgi?id=11217 void foo11217()( const int[] arr) {} void foo11217()(immutable int[] arr) {} void foo11217()( ref int[] arr) {} void foo11217()( lazy int[] arr) {} void foo11217()( auto ref int[] arr) {} void foo11217()( scope int[] arr) {} void foo11217()( in int[] arr) {} void foo11217()( inout int[] arr) {} // https://issues.dlang.org/show_bug.cgi?id=13275 void test13275() { if ( auto n = 1) {} if ( const n = 1) {} if ( immutable n = 1) {} if (shared n = 1) {} if (shared const n = 1) {} if ( int n = 1) {} if ( const int n = 1) {} if ( immutable int n = 1) {} if (shared int n = 1) {} if (shared const int n = 1) {} if ( const(int) n = 1) {} if ( immutable(int) n = 1) {} if (shared (int) n = 1) {} if (shared const(int) n = 1) {} foreach ( e; [1,2]) {} foreach ( const e; [1,2]) {} foreach ( immutable e; [1,2]) {} foreach (shared e; [1,2]) {} foreach (shared const e; [1,2]) {} foreach ( int e; [1,2]) {} foreach ( const int e; [1,2]) {} foreach ( immutable int e; [1,2]) {} foreach (shared int e; [1,2]) {} foreach (shared const int e; [1,2]) {} foreach ( int e; [1,2]) {} foreach ( const(int) e; [1,2]) {} foreach ( immutable(int) e; [1,2]) {} foreach (shared (int) e; [1,2]) {} foreach (shared const(int) e; [1,2]) {} } // https://issues.dlang.org/show_bug.cgi?id=9766 align (1) struct S9766 { align {} align (true ? 2 : 3): int var1; align: int var2; } align(2) struct S12200_1 { align: } align(2) struct S12200_2 { align(1): } // https://issues.dlang.org/show_bug.cgi?id=14694 inout(T)[] overlap(T)(inout(T)[] r1, inout(T)[] r2) @trusted pure nothrow { alias U = inout(T); static U* max(U* a, U* b) nothrow { return a > b ? a : b; } static U* min(U* a, U* b) nothrow { return a < b ? a : b; } auto b = max(r1.ptr, r2.ptr); auto e = min(r1.ptr + r1.length, r2.ptr + r2.length); return b < e ? b[0 .. e - b] : null; } // https://issues.dlang.org/show_bug.cgi?id=16140 void gun()() { int[] res; while (auto va = fun()) {} // expression expected, not 'auto' while (true) if (auto va = fun()) {} else break; } // https://issues.dlang.org/show_bug.cgi?id=14690 pragma(inline, true) int fun(int a, int b) { return 3; } // https://issues.dlang.org/show_bug.cgi?id=16649 void leFoo()() { sign = a == 2 ? false : (y < 0) ^ sign; sign = a == 2 ? false : sign ^ (y < 0); sign = 2 + 3 | 7 + 5; } // https://issues.dlang.org/show_bug.cgi?id=17371 interface LeInterface {} class LeClass { this() { auto foo = new class () LeInterface {}; } } const levar = new class LeClass, LeInterface {}; // https://issues.dlang.org/show_bug.cgi?id=20074 class CC { void fun()() @safe { () @trusted pure { } (); } } // https://issues.dlang.org/show_bug.cgi?id=17663 private: public struct Export {} ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_bom_UTF8.html0000644000175000017500000003552015205374125023717 0ustar fabiofabio ddoc_bom_UTF8

ddoc_bom_UTF8

  • Declaration

    int ruhred;

    This documents correctly.

  • Declaration

    int rühred;

    This should too

  • foo

    Declaration

    int foo(int ü, int ş, int ğ);

    BUG: The parameters are not listed under Params in the generated output

    Parameters

    int ü

    first

    int ş

    second

    int ğ

    third

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_breaks_verbose.html0000644000175000017500000003011415205374125027224 0ustar fabiofabiocompilable/ddoc_markdown_breaks_verbose.d(13): Ddoc: converted '___' to a thematic break compilable/ddoc_markdown_breaks_verbose.d(13): Ddoc: converted '- - -' to a thematic break compilable/ddoc_markdown_breaks_verbose.d(13): Ddoc: converted '***' to a thematic break === ${RESULTS_DIR}/compilable/ddoc_markdown_breaks_verbose.html ddoc_markdown_breaks

ddoc_markdown_breaks

Thematic Breaks

Discussion




./ldc-1.42.0-src/tests/dmd/compilable/extra-files/c6815.d0000644000175000017500000000005415205374125021362 0ustar fabiofabiovoid c() { import d6815 : d; d(); } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc17169.html0000644000175000017500000002701015205374125022657 0ustar fabiofabio ddoc17169

ddoc17169

  • foo

    Declaration

    void foo();

    P1

    Discussion

    P2

    P3

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9497d.html0000644000175000017500000003074615205374125022762 0ustar fabiofabio ddoc9497d

ddoc9497d

  • foo

    Declaration

    void foo();

    foo function.

    Args: ERROR_UNDEFINED_MACRO: "XYZ"

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc14413.html0000644000175000017500000003067315205374125022655 0ustar fabiofabio ddoc14413

ddoc14413

  • foo

    Declaration

    void foo();

    This should be one paragraph.

    Discussion

    Paragraph 2

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc14778.html0000644000175000017500000005052615205374125022672 0ustar fabiofabio ddoc14778

ddoc14778

  • Declaration

    template Z14778(T)

    docs for Z

    • E

      Declaration

      enum E;

      docs for E

    • x

      Declaration

      enum auto x;

      docs for x

    • mv

      Declaration

      auto mv;

      docs for mv

    • wv

      Declaration

      inout wv;

      docs for wv

    • cv

      Declaration

      const cv;

      doc for cv

    • wcv

      Declaration

      inout const wcv;

      docs for wcv

    • sv

      Declaration

      shared sv;

      doc for sv

    • swv

      Declaration

      shared inout swv;

      doc for swv

    • scv

      Declaration

      shared const scv;

      doc for scv

    • Declaration

      shared inout const swcv;

      docs for swcv

    • iv

      Declaration

      immutable iv;

      doc for iv

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/vcg-ast-arraylength-postscript.sh0000755000175000017500000000115415205374125027102 0ustar fabiofabio#!/usr/bin/env bash source tools/common_funcs.sh # Test if there's call to the runtime for .length = 100 grep "_d_arraysetlengthT(arr, 100.*)" "${TEST_DIR}/${TEST_NAME}.d.cg" && # Make sure there's no call to the runtime for .length = 0 ! grep "_d_arraysetlengthT(\(arr\|f\), 0.*)" "${TEST_DIR}/${TEST_NAME}.d.cg" && # Make sure there's no call to the runtime for .length = x ! grep "_d_arraysetlengthT(f, x.*)" "${TEST_DIR}/${TEST_NAME}.d.cg" && # Test if a slice expr is applied for the above case grep "arr = arr\[0..0\]" "${TEST_DIR}/${TEST_NAME}.d.cg" ret=$? rm_retry "${TEST_DIR}/${TEST_NAME}.d.cg" exit $ret ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test20280a.d0000644000175000017500000000022215205374125022325 0ustar fabiofabiomodule test20280a; struct Alpha(uint _) { import test20280a; } struct Foxtrot(uint _) { alias Attributes = Alpha!10; enum A = 10; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test16080b.d0000644000175000017500000000006615205374125022337 0ustar fabiofabioimport imp16080; void test2() { A!() v = A!().a; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9305.html0000644000175000017500000003677315205374125022610 0ustar fabiofabio ddoc9305

ddoc9305

  • foo

    Declaration

    void foo(alias p = (a) => a)();

    foo()

  • X

    Declaration

    template X(alias pred = (x) => x)
    template X(alias pred = (x) { int y; return y; } )
    template X(alias pred = (int x) => x)
    template X(alias pred = (int x) { int y; return y; } )

  • X

    Declaration

    template X(alias pred = function (x) => x)
    template X(alias pred = function (x) { return x + 1; } )
    template X(alias pred = function (int x) => x)
    template X(alias pred = function (int x) { return x + 1; } )
    template X(alias pred = function int(x) => x)
    template X(alias pred = function int(x) { return x + 1; } )
    template X(alias pred = function int(int x) => x)
    template X(alias pred = function int(int x) { return x + 1; } )

  • X

    Declaration

    template X(alias pred = delegate (x) => x)
    template X(alias pred = delegate (x) { return x + 1; } )
    template X(alias pred = delegate (int x) => x)
    template X(alias pred = delegate (int x) { return x + 1; } )
    template X(alias pred = delegate int(x) => x)
    template X(alias pred = delegate int(x) { return x + 1; } )
    template X(alias pred = delegate int(int x) => x)
    template X(alias pred = delegate int(int x) { return x + 1; } )

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/vcg-ast.d.cg0000644000175000017500000000721515205374125022556 0ustar fabiofabio=== compilable/vcg-ast.d.cg module vcg; import object; alias xyz = vcg; alias named = vcg; template Seq(A...) { alias Seq = A; } (int, int, int) a = AliasSeq!(1, 2, 3); template R(T) { struct _R { T elem; } } int x; static foreach (enum i; AliasSeq!(0, 1, 2)) { mixin("int a" ~ i.stringof ~ " = 1;"); } void foo() { int a0 = 1; int a1 = 1; int a2 = 1; } class C : Object { invariant { } invariant { assert(true); } int foo() in { } in (true) out { } out(r) { } out (; true) out (r; true) { pure nothrow @nogc @safe void __require() { { { } } { assert(true); } } __require(); this.__invariant(); __result = 2; goto __returnLabel; __returnLabel: this.__invariant(); pure nothrow @nogc @safe void __ensure(ref const(int) __result) { { } { ref const const(int) r = __result; { } } assert(true); { ref const const(int) r = __result; assert(true); } } __ensure(__result); return __result; } invariant { this.__invariant0() , this.__invariant1(); } } enum __c_wchar_t : dchar; alias wchar_t = __c_wchar_t; T[] values(T)() { T[] values = [T()]; return values; } void main() { values(); return 0; } import imports.vcg_ast_import; template imported() { import imported = imports.vcg_ast_import; } alias myImport = vcg_ast_import; enum bool compiles = true; enum bool isexp = true; R!int { struct _R { int elem; } } mixin _d_cmain!(); { extern (C) { extern (C) int _Dmain(char[][] args); version (Windows) { extern (C) int _d_wrun_main(int argc, wchar** wargv, void* mainFunc); extern (C) int wmain(int argc, wchar** wargv) { return _d_wrun_main(argc, wargv, &$?:windows= |$_Dmain); } } else { extern (C) int _d_run_main(int argc, char** argv, void* mainFunc); extern (C) int main(int argc, char** argv) { return _d_run_main(argc, argv, &$?:windows=| $_Dmain); } version (Solaris) { extern (C) int _main(int argc, char** argv) { return main(argc, argv); } } } } } imported!() { import object; struct O { invariant { } invariant { __invariant0(); } } } RTInfo!(C) { enum immutable(void)* RTInfo = null; } values!(__c_wchar_t) { pure nothrow @safe __c_wchar_t[] values() { __c_wchar_t[] values = [cast(__c_wchar_t)'\uffff']; return values; } } _d_arrayliteralTX!(__c_wchar_t) { pure nothrow @trusted void* _d_arrayliteralTX(ulong length) { const const(ulong) allocsize = length * 4LU; if (allocsize == 0LU) return null; else { import core.memory : GC; import core.internal.traits : hasIndirections, hasElaborateDestructor; alias BlkAttr = BlkAttr; uint attrs = 8u; attrs |= BlkAttr.NO_SCAN; return malloc(allocsize, attrs, typeid(__c_wchar_t)); } } } hasIndirections!(__c_wchar_t) { enum bool hasIndirections = false; } OriginalType!(__c_wchar_t) { alias OriginalType = dchar; } ModifyTypePreservingTQ!(Impl, __c_wchar_t) { alias ModifyTypePreservingTQ = dchar; } Modifier!(__c_wchar_t) { alias Impl = dchar; } OriginalType!dchar { alias OriginalType = dchar; } ModifyTypePreservingTQ!(Impl, dchar) { alias ModifyTypePreservingTQ = dchar; } Modifier!dchar { alias Impl = dchar; } hasIndirections!dchar { enum bool hasIndirections = false; } isFunctionPointer!dchar { enum bool isFunctionPointer = false; } isPointer!dchar { enum bool isPointer = false; } isAggregateType!dchar { enum bool isAggregateType = false; } isDelegate!dchar { enum bool isDelegate = false; } isDynamicArray!dchar { enum bool isDynamicArray = false; } Unqual!(dchar, dchar) { alias Unqual = dchar; } RTInfo!(_R) { enum immutable(void)* RTInfo = null; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/json_nosource.json0000644000175000017500000000076515205374125024241 0ustar fabiofabio{ "compilerInfo": { "__VERSION__": 0, "architectures": [ "VALUES_REMOVED_FOR_TEST" ], "interface": "dmd", "platforms": [ "VALUES_REMOVED_FOR_TEST" ], "predefinedVersions": [ "VALUES_REMOVED_FOR_TEST" ], "size_t": 0, "supportedFeatures": { "includeImports": true }, "vendor": "VALUE_REMOVED_FOR_TEST", "version": "VALUE_REMOVED_FOR_TEST" } } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc198.html0000644000175000017500000004000215205374125022505 0ustar fabiofabio ddoc198

ddoc198

  • I1

    Declaration

    interface I1;

  • C1

    Declaration

    class C1;

  • Foo

    Declaration

    class Foo: ddoc198.C1, ddoc198.I1;

  • X

    Declaration

    enum X: int;

  • Y

    Declaration

    enum Y: X;

  • S1

    Declaration

    struct S1;

  • enS

    Declaration

    enum enS: S1;

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc10869.html0000644000175000017500000003503115205374125022661 0ustar fabiofabio ddoc10869

ddoc10869

  • C

    Declaration

    class C;

    • Declaration

      void c1Foo() const;

    • Declaration

      void i1Foo() immutable;

    • Declaration

      void c2Foo() immutable;

    • Declaration

      void i2Foo() immutable;

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_quote_verbose.html0000644000175000017500000003007515205374125027120 0ustar fabiofabiocompilable/ddoc_markdown_quote_verbose.d(11): Ddoc: starting quote block with '> Great, just what I need.. another D in programming. -- Segfault' === ${RESULTS_DIR}/compilable/ddoc_markdown_quote_verbose.html test.compilable.ddoc_markdown_code_verbose

test.compilable.ddoc_markdown_code_verbose

Quote Block:

Discussion

Great, just what I need.. another D in programming. -- Segfault

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ctod.di0000644000175000017500000000012215205374125021712 0ustar fabiofabio// D import file generated from 'test.i' extern (C) uint equ(double x, double y); ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc6491.html0000644000175000017500000003067215205374125022603 0ustar fabiofabio ddoc6491

ddoc6491

  • Declaration

    void bug6491a(int a = ddoc6491.c6491, string b = core.cpuid.vendor);

    test

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/build23499.d0000644000175000017500000000014015205374125022322 0ustar fabiofabioimport imports.file23499; bool do_build() { string outdir ; return (exists(outdir)); } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddocAny-postscript.sh0000755000175000017500000000037615205374125024606 0ustar fabiofabio#!/usr/bin/env bash source tools/common_funcs.sh grep --text -v "Generated by Ddoc from" ${OUTPUT_BASE}.html > ${OUTPUT_BASE}.html.2 diff -up --strip-trailing-cr ${EXTRA_FILES}/${TEST_NAME}.html ${OUTPUT_BASE}.html.2 rm_retry ${OUTPUT_BASE}.html{,.2} ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/header17125.d0000644000175000017500000000026215205374125022445 0ustar fabiofabiovoid func1(real value = 10.35e4L); void func2(real value = 520.199e3F); void func3(real value = 9.70e5); void func4(real value = 1024.5e2F); void func5(real value = 41250.2e1L); ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc8.html0000644000175000017500000003047115205374125022344 0ustar fabiofabio ddoc8

ddoc8

  • Foo

    Declaration

    class Foo(T): Bar;

    foo

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/rdeps7016b.d0000644000175000017500000000012115205374125022404 0ustar fabiofabiomodule rdeps7016b; int i = 42; int g() { import rdeps7016; return i; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/makedeps-import.txt0000644000175000017500000000001615205374125024307 0ustar fabiofabioImported text ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc7.html0000644000175000017500000006115015205374125022341 0ustar fabiofabio ddoc7

ddoc7

  • E1

    Declaration

    enum E1: int;

    my enum

    • A

      Declaration

      A

      element a

    • B

      Declaration

      B

      element b

  • E2

    Declaration

    enum E2: int;

    my enum

    • A

      Declaration

      A

      element a

    • B

      Declaration

      B

      element b

  • E3

    Declaration

    enum E3: int;

    my enum

    • A

      Declaration

      A

      element a

    • B

      Declaration

      B

      element b

  • E4

    Declaration

    enum E4: int;

    my enum

    • A

      Declaration

      A

      element a

    • B

      Declaration

      B

      element b

  • E5

    Declaration

    enum E5: int;

    my enum

    • A

      Declaration

      A

      element a

    • B

      Declaration

      B

      element b

  • foo

    Declaration

    void foo();

    Some doc

  • bar

    Declaration

    alias bar = foo;

    More doc

  • C

    Declaration

    abstract class C;

    asdf

    • foo

      Declaration

      abstract void foo();

      Some doc

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test23626b.d0000644000175000017500000000034015205374125022336 0ustar fabiofabiointerface Timeline { } struct Policy { alias OldTagCallback = void delegate() @nogc nothrow; Timeline timeline; OldTagCallback oldTagCB; } import test23626; struct Tiering { StaticHashTable!(Policy) policies; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc7715.html0000644000175000017500000003227715205374125022606 0ustar fabiofabio ddoc7656

ddoc7656

  • foo

    Declaration

    void foo();

    $1 $2

    1. string s = "$1$2 $ &#36;4";
      

  • Declaration

    void test(string a = ")");

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test19463.d0000644000175000017500000000015115205374125022200 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19463 void test() @nogc { throw new Exception("wat"); } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc11.html0000644000175000017500000005760415205374125022425 0ustar fabiofabio ddoc11

ddoc11

  • Declaration

    FE_INVALID

  • Declaration

    FE_DENORMAL

  • Declaration

    FE_DIVBYZERO

  • Declaration

    FE_OVERFLOW

  • Declaration

    FE_UNDERFLOW

  • Declaration

    FE_INEXACT

  • Declaration

    FE_ALL_EXCEPT

    Mask of all the exceptions

  • bar

    Declaration

    myint bar;

  • foo

    Declaration

    myint foo(myint x = myint.max);

  • Foo

    Declaration

    class Foo;

    • Declaration

      this(string s);

  • Declaration

    struct div_t;

  • Declaration

    struct ldiv_t;

  • Declaration

    struct lldiv_t;

  • div

    Declaration

    div_t div(int, int);

  • Declaration

    ldiv_t ldiv(int, int);

  • Declaration

    lldiv_t lldiv(long, long);

  • Declaration

    void* calloc(size_t, size_t);

  • Declaration

    void* malloc(size_t);

    dittx

  • Declaration

    void test1();

    Example:

    1. private:
          int i = 0;
      

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc15475.html0000644000175000017500000003235715205374125022667 0ustar fabiofabio ddoc15475

ddoc15475

My module

  1.    // Computes the interval [x,y)
       auto interval = computeInterval(x, y);
    

Discussion

Backslash-escape parentheses with \( and \).

  1. (
    


  1. )
    


  1.     Here are some nested `backticks`
        // Another interval [x,y)
    


  1.     This won't end the code block: --- )
        // Yet another interval [x,y)
    

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9676a.ddoc0000644000175000017500000000003315205374125022705 0ustar fabiofabioDEPRECATED = $0 ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc648.html0000644000175000017500000006575415205374125022532 0ustar fabiofabio ddoc648

ddoc648

  • Declaration

    template Mixin1()

    Mixin declaration

    • S

      Declaration

      struct S;

      struct S

  • A

    Declaration

    class A;

    class A

    • x

      Declaration

      int x;

      field x

    • S

      Declaration

      struct S;

      struct S

  • AB

    Declaration

    class AB;

    class AB

    • x

      Declaration

      int x;

      field x

  • Declaration

    template Mixin2()

    Mixin declaration2

    • S2

      Declaration

      struct S2;

      struct S2

  • Declaration

    template Mixin3()

    Mixin declaration3

    • f

      Declaration

      int f;

      another field

  • B1

    Declaration

    class B1;

    class B1

    • f

      Declaration

      int f;

      another field

    • S2

      Declaration

      struct S2;

      struct S2

  • Declaration

    template Mixin4()

    Mixin declaration3

    • f

      Declaration

      int f;

      another field

  • B2

    Declaration

    class B2;

    class B2

    • f

      Declaration

      int f;

      another field

  • f

    Declaration

    int f;

    another field

  • S2

    Declaration

    struct S2;

    struct S2

  • TS

    Declaration

    struct TS(T);

    • Declaration

      int field;

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc4162.html0000644000175000017500000003262415205374125022573 0ustar fabiofabio ddoc4162

ddoc4162

  • A

    Declaration

    interface A;

    • Declaration

      static void staticHello();

    • Declaration

      final void hello();

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9727.html0000644000175000017500000003273015205374125022605 0ustar fabiofabio ddoc9727

ddoc9727

  • foo

    Declaration

    void foo(int x);

    The function foo.

    Examples

    1. foo(1);
      

    Examples

    foo can be used like this:

    1. foo(2);
      

    Examples

    foo can also be used like this:

    1. foo(3);
      

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/json2.json0000644000175000017500000000464015205374125022402 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/json2.out { "buildInfo": { "argv0": "VALUE_REMOVED_FOR_TEST", "config": "VALUE_REMOVED_FOR_TEST", "cwd": "VALUE_REMOVED_FOR_TEST", "ddocFiles": [], "defFile": null, "importPaths": [ "VALUES_REMOVED_FOR_TEST" ], "libName": "VALUE_REMOVED_FOR_TEST", "libraryFiles": [ "VALUES_REMOVED_FOR_TEST" ], "mapFile": "VALUE_REMOVED_FOR_TEST", "objectFiles": [ "VALUES_REMOVED_FOR_TEST" ], "resourceFile": null }, "compilerInfo": { "__VERSION__": 0, "architectures": [ "VALUES_REMOVED_FOR_TEST" ], "interface": "dmd", "platforms": [ "VALUES_REMOVED_FOR_TEST" ], "predefinedVersions": [ "VALUES_REMOVED_FOR_TEST" ], "size_t": 0, "supportedFeatures": { "includeImports": true }, "vendor": "VALUE_REMOVED_FOR_TEST", "version": "VALUE_REMOVED_FOR_TEST" }, "modules": [ { "file": "VALUE_REMOVED_FOR_TEST", "kind": "module", "members": [ { "char": 8, "kind": "import", "line": 9, "name": "json", "protection": "private" } ] } ], "semantics": { "modules": [ { "file": "compilable/json2.d", "isRoot": true, "name": null }, { "file": "compilable/json.d", "isRoot": false, "name": "json" }, { "file": "compilable/imports/jsonimport1.d", "isRoot": false, "name": "imports.jsonimport1" }, { "file": "compilable/imports/jsonimport2.d", "isRoot": false, "name": "imports.jsonimport2" }, { "file": "compilable/imports/jsonimport3.d", "isRoot": false, "name": "imports.jsonimport3" }, { "file": "compilable/imports/jsonimport4.d", "isRoot": false, "name": "imports.jsonimport4" } ] } } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc24171.dd0000644000175000017500000000000015205374125022257 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_headings_verbose.html0000644000175000017500000002746415205374125027555 0ustar fabiofabiocompilable/ddoc_markdown_headings_verbose.d(9): Ddoc: added heading 'Heading' === ${RESULTS_DIR}/compilable/ddoc_markdown_headings_verbose.html ddoc_markdown_headings_verbose

ddoc_markdown_headings_verbose

Heading

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddocbackticks.html0000644000175000017500000003473015205374125024135 0ustar fabiofabio ddocbackticks

ddocbackticks

Closely related to std.datetime is core.time, and some of the time types used in std.datetime come from there - such as , , and . core.time is publically imported into std.datetime, it isn't necessary to import it separately.

  • Declaration

    void test();

    This should produce inline code.

  • Declaration

    void test2();

    But `this should NOT be inline'

    Discussion

    However, restarting on a new line should be inline again.

  • foo

    Declaration

    void foo();

    This int foo; should show highlight on foo, but not int.

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/header2i.di0000644000175000017500000000703315205374125022454 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/testheader2i.di // D import file generated from 'compilable/extra-files/header2.d' class C { } void foo(const C c, const(char)[] s, const int* q, const(int*) p) { } void bar(in void* p) { } void f(void function() f2); class C2; void foo2(const C2 c); struct Foo3 { int k; @nogc @live @trusted @disable ~this() { k = 1; } this(this) { k = 2; } } class C3 { @property int get() { return 0; } } T foo3(T)() { } struct S4A(T) { T x; @safe ~this() { } } struct S4B(T) if (1) { T x; } union U4A(T) { T x; } union U4B(T) if (2 * 4 == 8) { T x; } class C4A(T) { T x; } class C4B(T) if (true) { T x; } class C4C(T) if (!false) : C4A!int { T x; } class C4D(T) if (!false) : C4B!long, C4C!(int[]) { T x; } interface I4(T) if ((int[1]).length == 1) { T x; } template MyClass4(T) if (is(typeof(T.subtype))) { alias HelperSymbol = T.subtype; class MyClass4 { } } enum isInt(T) = is(T == int); enum bool isString(T) = is(T == string); static immutable typeName(T) = T.stringof; int storageFor(T) = 0; enum int templateVariableFoo(T) = T.stringof.length; template templateVariableBar(T) if (is(T == int)) { enum int templateVariableBar = T.stringof.length; } extern typeof(3 / 2.0) flit; void foo11217()(const int[] arr) { } void foo11217()(immutable int[] arr) { } void foo11217()(ref int[] arr) { } void foo11217()(lazy int[] arr) { } void foo11217()(auto ref int[] arr) { } void foo11217()(scope int[] arr) { } void foo11217()(in int[] arr) { } void foo11217()(inout int[] arr) { } void test13275() { if (auto n = 1) { } if (const n = 1) { } if (immutable n = 1) { } if (shared n = 1) { } if (const shared n = 1) { } if (int n = 1) { } if (const int n = 1) { } if (immutable int n = 1) { } if (shared int n = 1) { } if (const shared int n = 1) { } if (const(int) n = 1) { } if (immutable(int) n = 1) { } if (shared(int) n = 1) { } if (shared const(int) n = 1) { } foreach (e; [1, 2]) { } foreach (const e; [1, 2]) { } foreach (immutable e; [1, 2]) { } foreach (shared e; [1, 2]) { } foreach (const shared e; [1, 2]) { } foreach (int e; [1, 2]) { } foreach (const int e; [1, 2]) { } foreach (immutable int e; [1, 2]) { } foreach (shared int e; [1, 2]) { } foreach (const shared int e; [1, 2]) { } foreach (int e; [1, 2]) { } foreach (const(int) e; [1, 2]) { } foreach (immutable(int) e; [1, 2]) { } foreach (shared(int) e; [1, 2]) { } foreach (shared const(int) e; [1, 2]) { } } align (1) struct S9766 { align {} align (true ? 2 : 3) { int var1; align int var2; } } align (2) struct S12200_1 { align {} } align (2) struct S12200_2 { align (1) {} } pure nothrow @trusted inout(T)[] overlap(T)(inout(T)[] r1, inout(T)[] r2) { alias U = inout(T); static nothrow U* max(U* a, U* b) { return a > b ? a : b; } static nothrow U* min(U* a, U* b) { return a < b ? a : b; } auto b = max(r1.ptr, r2.ptr); auto e = min(r1.ptr + r1.length, r2.ptr + r2.length); return b < e ? b[0..e - b] : null; } void gun()() { int[] res; while (auto va = fun()) { } while (true) if (auto va = fun()) { } else break; } pragma (inline, true)int fun(int a, int b) { return 3; } void leFoo()() { sign = a == 2 ? false : (y < 0) ^ sign; sign = a == 2 ? false : sign ^ (y < 0); sign = 2 + 3 | 7 + 5; } interface LeInterface { } class LeClass { this() { auto foo = new class LeInterface { } ; } } extern const typeof(new class LeClass, LeInterface { } ) levar; class CC { @safe void fun()() { () pure @trusted { } (); } } private struct Export { } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/imp9057_2.d0000644000175000017500000000005215205374125022145 0ustar fabiofabiostruct BugInt { uint[] data = [0]; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9764.html0000644000175000017500000002561615205374125022613 0ustar fabiofabio ddoc9764

ddoc9764





Check ddoc9764 document.
  1. // Check ddoc9764 comment. ddoc9764();
./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc13645.html0000644000175000017500000002721215205374125022656 0ustar fabiofabio ddoc13645

ddoc13645

Documentation comment on module

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/header1.di0000644000175000017500000001676415205374125022315 0ustar fabiofabioHello World === ${RESULTS_DIR}/compilable/testheader1.di // D import file generated from 'compilable/extra-files/header1.d' module foo.bar; import core.vararg; void writeln(T...)(T) { } pragma (lib, "test"); pragma (msg, "Hello World"); pragma (linkerDirective, "/DEFAULTLIB:test2"); static assert(true, "message"); alias mydbl = double; alias fl1 = function () in { } in (true) out (; true) out (r; true) out { } out(r) { } do { return 2; } ; alias fl2 = function () in (true) out (; true) out (r; true) { return 2; } ; int testmain(); struct S { int m; int n; } template Foo(T, int V) { void foo(...) { static if (is(Object _ : X!TL, alias X, TL...)) { } auto x = __traits(hasMember, Object, "noMember"); auto y = is(Object : X!TL, alias X, TL...); assert(!x && !y, "message"); S s = {1, 2}; auto a = [1, 2, 3]; auto aa = [1:1, 2:2, 3:3]; int n, m; } int bar(double d, int x) { if (d) { d++; } else d--; asm { naked; } asm { mov EAX,3; } for (;;) { { d = d + 1; } } for (int i = 0; i < 10; i++) { { d = i ? d + 1 : 5; } } char[] s; foreach (char c; s) { d *= 2; if (d) break; else continue; } switch (V) { case 1: { } case 2: { break; } case 3: { goto case 1; } case 4: { goto default; } default: { d /= 8; break; } } enum Label { A, B, C, } void fswitch(Label l) { final switch (l) { case A: { break; } case B: { break; } case C: { break; } } } loop: while (x) { x--; if (x) break loop; else continue loop; } do { x++; } while (x < 10); try { try { bar(1, 2); } catch(Object o) { x++; } } finally { x--; } try { try bar(1, 2); catch(Object o) { x++; } } finally x--; Object o; synchronized(o) { x = ~x; } synchronized { x = x < 3; } with (o) { toString(); } } } static this(); static ~this(); nothrow pure @nogc @safe static this(); nothrow pure @nogc @safe static ~this(); nothrow pure @nogc @safe static this(); nothrow pure @nogc @safe static ~this(); nothrow pure @nogc @safe shared static this(); nothrow pure @nogc @safe shared static ~this(); nothrow pure @nogc @safe shared static this(); nothrow pure @nogc @safe shared static ~this(); interface iFoo { } class xFoo : iFoo { } interface iFoo2 { } class xFoo2 : iFoo, iFoo2 { } class Foo3 { this(int a, ...); this(int* a); } alias myint = int; static extern typeof(1) notquit; class Test { void a(); void b(); void c(); void d(); void e(); void f(); void g(); void h(); void i(); void j(); void k(); void l(); void m(); void n(); void o(); void p(); void q(); void r(); void s(); void t(); void u(); void v(); void w(); void x(); void y(); void z(); void aa(); void bb(); void cc(); void dd(); void ee(); template A(T) { } alias getHUint = A!uint; alias getHInt = A!int; alias getHFloat = A!float; alias getHUlong = A!ulong; alias getHLong = A!long; alias getHDouble = A!double; alias getHByte = A!byte; alias getHUbyte = A!ubyte; alias getHShort = A!short; alias getHUShort = A!ushort; alias getHReal = A!real; alias void F(); } void templ(T)(T val) { pragma (msg, "Invalid destination type."); } static extern char[] charArray; class Point { auto x = 10; uint y = 20; } template Foo2(bool bar) { void test() { static if (bar) { int i; } else { } static if (!bar) { } else { } } } template Foo4() { void bar() { } } template Foo4x(T...) { } class Baz4 { mixin Foo4!() foo; mixin Foo4x!(int, "str") foox; alias baz = foo.bar; } int test(T)(T t) { if (auto o = cast(Object)t) return 1; return 0; } enum x6 = 1; bool foo6(int a, int b, int c, int d); auto foo7(int x) { return 5; } class D8 { } void func8(); T func9(T)() if (true) { T i; scope(exit) i = 1; scope(success) i = 2; scope(failure) i = 3; return i; } template V10(T) { void func() { for (int i, j = 4; i < 3; i++) { { } } } } int foo11(int function() fn); int bar11(T)() { return foo11(function int() { return 0; } ); } struct S6360 { pure nothrow @property long weeks1() const; pure nothrow @property long weeks2() const; } struct S12 { nothrow this(int n); nothrow this(string s); } struct T12 { this()(int args) immutable { } this(A...)(A args) immutable { } } import core.stdc.stdio : printf, F = FILE; void foo6591()() { import core.stdc.stdio : printf, F = FILE; } version (unittest) { public {} extern (C) {} align {} } template Foo10334(T) if (Bar10334!()) { } template Foo10334(T) if (Bar10334!100) { } template Foo10334(T) if (Bar10334!3.14) { } template Foo10334(T) if (Bar10334!"str") { } template Foo10334(T) if (Bar10334!1.4i) { } template Foo10334(T) if (Bar10334!null) { } template Foo10334(T) if (Bar10334!true) { } template Foo10334(T) if (Bar10334!false) { } template Foo10334(T) if (Bar10334!'A') { } template Foo10334(T) if (Bar10334!int) { } template Foo10334(T) if (Bar10334!string) { } template Foo10334(T) if (Bar10334!wstring) { } template Foo10334(T) if (Bar10334!dstring) { } template Foo10334(T) if (Bar10334!this) { } template Foo10334(T) if (Bar10334!([1, 2, 3])) { } template Foo10334(T) if (Bar10334!(Baz10334!())) { } template Foo10334(T) if (Bar10334!(Baz10334!T)) { } template Foo10334(T) if (Bar10334!(Baz10334!100)) { } template Foo10334(T) if (Bar10334!(.foo)) { } template Foo10334(T) if (Bar10334!(const(int))) { } template Foo10334(T) if (Bar10334!(shared(T))) { } template Test10334(T...) { } mixin Test10334!int a; mixin Test10334!(int, long) b; mixin Test10334!"str" c; auto clamp12266a(T1, T2, T3)(T1 x, T2 min_val, T3 max_val) { return 0; } pure clamp12266b(T1, T2, T3)(T1 x, T2 min_val, T3 max_val) { return 0; } @disable pure clamp12266c(T1, T2, T3)(T1 x, T2 min_val, T3 max_val) { return 0; } alias Dg13832 = ref int delegate(); class TestClass { int aa; int b1; int b2; this(int b1, int b2); ref foo() { return aa; } ref retFunc() return { return aa; } @nogc @trusted @disable ~this(); } class FooA { protected void method42(); @safe ~this(); } class Bar : FooA { override void method42(); } @trusted double foo(); struct Foo1(size_t Size = 42 / magic()) { } size_t magic(); class Foo2A { immutable(FooA) Dummy = new immutable(FooA); private pure nothrow @nogc @safe this() immutable; } struct Foo3A(T) { @disable this(this); @disable this(); } ref @safe int foo(return ref int a); @safe int* foo(return scope int* a); ref @safe int* foo(return ref scope int* a); struct SafeS { this(int[1] x) scope; this(int[2] x) return scope; this(int[3] x) scope return; this(int[4] x) return; @safe { ref SafeS foo() return; SafeS foo2() return scope; ref SafeS foo3() scope; ref SafeS foo4() scope return; int* p; } } void test13x(@(10) int a, @(20) int, @(AliasSeq!(30), AliasSeq!(40)) int[] arr...); enum Test14UDA1; struct Test14UDA2 { string str; } Test14UDA2 test14uda3(string name); struct Test14UDA4(string v) { } void test14x(@(Test14UDA1) int, @Test14UDA2("1") int, @test14uda3("2") int, @(Test14UDA4!"3") int); void test15x(@(20) void delegate(int) @safe dg); T throwStuff(T)(T t) { if (false) test13x(1, throw new Exception(""), 2); return t ? t : throw new Exception("Bad stuff happens!"); } class C12344 { abstract int c12344(int x) in (x > 0) out(result) { assert(result > 0); } ; } interface I12344 { int i12344(int x) in (x > 0) out(result) { assert(result > 0); } ; } debug { enum issue21406 = 1; }./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc_markdown_tables.html0000644000175000017500000003236515205374125025514 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/ddoc_markdown_tables.html test.compilable.ddoc_markdown_tables

test.compilable.ddoc_markdown_tables

Tables

Discussion

Rounding moderndint(4.5)rndint(5.5)rndint(-4.5)Notes
Round to nearest46-4Ties round to an even number
Round down45-5 
Round up56-4 
Round to zero45-4 
thisthat
cellcell
sell
abcdef
bar
barbaz

quote
table
  • list
    table
defaultleftcenterright
Look Ma, a table without a body!

| not | a | table | | -- | | wrong number of header columns |

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9497d.ddoc0000644000175000017500000000006115205374125022712 0ustar fabiofabioDDOC_UNDEFINED_MACRO=ERROR_UNDEFINED_MACRO: "$1" ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc11511.html0000644000175000017500000003551715205374125022653 0ustar fabiofabio ddoc11511

ddoc11511

  • foo

    Declaration

    void foo(int abcd, int bcdef, ...);

    Parameters

    int abcd

    none1

    int bcdef

    none23

    ...

    doo

  • foo

    Declaration

    void foo(int abcd, int bcdef, int[] arr...);

    Parameters

    int abcd

    none1

    int bcdef

    none23

    int[] arr

    doo

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test14894main.d0000644000175000017500000000010615205374125023050 0ustar fabiofabioimport test14894a; void main() { Foo foo; foo.onReceive(); } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test21331.d0000644000175000017500000000044715205374125022173 0ustar fabiofabiostruct S(alias fun) { int foo() { int r = fun(0); static foreach (i; 0..2) r += (x => 2)(0); return r; } } int bar() { int r; static foreach (i; 0..2) r += S!(x => 1)().foo(); return r; } // nm test21331.o | grep __lambda_L5_C19 ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc12745.html0000644000175000017500000003115715205374125022661 0ustar fabiofabio ddoc12745

ddoc12745

  • i

    Declaration

    int i;

    i underlined
    i not underlined
    _i force underscore

    0 not underscored
    _0 force underscored

    Discussion

    1 underscore:
    1_1
    1_a
    a_1
    a_a

    2 underscores:
    1__a
    2__b

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc13.html0000644000175000017500000004151115205374125022415 0ustar fabiofabio ddoc13

ddoc13

  • Declaration

    struct Bug4107(T);

    struct doc

    • foo

      Declaration

      void foo(U)(U u);

      templated function doc

  • Declaration

    struct Bug4107b(T);

    alpha

    • B

      Declaration

      struct B(U);

      beta

      • C

        Declaration

        struct C(V);

        gamma

        • D

          Declaration

          struct D(W);

          delta

          • e

            Declaration

            B!W e(X)(C!V c, X[] x...);

            epsilon

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test9680dllmain.d0000644000175000017500000000021015205374125023455 0ustar fabiofabioimport core.sys.windows.windef; extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { return 0; } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9676a.html0000644000175000017500000003032715205374125022751 0ustar fabiofabio ddoc9676a

ddoc9676a

  • foo

    Declaration

    deprecated void foo();

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc5.html0000644000175000017500000003343515205374125022344 0ustar fabiofabio test

test

Test module

  • Declaration

    class TestMembers(TemplateArg);

    class to test DDOC on members

    • Declaration

      static void PublicStaticMethod(int idx);

      a static method

      Parameters

      int idx

      index

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc7795.html0000644000175000017500000003161315205374125022607 0ustar fabiofabio ddoc7795

ddoc7795

  • Declaration

    struct DateTime;

    • Declaration

      this(int x, TimeValue t = TimeValue(0, 0));

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc13270.html0000644000175000017500000003303415205374125022647 0ustar fabiofabio ddoc13270

ddoc13270

  • Declaration

    void doStuff(string task);
    void doStuff(string[] tasks, int maxJobs);

    My overloaded function.

    Parameters

    string task

    String description of stuff to do.

    string[] tasks

    Array of descriptions of stuff to do.

    int maxJobs

    Max parallel jobs to run while doing stuff.

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/checkaction-context-assert-0.d.cg0000644000175000017500000000026715205374125026603 0ustar fabiofabio=== compilable/checkaction-context-assert-0.d.cg module checkaction_context_assert_0; import object; void a() { assert(0); } void b() { assert(false); } void c() { assert(null); } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddocYear-postscript.sh0000755000175000017500000000070315205374125024751 0ustar fabiofabio#!/usr/bin/env bash source tools/common_funcs.sh YEAR=$(date +%Y) # make sure the __YEAR__ placeholder is found in ddocYear.html grep "__YEAR__" ${EXTRA_FILES}/${TEST_NAME}.html sed "s/__YEAR__/${YEAR}/" ${EXTRA_FILES}/${TEST_NAME}.html > ${OUTPUT_BASE}.html.1 grep -v "Generated by Ddoc from" ${OUTPUT_BASE}.html > ${OUTPUT_BASE}.html.2 diff -up --strip-trailing-cr ${OUTPUT_BASE}.html.1 ${OUTPUT_BASE}.html.2 rm_retry ${OUTPUT_BASE}.html{,.1,.2} ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc10325.html0000644000175000017500000003152415205374125022647 0ustar fabiofabio ddoc10325

ddoc10325

  • Declaration

    template templ(T...) if (someConstraint!T)

  • foo

    Declaration

    void foo(T)(T t) if (someConstraint!T);

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc198.ddoc0000644000175000017500000000030115205374125022450 0ustar fabiofabioDDOC_PSYMBOL = $0 DDOC_PSUPER_SYMBOL = $0 ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc24871.html0000644000175000017500000003133015205374125022655 0ustar fabiofabio ddoc24871

ddoc24871

  • Declaration

    void main();

    Example

    1. void main() {
      	foreach (i; 0..10) {
      		writeln("Hello, world!");
      	}
      }
      

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/imp12624.d0000644000175000017500000000067715205374125022013 0ustar fabiofabio// typecons.d template RebindableCommon(T, U, This) { union { U stripped; } void opAssign(T another) { stripped = cast() another; } this(T initializer) { opAssign(initializer); } } template Rebindable(T) { static if (is(T == immutable U, U)) struct Rebindable { mixin RebindableCommon!(T, U, Rebindable); } } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/header3.d0000644000175000017500000000016715205374125022134 0ustar fabiofabioauto elseifchain() { bool a,b,c; if (a) { } else if (b) { } else if (c) { } } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc10334.html0000644000175000017500000005615615205374125022657 0ustar fabiofabio ddoc10334

ddoc10334

  • Declaration

    template Foo10334(T) if (Bar10334!())

  • Declaration

    template Foo10334(T) if (Bar10334!100)

  • Declaration

    template Foo10334(T) if (Bar10334!3.14)

  • Declaration

    template Foo10334(T) if (Bar10334!"str")

  • Declaration

    template Foo10334(T) if (Bar10334!1.4i)

  • Declaration

    template Foo10334(T) if (Bar10334!null)

  • Declaration

    template Foo10334(T) if (Bar10334!true)

  • Declaration

    template Foo10334(T) if (Bar10334!false)

  • Declaration

    template Foo10334(T) if (Bar10334!'A')

  • Declaration

    template Foo10334(T) if (Bar10334!int)

  • Declaration

    template Foo10334(T) if (Bar10334!string)

  • Declaration

    template Foo10334(T) if (Bar10334!([1, 2, 3]))

  • Declaration

    template Foo10334(T) if (Bar10334!(Baz10334!()))

  • Declaration

    template Foo10334(T) if (Bar10334!(Baz10334!T))

  • Declaration

    template Foo10334(T) if (Bar10334!(Baz10334!100))

  • Declaration

    template Foo10334(T) if (Bar10334!(.foo))

  • Declaration

    template Foo10334(T) if (Bar10334!(const(int)))

  • Declaration

    template Foo10334(T) if (Bar10334!(shared(T)))

  • Declaration

    template Test10334(T...)

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc17697.html0000644000175000017500000003076515205374125022700 0ustar fabiofabio test1
./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc9475.html0000644000175000017500000003350215205374125022603 0ustar fabiofabio ddoc9475

ddoc9475

  • foo

    Declaration

    void foo();

    foo

    Examples

    1. // comment 1
      foreach (i; 0 .. 10)
      {
          // comment 2
          documentedFunction();
      }
      

  • bar

    Declaration

    void bar();

    bar

    Examples

    1. // bar comment
      

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/ddoc7555.html0000644000175000017500000003132715205374125022603 0ustar fabiofabio ddoc7555

ddoc7555

  • Declaration

    void dummy();

    Dummy doc.

    Discussion

    DelimitedString TokenString

    DelimitedString TokenString

    HexString HexString

    HexString HexString

    HexString HexString

    HexString HexString

    HexString HexString

    HexString HexString

    HexString HexString

    HexString HexString

./ldc-1.42.0-src/tests/dmd/compilable/extra-files/test14894a.d0000644000175000017500000000022315205374125022344 0ustar fabiofabiomodule imports.test14894a; mixin template Protocol() { void onReceive() {} } struct Foo { mixin Protocol!(); unittest { } } ./ldc-1.42.0-src/tests/dmd/compilable/extra-files/header2.di0000644000175000017500000000475515205374125022313 0ustar fabiofabio=== ${RESULTS_DIR}/compilable/testheader2.di // D import file generated from 'compilable/extra-files/header2.d' class C { } void foo(const C c, const(char)[] s, const int* q, const(int*) p); void bar(in void* p); void f(void function() f2); class C2; void foo2(const C2 c); struct Foo3 { int k; @nogc @live @trusted @disable ~this(); this(this); } class C3 { @property int get(); } T foo3(T)() { } struct S4A(T) { T x; @safe ~this() { } } struct S4B(T) if (1) { T x; } union U4A(T) { T x; } union U4B(T) if (2 * 4 == 8) { T x; } class C4A(T) { T x; } class C4B(T) if (true) { T x; } class C4C(T) if (!false) : C4A!int { T x; } class C4D(T) if (!false) : C4B!long, C4C!(int[]) { T x; } interface I4(T) if ((int[1]).length == 1) { T x; } template MyClass4(T) if (is(typeof(T.subtype))) { alias HelperSymbol = T.subtype; class MyClass4 { } } enum isInt(T) = is(T == int); enum bool isString(T) = is(T == string); static immutable typeName(T) = T.stringof; int storageFor(T) = 0; enum int templateVariableFoo(T) = T.stringof.length; template templateVariableBar(T) if (is(T == int)) { enum int templateVariableBar = T.stringof.length; } extern typeof(3 / 2.0) flit; void foo11217()(const int[] arr) { } void foo11217()(immutable int[] arr) { } void foo11217()(ref int[] arr) { } void foo11217()(lazy int[] arr) { } void foo11217()(auto ref int[] arr) { } void foo11217()(scope int[] arr) { } void foo11217()(in int[] arr) { } void foo11217()(inout int[] arr) { } void test13275(); align (1) struct S9766 { align {} align (true ? 2 : 3) { int var1; align int var2; } } align (2) struct S12200_1 { align {} } align (2) struct S12200_2 { align (1) {} } pure nothrow @trusted inout(T)[] overlap(T)(inout(T)[] r1, inout(T)[] r2) { alias U = inout(T); static nothrow U* max(U* a, U* b) { return a > b ? a : b; } static nothrow U* min(U* a, U* b) { return a < b ? a : b; } auto b = max(r1.ptr, r2.ptr); auto e = min(r1.ptr + r1.length, r2.ptr + r2.length); return b < e ? b[0..e - b] : null; } void gun()() { int[] res; while (auto va = fun()) { } while (true) if (auto va = fun()) { } else break; } pragma (inline, true)int fun(int a, int b) { return 3; } void leFoo()() { sign = a == 2 ? false : (y < 0) ^ sign; sign = a == 2 ? false : sign ^ (y < 0); sign = 2 + 3 | 7 + 5; } interface LeInterface { } class LeClass { this(); } extern const typeof(new class LeClass, LeInterface { } ) levar; class CC { @safe void fun()() { () pure @trusted { } (); } } private struct Export { }./ldc-1.42.0-src/tests/dmd/compilable/extra-files/emptymain.d0000644000175000017500000000001715205374125022616 0ustar fabiofabiovoid main() { }./ldc-1.42.0-src/tests/dmd/compilable/protection/0000755000175000017500000000000015151104326020405 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/protection/bug/0000755000175000017500000000000015205374126021171 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/protection/bug/bug14275.d0000644000175000017500000000033115205374126022513 0ustar fabiofabiomodule protection.bug.bug14275; import protection.aggregate.mod14275; // https://issues.dlang.org/show_bug.cgi?id=14275 void main() { Foo f; f.foo(); static assert (!is(typeof(f.foo2()))); bar(); } ./ldc-1.42.0-src/tests/dmd/compilable/protection/basic/0000755000175000017500000000000015205374126021475 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/protection/basic/tests.d0000644000175000017500000000125215205374126023004 0ustar fabiofabiomodule protection.basic.tests; import protection.basic.mod1; static assert ( is(typeof(publicFoo()))); static assert ( is(typeof(packageFoo()))); static assert (!is(typeof(privateFoo()))); static assert ( is(typeof(Test.init.publicFoo()))); static assert (!is(typeof(Test.init.protectedFoo()))); static assert ( is(typeof(Test.init.packageFoo()))); static assert (!is(typeof(Test.init.privateFoo()))); class Deriv : Test { void stub() { static assert ( is(typeof(this.publicFoo()))); static assert ( is(typeof(this.protectedFoo()))); static assert ( is(typeof(this.packageFoo()))); static assert (!is(typeof(this.privateFoo()))); } } ./ldc-1.42.0-src/tests/dmd/compilable/protection/basic/mod1.d0000644000175000017500000000040215205374126022476 0ustar fabiofabiomodule protection.basic.mod1; public void publicFoo() {} package void packageFoo() {} private void privateFoo() {} class Test { public void publicFoo(); protected void protectedFoo(); package void packageFoo(); private void privateFoo(); } ./ldc-1.42.0-src/tests/dmd/compilable/protection/issue21726/0000755000175000017500000000000015205374126022146 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/protection/issue21726/format/0000755000175000017500000000000015205374126023436 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/protection/issue21726/format/package.d0000644000175000017500000000027415205374126025201 0ustar fabiofabiomodule protection.issue21726.format; package(protection.issue21726.format): package(protection.issue21726) int issuePkgSym; package(protection) int protectionPkgSym(); int formatPkgSym; ./ldc-1.42.0-src/tests/dmd/compilable/protection/issue21726/package.d0000644000175000017500000000003615205374126023705 0ustar fabiofabiomodule protection.issue21726; ./ldc-1.42.0-src/tests/dmd/compilable/protection/issue21726/typecons.d0000644000175000017500000000041015205374126024152 0ustar fabiofabiomodule protection.issue21726.typecons; import protection.issue21726.format : issuePkgSym; import protection.issue21726.format : protectionPkgSym; static assert(!__traits(compiles, { import protection.issue21726.format : formatPkgSym; })); ./ldc-1.42.0-src/tests/dmd/compilable/protection/aggregate/0000755000175000017500000000000015205374126022342 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/protection/aggregate/mod14275.d0000644000175000017500000000024215205374126023667 0ustar fabiofabiomodule protection.aggregate.mod14275; public struct Foo { package(protection) void foo() {} package void foo2() {} } package(protection) void bar() { } ./ldc-1.42.0-src/tests/dmd/compilable/protection/issue20796/0000755000175000017500000000000015205374126022154 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/protection/issue20796/package.d0000644000175000017500000000006715205374126023717 0ustar fabiofabiomodule issue20796; package(issue20796) void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/protection/subpkg2/0000755000175000017500000000000015205374126021771 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/protection/subpkg2/tests.d0000644000175000017500000000020115205374126023271 0ustar fabiofabiomodule protection.subpkg2.tests; import pkg = protection.subpkg.explicit; static assert (is(typeof(pkg.commonAncestorFoo()))); ./ldc-1.42.0-src/tests/dmd/compilable/protection/subpkg/0000755000175000017500000000000015205374126021707 5ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/protection/subpkg/explicit.d0000644000175000017500000000020015205374126023665 0ustar fabiofabiomodule protection.subpkg.explicit; package(protection) void commonAncestorFoo(); package(protection.subpkg) void samePkgFoo(); ./ldc-1.42.0-src/tests/dmd/compilable/protection/subpkg/tests.d0000644000175000017500000000060215205374126023214 0ustar fabiofabiomodule protection.subpkg.tests; import crosspkg = protection.basic.mod1; static assert ( is(typeof(crosspkg.publicFoo()))); static assert (!is(typeof(crosspkg.packageFoo()))); static assert (!is(typeof(crosspkg.privateFoo()))); import samepkg = protection.subpkg.explicit; static assert ( is(typeof(samepkg.commonAncestorFoo()))); static assert ( is(typeof(samepkg.samePkgFoo()))); ./ldc-1.42.0-src/tests/dmd/compilable/zerosize.d0000644000175000017500000000037115205374124020244 0ustar fabiofabio extern (C) struct S { } version (CRuntime_Microsoft) static assert(S.sizeof == 4); else static assert(S.sizeof == 0); static assert(S.alignof == 1); extern (C++) struct T { } static assert(T.sizeof == 1); static assert(T.alignof == 1); ./ldc-1.42.0-src/tests/dmd/compilable/test16080.d0000644000175000017500000000030115205374124017741 0ustar fabiofabio// REQUIRED_ARGS: -lib -Icompilable/imports // COMPILED_IMPORTS: extra-files/test16080b.d // EXTRA_FILES: imports/imp16080.d // https://issues.dlang.org/show_bug.cgi?id=16080 import imp16080; ./ldc-1.42.0-src/tests/dmd/compilable/importtests.d0000644000175000017500000000021415205374124020763 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23369 import imports.aliasdump : iainBuclaw; import imports.aliasdump : iainBuclaw, iainBuclaw; ./ldc-1.42.0-src/tests/dmd/compilable/issue24566.d0000644000175000017500000000114415205374124020130 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24566 void test24566a() { enum a = true; bool b = true; enum str = "a"; if (a && str.length > 1 && str[1] == 'a') {} if (b && str.length > 1 && str[1] == 'a') {} if (!b && str.length > 1 && str[1] == 'a') {} if (str.length > 1 && b && str[1] == 'a') {} } void test24566b() { enum a = false; bool b = false; enum str = "a"; if (a || str.length <= 1 || str[1] == 'a') {} if (b || str.length <= 1 || str[1] == 'a') {} if (!b || str.length <= 1 || str[1] == 'a') {} if (str.length <= 1 || b || str[1] == 'a') {} } ./ldc-1.42.0-src/tests/dmd/compilable/ice11610.d0000644000175000017500000000400015205374124017514 0ustar fabiofabio struct Token { TokenType type; } enum TokenType : ushort { invalid } class Parser { bool peekIsOneOf(TokenType[] types...) { canFind(types, tokens[1].type); return true; } Token[] tokens; } /*************************************************/ // std.algorithm R find(alias pred = "a == b", R, E)(R haystack, E needle) { enum isIntegralNeedle = isSomeChar!E/* || isIntegral!E || isBoolean!E*/; return haystack; } bool canFind(alias pred = "a == b", R, E)(R haystack, E needle) if (is(typeof(find!pred(haystack, needle)))) // 1st instantiate of find template with error gagging { return find!pred(haystack, needle).length != 0; // 2nd instantiate of find template without gagging } /*************************************************/ // std.traits template CharTypeOf(T) { inout( char) idx( inout( char) ); inout(wchar) idx( inout(wchar) ); inout(dchar) idx( inout(dchar) ); shared(inout char) idx( shared(inout char) ); shared(inout wchar) idx( shared(inout wchar) ); shared(inout dchar) idx( shared(inout dchar) ); static if (is(T == enum)) { /* This line instantiates CharTypeOf!short and will make error. * But, when CharTypeOf!short is re-instantiated without gagging, * that's for correct error report, its 'members' does not re-created. * so, members' semantic will call FuncDeclaration::overloadInsert of * 'idx' functions, and will make circular linked list of * FuncDeclaration::overnext. Finally, iterating it will cause * infinite recursion and compiler segfault. */ alias .CharTypeOf!(OriginalType!T) CharTypeOf; } else static if (is(typeof(idx(T.init)) X)) { alias X CharTypeOf; } else static assert(0, T.stringof~" is not a character type"); } template isSomeChar(T) { enum isSomeChar = is(CharTypeOf!T); } template OriginalType(T) { alias OriginalType = ushort; } ./ldc-1.42.0-src/tests/dmd/compilable/implicitconv.d0000644000175000017500000000256415205374124021100 0ustar fabiofabioenum __c_wchar_t : wchar; alias wchar_t = __c_wchar_t; immutable(wchar_t)[] a = "somestring"; const(wchar_t)[] b = "somestring"; immutable(wchar_t)* c = "somestring"; const(wchar_t)* d = "somestring"; string foo = "foo"; static assert(!__traits(compiles, { immutable(wchar_t)[] bar = foo; } )); static assert(!__traits(compiles, { const(wchar_t)[] bar = foo; } )); static assert(!__traits(compiles, { immutable(wchar_t)* bar = foo; } )); static assert(!__traits(compiles, { const(wchar_t)* bar = foo; } )); // https://issues.dlang.org/show_bug.cgi?id=17141 static assert(is(typeof(true ? char.init : char.init) == char)); static assert(is(typeof(true ? char.init : wchar.init) == dchar)); static assert(is(typeof(true ? char.init : dchar.init) == dchar)); static assert(is(typeof(true ? wchar.init : wchar.init) == wchar)); static assert(is(typeof(true ? wchar.init : dchar.init) == dchar)); static assert(is(typeof(true ? dchar.init : dchar.init) == dchar)); enum cenum : char { a } enum wenum : wchar{ b } enum denum : dchar{ c } static assert(is(typeof(true ? char.init : cenum.init) == char)); static assert(is(typeof(true ? wchar.init : cenum.init) == dchar)); static assert(is(typeof(true ? char.init : wenum.init) == dchar)); static assert(is(typeof(true ? dchar.init : wenum.init) == dchar)); static assert(is(typeof(true ? cenum.init : wenum.init) == dchar)); ./ldc-1.42.0-src/tests/dmd/compilable/test23871.c0000644000175000017500000000024615205374124017756 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23871 extern void foo() __attribute((noreturn)); typedef void (*fp_t)(); extern void bar(fp_t __attribute((noreturn))); ./ldc-1.42.0-src/tests/dmd/compilable/vgc2.d0000644000175000017500000000444015205374124017234 0ustar fabiofabio// REQUIRED_ARGS: -vgc -o- // PERMUTE_ARGS: /***************** CatExp *******************/ /* TEST_OUTPUT: --- compilable/vgc2.d(21): vgc: operator `~` may cause a GC allocation compilable/vgc2.d(22): vgc: operator `~` may cause a GC allocation compilable/vgc2.d(23): vgc: operator `~` may cause a GC allocation compilable/vgc2.d(25): vgc: operator `~` may cause a GC allocation compilable/vgc2.d(26): vgc: operator `~` may cause a GC allocation compilable/vgc2.d(27): vgc: operator `~` may cause a GC allocation compilable/vgc2.d(28): vgc: operator `~` may cause a GC allocation compilable/vgc2.d(29): vgc: operator `~` may cause a GC allocation --- */ void testCat(int[] a, string s) { int[] a1 = a ~ a; int[] a2 = a ~ 1; int[] a3 = 1 ~ a; string s1 = s ~ s; string s2 = s ~ "a"; string s3 = "a" ~ s; string s4 = s ~ 'c'; string s5 = 'c' ~ s; string s6 = "a" ~ "b"; // no error string s7 = "a" ~ 'c'; // no error string s8 = 'c' ~ "b"; // no error } /***************** CatAssignExp *******************/ /* TEST_OUTPUT: --- compilable/vgc2.d(48): vgc: operator `~=` may cause a GC allocation compilable/vgc2.d(50): vgc: operator `~=` may cause a GC allocation compilable/vgc2.d(51): vgc: operator `~=` may cause a GC allocation --- */ void testCatAssign(int[] a, string s) { a ~= 1; s ~= "a"; s ~= 'c'; } /***************** ArrayLiteralExp *******************/ int* barA(); /* TEST_OUTPUT: --- compilable/vgc2.d(70): vgc: array literal may cause a GC allocation compilable/vgc2.d(71): vgc: array literal may cause a GC allocation --- */ void testArray() { enum arrLiteral = [null, null]; int* p; auto a = [p, p, barA()]; a = arrLiteral; } /***************** AssocArrayLiteralExp *******************/ /* TEST_OUTPUT: --- compilable/vgc2.d(87): vgc: associative array literal may cause a GC allocation compilable/vgc2.d(88): vgc: associative array literal may cause a GC allocation --- */ void testAssocArray() { enum aaLiteral = [10: 100]; auto aa = [1:1, 2:3, 4:5]; aa = aaLiteral; } /***************** IndexExp *******************/ /* TEST_OUTPUT: --- compilable/vgc2.d(101): vgc: assigning an associative array element may cause a GC allocation --- */ void testIndex(int[int] aa) { aa[1] = 0; int n = aa[1]; } ./ldc-1.42.0-src/tests/dmd/compilable/test23166.d0000644000175000017500000000061215205374124017751 0ustar fabiofabio// REQUIRED_ARGS: -inline // https://issues.dlang.org/show_bug.cgi?id=23166 // seg fault with -inline bool __equals(scope const char[] lhs, scope const char[] rhs) { if (lhs.length != rhs.length) return false; { import core.stdc.string : memcmp; return lhs.length == 0; } return true; } int test(string type) { return __equals(type, "as-is"); } ./ldc-1.42.0-src/tests/dmd/compilable/test21504b.d0000644000175000017500000000063215205374124020107 0ustar fabiofabio// https://github.com/dlang/dmd/issues/21504 // Test case where `@safe` triggers attribute inference of all nested // declarations, and the NOGCVisitor for `new` expressions encounters a self // referencing GC action. void test21504() @nogc @safe { static struct Nest { this(int i) { static assert(__traits(compiles, new Nest(i))); } } auto s = Nest(1); } ./ldc-1.42.0-src/tests/dmd/compilable/test22884.c0000644000175000017500000000043415205374124017760 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22884 int printf(const char*, ...); typedef void (*funcptr)(void); funcptr a = printf; funcptr b = (void(*)())printf; funcptr c = (funcptr)printf; funcptr d = &printf; funcptr foo(void) { funcptr f = (funcptr)printf; return f; } ./ldc-1.42.0-src/tests/dmd/compilable/test21802.d0000644000175000017500000000103015205374124017737 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21802 struct A { auto opAssign(lazy void foo) { foo(); } auto opOpAssign(string op)(lazy void foo) { foo(); } } class C { auto opAssign(lazy void foo) { foo(); } auto opOpAssign(string op)(lazy void foo) { foo(); } } void bar(int x) { } void main () { A a; a ~= bar (1); // OK a = bar (1); // Error: expression bar(1) is void and has no value C c = new C; c ~= bar(1); c = bar(1); } ./ldc-1.42.0-src/tests/dmd/compilable/testheaderudamodule.d0000644000175000017500000000105215205374124022417 0ustar fabiofabio/* REQUIRED_ARGS: -o- -H -Hf${RESULTS_DIR}/compilable/testheaderudamodule.di PERMUTE_ARGS: OUTPUT_FILES: ${RESULTS_DIR}/compilable/testheaderudamodule.di TEST_OUTPUT: --- === ${RESULTS_DIR}/compilable/testheaderudamodule.di // D import file generated from 'compilable/testheaderudamodule.d' @(1, UDA(2)) module testheaderudamodule; struct UDA { int a; } void main(); void foo(@(1) int bar, @UDA(2) string bebe); --- */ @(1, UDA(2)) module testheaderudamodule; struct UDA { int a; } void main() {} void foo(@(1) int bar, @UDA(2) string bebe) {} ./ldc-1.42.0-src/tests/dmd/compilable/test16031.d0000644000175000017500000000124015205374124017740 0ustar fabiofabio// REQUIRED_ARGS: -fPIC -lib // PERMUTE_ARGS: // DISABLED: win32 win64 extern void throwing(); void foo() { // create plenty of symbols, so that the catch references get a high symbol index static int a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, d0, d1, d2, d3, d4, d5, d6, d7, d8, d9; try { throwing(); } catch (Exception) { } } void bar() { try { throwing(); } // symbol index for DW.ref._D9Exception7__ClassZ // gets reused for another object and is out of bounds catch (Exception) { } } ./ldc-1.42.0-src/tests/dmd/compilable/test6089.d0000644000175000017500000000007315205374124017677 0ustar fabiofabio// PERMUTE_ARGS: void main() { extern int[1][1] foo; } ./ldc-1.42.0-src/tests/dmd/compilable/test18115.d0000644000175000017500000000026515205374124017753 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=18115 int test() { if (test.stringof.length > 6 && test.stringof[$-7..$] == "1234567") {} return 0; } enum a = test(); ./ldc-1.42.0-src/tests/dmd/compilable/test12807.d0000644000175000017500000000031715205374124017753 0ustar fabiofabiovoid foo(T)(ref T t) { } struct S { int impure() {assert(0);} alias impure this; } void main() pure { S s; foo(s); s.foo(); // triggering alias this violates purity, but ufcs matches } ./ldc-1.42.0-src/tests/dmd/compilable/test13902.d0000644000175000017500000000014015205374124017742 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: void foo() { int a; int* bar() { return &a; } } ./ldc-1.42.0-src/tests/dmd/compilable/udamodule1.d0000644000175000017500000000043115205374124020427 0ustar fabiofabio// REQUIRED_ARGS: -verrors=simple // PERMUTE_ARGS: // EXTRA_FILES: imports/udamodule1.d /* TEST_OUTPUT: --- compilable/udamodule1.d(10): Deprecation: module `imports.udamodule1` is deprecated - This module will be removed. --- */ import imports.udamodule1; void main() { foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/uda_lambda.d0000644000175000017500000000007215205374124020441 0ustar fabiofabioenum UDA; int fun() @UDA => 7; static assert(fun() == 7); ./ldc-1.42.0-src/tests/dmd/compilable/test4090.d0000644000175000017500000002347415205374124017677 0ustar fabiofabiovoid test4090a() { // for the mutable elements { int[] arr = [1,2,3]; // inference + qualifier foreach ( x; arr) static assert(is(typeof(x) == int)); foreach ( const x; arr) static assert(is(typeof(x) == const int)); foreach (immutable x; arr) static assert(is(typeof(x) == immutable int)); // inference + qualifier + ref foreach ( ref x; arr) static assert(is(typeof(x) == int)); foreach ( const ref x; arr) static assert(is(typeof(x) == const int)); // with exact type + qualifier foreach ( int x; arr) static assert(is(typeof(x) == int)); foreach ( const int x; arr) static assert(is(typeof(x) == const int)); foreach (immutable int x; arr) static assert(is(typeof(x) == immutable int)); // with exact type + qualifier + ref foreach ( ref int x; arr) static assert(is(typeof(x) == int)); foreach ( const ref int x; arr) static assert(is(typeof(x) == const int)); // convertible type + qualifier foreach ( double x; arr) static assert(is(typeof(x) == double)); foreach ( const double x; arr) static assert(is(typeof(x) == const double)); foreach (immutable double x; arr) static assert(is(typeof(x) == immutable double)); } // for the immutable elements { immutable(int)[] iarr = [1,2,3]; // inference + qualifier foreach ( x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration foreach ( const x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration foreach (immutable x; iarr) static assert(is(typeof(x) == immutable int)); // inference + qualifier + ref foreach ( ref x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration foreach ( const ref x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration foreach (immutable ref x; iarr) static assert(is(typeof(x) == immutable int)); // with exact type + qualifier foreach ( int x; iarr) static assert(is(typeof(x) == int)); foreach ( const int x; iarr) static assert(is(typeof(x) == const int)); foreach (immutable int x; iarr) static assert(is(typeof(x) == immutable int)); // with exact type + qualifier + ref static assert(!__traits(compiles, { foreach ( ref int x; iarr) {} })); foreach ( const ref int x; iarr) static assert(is(typeof(x) == const int)); foreach (immutable ref int x; iarr) static assert(is(typeof(x) == immutable int)); // convertible type + qualifier foreach ( double x; iarr) static assert(is(typeof(x) == double)); foreach ( const double x; iarr) static assert(is(typeof(x) == const double)); foreach (immutable double x; iarr) static assert(is(typeof(x) == immutable double)); // convertible type + qualifier + ref static assert(!__traits(compiles, { foreach (ref double x; iarr) {} })); static assert(!__traits(compiles, { foreach (const ref double x; iarr) {} })); static assert(!__traits(compiles, { foreach (immutable ref double x; iarr) {} })); } } void test4090b() { // for the key { int[] arr = [1,2,3]; // inference + qualifier foreach ( i, x; arr) static assert(is(typeof(i) == size_t)); foreach ( const i, x; arr) static assert(is(typeof(i) == const size_t)); foreach (immutable i, x; arr) static assert(is(typeof(i) == immutable size_t)); // inference + qualifier + ref foreach ( ref i, x; arr) static assert(is(typeof(i) == size_t)); foreach ( const ref i, x; arr) static assert(is(typeof(i) == const size_t)); static assert(!__traits(compiles, { foreach (immutable ref i, x; arr) {} })); // with exact type + qualifier foreach ( size_t i, x; arr) static assert(is(typeof(i) == size_t)); foreach ( const size_t i, x; arr) static assert(is(typeof(i) == const size_t)); foreach (immutable size_t i, x; arr) static assert(is(typeof(i) == immutable size_t)); // with exact type + qualifier + ref foreach ( ref size_t i, x; arr) static assert(is(typeof(i) == size_t)); foreach ( const ref size_t i, x; arr) static assert(is(typeof(i) == const size_t)); static assert(!__traits(compiles, { foreach (immutable ref size_t i, x; arr) {} })); } // for the mutable elements { int[] arr = [1,2,3]; // inference + qualifier foreach (i, x; arr) static assert(is(typeof(x) == int)); foreach (i, const x; arr) static assert(is(typeof(x) == const int)); foreach (i, immutable x; arr) static assert(is(typeof(x) == immutable int)); // inference + qualifier + ref foreach (i, ref x; arr) static assert(is(typeof(x) == int)); foreach (i, const ref x; arr) static assert(is(typeof(x) == const int)); static assert(!__traits(compiles, { foreach (i, immutable ref x; arr) {} })); // with exact type + qualifier foreach (i, int x; arr) static assert(is(typeof(x) == int)); foreach (i, const int x; arr) static assert(is(typeof(x) == const int)); foreach (i, immutable int x; arr) static assert(is(typeof(x) == immutable int)); // with exact type + qualifier + ref foreach (i, ref int x; arr) static assert(is(typeof(x) == int)); foreach (i, const ref int x; arr) static assert(is(typeof(x) == const int)); static assert(!__traits(compiles, { foreach (i, immutable ref int x; arr) {} })); // convertible type + qualifier foreach (i, double x; arr) static assert(is(typeof(x) == double)); foreach (i, const double x; arr) static assert(is(typeof(x) == const double)); foreach (i, immutable double x; arr) static assert(is(typeof(x) == immutable double)); // convertible type + qualifier + ref static assert(!__traits(compiles, { foreach (i, ref double x; arr) {} })); static assert(!__traits(compiles, { foreach (i, const ref double x; arr) {} })); static assert(!__traits(compiles, { foreach (i, immutable ref double x; arr) {} })); } // for the immutable elements { immutable(int)[] iarr = [1,2,3]; // inference + qualifier foreach (i, x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration foreach (i, const x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration foreach (i, immutable x; iarr) static assert(is(typeof(x) == immutable int)); // inference + qualifier + ref foreach (i, ref x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration foreach (i, const ref x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration foreach (i, immutable ref x; iarr) static assert(is(typeof(x) == immutable int)); // with exact type + qualifier foreach (i, int x; iarr) static assert(is(typeof(x) == int)); foreach (i, const int x; iarr) static assert(is(typeof(x) == const int)); foreach (i, immutable int x; iarr) static assert(is(typeof(x) == immutable int)); // with exact type + qualifier + ref static assert(!__traits(compiles, { foreach (i, ref int x; iarr) {} })); foreach (i, const ref int x; iarr) static assert(is(typeof(x) == const int)); foreach (i, immutable ref int x; iarr) static assert(is(typeof(x) == immutable int)); // convertible type + qualifier foreach (i , double x; iarr) static assert(is(typeof(x) == double)); foreach (i, const double x; iarr) static assert(is(typeof(x) == const double)); foreach (i, immutable double x; iarr) static assert(is(typeof(x) == immutable double)); // convertible type + qualifier + ref static assert(!__traits(compiles, { foreach (i, ref double x; iarr) {} })); static assert(!__traits(compiles, { foreach (i, const ref double x; iarr) {} })); static assert(!__traits(compiles, { foreach (i, immutable ref double x; iarr) {} })); } } void test4090c() { foreach ( x; 1..11) static assert(is(typeof(x) == int)); foreach ( const x; 1..11) static assert(is(typeof(x) == const int)); foreach (immutable x; 1..11) static assert(is(typeof(x) == immutable int)); foreach ( int x; 1..11) static assert(is(typeof(x) == int)); foreach ( const int x; 1..11) static assert(is(typeof(x) == const int)); foreach (immutable int x; 1..11) static assert(is(typeof(x) == immutable int)); foreach ( ref x; 1..11) static assert(is(typeof(x) == int)); foreach ( const ref x; 1..11) static assert(is(typeof(x) == const int)); static assert(!__traits(compiles, { foreach (immutable ref x; 1..11) {} })); foreach ( double x; 1..11) static assert(is(typeof(x) == double)); foreach ( const double x; 1..11) static assert(is(typeof(x) == const double)); foreach (immutable double x; 1..11) static assert(is(typeof(x) == immutable double)); foreach ( ref double x; 1..11) static assert(is(typeof(x) == double)); foreach ( const ref double x; 1..11) static assert(is(typeof(x) == const double)); static assert(!__traits(compiles, { foreach (immutable ref double x; 1..11) {} })); } ./ldc-1.42.0-src/tests/dmd/compilable/ice13071.d0000644000175000017500000000021115205374124017517 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: T foo(T)() { __gshared int[] bar = []; return T.init; } void main() { foo!char(); } ./ldc-1.42.0-src/tests/dmd/compilable/test24066.d0000644000175000017500000000021115205374124017744 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24066 /* TEST_OUTPUT: --- false --- */ class C; pragma(msg, __traits(isAbstractClass, C)); ./ldc-1.42.0-src/tests/dmd/compilable/test8543.d0000644000175000017500000000137015205374124017675 0ustar fabiofabio static if (__traits(compiles, __vector(float[4]))) { struct vfloat { public: __vector(float[4]) f32; this(float X) nothrow { f32.ptr[0] = X; f32.ptr[1] = X; f32.ptr[2] = X; f32.ptr[3] = X; } this(float X, float Y, float Z, float W) nothrow { f32.array[0] = X; f32.array[1] = Y; f32.array[2] = Z; f32.array[3] = W; } this(float[4] values) nothrow { f32.array = values; } } immutable GvfGlobal_ThreeA = vfloat(3.0f); immutable GvfGlobal_ThreeB = vfloat(3.0f, 3.0f, 3.0f, 3.0f); immutable GvfGlobal_ThreeC = vfloat([3.0f, 3.0f, 3.0f, 3.0f]); } ./ldc-1.42.0-src/tests/dmd/compilable/test21359.sh0000755000175000017500000000122615205374124020147 0ustar fabiofabio#!/usr/bin/env bash objfile="${OUTPUT_BASE}${OBJ}" $DMD -c -m${MODEL} -allinst -of${objfile} ${EXTRA_FILES}/${TEST_NAME}a.d -I${EXTRA_FILES} # This test is brittle and might break in the future. # For now, ensure a specific AA TypeInfo isn't defined multiple times, as happened with DMD v2.111.0. # LDC: different TypeInfo emission strategy, test doesn't apply exit 0 mangled_sym='_D14TypeInfo_HiAya6__initZ' num_typeinfo_syms=$(nm --defined-only ${objfile} | grep -F ${mangled_sym} | wc -l) if [[ "${num_typeinfo_syms}" -ne 1 ]]; then echo "Expected 1 '${mangled_sym}' symbol definition but got: ${num_typeinfo_syms}" exit 1 fi rm_retry ${objfile} ./ldc-1.42.0-src/tests/dmd/compilable/deprecated_override.d0000644000175000017500000000434015205374124022371 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22668 // REQUIRED_ARGS: -verrors=simple // Overrides with same deprecated'ness are allowed class SameParent { deprecated void foo() {} void foo(int) {} void bar(int) {} deprecated void bar() {} } class SameChild : SameParent { deprecated override void foo() {} override void foo(int) {} override void bar(int) {} deprecated override void bar() {} } /** Only the parent declaration is deprecated TEST_OUTPUT: ---- compilable/deprecated_override.d(44): Deprecation: `deprecated_override.IntroducingChild.foo` is overriding the deprecated method `deprecated_override.IntroducingParent.foo` compilable/deprecated_override.d(48): Deprecation: `deprecated_override.IntroducingChild.bar` is overriding the deprecated method `deprecated_override.IntroducingParent.bar` ---- **/ class IntroducingParent { deprecated void foo() {} void foo(int) {} void bar(int) {} deprecated void bar() {} } class IntroducingChild : IntroducingParent { override void foo() {} override void foo(int) {} override void bar(int) {} override void bar() {} } // Unrelated to this path but should this error as well? class IntroducingGrandchild : IntroducingChild { override void foo() {} override void foo(int) {} override void bar(int) {} override void bar() {} } /** Only the overriding declaration is deprecated TEST_OUTPUT: ---- compilable/deprecated_override.d(83): Deprecation: `deprecated_override.OverrideChild.foo` cannot be marked as `deprecated` because it is overriding a function in the base class compilable/deprecated_override.d(87): Deprecation: `deprecated_override.OverrideChild.bar` cannot be marked as `deprecated` because it is overriding a function in the base class ---- **/ class OverrideParent { void foo() {} void foo(int) {} void bar(int) {} void bar() {} } class OverrideChild : OverrideParent { deprecated override void foo() {} override void foo(int) {} override void bar(int) {} deprecated override void bar() {} } class OverrideGrandChild : OverrideChild { deprecated override void foo() {} override void foo(int) {} override void bar(int) {} deprecated override void bar() {} } ./ldc-1.42.0-src/tests/dmd/compilable/test22885.c0000644000175000017500000000025015205374124017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22885 typedef int T; void test() { typedef T* T; // should declare a new T that is an int* int i; T p = &i; } ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_mangling.d0000644000175000017500000000360515205374124021207 0ustar fabiofabio/++ REQUIRED_ARGS: -HC=verbose TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler v$n$ #pragma once #include #include #include #include extern "C" int32_t freeC(); // Ignored function dtoh_mangling.bar because C++ doesn't support explicit mangling struct Data final { // Ignored function dtoh_mangling.Data.foo because of linkage // Ignored function dtoh_mangling.Data.bar because C++ doesn't support explicit mangling Data() { } }; extern void accept(Data data); extern "C" void hasDefault(int32_t i = freeC()); extern "C" void hasDefaultMember(int32_t i = memberC()); extern "C" int32_t someVarC; // Ignored variable dtoh_mangling.var2 because C++ doesn't support explicit mangling struct HasMangleMember final { int32_t someAttrC; int32_t someAttrCpp; void hasDefaultVar(int32_t i = someAttrC); HasMangleMember() : someAttrC(), someAttrCpp() { } HasMangleMember(int32_t someAttrC, int32_t someAttrCpp = 0) : someAttrC(someAttrC), someAttrCpp(someAttrCpp) {} }; extern "C" void hasDefaultVar(int32_t i = someVarC); --- ++/ extern(C): pragma(mangle, "freeC") int foo() { return 0; } pragma(mangle, "freeCpp") extern (C++) void bar() {} pragma(mangle, "Aggregate") struct Data { pragma(mangle, "memberC") static int foo() { return 0; } pragma(mangle, "memberCpp") extern (C++) void bar() {} } extern(C++) void accept(Data data) {} void hasDefault(int i = foo()) {} void hasDefaultMember(int i = Data.foo()) {} pragma(mangle, "someVarC") __gshared int var; pragma(mangle, "someVarCpp") extern(C++) __gshared int var2; struct HasMangleMember { pragma(mangle, "someAttrC") int var; pragma(mangle, "someAttrCpp") extern(C++) int var2; extern(C++) void hasDefaultVar(int i = var) {} } void hasDefaultVar(int i = var) {} ./ldc-1.42.0-src/tests/dmd/compilable/issue20339.d0000644000175000017500000000074515205374124020130 0ustar fabiofabio/* TEST_OUTPUT: --- 4 false false --- */ // https://issues.dlang.org/show_bug.cgi?id=20339 struct S { pragma(msg, cast(int)S.sizeof); this(this){} ~this(){} int f; } static assert(__traits(isPOD, S) == false); pragma(msg, __traits(isPOD, T)); struct T { this(this){} ~this(){} } static assert(__traits(isPOD, T) == false); struct U { pragma(msg, __traits(isPOD, U)); this(this){} ~this(){} } static assert(__traits(isPOD, U) == false); ./ldc-1.42.0-src/tests/dmd/compilable/test12567c.d0000644000175000017500000000043715205374124020124 0ustar fabiofabio// REQUIRED_ARGS: -verrors=simple // EXTRA_FILES: imports/a12567.d // PERMUTE_ARGS: /* TEST_OUTPUT: --- compilable/test12567c.d(10): Deprecation: module `imports.a12567` is deprecated - This module will be removed in future release. --- */ import imports.a12567; void main() { foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc8739.d0000644000175000017500000000044415205374124017637 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc8739; /// void delegate(int a) dg; /// void delegate(int b) dg2; /// void delegate(int c)[] dg3; /// void delegate(int d)* dg4; void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/emptygenmain.d0000644000175000017500000000005315205374124021064 0ustar fabiofabio// REQUIRED_ARGS: -main -c void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/test16709.d0000644000175000017500000000035115205374124017756 0ustar fabiofabio// EXTRA_FILES: imports/test16709a.d imports/test16709b.d imports/test16709c.d imports/test16709d.d // https://issues.dlang.org/show_bug.cgi?id=16709 import imports.test16709a; import imports.test16709b; void test(){ 1.to!int; } ./ldc-1.42.0-src/tests/dmd/compilable/test7399.d0000644000175000017500000000033715205374124017707 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=7399 static assert(!__traits(compiles, { import non.existing.file; })); // https://issues.dlang.org/show_bug.cgi?id=7400 static assert(!is(typeof({import non_existing_file;}))); ./ldc-1.42.0-src/tests/dmd/compilable/test23490.d0000644000175000017500000000024515205374124017753 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23490 // EXTRA_FILES: imports/test23490frop.d imports/test23490pop.d imports/test23490zoo.d import imports.test23490pop; ./ldc-1.42.0-src/tests/dmd/compilable/fix21585.d0000644000175000017500000000120115205374124017556 0ustar fabiofabio/* 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*)); ./ldc-1.42.0-src/tests/dmd/compilable/test11656.d0000644000175000017500000000025615205374124017756 0ustar fabiofabio static if (__traits(compiles, __vector(float[4]))) { struct Foo { __vector(float[4]) x; } static assert(Foo.x.offsetof == 0); static assert(Foo.x.stringof == "x"); } ./ldc-1.42.0-src/tests/dmd/compilable/test21271.c0000644000175000017500000000052015205374124017741 0ustar fabiofabio// https://github.com/dlang/dmd/issues/21271 #define PUSH __pragma(pack(push)) #define PACK __pragma(pack(1)) #define POP __pragma(pack(pop)) PUSH PACK struct S21271_1 { int x; }; _Static_assert(_Alignof(struct S21271_1)==1, "1"); POP struct S21271_2 { int x; }; _Static_assert(_Alignof(struct S21271_2)==_Alignof(int), "2"); ./ldc-1.42.0-src/tests/dmd/compilable/ddoc9497d.d0000644000175000017500000000036615205374124020010 0ustar fabiofabio// EXTRA_SOURCES: extra-files/ddoc9497d.ddoc // PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /** foo function. Args: $(XYZ arg1, arg2) */ void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/test23047.d0000644000175000017500000000033215205374124017746 0ustar fabiofabio/* REQUIRED_ARGS: -defaultlib= -c -O */ // https://issues.dlang.org/show_bug.cgi?id=23047 version(D_SIMD): alias long2 = __vector(long[2]); long2 _mm_srl_epi64 () { long2 r = void; r[0] = 1; return r; } ./ldc-1.42.0-src/tests/dmd/compilable/test3775.d0000644000175000017500000000023115205374124017672 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=3775 struct Bug3775 { static int byLine()() { return 1; } } static assert(cast(int)Bug3775.byLine == 1); ./ldc-1.42.0-src/tests/dmd/compilable/test24069.i0000644000175000017500000000045015205374124017761 0ustar fabiofabio // https://issues.dlang.org/show_bug.cgi?id=24069 typedef void (*fp_t)(int*); float parse1(void f(int*)); // float (void (*)(int *)) float parse2(void (int*)); typedef int Dat; float parse3(void (Dat*)); void test(float i) { fp_t x; parse1(x); parse2(x); parse3(x); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc10869.d0000644000175000017500000000061715205374124017716 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc10869; /// class C { const { /// void c1Foo() const { } /// void i1Foo() immutable { } } immutable { /// void c2Foo() const { } /// void i2Foo() immutable { } } } ./ldc-1.42.0-src/tests/dmd/compilable/test23626.d0000644000175000017500000000026015205374124017751 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23626 // EXTRA_SOURCES: extra-files/test23626a.d extra-files/test23626b.d module test23626; struct StaticHashTable(V) { V v; } ./ldc-1.42.0-src/tests/dmd/compilable/test16685.d0000644000175000017500000000024315205374124017761 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16685 struct Id { ushort value; } enum Id x = Id(5); struct S(ushort A) {} alias CannotCreateFromValue = S!(x.value); ./ldc-1.42.0-src/tests/dmd/compilable/json2.d0000644000175000017500000000042415205374124017424 0ustar fabiofabio/* PERMUTE_ARGS: REQUIRED_ARGS: -d -o- -Xf=${RESULTS_DIR}/compilable/json2.out -Xi=compilerInfo -Xi=buildInfo -Xi=modules -Xi=semantics OUTPUT_FILES: ${RESULTS_DIR}/compilable/json2.out TRANSFORM_OUTPUT: sanitize_json TEST_OUTPUT_FILE: extra-files/json2.json */ import json; ./ldc-1.42.0-src/tests/dmd/compilable/test16540.d0000644000175000017500000000040515205374124017747 0ustar fabiofabio/* REQUIRED_ARGS: PERMUTE_ARGS: */ // https://issues.dlang.org/show_bug.cgi?id=16540 @safe: void foo(scope lazy int* f) @nogc { } void bar1() @nogc { foo(new int(5)); // It does not understand that the new here is wrapped in an invisible delegate } ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_662.d0000644000175000017500000000004015205374124021064 0ustar fabiofabioimport imports.ldc_github_662b; ./ldc-1.42.0-src/tests/dmd/compilable/test22757.c0000644000175000017500000000027015205374124017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22757 typedef struct S S; struct T { int x; }; struct S { struct T *pChunk; }; void foo(struct S pS){ void *p = &pS.pChunk; } ./ldc-1.42.0-src/tests/dmd/compilable/makedeps_lib.d0000644000175000017500000000107015205374124021006 0ustar fabiofabio/** DISABLED: win REQUIRED_ARGS: -makedeps -Jcompilable/extra-files -lib LINK: TRANSFORM_OUTPUT: remove_lines(druntime) TEST_OUTPUT: --- $r:.*makedeps_lib_$0.$?:windows=lib|a$: \ $p:makedeps_lib.d$ \ $p:imports/makedeps_a.d$ \ $p:makedeps-import.txt$ --- **/ // Disabling on windows because default naming of -lib seems broken (names to .exe) module makedeps_lib; // Test import statement import imports.makedeps_a; // Test import expression enum text = import("makedeps-import.txt"); static assert(text == "Imported text\x0a"); void func() { a_func(); } ./ldc-1.42.0-src/tests/dmd/compilable/testheader12567b.d0000644000175000017500000000062315205374124021271 0ustar fabiofabio/* REQUIRED_ARGS: -o- -H -Hf${RESULTS_DIR}/compilable/testheader12567b.di PERMUTE_ARGS: OUTPUT_FILES: ${RESULTS_DIR}/compilable/testheader12567b.di TEST_OUTPUT: --- === ${RESULTS_DIR}/compilable/testheader12567b.di // D import file generated from 'compilable/testheader12567b.d' deprecated("message") module header12567b; void main(); --- */ deprecated("message") module header12567b; void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test19268.d0000644000175000017500000000015715205374124017765 0ustar fabiofabio/* REQUIRED_ARGS: -betterC */ // https://issues.dlang.org/show_bug.cgi?id=19268 mixin(`void foo(){}`.idup); ./ldc-1.42.0-src/tests/dmd/compilable/ice15760.d0000644000175000017500000000021315205374124017530 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_SOURCES: imports/a15760.d module ice15760; import imports.a15760 : Foo; struct Bar { __gshared Foo foo; } ./ldc-1.42.0-src/tests/dmd/compilable/test3004.d0000644000175000017500000000107615205374124017663 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=3004 /* REQUIRED_ARGS: -ignore -v LDC: additionally exclude 'GC stats' line TRANSFORM_OUTPUT: remove_lines("^(predefs|binary|version|config|DFLAG|parse|inline|.*_d_newarrayU|import|\(imported|semantic|entry|library|function object|function core|GC stats|\s*$)") TEST_OUTPUT: --- pragma GNU_attribute (__error) pragma GNU_attribute (__error) code test3004 --- */ extern(C) int printf(char*, ...); pragma(GNU_attribute, flatten) void test() { printf("Hello GNU world!\n".dup.ptr); } pragma(GNU_attribute, flatten); ./ldc-1.42.0-src/tests/dmd/compilable/b18242.d0000644000175000017500000000056315205374124017217 0ustar fabiofabio// REQUIRED_ARGS: -c // PERMUTE_ARGS: // LDC depends on proper TypeInfo declarations (fields) // DISABLED: LDC module object; class Object { } class TypeInfo { } class TypeInfo_Class : TypeInfo { version(D_LP64) { ubyte[136+16] _x; } else { ubyte[68+16] _x; } } class Throwable { } int _d_run_main() { try { } catch(Throwable e) { return 1; } return 0; } ./ldc-1.42.0-src/tests/dmd/compilable/test10028.d0000644000175000017500000000021215205374124017736 0ustar fabiofabioenum E:char[4]{ str = "abcd" } enum x = { int[char[4]] aa; aa[E.str] = 1; foreach(key,val; aa) {} return aa["abcd"]; }(); ./ldc-1.42.0-src/tests/dmd/compilable/test10520.d0000644000175000017500000000043415205374124017741 0ustar fabiofabio// REQUIRED_ARGS: -debug -profile // https://issues.dlang.org/show_bug.cgi?id=10520 // [profile+nothrow] Building with profiler results in "is not nothrow" error on some contracts void f() { } void g()() in { f(); } // OK <- Error: 'main.f' is not nothrow do { } alias gi = g!(); ./ldc-1.42.0-src/tests/dmd/compilable/ice20415.d0000644000175000017500000000020515205374124017522 0ustar fabiofabio// REQUIRED_ARGS: -O void t() { auto a = A(false ? B().p : null); } struct A { void* p; } struct B { void* p; ~this() {} } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc8271.d0000644000175000017500000000037615205374124017632 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc8271; /** $(まくろ) Macros: まくろ = $(マクロ) マクロ = Macro */ void ddoc8271() { } ./ldc-1.42.0-src/tests/dmd/compilable/test23533.d0000644000175000017500000000023015205374124017743 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23533 // REQUIRED_ARGS: -preview=nosharedaccess enum E { a, b } void main() { E x = E.b; E y = E.max; } ./ldc-1.42.0-src/tests/dmd/compilable/b16244.d0000644000175000017500000000015215205374124017211 0ustar fabiofabiostruct Foo { void bar()(typeof(cast()this) x) { } } void main() { Foo x; x.bar(x); } ./ldc-1.42.0-src/tests/dmd/compilable/test17351.d0000644000175000017500000000132115205374124017746 0ustar fabiofabio// PERMUTE_ARGS: -preview=in bool fun(S)(ref S[3] a) { assert(a == [42, 84, 169]); return true; } bool fun2(S)(ref S a) { return true; } void main() { static const int[3] sa = [42, 84, 169]; static const double sa2 = 42.42; static assert(fun(sa)); static assert(fun2(sa2)); } int f1(ref const int p) { return p; } int f2(ref const int[2] p) { return p[0] + p[1]; } void test2() { static immutable int[2] P = [ 0, 1 ]; static assert(f2(P) == 1); immutable BigInt a, b; static assert(glob1.twice == b.twice); static assert(a.twice == b.twice); } struct BigInt { int[64] big; } BigInt twice (in BigInt v) @safe pure nothrow @nogc { return v; } immutable BigInt glob1 = BigInt.init; ./ldc-1.42.0-src/tests/dmd/compilable/test313a.d0000644000175000017500000000111015205374124017731 0ustar fabiofabio/* REQUIRED_ARGS: -de EXTRA_FILES: imports/a313.d imports/a313templatemixin1.d imports/a313templatemixin2.d imports/b313.d imports/pkg313/c313.d */ module test313; import imports.a313; void test1() { import imports.b313; imports.b313.bug(); } void test2() { cstdio.printf(""); } import imports.pkg313.c313; void test3() { imports.pkg313.c313.bug(); } template imp() { static import imports.a313templatemixin1; import imports.a313templatemixin2; } mixin imp!(); void test4() { imports.a313templatemixin1.bug(); imports.a313templatemixin2.bug(); } ./ldc-1.42.0-src/tests/dmd/compilable/test16635.d0000644000175000017500000000174515205374124017764 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16635 struct A { alias get this; const(A) get() const { return A(); } } static assert(!__traits(compiles, A() + A())); // Original test (covers another path) struct Vector2 { float x; float y; alias byRef this; ref const(Vector2) byRef() const { static Vector2 v; return v; } Vector2 opBinary(string op : "+")(ref const(Vector2) a) const { return Vector2(x + a.x, y + a.y); } } void test16635_1() { Vector2 a = Vector2(1, 2); Vector2 b = Vector2(3, 4); // this line causes application to run infinitely // Already fixed. It was https://issues.dlang.org/show_bug.cgi?id=16621 Vector2 c = a + b; // OK <- this line seg faults without the above line Vector2 d = a + Vector2(5, 6); } void test16635_2() { Vector2 a = Vector2(1, 2); Vector2 b = Vector2(3, 4); // just this line alone Vector2 d = a + Vector2(5, 6); } ./ldc-1.42.0-src/tests/dmd/compilable/test22886.c0000644000175000017500000000024515205374124017762 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22886 struct config *Configlist_add(int); struct config *Configlist_add(int) { return 0; } struct config { int dot; }; ./ldc-1.42.0-src/tests/dmd/compilable/ice15789.d0000644000175000017500000000107115205374124017546 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: struct InputRange {} auto md5OfA(T...)(T ) {} auto md5OfB(T...)(T ) {} template fqnSymA(alias T : X!A, alias X, A...) { template fqnTuple(B) { enum fqnTuple = 1; } enum fqnSymA = fqnTuple!A; } template fqnSymB(alias T : X!A, alias X, A...) { template fqnTuple(B) { enum fqnTuple = 1; } enum fqnSymB = fqnTuple!A; } void test1() // OK <- NG { md5OfA(InputRange()); auto n = fqnSymA!(md5OfA!InputRange); } void test2() // OK { auto n = fqnSymB!(md5OfB!InputRange); md5OfB(InputRange()); } ./ldc-1.42.0-src/tests/dmd/compilable/named_arguments_ifti.d0000644000175000017500000000144415205374124022560 0ustar fabiofabio// Basic out-of-order test int f0(T0, T1)(T0 t0, T1 t1) { static assert(is(T0 == int)); static assert(is(T1 == string)); return t0; } static assert(f0(t1: "a", t0: 10) == 10); // Default argument at beginning instead of end int f1(T0, T1)(T0 t0 = 20, T1 t1) { return t0; } static assert(f1(t1: "a") == 20); // Two default arguments int f2(T0, T1)(T0 t0 = 20, T1 t1, T2 t2 = 30) { return t2; } // Selecting overload based on name string f3(T)(T x) { return "x"; } string f3(T)(T y) { return "y"; } static assert(f3(x: 0) == "x"); static assert(f3(y: 0) == "y"); // Variadic tuple cut short by named argument int f4(T...)(T x, int y, int z) { assert(y == 30); assert(z == 50); return T.length; } static assert(f4(10, 10, 10, y: 30, z: 50) == 3); static assert(f4(10, 10, 30, z: 50) == 2); ./ldc-1.42.0-src/tests/dmd/compilable/test22388.d0000644000175000017500000000072515205374124017763 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22388 void setTimer(void delegate()) @system; void setTimer(void delegate() @safe) @safe; void setTimer2(void delegate() @safe) @safe; void setTimer2(void delegate()) @system; void main() @safe { setTimer(() => assert(false)); alias lambda = () => assert(false); setTimer(lambda); // Reversed order setTimer2(() => assert(false)); alias lambda2 = () => assert(false); setTimer2(lambda2); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc14.d0000644000175000017500000000637015205374124017455 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh alias void V; alias double* P; /// -1 struct Structure { public P variable; /// 0 V mNone(lazy P p) {} /// 1 pure nothrow V mPrefix(lazy P p) {} /// 2 V mSuffix(lazy P p) pure nothrow {} /// 3 // pure nothrow V mPrefixTemplate(T)(lazy P p, T[] t...) {} /// 4 V mSuffixTemplate(T)(lazy P p, T[] t...) pure nothrow {} /// 5 pure nothrow { V mScoped(lazy P p) {} /// 6 } pure nothrow auto mAutoPrefix(ref P p) { return p; } /// 7 // pure nothrow auto mAutoTemplatePrefix(alias T)(ref T t) { return p; } /// 8 auto mAutoTemplateSuffix(alias T)(ref T t) pure nothrow { return p; } /// 9 pure nothrow: V mColon(lazy P p) {} /// 10 } /// -1 class Class { public P variable; /// 0 V mNone(lazy P p) {} /// 1 pure nothrow V mPrefix(lazy P p) {} /// 2 V mSuffix(lazy P p) pure nothrow {} /// 3 // pure nothrow V mPrefixTemplate(T)(lazy P p, T[] t...) {} /// 4 V mSuffixTemplate(T)(lazy P p, T[] t...) pure nothrow {} /// 5 pure nothrow { V mScoped(lazy P p) {} /// 6 } pure nothrow auto mAutoPrefix(ref P p) { return p; } /// 7 // pure nothrow auto mAutoTemplatePrefix(alias T)(ref T t) { return p; } /// 8 auto mAutoTemplateSuffix(alias T)(ref T t) pure nothrow { return p; } /// 9 pure nothrow: V mColon(lazy P p) {} /// 10 } /+ /// -1 struct StructTemplate() { public P variable; /// 0 V mNone(lazy P p) {} /// 1 pure nothrow V mPrefix(lazy P p) {} /// 2 V mSuffix(lazy P p) pure nothrow {} /// 3 // pure nothrow V mPrefixTemplate(T)(lazy P p, T[] t...) {} /// 4 V mSuffixTemplate(T)(lazy P p, T[] t...) pure nothrow {} /// 5 pure nothrow { V mScoped(lazy P p) {} /// 6 } pure nothrow auto mAutoPrefix(ref P p) { return p; } /// 7 // pure nothrow auto mAutoTemplatePrefix(alias T)(ref T t) { return p; } /// 8 auto mAutoTemplateSuffix(alias T)(ref T t) pure nothrow { return p; } /// 9 pure nothrow: V mColon(lazy P p) {} /// 10 } /// -1 interface Interface { V mNone(lazy P p) ; /// 1 pure nothrow V mPrefix(lazy P p) ; /// 2 V mSuffix(lazy P p) pure nothrow ; /// 3 // pure nothrow V mPrefixTemplate(T)(lazy P p, T[] t...) ; /// 4 V mSuffixTemplate(T)(lazy P p, T[] t...) pure nothrow ; /// 5 pure nothrow { V mScoped(lazy P p) ; /// 6 } // pure nothrow auto mAutoTemplatePrefix(alias T)(ref T t) { return p; } /// 8 auto mAutoTemplateSuffix(alias T)(ref T t) pure nothrow { return p; } /// 9 pure nothrow: V mColon(lazy P p) ; /// 10 } +/ public P variable; /// 0 V mNone(lazy P p) {} /// 1 pure nothrow V mPrefix(lazy P p) {} /// 2 V mSuffix(lazy P p) pure nothrow {} /// 3 // pure nothrow V mPrefixTemplate(T)(lazy P p, T[] t...) {} /// 4 V mSuffixTemplate(T)(lazy P p, T[] t...) pure nothrow {} /// 5 pure nothrow { V mScoped(lazy P p) {} /// 6 } pure nothrow auto mAutoPrefix(ref P p) { return p; } /// 7 // pure nothrow auto mAutoTemplatePrefix(alias T)(ref T t) { return p; } /// 8 auto mAutoTemplateSuffix(alias T)(ref T t) pure nothrow { return p; } /// 9 pure nothrow: V mColon(lazy P p) {} /// 10 ./ldc-1.42.0-src/tests/dmd/compilable/bug20796.d0000644000175000017500000000014415205374124017555 0ustar fabiofabio// EXTRA_SOURCES: protection/issue20796/package.d // https://issues.dlang.org/show_bug.cgi?id=20796 ./ldc-1.42.0-src/tests/dmd/compilable/testimport12242.d0000644000175000017500000000162515205374124021202 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/imp12242a.d imports/imp12242a1.d imports/imp12242a2.d imports/imp12242b.d imports/imp12242b1.d imports/imp12242b2.d module testimport12242; import imports.imp12242a; // test // stripA == OverloadSet import imports.imp12242a1; // std.string // stripA == template import imports.imp12242b1; // std.string // stripB == template import imports.imp12242b; // test // stripB == OverloadSet void main() { static assert(stripA(" af ") == 1); static assert(" af ".stripA() == 1); // UFCS (1) static assert(" af ".stripA == 1); // UFCS (2) static assert(stripB(" af ") == 1); static assert(" af ".stripB() == 1); // UFCS (1) static assert(" af ".stripB == 1); // UFCS (2) static assert(foo!int == 1); static assert(foo!long == 2); static assert(foo!float == 3); static assert(foo!real == 4); } ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_419.d0000644000175000017500000000015015205374124021066 0ustar fabiofabioimport core.simd; static ubyte16 v = ['a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a']; ./ldc-1.42.0-src/tests/dmd/compilable/json20742.d0000644000175000017500000000205415205374124017742 0ustar fabiofabio/* REQUIRED_ARGS: -Xf- -o- -version=Showme PERMUTE_ARGS: TEST_OUTPUT: ---- [ { "kind" : "module", "file" : "compilable$?:windows=\\|/$json20742.d", "members" : [ { "name" : "X1", "kind" : "struct", "protection" : "private", "line" : 52, "char" : 13, "members" : [] }, { "name" : "Y2", "kind" : "struct", "protection" : "private", "line" : 59, "char" : 13, "members" : [] }, { "name" : "A1", "kind" : "struct", "protection" : "private", "line" : 62, "char" : 13, "members" : [] }, { "name" : "B2", "kind" : "struct", "protection" : "private", "line" : 69, "char" : 13, "members" : [] } ] } ] ---- https://issues.dlang.org/show_bug.cgi?id=20742 */ version(Showme) private struct X1 {} else private struct X2 {} version(Hideme) private struct Y1 {} else private struct Y2 {} static if (true) private struct A1 {} else private struct A2 {} static if (false) private struct B1 {} else private struct B2 {} ./ldc-1.42.0-src/tests/dmd/compilable/test20039.d0000644000175000017500000000042015205374124017742 0ustar fabiofabiovoid foo()() { } void bar(int) { } alias bug = foo; alias bug = bar; template Identity(T...) { } void main() { alias member1 = Identity!(__traits(getMember, mixin(__MODULE__), "bug")); alias member2 = Identity!(__traits(getMember, mixin(__MODULE__), "bug")); } ./ldc-1.42.0-src/tests/dmd/compilable/test7886.d0000644000175000017500000000017115205374124017704 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=7886 struct A { static assert (__traits(derivedMembers, A).length == 0); } ./ldc-1.42.0-src/tests/dmd/compilable/test22808.c0000644000175000017500000000036315205374124017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22808 typedef int(*cmp)(int, int); int icmp(int a, int b); cmp getcmp(void){ cmp c; c = icmp; c = &icmp; if(0) return c; if(0) return &icmp; return icmp; } ./ldc-1.42.0-src/tests/dmd/compilable/test15711.d0000644000175000017500000000124415205374124017750 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=15711 struct Quu { string val; } string[] result = foo!(0, [Quu(['z']), Quu("")]); template foo(size_t i, Quu[] data, string[] results = []) { static if (i < data.length) { enum def = data[i]; enum foo = foo!(i+1, data, results ~ def.val); } else { enum foo = results; } } // Run-time version already works string[] result_rt = foo_rt(0, [Quu(['z']), Quu("")]); string[] foo_rt(size_t i, Quu[] data, string[] results = []) { if (i < data.length) { auto def = data[i]; return foo_rt(i+1, data, results ~ def.val); } else { return results; } } ./ldc-1.42.0-src/tests/dmd/compilable/test8513.d0000644000175000017500000000117115205374124017671 0ustar fabiofabiointerface I_Foo { void i_outer(); } class C_Foo { void c_outer() { } } class Bar { interface I_Foo { void i_inner(); } class C_Foo { void c_inner() { } } class Impl1 : C_Foo, I_Foo { override void i_inner() { } override void c_inner() { } } class Impl2 : C_Foo, .I_Foo { override void i_outer() { } override void c_inner() { } } class Impl3 : .C_Foo, I_Foo { override void i_inner() { } override void c_outer() { } } class Impl4 : .C_Foo, .I_Foo { override void i_outer() { } override void c_outer() { } } } ./ldc-1.42.0-src/tests/dmd/compilable/test15802.d0000644000175000017500000000017615205374124017754 0ustar fabiofabioextern(C++) { template Foo(T) { static int boo(); } } void main() { string s = Foo!(int).boo.mangleof; } ./ldc-1.42.0-src/tests/dmd/compilable/test21299b.d0000644000175000017500000000023515205374124020121 0ustar fabiofabio// EXTRA_SOURCES: imports/test21299/mtype.d imports/test21299/func.d imports/test21299/rootstringtable.d // REQUIRED_ARGS: -main // LINK: module test21299b; ./ldc-1.42.0-src/tests/dmd/compilable/copyCtor2.d0000644000175000017500000000027415205374124020260 0ustar fabiofabio/* This used to not be allowed * https://github.com/dlang/dmd/pull/20634 */ struct A { this (ref shared A a) immutable {} } struct B { A a; this(immutable B b) shared {} } ./ldc-1.42.0-src/tests/dmd/compilable/test1.d0000644000175000017500000000031515205374124017430 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/test1imp.d class File { import imports.test1imp; static char[] read(char[] name) { DWORD size; // DWORD is defined in test1imp return null; } } ./ldc-1.42.0-src/tests/dmd/compilable/issue12520.d0000644000175000017500000000122415205374124020112 0ustar fabiofabiomodule issue12520; // https://issues.dlang.org/show_bug.cgi?id=12520 alias Seq(T...) = T; static assert( Seq!() == Seq!() ); static assert( Seq!(1) == Seq!(1) ); static assert((Seq!() != Seq!()) == false); static assert((Seq!(1) != Seq!(1)) == false); static assert( Seq!() != Seq!(1) ); static assert( Seq!(1) != Seq!() ); static assert( Seq!(0) != Seq!(1) ); static assert( Seq!(0,1) != Seq!() ); static assert((Seq!() == Seq!(1)) == false); static assert((Seq!(1) == Seq!()) == false); static assert((Seq!(0) == Seq!(1)) == false); static assert((Seq!(0,1) == Seq!()) == false); ./ldc-1.42.0-src/tests/dmd/compilable/test19491.d0000644000175000017500000000020715205374124017757 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19491 class Foo { shared this(); } void test() { scope foo = new shared Foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/test18936.d0000644000175000017500000000104615205374124017764 0ustar fabiofabio// REQUIRED_ARGS: -fPIC -O -release -inline -m64 -betterC // DISABLED: win32 win64 // https://issues.dlang.org/show_bug.cgi?id=18936 // produces assert failure cgxmm.c line 684 import core.stdc.math; struct S { double re, im; static S sqrtcx(S* z) { S c; real x,y,w,r; { x = fabs(z.re); y = fabs(z.im); if (z.re >= 0) { c.im = (z.im >= 0) ? w : -w; c.re = z.im / (c.im + c.im); } } return c; } } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc_markdown_tables.d0000644000175000017500000000163015205374124022536 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // TEST_OUTPUT_FILE: extra-files/ddoc_markdown_tables.html // OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_tables.html /++ # Tables | Rounding mode | rndint(4.5) | rndint(5.5) | rndint(-4.5) | Notes | | ------------- | ----------: | ----------: | -----------: | ----- | | Round to nearest | 4 | 6 | -4 | Ties round to an even number | | Round down | 4 | 5 | -5 |   | | Round up | 5 | 6 | -4 |   | | Round to zero | 4 | 5 | -4 |   | this|that ----|---- cell|cell
sell | abc | def | | --- | --- | | bar | | *bar* | baz | boo | > | quote | > | ----- | > | table | * | list | | ---- | | table | | default | left | center | right | | --- | :-- | :--: | --: | Look Ma, a table without a body! | not | a | table | | -- | | wrong number of header columns | +/ module test.compilable.ddoc_markdown_tables; ./ldc-1.42.0-src/tests/dmd/compilable/needsmod.d0000644000175000017500000000024715205374124020172 0ustar fabiofabio// ARG_SETS: -i // ARG_SETS: -i=. // ARG_SETS: -i=imports // ARG_SETS: -i=imports.foofunc // PERMUTE_ARGS: // LINK: import imports.foofunc; void main() { foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/a3682.d0000644000175000017500000000057115205374124017137 0ustar fabiofabio// COMPILED_IMPORTS: imports/b3682.d // PERMUTE_ARGS: // https://issues.dlang.org/show_bug.cgi?id=3682 struct Tuple(Types...) { Tuple!(Types[0..1]) slice()() { Tuple!(Types[0..1]) x; return x; } void fail() { Tuple!(float, double, int) a; auto s = a.slice(); static assert(is(typeof(s) == Tuple!(float))); } } ./ldc-1.42.0-src/tests/dmd/compilable/must_use_assign.d0000644000175000017500000000012515205374124021577 0ustar fabiofabioimport core.attribute; @mustuse struct S {} void test() { S a, b; a = b; } ./ldc-1.42.0-src/tests/dmd/compilable/test21504a.d0000644000175000017500000000340615205374124020110 0ustar fabiofabio// https://github.com/dlang/dmd/issues/21504 // Test that: // 1. __traits(compiles) tests fail when violating an explicitly set attribute. // 2. __traits(compiles) tests pass when attribute is inferred (see functions // isPureBypassingInference, isSafeBypassingInference, isNogcBypassingInference). // 3. __traits(compiles) tests do not affect the result of attribute inference, // as the they are only evaluated at compile-time, not run-time. __gshared int testPure; auto testPure1() pure { return __traits(compiles, testPure = 1); } auto testPure2() { return __traits(compiles, testPure = 1); } static assert(!testPure1() && testPure2()); static assert(__traits(getFunctionAttributes, testPure1) == __traits(getFunctionAttributes, testPure2)); //////////////////////////// __gshared Exception testNothrow; auto testNothrow1() nothrow { return __traits(compiles, throw testNothrow); } auto testNothrow2() { return __traits(compiles, throw testNothrow); } static assert(!testNothrow1() && testNothrow2()); static assert(__traits(getFunctionAttributes, testNothrow1) == __traits(getFunctionAttributes, testNothrow2)); //////////////////////////// __gshared int* testSafe; auto testSafe1() @safe { return __traits(compiles, testSafe + 1); } auto testSafe2() { return __traits(compiles, testSafe + 1); } static assert(!testSafe1() && testSafe2()); static assert(__traits(getFunctionAttributes, testSafe1) == __traits(getFunctionAttributes, testSafe2)); //////////////////////////// auto testNogc1() @nogc { return __traits(compiles, [1, 2]); } auto testNogc2() { return __traits(compiles, [1, 2]); } static assert(!testNogc1() && testNogc2()); static assert(__traits(getFunctionAttributes, testNogc1) == __traits(getFunctionAttributes, testNogc2)); ./ldc-1.42.0-src/tests/dmd/compilable/b6227.d0000644000175000017500000000021615205374124017132 0ustar fabiofabioenum X { O, R } enum Y { U } static assert( (X.O == cast(const)X.O)); static assert( (X.O == X.O)); static assert( (X.O != X.R)); ./ldc-1.42.0-src/tests/dmd/compilable/issue22130.d0000644000175000017500000000033515205374124020112 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22130 int* f(const int* input) pure nothrow @safe { int* output; return output; } void main() pure nothrow @safe { int* c = new int; immutable int* i = f(c); } ./ldc-1.42.0-src/tests/dmd/compilable/test10073.d0000644000175000017500000000046515205374124017750 0ustar fabiofabiostruct Arr(T) { T[] dArr; alias dArr this; bool opEquals(Arr!T d) { foreach (idx, it; d) { if (this[idx] != it) { return false; } } return true; } } class Bar { Arr!Foo fooQ; } class Foo {} // NG ./ldc-1.42.0-src/tests/dmd/compilable/issue21390.d0000644000175000017500000000020215205374124020112 0ustar fabiofabiostruct S { @disable this(); } // Does not compile: "default construction is disabled for type `S`" extern __gshared S gVariable1; ./ldc-1.42.0-src/tests/dmd/compilable/test22727.c0000644000175000017500000000054015205374124017752 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22727 int fooc(int a) { return a; } __stdcall int foostdcall(int a) { return a; } int __stdcall foostdcall2(int a) { return a; } #if _MSC_VER int _stdcall foostdcall3(int a) { return a; } // test issue 24509 #endif int __stdcall (*fp1)(int a) = &foostdcall; int (__stdcall *fp2)(int a) = &foostdcall2; ./ldc-1.42.0-src/tests/dmd/compilable/test17349.d0000644000175000017500000000134615205374124017764 0ustar fabiofabio /* REQUIRED_ARGS: PERMUTE_ARGS: */ // https://issues.dlang.org/show_bug.cgi?id=16538 const(int) retConst1(); int retConst2(); auto retConst = [&retConst1, &retConst2]; const(int*) retConstPtr1(); const(int)* retConstPtr2(); auto retConstPtr = [&retConstPtr1, &retConstPtr2]; void constArray1(const(int)[1]); void constArray2(const(int[1])); auto constArray = [&constArray1, &constArray2]; const(int)[] retConstSlice1(); const(int[]) retConstSlice2(); auto retConstSlice = [&retConstSlice1, &retConstSlice2]; void constSlice1(const(int)[]); void constSlice2(const(int[])); auto constSlice = [&constSlice1, &constSlice2]; void ptrToConst1(const(int)*); void ptrToConst2(const(int*)); auto ptrToConst = [&ptrToConst1, &ptrToConst2]; ./ldc-1.42.0-src/tests/dmd/compilable/jsonCompilerInfo.d0000644000175000017500000000022715205374124021652 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -o- -Xi=compilerInfo -Xf- // TRANSFORM_OUTPUT: sanitize_json // TEST_OUTPUT_FILE: extra-files/jsonCompilerInfo.json ./ldc-1.42.0-src/tests/dmd/compilable/include_unittest.d0000644000175000017500000000142315205374124021753 0ustar fabiofabio/+ https://issues.dlang.org/show_bug.cgi?id=22730 EXTRA_FILES: imports/include_unittest/compiled_lib.d import imports/include_unittest/skipped_unittest_lib.d import imports/include_unittest/compiled_unittest_lib.d REQUIRED_ARGS: -i=compiled_lib -i=lib.with_.unittests -unittest TEST_OUTPUT: --- Found module with skipped unittests Compiling compiled_lib.unittests Compiling compiled_lib.someFunction Compiling lib.with_.unittests.someFunction Compiling lib.with_.unittests.unittest --- +/ import imports.include_unittest.compiled_lib; // Matches the first -i pattern, no module decl. import imports.include_unittest.skipped_unittest_lib; // Matches neither -i pattern import imports.include_unittest.compiled_unittest_lib; // Matches the second -i pattern, has module decl. ./ldc-1.42.0-src/tests/dmd/compilable/issue22975.d0000644000175000017500000000034015205374124020127 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22975 void test22975a(int) {}; alias test22975b = test22975a; void test22975b(bool) {} alias test22975c = test22975b; alias test22975a = test22975c; void test22975c(float) {} ./ldc-1.42.0-src/tests/dmd/compilable/bug11735.d0000644000175000017500000000133115205374124017545 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: /* TEST_OUTPUT: --- print string print wstring print dstring يطبع الترميز الموحد يطبع الترميز الموحد يطبع الترميز الموحد foo_str foo_wstr foo_dstr X%nY --- */ pragma(msg, "print string"); pragma(msg, "print wstring"w); pragma(msg, "print dstring"d); pragma(msg, "يطبع الترميز الموحد"); pragma(msg, "يطبع الترميز الموحد"w); pragma(msg, "يطبع الترميز الموحد"d); void main() { enum a = "foo_str"; enum b = "foo_wstr"w; enum c = "foo_dstr"d; pragma(msg, a); pragma(msg, b); pragma(msg, c); // https://github.com/dlang/dmd/issues/20894 pragma(msg, "X%nY"); } ./ldc-1.42.0-src/tests/dmd/compilable/testheader2i.d0000644000175000017500000000036615205374124020761 0ustar fabiofabio/* EXTRA_SOURCES: extra-files/header2.d REQUIRED_ARGS: -o- -H -Hf${RESULTS_DIR}/compilable/testheader2i.di -inline PERMUTE_ARGS: OUTPUT_FILES: ${RESULTS_DIR}/compilable/testheader2i.di TEST_OUTPUT_FILE: extra-files/header2i.di */ void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/b15428.d0000644000175000017500000000020715205374124017215 0ustar fabiofabioclass A { this() {} } class B : A { this() { static if (__traits(compiles, super())) super(); } } ./ldc-1.42.0-src/tests/dmd/compilable/test12624.d0000644000175000017500000000077015205374124017753 0ustar fabiofabio// REQUIRED_ARGS: -lib -Icompilable/extra-files // EXTRA_FILES: extra-files/imp12624.d // https://issues.dlang.org/show_bug.cgi?id=12624 struct SysTime { import imp12624; Rebindable!(immutable TimeZone) _timezone = UTC(); } class TimeZone { this(string , string , string ) immutable {} } class UTC : TimeZone { static immutable(UTC) opCall() { return _utc; } this() immutable { super("UTC", "UTC", "UTC"); } static _utc = new immutable(UTC); } ./ldc-1.42.0-src/tests/dmd/compilable/ice11596.d0000644000175000017500000000042215205374124017535 0ustar fabiofabio// PERMUTE_ARGS: -inline -release -g -O -version=X version(X) alias M = real; else alias M = int[2]; /* or other T[n] with n != 1 */ struct S { M m; } S f() { assert(false); } class C { S[1] ss; /* Here, size doesn't matter. */ this() { ss[] = f(); } } ./ldc-1.42.0-src/tests/dmd/compilable/cet_ibt.d0000644000175000017500000000022515205374124020001 0ustar fabiofabio// REQUIRED_ARGS: -fIBT // DISABLED: LDC_not_x86 // Test for Intel CET IBT (branch) protection static assert(__traits(getTargetInfo, "CET") == 1); ./ldc-1.42.0-src/tests/dmd/compilable/test5973.d0000644000175000017500000000107515205374124017703 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=5973 class A { int a = 1; } class B { int b = 2; } class C : A { B obj; alias obj this; this(){ obj = new B(); } } class X : C {} class D { int i; } class E { D x; alias x this; } class F : E { void test() { i = 5; } } void main() { auto c = new C(); assert(c.a == 1); // lookup C -> A, OK assert(c.b == 2); // lookup C => B, OK auto x = new X(); assert(x.a == 1); // lookup X -> C -> A, OK assert(x.b == 2); // lookup X -> C => B, NG (Line 17) } ./ldc-1.42.0-src/tests/dmd/compilable/test23978.d0000644000175000017500000000135515205374124017771 0ustar fabiofabio// REQUIRED_ARGS: -preview=dip1021 -lowmem // https://issues.dlang.org/show_bug.cgi?id=23978 // Note: this is a memory corruption bug. // Memory returned by `GC.realloc` retains references to old memory in it, // mostly because of the smallarray optimization for `Array(T)`. // If this fails again, it might not be consistent, so try running it multiple times. class LUBench { } void lup(ulong , ulong , int , int = 1) { new LUBench; } void lup_3200(ulong iters, ulong flops) { lup(iters, flops, 3200); } void raytrace() { struct V { float x, y, z; auto normalize() { } struct Tid { } auto spawnLinked() { } string[] namesByTid; class MessageBox { } auto cross() { } } } ./ldc-1.42.0-src/tests/dmd/compilable/ucn.d0000644000175000017500000000046715205374124017165 0ustar fabiofabio/+ REQUIRED_ARGS: -Icompilable/extra-files EXTRA_FILES: extra-files/ucn_vars.i +/ import ucn_vars; alias M = __traits(allMembers, Vars); enum expected = ["x²", "Ⅰ", "ↂ", "À", "Á", "Â", "whÿ", "aÄbсδe", "b〡𗘰〣e"]; static foreach(i; 0 .. M.length) { static assert(M[i] == expected[i]); } ./ldc-1.42.0-src/tests/dmd/compilable/b16697.d0000644000175000017500000000127115205374124017230 0ustar fabiofabiostatic assert(!is( float == __vector)); static assert(!is( float[1] == __vector)); static assert(!is( float[4] == __vector)); version (LDC) { /* very permissive wrt. vector types */ } else { static assert(!is(__vector(float[3]) == __vector)); static assert(!is(__vector(float[5]) == __vector)); } static if (__traits(compiles, __vector(float[4]))) { static assert(is(__vector(float[4]) == __vector)); static assert(is(__vector(float[4]) X == __vector) && is(X == float[4])); } static if (__traits(compiles, __vector(byte[16]))) { static assert(is(__vector(byte[16]) X == __vector) && is(X == byte[16])); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc14413.d0000644000175000017500000000034315205374124017677 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc14413; /// This should /// be one /// paragraph. /// /// Paragraph 2 void foo(){} ./ldc-1.42.0-src/tests/dmd/compilable/must_use_suppress.d0000644000175000017500000000015515205374124022202 0ustar fabiofabioimport core.attribute; @mustuse struct S {} S fun() { return S(); } void test() { cast(void) fun(); } ./ldc-1.42.0-src/tests/dmd/compilable/issue18097.d0000644000175000017500000000037315205374124020135 0ustar fabiofabio// REQUIRED_ARGS: -unittest module issue18097; unittest // this first unittest is needed to trigger the bug { } unittest // second unittest { auto a = &mixin(__traits(identifier, __traits(parent, { }))); auto b = &__traits(parent, { }); } ./ldc-1.42.0-src/tests/dmd/compilable/testnoinline.c0000644000175000017500000000031115205374124021076 0ustar fabiofabio __attribute__((noinline)) int abc() { return 1; } __declspec(noinline) int def() { return 2; } inline int ghi() { return 3; } int test() { return abc() + def() + ghi(); } ./ldc-1.42.0-src/tests/dmd/compilable/test22577.c0000644000175000017500000000023215205374124017753 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22577 typedef int(func)(void); int one(void) { return 1; } func* const fp1 = &one; func* const fp2 = one; ./ldc-1.42.0-src/tests/dmd/compilable/test19754.d0000644000175000017500000000143715205374124017767 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19754 void test19754() { shared int x; static assert((cast(int*) &x) == &(cast() x)); (cast() x) = 5; (cast() x) += 3; const int x1; static assert(&x1 == &(cast() x1)); (cast() x1) = 5; (cast() x1) *= 3; immutable int x2; static assert(&x2 == &(cast() x2)); (cast() x2) = 5; (cast() x2) &= 3; int[4] a; (cast(long[2]) a)[0] = 5; (cast(long[2]) a)[0] += 3; static if (is(__vector(int[4]))) { __vector(int[4]) v; (cast(int[4]) v)[0] = 5; (cast(int[4]) v)[0] += 3; } } // https://issues.dlang.org/show_bug.cgi?id=20608 void foo(T...)(auto ref T args) {} struct Tuple { int expand; } void test20608() { enum tup = Tuple(); foo(tup.expand); } ./ldc-1.42.0-src/tests/dmd/compilable/test21438.d0000644000175000017500000000041615205374124017753 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21438 int genGBPLookup() { static struct Table { int[1] entries; } auto table = new Table; auto x = table.entries[0]; static assert(is(typeof(x) == int)); return 0; } enum x = genGBPLookup; ./ldc-1.42.0-src/tests/dmd/compilable/test9399.d0000644000175000017500000000030415205374124017703 0ustar fabiofabio// REQUIRED_ARGS: -c -inline -Icompilable/imports // EXTRA_SOURCES: imports/test9399a.d import imports.test9399a; void fun(int a) { void nested() { a = 42; } call!nested(); } ./ldc-1.42.0-src/tests/dmd/compilable/test15856.d0000644000175000017500000000023715205374124017763 0ustar fabiofabio// REQUIRED_ARGS: -de // PERMUTE_ARGS: // EXTRA_FILES: imports/a15856.d class Foo { import imports.a15856; struct Bar { c_long a; } } ./ldc-1.42.0-src/tests/dmd/compilable/test13858.d0000644000175000017500000000037015205374124017761 0ustar fabiofabio// REQUIRED_ARGS: -w // https://issues.dlang.org/show_bug.cgi?id=13858 void foo() { assert(0); } void main() { int x = 0; LSwitch: switch (x) { case 0: break LSwitch; default: return; } foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/cimports2.i0000644000175000017500000000011115205374124020311 0ustar fabiofabio__import imports.cimports2a; __import imports.cimports2b; int *p = &xx; ./ldc-1.42.0-src/tests/dmd/compilable/test19833.d0000644000175000017500000000062015205374124017756 0ustar fabiofabiostruct S { template Temp(int x) { enum xxx = x; } } alias TT = __traits(getMember, S, "Temp"); enum x = TT!2.xxx; static assert(x == 2); class A { mixin temp!("uint"); mixin temp!("float"); mixin template temp(string source) { private enum inner(string s) = s; } } class B { alias member = __traits(getMember, A, __traits(allMembers, A)[0]); } ./ldc-1.42.0-src/tests/dmd/compilable/ice10770.d0000644000175000017500000000015315205374124017527 0ustar fabiofabioenum E1 : int; static assert(is(E1 e == enum) && is(e == int)); enum E2; static assert(is(E2 e == enum)); ./ldc-1.42.0-src/tests/dmd/compilable/jsonNoOutFile.d0000644000175000017500000000125215205374124021127 0ustar fabiofabio/* REQUIRED_ARGS: -Xi=compilerInfo PERMUTE_ARGS: OUTPUT_FILES: jsonNoOutFile_0.json TRANSFORM_OUTPUT: sanitize_json TEST_OUTPUT: --- === jsonNoOutFile_0.json { "compilerInfo": { "__VERSION__": 0, "architectures": [ "VALUES_REMOVED_FOR_TEST" ], "interface": "dmd", "platforms": [ "VALUES_REMOVED_FOR_TEST" ], "predefinedVersions": [ "VALUES_REMOVED_FOR_TEST" ], "size_t": 0, "supportedFeatures": { "includeImports": true }, "vendor": "VALUE_REMOVED_FOR_TEST", "version": "VALUE_REMOVED_FOR_TEST" } } --- */ void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test6534.d0000644000175000017500000000507315205374124017677 0ustar fabiofabiovoid main() { class MC{ int x; } const class CC{ int x; } static assert(is(typeof( CC.x) == const)); immutable class IC{ int x; } static assert(is(typeof( IC.x) == immutable)); shared class SC{ int x; } static assert(is(typeof( SC.x) == shared)); shared const class SCC{ int x; } static assert(is(typeof(SCC.x) == shared) && is(typeof(SCC.x) == const)); struct MS{ int x; } const struct CS{ int x; } static assert(is(typeof( CS.x) == const)); immutable struct IS{ int x; } static assert(is(typeof( IS.x) == immutable)); shared struct SS{ int x; } static assert(is(typeof( SS.x) == shared)); shared const struct SCS{ int x; } static assert(is(typeof(SCS.x) == shared) && is(typeof(SCS.x) == const)); union MU{ int x; } const union CU{ int x; } static assert(is(typeof( CU.x) == const)); immutable union IU{ int x; } static assert(is(typeof( IU.x) == immutable)); shared union SU{ int x; } static assert(is(typeof( SU.x) == shared)); shared const union SCU{ int x; } static assert(is(typeof(SCU.x) == shared) && is(typeof(SCU.x) == const)); static class S_MC{ int x; } const static class S_CC{ int x; } static assert(is(typeof( S_CC.x) == const)); immutable static class S_IC{ int x; } static assert(is(typeof( S_IC.x) == immutable)); shared static class S_SC{ int x; } static assert(is(typeof( S_SC.x) == shared)); shared const static class S_SCC{ int x; } static assert(is(typeof(S_SCC.x) == shared) && is(typeof(S_SCC.x) == const)); static struct S_MS{ int x; } const static struct S_CS{ int x; } static assert(is(typeof( S_CS.x) == const)); immutable static struct S_IS{ int x; } static assert(is(typeof( S_IS.x) == immutable)); shared static struct S_SS{ int x; } static assert(is(typeof( S_SS.x) == shared)); shared const static struct S_SCS{ int x; } static assert(is(typeof(S_SCS.x) == shared) && is(typeof(S_SCS.x) == const)); static union S_MU{ int x; } const static union S_CU{ int x; } static assert(is(typeof( S_CU.x) == const)); immutable static union S_IU{ int x; } static assert(is(typeof( S_IU.x) == immutable)); shared static union S_SU{ int x; } static assert(is(typeof( S_SU.x) == shared)); shared const static union S_SCU{ int x; } static assert(is(typeof(S_SCU.x) == shared) && is(typeof(S_SCU.x) == const)); } ./ldc-1.42.0-src/tests/dmd/compilable/betterCswitch.d0000644000175000017500000000027515205374124021207 0ustar fabiofabioimport core.stdc.stdio; extern (C) int main() { printf("hello world\n"); foo(3); return 0; } int foo(int i) { final switch (i) { case 1: break; } return i; } ./ldc-1.42.0-src/tests/dmd/compilable/b19442.d0000644000175000017500000000050115205374124017212 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19442 enum x1 = 42; enum x2 = mixin('x', 1); enum x3 = mixin(wchar('x'), 2); enum x4 = mixin(dchar('x'), 3); static assert(x2 == 42); static assert(x3 == 42); static assert(x4 == 42); mixin(`enum string s = "`, wchar('ö'), dchar('🍺'), `";`); static assert(s == "ö🍺"); ./ldc-1.42.0-src/tests/dmd/compilable/test16578b.d0000644000175000017500000000033315205374124020124 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16578 void main() { string[string] opts; switch (2) { case 0: opts["a"] = ""; { case 1: break; } default: } } ./ldc-1.42.0-src/tests/dmd/compilable/testCpCtor.d0000644000175000017500000000040315205374124020460 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19870 struct T { int i; this(ref return scope inout typeof(this) src) inout @safe pure nothrow @nogc { i = src.i; } } struct S { T t; } void main() { T a; S b = S(a); } ./ldc-1.42.0-src/tests/dmd/compilable/test9692.d0000644000175000017500000000043215205374124017701 0ustar fabiofabio// EXTRA_FILES: test9692a.d imports/test9692b.d module test9692; import test9692a; import imports.test9692b; static assert([__traits(allMembers, imports.test9692b)] == ["object", "k"]); // ok static assert([__traits(allMembers, test9692a)] == ["object", "j"]); // ng: should work ./ldc-1.42.0-src/tests/dmd/compilable/ident_all.d0000644000175000017500000000034015205374124020321 0ustar fabiofabio// REQUIRED_ARGS: -identifiers=all // verify that the UAX31 identifier set is applied. int øideùnt; int ªideµnt; int ¨ide¯nt; // just to play it safe, do we support one unicode then another at start? int øùident; ./ldc-1.42.0-src/tests/dmd/compilable/test7524.d0000644000175000017500000000010715205374124017670 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=7524 #line __LINE__ "y.d" ./ldc-1.42.0-src/tests/dmd/compilable/test24511.d0000644000175000017500000000233415205374124017747 0ustar fabiofabio// EXTRA_SOURCES: imports/test24511_c.c import test24511_c; static assert(__traits(getLinkage, CFunctionPointer) == "C"); static assert(__traits(getLinkage, StdCallFunctionPointer) == "Windows"); static assert(__traits(getLinkage, cFunction) == "C"); static assert(__traits(getLinkage, stdcallFunction) == "Windows"); static assert(__traits(getLinkage, takesCFunctionPointer) == "Windows"); static if (is(typeof(&takesCFunctionPointer) ParamsA == __parameters)) static assert(__traits(getLinkage, ParamsA[0]) == "C"); static assert(__traits(getLinkage, takesStdCallFunctionPointer) == "C"); static if (is(typeof(&takesStdCallFunctionPointer) ParamsB == __parameters)) static assert(__traits(getLinkage, ParamsB[0]) == "Windows"); static assert(__traits(getLinkage, StdCallFunctionPointerTakingCFunctionPointer) == "Windows"); static if (is(typeof(&StdCallFunctionPointerTakingCFunctionPointer) ParamsC == __parameters)) static assert(__traits(getLinkage, ParamsC[0]) == "C"); static assert(__traits(getLinkage, CFunctionPointerTakingStdCallFunctionPointer) == "C"); static if (is(typeof(&CFunctionPointerTakingStdCallFunctionPointer) ParamsD == __parameters)) static assert(__traits(getLinkage, ParamsD[0]) == "Windows"); ./ldc-1.42.0-src/tests/dmd/compilable/b6395.d0000644000175000017500000000057215205374124017145 0ustar fabiofabio// REQUIRED_ARGS: -Icompilable/extra-files // EXTRA_FILES: extra-files/c6395.d // https://issues.dlang.org/show_bug.cgi?id=6395 import c6395; int regex(string pattern) { return 0; } bool match(string r) { return true; } void applyNoRemoveRegex() { void scan(string[] noRemoveStr, string e) { auto a = find!((a){return match(e);})(map!regex(noRemoveStr)); } } ./ldc-1.42.0-src/tests/dmd/compilable/test19746.d0000644000175000017500000000053415205374124017765 0ustar fabiofabio// REQUIRED_ARGS: -Icompilable/imports // EXTRA_FILES: imports/test19746a.d imports/test19746b.d imports/test19746c.d imports/test19746d.d import test19746c; import test19746b: Frop; template Base(T) { static if (is(T == super)) alias Base = Object; } class Foo { class Nested: Base!Foo { } void func(Frop) { } void thunk() { } } ./ldc-1.42.0-src/tests/dmd/compilable/testprofile.d0000644000175000017500000000102115205374124020723 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -profile template LaLa(E...) { class LaLa { this() { } } } void main() { // doesn't work new LaLa!("lala", "lalalalala", "lala", "lala", "lala", "lala", "lalalala", "lala", "lala", "lala", "lalala", "lala", "lala", "lala", "lala", "lala", "lala", "lala", "lala", "lala", "lala", "lala", "lala", "lala", "lala", "lala", "lala"); } ./ldc-1.42.0-src/tests/dmd/compilable/ctests1.c0000644000175000017500000000553115205374124017762 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22252 /* Test conversion of parameter types: * array of T => pointer to T * function => pointer to function */ int test1(int a[]) { return *a; } int test2(int a[3]) { return *a; } int test3(int fp()) { return (*fp)(); } /*********************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22275 void test22275(char *dest) { char buf[1]; if (dest != buf) return; if (test22275 != &test22275) return; } /*********************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22294 enum { A, B, C }; _Static_assert(A == 0 && B == 1 && C == 2, "in"); int array[C]; /*********************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22313 typedef int Integer; int castint(int x){ Integer a = (Integer)(x); // cast.c(4) Integer b = (Integer)(4); // cast.c(5) Integer c = (Integer)x; Integer d = (Integer)4; Integer e = (int)(x); // cast.c(8) int f = (Integer)x; Integer g = (int)x; Integer h = (int)(4); // cast.c(11) Integer i = (int)4; int j = (Integer)(x); return x; } /*********************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22314 enum E22314 { oldval __attribute__((deprecated)), newval }; /*********************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22322 struct S22322 { float f; double d; long double ld; }; /*********************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22362 typedef struct Foo22362 { int x, y; } Foo22362; Foo22362 gfoo = (Foo22362){0, 1}; int main(int argc, char** argv) { Foo22362 foo1 = (Foo22362){0}; Foo22362 foo2 = (Foo22362){0, 1}; } /*********************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22623 struct S22623 { struct T *child; }; typedef struct T { int xyz; } U; void f22623() { struct S22623 s; struct T t; if (s.child != &t) ; } /*********************************************************/ //https://issues.dlang.org/show_bug.cgi?id=22267 typedef signed int int32_t; int32_t ret22267() { int32_t init = (1 + 3); return init; } _Static_assert(ret22267() == 4, "Ret != 4"); /*********************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22233 int foo22233(); void test22233() { (foo22233)(); } /*********************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22286 int foo122286(int); int foo222286(int, int); typedef int Int22286; void test22286() { Int22286 b; int x = (foo122286)(3); x = (foo222286)(3,4); x = (Int22286)(3); x = (Int22286)(3,4); } ./ldc-1.42.0-src/tests/dmd/compilable/test23979.d0000644000175000017500000000047715205374124017776 0ustar fabiofabio// REQUIRED_ARGS: -o- // https://issues.dlang.org/show_bug.cgi?id=23979 // Issue 23979 - ICE on failed alias this attempt on pointer expression class A {} void h() { const auto classPtr = SPtr.init; assert(!__traits(compiles, *classPtr)); } struct SPtr { A ptr() { return A.init; } alias ptr this; } ./ldc-1.42.0-src/tests/dmd/compilable/test17908.d0000644000175000017500000000035115205374124017760 0ustar fabiofabio// PERMUTE ARGS: @disable void foo() {} void foo(int) {} alias g = foo; // make sure the order of declaration // doesn't change anything void bar(int) {} @disable void bar() {} alias h = bar; void main() { g(10); h(10); } ./ldc-1.42.0-src/tests/dmd/compilable/test11980.d0000644000175000017500000000011415205374124017747 0ustar fabiofabiovoid start() { pragma(startaddress, start); } pragma(startaddress, start); ./ldc-1.42.0-src/tests/dmd/compilable/test21672.d0000644000175000017500000000060415205374124017752 0ustar fabiofabio// LDC: removed required arg `-mcpu=avx2` // REQUIRED_ARGS: -O // DISABLED: win32 linux32 freebsd32 openbsd32 // https://issues.dlang.org/show_bug.cgi?id=21672 import core.simd; int4 _mm_loadu_si16(const(void)* mem_addr) pure @trusted { int r = *cast(short*)(mem_addr); short8 result = [0, 0, 0, 0, 0, 0, 0, 0]; result.ptr[0] = cast(short)r; return cast(int4)result; } ./ldc-1.42.0-src/tests/dmd/compilable/filefullpath_18911.d0000644000175000017500000000041015205374124021606 0ustar fabiofabio// REQUIRED_ARGS: -Icompilable/imports -c -o- // EXTRA_FILES: imports/a18911.d import a18911; enum THIS_FILE = __FILE_FULL_PATH__; enum suffix_this = "filefullpath_18911.d"; static assert(THIS_FILE[0..$-suffix_this.length-1] == A_FILE[0..$-suffix_a.length-1]); ./ldc-1.42.0-src/tests/dmd/compilable/test14114.d0000644000175000017500000000040215205374124017737 0ustar fabiofabio// REQUIRED_ARGS: -O // https://issues.dlang.org/show_bug.cgi?id=14114 import core.volatile; struct Ports { static ubyte B() { return volatileLoad(cast(ubyte *)0x0025); } static void B(ubyte value) { volatileStore(cast(ubyte *)0x0025, value); } } ./ldc-1.42.0-src/tests/dmd/compilable/pragmapack.c0000644000175000017500000000457315205374124020507 0ustar fabiofabio/* REQUIRED_ARGS: -wi -verrors=simple TEST_OUTPUT: --- compilable/pragmapack.c(101): Warning: current pack attribute is default compilable/pragmapack.c(104): Warning: current pack attribute is 2 compilable/pragmapack.c(112): Warning: current pack attribute is default compilable/pragmapack.c(117): Warning: current pack attribute is 8 compilable/pragmapack.c(123): Warning: current pack attribute is default compilable/pragmapack.c(128): Warning: current pack attribute is 8 compilable/pragmapack.c(135): Warning: current pack attribute is default compilable/pragmapack.c(140): Warning: current pack attribute is default compilable/pragmapack.c(143): Warning: current pack attribute is 2 compilable/pragmapack.c(145): Warning: current pack attribute is 2 compilable/pragmapack.c(147): Warning: current pack attribute is 2 compilable/pragmapack.c(149): Warning: current pack attribute is 2 compilable/pragmapack.c(151): Warning: current pack attribute is 2 compilable/pragmapack.c(153): Warning: current pack attribute is 2 compilable/pragmapack.c(155): Warning: current pack attribute is 2 compilable/pragmapack.c(157): Warning: current pack attribute is 8 compilable/pragmapack.c(159): Warning: current pack attribute is 2 compilable/pragmapack.c(161): Warning: current pack attribute is 2 compilable/pragmapack.c(163): Warning: current pack attribute is default --- */ // Test #pragma pack #line 100 #pragma pack(show) #pragma pack(2) #pragma pack(show) struct S { int i; short j; double k; }; #pragma pack() #pragma pack(show) _Static_assert(sizeof(struct S) == 4 + 2 + 8, "1"); #pragma pack(push, 8) #pragma pack(show) struct S2 { char a, b; }; #pragma pack(pop) #pragma pack(show) _Static_assert(sizeof(struct S2) == 8, "2"); #pragma pack(push, 8) #pragma pack(show) struct S3 { unsigned short u; char a; }; #pragma pack(pop) #pragma pack(show) _Static_assert(sizeof(struct S3) == 8, "3"); #pragma pack() #pragma pack(show) #pragma pack(2) #pragma pack(push) #pragma pack(show) #pragma pack(push,2) #pragma pack(show) #pragma pack(push,abc) #pragma pack(show) #pragma pack(push,abc,2) #pragma pack(show) #pragma pack(pop) #pragma pack(show) #pragma pack(pop,a) #pragma pack(show) #pragma pack(pop,2) #pragma pack(show) #pragma pack(pop,a,b,4,8,c) #pragma pack(show) #pragma pack(pop); #pragma pack(show) #pragma pack(pop); #pragma pack(show) #pragma pack(pop); #pragma pack(show) int x; ./ldc-1.42.0-src/tests/dmd/compilable/fix24187.c0000644000175000017500000000054715205374124017572 0ustar fabiofabio/*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=24187 #ifdef __linux__ #ifndef __clang__ extern _Complex _Float32 cacosf32 (_Complex _Float32 __z) __attribute__ ((__nothrow__ , __leaf__)); extern _Complex _Float32x __cacosf32x (_Complex _Float32x __z) __attribute__ ((__nothrow__ , __leaf__)); #endif #endif ./ldc-1.42.0-src/tests/dmd/compilable/ddoc5446b.d0000644000175000017500000000016715205374124017773 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- module ddoc5446b; /** */ enum A_Enum_New { x } ./ldc-1.42.0-src/tests/dmd/compilable/test12979b.d0000644000175000017500000000124415205374124020127 0ustar fabiofabio// REQUIRED_ARGS: -w -de // DISABLED: LDC_not_x86 void foo() pure nothrow @nogc @safe { asm pure nothrow @nogc @trusted { ret; } } void bar()() { asm pure nothrow @nogc @trusted { ret; } } static assert(__traits(compiles, () pure nothrow @nogc @safe => bar())); void baz()() { asm { ret; } } // wait for deprecation of asm pure inference // static assert(!__traits(compiles, () pure => baz())); static assert(!__traits(compiles, () nothrow => baz())); // wait for deprecation of asm @nogc inference // static assert(!__traits(compiles, () @nogc => baz())); static assert(!__traits(compiles, () @safe => baz())); ./ldc-1.42.0-src/tests/dmd/compilable/vtemplates.d0000644000175000017500000000116115205374124020554 0ustar fabiofabio/* REQUIRED_ARGS: -vtemplates TEST_OUTPUT: --- compilable/vtemplates.d(10): vtemplate: 4 (3 distinct) instantiation(s) of template `foo(int I)()` found compilable/vtemplates.d(11): vtemplate: 5 (2 distinct) instantiation(s) of template `goo1(int I)()` found compilable/vtemplates.d(12): vtemplate: 3 (2 distinct) instantiation(s) of template `goo2(int I)()` found --- */ void foo(int I)() { } void goo1(int I)() { } void goo2(int I)() { goo1!(I); } void test() { foo!(1)(); foo!(1)(); foo!(2)(); foo!(3)(); goo1!(1)(); goo1!(1)(); goo1!(2)(); goo2!(1)(); goo2!(2)(); goo2!(2)(); } ./ldc-1.42.0-src/tests/dmd/compilable/union_initialization.d0000644000175000017500000000103415205374124022626 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20068 union B { int i; int* p; @safe this(int* p) { // Error: cannot access pointers in @safe code that overlap other fields this.p = p; } } /**************************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21229 struct NeedsInit { int var; @disable this(); } union Union { NeedsInit ni; } union Proxy { Union union_; } struct S { Union union_; Proxy proxy; this(NeedsInit arg) { union_.ni = arg; proxy.union_.ni = arg; } } ./ldc-1.42.0-src/tests/dmd/compilable/b12001.d0000644000175000017500000000042415205374124017176 0ustar fabiofabiovoid main() { static assert(__traits(isSame, int, int)); static assert(__traits(isSame, int[][], int[][])); static assert(__traits(isSame, bool*, bool*)); static assert(!__traits(isSame, bool*, bool[])); static assert(!__traits(isSame, float, double)); } ./ldc-1.42.0-src/tests/dmd/compilable/test22933.c0000644000175000017500000000015515205374124017753 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22933 void fn() { goto L; int x = 1; L: return; } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc9475.d0000644000175000017500000000056015205374124017634 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -w -o- -c -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc9475; /// foo void foo() { } /// unittest { // comment 1 foreach (i; 0 .. 10) { // comment 2 documentedFunction(); } } /// bar void bar() { } /// unittest { // bar comment } ./ldc-1.42.0-src/tests/dmd/compilable/test313e.d0000644000175000017500000000042315205374124017743 0ustar fabiofabio// first resolved as package, then created as module (with name package) // COMPILED_IMPORTS: imports/pkgmod313/mod.d imports/pkgmod313/package.d // REQUIRED_ARGS: -de import imports.pkgmod313; // then imported as package module void test() { imports.pkgmod313.foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/test20388.d0000644000175000017500000000027015205374124017754 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20388 void main() { foo!(mixin("(int a) { return a; }"))(); foo!(mixin("1+1"))(); foo!(mixin(0))(); } void foo(alias t)() { } ./ldc-1.42.0-src/tests/dmd/compilable/test23532.d0000644000175000017500000000734415205374124017757 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23532 // DISABLED: win32 win64 struct _Complex(T) { T re; T im; static @property epsilon()() { return _Complex(T.epsilon, T.epsilon); } static @property infinity()() { return _Complex(T.infinity, T.infinity); } static @property max()() { return _Complex(T.max, T.max); } static @property min_normal()() { return _Complex(T.min_normal, T.min_normal); } static @property nan()() { return _Complex(T.nan, T.nan); } static @property dig()() { return T.dig; } static @property mant_dig()() { return T.mant_dig; } static @property max_10_exp()() { return T.max_10_exp; } static @property max_exp()() { return T.max_exp; } static @property min_10_exp()() { return T.min_10_exp; } static @property min_exp()() { return T.min_exp; } } enum __c_complex_float : _Complex!float; enum __c_complex_double : _Complex!double; enum __c_complex_real : _Complex!real; static assert(__c_complex_float.epsilon is _Complex!float.epsilon); static assert(__c_complex_float.infinity is _Complex!float.infinity); static assert(__c_complex_float.init is _Complex!float.init); static assert(__c_complex_float.max is _Complex!float.max); static assert(__c_complex_float.min_normal is _Complex!float.min_normal); static assert(__c_complex_float.nan is _Complex!float.nan); static assert(__c_complex_float.sizeof == _Complex!float.sizeof); static assert(__c_complex_float.alignof == _Complex!float.alignof); static assert(__c_complex_float.dig == _Complex!float.dig); static assert(__c_complex_float.mant_dig == _Complex!float.mant_dig); static assert(__c_complex_float.max_10_exp == _Complex!float.max_10_exp); static assert(__c_complex_float.max_exp == _Complex!float.max_exp); static assert(__c_complex_float.min_10_exp == _Complex!float.min_10_exp); static assert(__c_complex_float.min_exp == _Complex!float.min_exp); static assert(__c_complex_double.epsilon is _Complex!double.epsilon); static assert(__c_complex_double.infinity is _Complex!double.infinity); static assert(__c_complex_double.init is _Complex!double.init); static assert(__c_complex_double.max is _Complex!double.max); static assert(__c_complex_double.min_normal is _Complex!double.min_normal); static assert(__c_complex_double.nan is _Complex!double.nan); static assert(__c_complex_double.sizeof == _Complex!double.sizeof); static assert(__c_complex_double.alignof == _Complex!double.alignof); static assert(__c_complex_double.dig == _Complex!double.dig); static assert(__c_complex_double.mant_dig == _Complex!double.mant_dig); static assert(__c_complex_double.max_10_exp == _Complex!double.max_10_exp); static assert(__c_complex_double.max_exp == _Complex!double.max_exp); static assert(__c_complex_double.min_10_exp == _Complex!double.min_10_exp); static assert(__c_complex_double.min_exp == _Complex!double.min_exp); static assert(__c_complex_real.epsilon is _Complex!real.epsilon); static assert(__c_complex_real.infinity is _Complex!real.infinity); static assert(__c_complex_real.init is _Complex!real.init); static assert(__c_complex_real.max is _Complex!real.max); static assert(__c_complex_real.min_normal is _Complex!real.min_normal); static assert(__c_complex_real.nan is _Complex!real.nan); static assert(__c_complex_real.sizeof == _Complex!real.sizeof); static assert(__c_complex_real.alignof == _Complex!real.alignof); static assert(__c_complex_real.dig == _Complex!real.dig); static assert(__c_complex_real.mant_dig == _Complex!real.mant_dig); static assert(__c_complex_real.max_10_exp == _Complex!real.max_10_exp); static assert(__c_complex_real.max_exp == _Complex!real.max_exp); static assert(__c_complex_real.min_10_exp == _Complex!real.min_10_exp); static assert(__c_complex_real.min_exp == _Complex!real.min_exp); ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_1308.d0000644000175000017500000000016215205374124021147 0ustar fabiofabiointerface Foo { package @property bool baz() { return true; } } bool consumer(Foo f) { return f.baz(); } ./ldc-1.42.0-src/tests/dmd/compilable/test11720.d0000644000175000017500000000125515205374124017746 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=11720 void test11720() { foo(); bar(); } alias TypeTuple(T...) = T; void foo()() { foreach (T; TypeTuple!(int, double)) { static temp = T.stringof; } } void bar() { foreach (T; TypeTuple!(int, double)) { static temp = T.stringof; } } /*********************************************/ // https://issues.dlang.org/show_bug.cgi?id=18266 void test18266() { foreach (i; 0 .. 10) { struct S { int x; } auto s = S(i); } foreach (i; 11 .. 20) { struct S { int y; } auto s = S(i); } } ./ldc-1.42.0-src/tests/dmd/compilable/test6999.d0000644000175000017500000000050615205374124017712 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=6999: inout in front of return type struct A { inout: inout(int) foo() { return 0; } } struct B { inout { inout(int) foo() { return 0; } } } struct C { inout inout(int) foo() { return 0; } } ./ldc-1.42.0-src/tests/dmd/compilable/test23799.d0000644000175000017500000000064115205374124017767 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23799 // REQUIRED_ARGS: -betterC struct Data { Data[] range; string test; } Data[] foo() { Data[] ret; if (__ctfe) { Data tmp; tmp.range ~= Data.init; ret ~= tmp; } return ret; } void func(Data dat)() { } void bar(Data dat)() { if (dat.test.length) func!(dat.range[0])(); } extern (C) void main() { static immutable data = foo(); bar!(data[0])(); } ./ldc-1.42.0-src/tests/dmd/compilable/test15150.d0000644000175000017500000000024115205374124017741 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/test15150a.d imports/test15150b.d module test15150; import imports.test15150a; import imports.test15150b; enum y = x; ./ldc-1.42.0-src/tests/dmd/compilable/test930.d0000644000175000017500000000050515205374124017604 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=930 template ATemplate(T) { template ATemplate() { auto foo() { T x = 2; // this line causes an error } } } class TheClass(alias MixIt) { mixin MixIt!(); } void main() { auto val = new TheClass!(ATemplate!(int)); val.foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/fix19983.c0000644000175000017500000000061715205374124017600 0ustar fabiofabio// fix ImportC function redeclarations should be allowed in function scope void test() { struct Foo; struct Foo; struct Foo; enum bar; enum bar; enum bar; union see; union see; union see; int f(); extern int f(); int f(); extern int h; extern int h; } void test1() { extern int f(); int f(); extern int x; extern int x; } ./ldc-1.42.0-src/tests/dmd/compilable/test21464.d0000644000175000017500000000033515205374124017752 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21464 // EXTRA_FILES: imports/test21464a.d void foo() pure { import imports.test21464a : Mallocator; auto a = Mallocator.instance; // mutable static, but empty struct } ./ldc-1.42.0-src/tests/dmd/compilable/test20236.d0000644000175000017500000000040515205374124017744 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20236 /* TEST_OUTPUT: --- --- */ struct X { alias y this; deprecated int y() { return 5; } int x() { return 5; } } void main() { static void func(int) {} with(X.init) { func(x); } } ./ldc-1.42.0-src/tests/dmd/compilable/test18871.d0000644000175000017500000000040615205374124017761 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=18871 // and https://issues.dlang.org/show_bug.cgi?id=18819 struct Problem { ~this() {} } struct S { Problem[1] payload; } enum theTemplateB = { static foreach (e; S.init.tupleof) {} return true; }(); ./ldc-1.42.0-src/tests/dmd/compilable/isZeroInit.d0000644000175000017500000000476215205374124020501 0ustar fabiofabioalias AliasSeq(T...) = T; struct Holder(T, ubyte val) { T x = val; } struct SArrayHolder(T, ubyte val) { T[2] x = val; } static foreach (T; AliasSeq!(bool, byte, short, int, long, ubyte, ushort, uint, ulong, char, wchar, dchar, float, double, real)) { static assert(__traits(isZeroInit, T) == (T.init is T(0))); static assert(__traits(isZeroInit, T[2]) == (T.init is T(0))); static assert(!__traits(isZeroInit, Holder!(T, 1))); static assert(__traits(isZeroInit, Holder!(T, 0))); static assert(__traits(isZeroInit, SArrayHolder!(T, 0))); static assert(!__traits(isZeroInit, SArrayHolder!(T, 1))); } static assert(__traits(isZeroInit, void)); // For initializing arrays of element type `void`. static assert(__traits(isZeroInit, void*)); static assert(__traits(isZeroInit, void[])); static assert(__traits(isZeroInit, float[])); static assert(__traits(isZeroInit, Object)); class C1 : Object { int x = 1; } static assert(__traits(isZeroInit, C1)); // An Object's fields are irrelevant. struct S1 { int[] a; int b; } static assert(__traits(isZeroInit, S1)); struct S2 { alias H = Holder!(int, 1); H h; int a; } static assert(!__traits(isZeroInit, S2)); struct S3 { S1 h; float f = 0; } static assert(__traits(isZeroInit, S3)); struct S4 { S2 h = S2(S2.H(0), 0); int a; } static assert(__traits(isZeroInit, S4)); struct S5 { Object o = null; } static assert(__traits(isZeroInit, S5)); template Vector(T) { alias __vector(T) Vector; } static if (is(Vector!(int[4]))) { static assert(__traits(isZeroInit, Holder!(Vector!(int[4]), 0))); static assert(!__traits(isZeroInit, Holder!(Vector!(int[4]), 1))); } // https://issues.dlang.org/show_bug.cgi?id=24776 struct S6 { union { int i1; float f1; } } static assert(__traits(isZeroInit, S6)); struct S7 { union { float f2; int i2; } } static assert(!__traits(isZeroInit, S7)); // https://issues.dlang.org/show_bug.cgi?id=23841 union U { float x = 0; float y; } static assert(__traits(isZeroInit, U)); union U2 { float x; int y; } static assert(!__traits(isZeroInit, U2)); struct S8 { int[0] dummy; // same offset as anon union, but doesn't overlap; should be ignored anyway for zero-init check union { float f; // is the first member of the anon union and must be checked int i; } } static assert(!__traits(isZeroInit, S8)); ./ldc-1.42.0-src/tests/dmd/compilable/test16572.d0000644000175000017500000000022115205374124017750 0ustar fabiofabioclass K { inout(int) f() inout { return var; } void bug() { auto d = &f; d(); } int var; } ./ldc-1.42.0-src/tests/dmd/compilable/testlibmain.d0000644000175000017500000000007015205374124020701 0ustar fabiofabio// REQUIRED_ARGS: -lib // PERMUTE_ARGS: void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test24107.d0000644000175000017500000000044215205374124017746 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24107 /* TEST_OUTPUT: --- This should not output an error message: false --- */ bool recurse () { return recurse(); } pragma(msg, "This should not output an error message: ", __traits(compiles, {enum bool r = recurse();})); ./ldc-1.42.0-src/tests/dmd/compilable/ident_c99.c0000644000175000017500000000020615205374124020155 0ustar fabiofabio// REQUIRED_ARGS: -identifiers-importc=c99 // verify that the C99 identifier set is applied. int \u00AAide\u00B5nt; int ªideµnt2; ./ldc-1.42.0-src/tests/dmd/compilable/test17434.d0000644000175000017500000000032015205374124017746 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=17434 // EXTRA_FILES: test17434a.d imports/imp17434a.d imports/imp17434b.d module test17434; import test17434a; void main() { imports.imp17434b.testing(); } ./ldc-1.42.0-src/tests/dmd/compilable/test9672.d0000644000175000017500000000022415205374124017676 0ustar fabiofabio// EXTRA_FILES: imports/test9672a.d module test9672; // node import imports.test9672a; // interpret mixin template ForwardCtor() { } ./ldc-1.42.0-src/tests/dmd/compilable/mixintempl.d0000644000175000017500000000045415205374124020562 0ustar fabiofabio struct TypeObj { alias This = typeof(this); mixin template MixinTempl() { int value; } } ref TypeObj Obj() { static TypeObj a; return a; } void func() { mixin Obj.This.MixinTempl; // ok mixin Obj.MixinTempl; // fixed: "MixinTempl!()" is not defined } ./ldc-1.42.0-src/tests/dmd/compilable/test1754.d0000644000175000017500000000023115205374124017665 0ustar fabiofabio// EXTRA_FILES: imports/test1754a.d imports/test1754b.d module test1754; import imports.test1754a; import imports.test1754b; void foo() { bar(); } ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_verbose.d0000644000175000017500000000553415205374124021063 0ustar fabiofabio/* REQUIRED_ARGS: -HC=verbose -o- -Icompilable/extra-files PERMUTE_ARGS: EXTRA_FILES: extra-files/dtoh_imports.d extra-files/dtoh_imports2.d TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler v$n$ #pragma once #include #include #include #include extern void importFunc(); // Ignored function dtoh_verbose.foo because of linkage // Ignored variable dtoh_verbose.i because of linkage // Ignored function dtoh_verbose.bar because of linkage // Ignored struct dtoh_verbose.S because of linkage // Ignored class dtoh_verbose.C because of linkage // Ignored function dtoh_verbose.bar because it is extern // Ignored variable dtoh_verbose.i1 because of linkage // Ignored template dtoh_verbose.templ(T)(T t) because of linkage // Ignored alias dtoh_verbose.inst because of linkage // Ignored enum dtoh_verbose.arrayOpaque because of its base type // Ignored renamed import `myFunc = importFunc` because `using` only supports types struct A final { // Ignored renamed import `myFunc = importFunc` because `using` only supports types A() { } }; struct Hidden final { // Ignored function dtoh_verbose.Hidden.hidden because it is private Hidden() { } }; // Ignored alias dtoh_verbose.D because of linkage class Visitor { public: virtual void stat(); // Ignored dtoh_verbose.Visitor.bar because `using` cannot rename functions in aggregates // Ignored dtoh_verbose.Visitor.unused because free functions cannot be aliased in C++ }; extern void unused(); // Ignored variable dtoh_verbose.and because its name is a special operator in C++ template struct FullImportTmpl final { // Ignored `dtoh_imports` because it's inside of a template declaration FullImportTmpl() { } }; template struct SelectiveImportsTmpl final { // Ignored `__anonymous` because it's inside of a template declaration SelectiveImportsTmpl() { } }; --- */ void foo() {} extern (D) { int i; } void bar(); struct S {} class C {} extern(C++) void bar(); int i1; void templ(T)(T t) {} alias inst = templ!int; extern(C++) enum arrayOpaque : int[4]; public import dtoh_imports : myFunc = importFunc; extern(C++) struct A { public import dtoh_imports : myFunc = importFunc; } extern(C++) struct Hidden { private void hidden() {} } private { enum PI = 4; } alias D = size_t delegate (size_t x); extern(C++) T foo(T) = T.init; extern(C++) class Visitor { void stat() {} // Ignored because those cannot be represented in C++ alias bar = stat; alias unused = .unused; } extern(C++) void unused() {} extern(C++) __gshared bool and; extern(C++) struct FullImportTmpl(T) { public import dtoh_imports; } extern(C++) struct SelectiveImportsTmpl(T) { public import dtoh_imports : importFunc, aliasName = ImportsC; } ./ldc-1.42.0-src/tests/dmd/compilable/test20420.d0000644000175000017500000000034315205374124017740 0ustar fabiofabio// REQUIRED_ARGS: -inline // https://issues.dlang.org/show_bug.cgi?id=20420 struct S { ~this(); } class C { this(S, int) {} } int i(); C create() { return new C(S(), i()); } auto test() { auto c = create(); } ./ldc-1.42.0-src/tests/dmd/compilable/test17970.d0000644000175000017500000000045715205374124017766 0ustar fabiofabioshared struct Shared { static Shared make() { return Shared(); } ~this() { } } shared struct Foo { ~this() { } } struct Inner { ~this() {} } struct Outer { shared(Inner) inner; } void main() { Foo x = Foo(); auto s = Shared.make(); Outer _; } ./ldc-1.42.0-src/tests/dmd/compilable/test22761.c0000644000175000017500000000045515205374124017755 0ustar fabiofabio // https://issues.dlang.org/show_bug.cgi?id=22761 extern long reg22344 (long adler, const char *buf, int len); long reg22344(adler, buf, len) long adler; const char *buf; int len; { return 0; } // https://issues.dlang.org/show_bug.cgi?id=22896 void fn(int); void fn(const int x); ./ldc-1.42.0-src/tests/dmd/compilable/test8922e.d0000644000175000017500000000062315205374124020043 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/bug8922.d import renamed = imports.bug8922; void test() { enum x = __traits(parent, renamed).stringof; static assert(x == "package imports"); static assert(!__traits(compiles, __traits(parent, imports))); static assert(!__traits(compiles, __traits(parent, bug8922))); static assert(!__traits(compiles, __traits(parent, imports.bug8922))); } ./ldc-1.42.0-src/tests/dmd/compilable/test14954.d0000644000175000017500000000053415205374124017761 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=14954 EXTRA_SOURCES: imports/test14954_implementation.d LINK: // LDC: conflicting globals `blah` (of different types) when compiling to a single object file DISABLED: LDC */ extern(C) struct UndeclaredStruct; extern(C) __gshared extern UndeclaredStruct blah; __gshared auto p = &blah; void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test23054.c0000644000175000017500000000102615205374124017744 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=23054 */ // DISABLED: LDC // FIXME - importC special case for struct literals struct S { int x; }; struct S* s = &(struct S){1}; int test1(int i) { struct S *b = &(struct S){i}; return b->x + 1; } int test2(int x) { struct S *s = &(struct S){0}; s->x = x; if (x != 0) { test2(0); if (s->x != x) return 2; } return 0; } _Static_assert(test1(1) == 2, "1"); _Static_assert(test2(1) == 0, "2"); ./ldc-1.42.0-src/tests/dmd/compilable/test21197.d0000644000175000017500000000050415205374124017753 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 */ // https://issues.dlang.org/show_bug.cgi?id=21197 @safe void check2() { int random; S create1() return scope { return S(); } scope S gen1 = create1; S create2() { return S(&random); } scope S gen2 = create2; } struct S { int* r; } ./ldc-1.42.0-src/tests/dmd/compilable/test20296.d0000644000175000017500000000016315205374124017753 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20296 extern (C++) void foo(T...)(T args) { } alias F = foo!(char*); ./ldc-1.42.0-src/tests/dmd/compilable/b16483.d0000644000175000017500000000046415205374124017224 0ustar fabiofabiostruct S { enum a = is(typeof(false.bar!(x => x))); // The lambda compiles enum b = is(typeof(false.bar!(x => y))); // The lambda doesn't compile } auto bar(alias foo)(bool var) { return foo(var); } static assert(is(typeof(S.a) == bool)); static assert(S.a == true); static assert(S.b == false); ./ldc-1.42.0-src/tests/dmd/compilable/test12527.d0000644000175000017500000000040215205374124017745 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=12527 @system: alias Fun = void function() @safe; static assert(Fun.stringof == "void function() @safe"); alias Del = void delegate() @safe; static assert(Del.stringof == "void delegate() @safe"); ./ldc-1.42.0-src/tests/dmd/compilable/test23217.c0000644000175000017500000000027015205374124017745 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23217 typedef struct { int a,b,c; } code; const code array[2] = { {96,7,0}, {0,8,80} }; const code distfix[2] = { {22,5,193},{64,5,0} }; ./ldc-1.42.0-src/tests/dmd/compilable/test20990.d0000644000175000017500000000042615205374124017756 0ustar fabiofabio// REQUIRED_ARGS: -O // https://issues.dlang.org/show_bug.cgi?id=20990 // foo() and bar() should produce the same code when // optimized. void foo(int* ptr) { if (ptr is null) assert(false); *ptr = 42; } void bar(int* ptr) { assert(ptr); *ptr = 42; } ./ldc-1.42.0-src/tests/dmd/compilable/test15519_y.d0000644000175000017500000000026215205374124020305 0ustar fabiofabio// EXTRA_FILES: test15519_x.d import test15519_x: NS = ns; // fails //import test15519_x; alias test15519_x.ns NS; // works extern(C++, ns) { class Y { NS.X v; } } ./ldc-1.42.0-src/tests/dmd/compilable/test20065.d0000644000175000017500000000031615205374124017745 0ustar fabiofabioalias AliasSeq(T...) = T; void main() { enum string[] array1 = [AliasSeq!("foo")]; static assert(array1 == ["foo"]); enum string[] array2 = [AliasSeq!()]; static assert(array2 == []); } ./ldc-1.42.0-src/tests/dmd/compilable/testpostblit.d0000644000175000017500000000021615205374124021130 0ustar fabiofabiostruct Test1a { this(this) { } } struct Test1b { Test1a a; } struct Test1c { const Test1b b; @disable this(this); } ./ldc-1.42.0-src/tests/dmd/compilable/test19895.d0000644000175000017500000000015715205374124017773 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19895 void fn() { void[] a; auto b = cast(byte[0][]) a; } ./ldc-1.42.0-src/tests/dmd/compilable/test21179.d0000644000175000017500000000032715205374124017756 0ustar fabiofabio// https://github.com/dlang/dmd/issues/21179 void bigEndianToNative(ubyte[2] a) {} void main() { ubyte[] arr; const ubyte[2] bytes; bigEndianToNative(bytes); auto b = cast(const ubyte[2][]) arr; } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc9676b.d0000644000175000017500000000026515205374124020003 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc9676b; /// deprecated void foo() {} ./ldc-1.42.0-src/tests/dmd/compilable/isexpalias.d0000644000175000017500000000026215205374124020533 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23578 struct S(alias a) { } static if (is(S!int == S!av, alias av)) static assert(is(av == int)); else static assert(false); ./ldc-1.42.0-src/tests/dmd/compilable/udamodule2.d0000644000175000017500000000035115205374124020431 0ustar fabiofabio// EXTRA_FILES: imports/udamodule2.d imports/udamodule2a.d import imports.udamodule2; import imports.udamodule2a; enum Attrib = __traits(getAttributes, imports.udamodule2); static assert(Attrib[0] == UDA(1) && Attrib[1] == UDA(2)); ./ldc-1.42.0-src/tests/dmd/compilable/test21243.d0000644000175000017500000000113115205374124017740 0ustar fabiofabio// Parsing - expressions auto a = auto ref (int x) => x; auto b = auto ref (int x) { return x; }; auto c = function auto ref (int x) { return x; }; auto d = delegate auto ref (int x) { return x; }; // Parsing - aliases alias e = auto ref (int x) => x; alias f = auto ref (int x) { return x; }; alias g = function auto ref (int x) { return x; }; alias h = delegate auto ref (int x) { return x; }; // Semantic void test() { alias fun(alias x) = auto ref () => x; int n = 123; auto _ = fun!123(); static assert(!__traits(compiles, &fun!123())); // rvalue fun!n() = 456; // lvalue } ./ldc-1.42.0-src/tests/dmd/compilable/test7569.d0000644000175000017500000000013715205374124017704 0ustar fabiofabiotemplate Tuple(T...) { alias T Tuple; } void main() { Tuple!(int, int) tup1 = void; } ./ldc-1.42.0-src/tests/dmd/compilable/issue24018.d0000644000175000017500000000011515205374124020115 0ustar fabiofabiostruct S { @disable this(); } void main() { S[] s; s = s ~ s; } ./ldc-1.42.0-src/tests/dmd/compilable/test14894.sh0000755000175000017500000000047515205374124020162 0ustar fabiofabio#!/usr/bin/env bash $DMD -c -m${MODEL} -of${OUTPUT_BASE}a${OBJ} -I${EXTRA_FILES} ${EXTRA_FILES}/${TEST_NAME}a.d $DMD -unittest -m${MODEL} -od${RESULTS_TEST_DIR} -I${EXTRA_FILES} ${EXTRA_FILES}/${TEST_NAME}main.d ${OUTPUT_BASE}a${OBJ} rm_retry ${OUTPUT_BASE}a${OBJ} ${TEST_NAME}main${EXE} ${TEST_NAME}main${OBJ}} ./ldc-1.42.0-src/tests/dmd/compilable/test22997.d0000644000175000017500000000040615205374124017765 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22997 struct Forward {} struct Foo { this(ref typeof(this) rhs) { this(rhs, Forward.init); } this(ref typeof(this) rhs, Forward) {} this(typeof(this) rhs, int i, double d, string s) {} } ./ldc-1.42.0-src/tests/dmd/compilable/test69.d0000644000175000017500000000271415205374124017533 0ustar fabiofabio// PERMUTE_ARGS: // ICE(expression.c) DMD 0.110 // https://www.digitalmars.com/d/archives/digitalmars/D/bugs/2966.html string str255() { return "\255"; } void fromFail49() { switch("abc") { case "": case str255(): break; default: break; } } // https://issues.dlang.org/show_bug.cgi?id=5735 struct A {} void b() {} void foo(bool cond) {} void main() { A a; int i; static assert(!__traits(compiles, assert(a))); static assert(!__traits(compiles, assert(i || a))); static assert(!__traits(compiles, assert(0 || a))); static assert(!__traits(compiles, assert(i && a))); static assert(!__traits(compiles, assert(1 && a))); static assert(!__traits(compiles, foo(a))); static assert(!__traits(compiles, foo(i || a))); static assert(!__traits(compiles, foo(0 || a))); static assert(!__traits(compiles, foo(i && a))); static assert(!__traits(compiles, foo(1 && a))); static assert(!__traits(compiles, assert(b))); static assert(!__traits(compiles, assert(i || b))); static assert(!__traits(compiles, assert(0 || b))); static assert(!__traits(compiles, assert(i && b))); static assert(!__traits(compiles, assert(1 && b))); static assert(!__traits(compiles, foo(b))); static assert(!__traits(compiles, foo(i || b))); static assert(!__traits(compiles, foo(0 || b))); static assert(!__traits(compiles, foo(i && b))); static assert(!__traits(compiles, foo(1 && b))); } ./ldc-1.42.0-src/tests/dmd/compilable/test9029.d0000644000175000017500000000151415205374124017675 0ustar fabiofabio// 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(); } } ./ldc-1.42.0-src/tests/dmd/compilable/test17352.d0000644000175000017500000000035515205374124017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=17352 void bug(Args...)() { } void test(bool coin) { if (coin) { string foobar; bug!foobar(); } else { string foobar; bug!foobar(); } } ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_1698.d0000644000175000017500000000006115205374124021161 0ustar fabiofabioimport imports.ldc_github_1698a; void foo(C) {} ./ldc-1.42.0-src/tests/dmd/compilable/issue17167.sh0000755000175000017500000000131715205374124020323 0ustar fabiofabio#!/usr/bin/env bash # Test that file paths larger than 248 characters can be used # Test CRLF and mixed line ending handling in D lexer. test_dir=${OUTPUT_BASE}/uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu mkdir -p "$test_dir" bin_base=${test_dir}/${TEST_NAME} bin="$bin_base$OBJ" src="$bin_base.d" echo 'void main() {}' > "${src}" # Only compile, don't link, since the Microsoft linker doesn't implicitly support long paths $DMD -m"${MODEL}" "${DFLAGS}" -c -of"${bin}" "${src}" rm_retry -r "${OUTPUT_BASE}" ./ldc-1.42.0-src/tests/dmd/compilable/test22133.d0000644000175000017500000000077715205374124017756 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22133 struct Slice { bool empty() const; int front() const; void popFront()() // note: requires a mutable Slice {} } enum isInputRange1(R) = is(typeof((R r) => r.popFront)); enum isInputRange2(R) = __traits(compiles, (R r) => r.popFront); static assert(isInputRange1!( Slice) == true); static assert(isInputRange1!(const Slice) == false); static assert(isInputRange2!( Slice) == true); static assert(isInputRange2!(const Slice) == false); ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_823.d0000644000175000017500000000011115205374124021062 0ustar fabiofabio// REQUIRED_ARGS: -d cdouble bar; ref cdouble foo() { return bar; } ./ldc-1.42.0-src/tests/dmd/compilable/test22714.d0000644000175000017500000000020715205374124017747 0ustar fabiofabio// EXTRA_FILES: imports/test22714a.d imports/test22714b.d // https://issues.dlang.org/show_bug.cgi?id=22714 import imports.test22714a; ./ldc-1.42.0-src/tests/dmd/compilable/test14973.d0000644000175000017500000000462415205374124017766 0ustar fabiofabiotemplate map(fun...) { auto map(R)(R r) { return MapResult!(fun, R)(r); } } struct MapResult(alias fun, R) { R _input; @property bool empty() { return _input.length == 0; } @property auto front() { return fun(_input[0]); } void popFront() { _input = _input[1..$]; } } class Foo { int baz() { return 1; } void bar() { auto s = [1].map!(i => baz()); // compiles auto r = [1].map!( // returns MapResult-1 // lambda1 i => [1].map!( // returns MapResult-2 // lambda2 j => baz() ) ); // compiles <- error // When lambda1 is called in MapResult-1.front(), it was changed to // TOKfunction in functionResolve. But in that time, MapResult-2 semantic3 // was not yet finished, then the lambda2 call in MapResult-2.front() // could not access to enclosing scope frame to call baz(). // To fix the issue, MapResult-2 semantic3 should be finished during the // lambda1 body analysis. } } class Bar { int baz; void bar() { auto s = [1].map!(i => baz); // compiles auto r = [1].map!( // lambda1 i => [1].map!( // lambda2 j => baz ) ); // compiles <- error } } /*******************************************/ struct ChunkByImpl(alias eq) { struct Group { int[] start; int[] current; void popFront() { // In here: // SortedRange.pred == (a, b) => a @ test14978b() // ChunkByImpl.eq == (a, b) => pred(a, b) @ SortedRange.groupBy() // // The context deduction should be: // First pred is deduced to function pointer, // and then, eq is also deduced to function pointer because pred is function pointer. // // Therefore, when ChunkByImpl is instantiated in groupBy(), its semantic3 // needs to be invoked to analyze ??? eq(start, current); } } } struct SortedRange(alias pred) { int[] input; auto groupBy() { ChunkByImpl!( (a, b) => pred(a, b) ) r; } } void test14973b() { SortedRange!( (a, b) => a ) r; } ./ldc-1.42.0-src/tests/dmd/compilable/test14831.d0000644000175000017500000000260715205374124017756 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=14831 void main() { { int x; static assert(x.mangleof == "_D9test148314mainFZ1xi"); } { int x; static assert(x.mangleof == "_D9test148314mainFZ4__S11xi"); } { static int y = 0; static assert(y.mangleof == "_D9test148314mainFZ1yi"); } { static int y = 0; static assert(y.mangleof == "_D9test148314mainFZ4__S11yi"); } { void f() {} static assert(f.mangleof == "_D9test148314mainFZ1fMFNaNbNiNfZv"); } { void f() {} static assert(f.mangleof == "_D9test148314mainFZ4__S11fMFNaNbNiNfZv"); } { struct S {} static assert(S.mangleof == "S9test148314mainFZ1S"); } { struct S {} static assert(S.mangleof == "S9test148314mainFZ4__S11S"); } { class C {} static assert(C.mangleof == "C9test148314mainFZ1C"); } { class C {} static assert(C.mangleof == "C9test148314mainFZ4__S11C"); } { enum E { a } static assert(E.mangleof == "E9test148314mainFZ1E"); static assert(E.a.mangleof == "_D9test148314mainFZ1E1aEQwQoFZQl"); } { enum E { a } static assert(E.mangleof == "E9test148314mainFZ4__S11E"); static assert(E.a.mangleof == "_D9test148314mainFZ4__S11E1aEQBbQuFZ4__S1Qr"); } } ./ldc-1.42.0-src/tests/dmd/compilable/test18468.d0000644000175000017500000000013415205374124017761 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=18468 @safe void main() { synchronized {} } ./ldc-1.42.0-src/tests/dmd/compilable/ldmd_response_file.sh0000755000175000017500000000146315205374124022424 0ustar fabiofabio#!/usr/bin/env bash # Make sure LDMD forwards a huge command line correctly to LDC. dir=${RESULTS_DIR}/compilable # generate a ~100K response file for LDMD rsp_file=${dir}/ldmd_response_file.rsp echo "-version=FirstLine" > ${rsp_file} for i in {1..1000} do echo "-I=Some/lengthy/string/Some/lengthy/string/Some/lengthy/string/Some/lengthy/string/Some/lengthy/string/" >> ${rsp_file} done echo "-version=LastLine" >> ${rsp_file} # statically assert that both versions are set src_file=${dir}/ldmd_response_file.d echo "version (FirstLine) {" > ${src_file} echo " version (LastLine) {} else static assert(0);" >> ${src_file} echo "} else" >> ${src_file} echo " static assert(0);" >> ${src_file} # LDMD errors if there's no source file. $DMD @${rsp_file} -c -o- ${src_file} if [ $? -ne 0 ]; then exit 1; fi; ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_special_enum.d0000644000175000017500000000301715205374124022054 0ustar fabiofabio/+ REQUIRED_ARGS: -HC -c -o- PERMUTE_ARGS: TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler #pragma once #include #include #include #include enum class __c_not_special; extern "C" void fn_long(long __param_0_); extern "C" void fn_ulong(unsigned long __param_0_); extern "C" void fn_longlong(long long __param_0_); extern "C" void fn_ulonglong(unsigned long long __param_0_); extern "C" void fn_long_double(long double __param_0_); extern "C" void fn_wchar_t(wchar_t __param_0_); extern "C" void fn_complex_float(_Complex float __param_0_); extern "C" void fn_complex_double(_Complex double __param_0_); extern "C" void fn_complex_real(_Complex long double __param_0_); extern "C" void fn_not_special(__c_not_special __param_0_); --- +/ enum __c_long : int; enum __c_ulong : int; enum __c_longlong : int; enum __c_ulonglong : int; enum __c_long_double : int; enum __c_wchar_t : int; enum __c_complex_float : int; enum __c_complex_double : int; enum __c_complex_real : int; enum __c_not_special : int; extern(C) void fn_long(__c_long) {} extern(C) void fn_ulong(__c_ulong) {} extern(C) void fn_longlong(__c_longlong) {} extern(C) void fn_ulonglong(__c_ulonglong) {} extern(C) void fn_long_double(__c_long_double) {} extern(C) void fn_wchar_t(__c_wchar_t) {} extern(C) void fn_complex_float(__c_complex_float) {} extern(C) void fn_complex_double(__c_complex_double) {} extern(C) void fn_complex_real(__c_complex_real) {} extern(C) void fn_not_special(__c_not_special) {} ./ldc-1.42.0-src/tests/dmd/compilable/b19432.d0000644000175000017500000000016115205374124017213 0ustar fabiofabio void main(){ enum a = 18446744073709551615; // 2^^64 - 1 ulong b = 18446744073709551615; // 2^^64 - 1 } ./ldc-1.42.0-src/tests/dmd/compilable/test14375.d0000644000175000017500000000053415205374124017756 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=14375 interface IKeysAPI(string greetings) { static assert(greetings == "Hello world", greetings); } void main() { foreach (method; __traits(allMembers, IKeysAPI!("Hello world"))) { static assert (method.length, "Empty string from the compiler ??"); pragma(msg, method); } } ./ldc-1.42.0-src/tests/dmd/compilable/test23256.d0000644000175000017500000000032015205374124017745 0ustar fabiofabio/* REQUIRED_ARGS: -os=windows * DISABLED: LDC // needs full triple, and would only work with available X86 backend - not worth it */ // https://issues.dlang.org/show_bug.cgi?id=23256 void test23256() { } ./ldc-1.42.0-src/tests/dmd/compilable/test3543.d0000644000175000017500000000253415205374124017673 0ustar fabiofabio // https://issues.dlang.org/show_bug.cgi?id=3543 // merge with commontype.d? void testi(bool bla) { interface Root { } interface A : Root { } interface B : Root { } A a; B b; Root r = bla ? a : b; static assert(is(typeof(r) == Root)); Root[] t = [a, b]; static assert(is(typeof(t[0]) == Root)); } void testc(bool bla) { class Root { } class A : Root { } class B : Root { } A a; B b; Root r = bla ? a : b; static assert(is(typeof(r) == Root)); Root[] t = [a, b]; static assert(is(typeof(t[0]) == Root)); } void teste(bool bla) { interface Root { } interface Othe { } interface A : Root, Othe { } interface B : Root, Othe { } A a; B b; static assert(!__traits(compiles, bla ? a : b)); } void testf(bool bla) { interface Othe { } interface Root : Othe { } interface A : Root { } interface B : Othe { } A a; B b; Othe r = bla ? a : b; } void testg() { interface A{} interface B{} interface C:A{} interface D:B,C{} interface E:B{} interface F:A,E{} D d; F f; static assert(!__traits(compiles, true ? d : f)); static assert(!__traits(compiles, true ? f : d)); } void testh() { interface I {} class B {} class C : B, I {} class D : B {} C c; D d; auto b = true ? c : d; } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc14778.d0000644000175000017500000000126215205374124017716 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc14778; /// docs for Z template Z14778(T) { /// docs for E enum E; /// docs for x enum x = 1.0; /// docs for mv auto mv = 1; /// docs for wv inout wv = 3; /// doc for cv const cv = "a"; /// docs for wcv inout const wcv = "ab"; /// doc for sv shared sv = 1.4142; /// doc for swv shared inout swv = 3.14; /// doc for scv shared const scv = new Object(); /// docs for swcv shared inout const swcv = undefined; /// doc for iv immutable iv = [1,2,3]; } ./ldc-1.42.0-src/tests/dmd/compilable/nestedtempl0.d0000644000175000017500000000054215205374124020776 0ustar fabiofabioclass C2 { class N(alias a) {} } void test2() { int a; static assert(__traits(isSame, __traits(parent, C2.N!0), C2)); static assert(__traits(isSame, __traits(parent, C2.N!a), C2)); static assert(__traits(classInstanceSize, C2.N!0) == size_t.sizeof * 3); static assert(__traits(classInstanceSize, C2.N!a) == size_t.sizeof * 4); } ./ldc-1.42.0-src/tests/dmd/compilable/ftimetrace.d0000644000175000017500000000242315205374125020516 0ustar fabiofabio/** REQUIRED_ARGS: -ftime-trace -ftime-trace-file=- -ftime-trace-granularity=0 TRANSFORM_OUTPUT: sanitize_timetrace TEST_OUTPUT: --- Code generation, Codegen: function add, object.add Codegen: function fun, object.fun Codegen: function id, object.id!int.id Codegen: function uses, object.uses Codegen: module object, object Ctfe: add(4, 8), add(4, 8) Ctfe: call add, object.add(4, 8) Generate IR, object Import object.object, object.object Optimize, $r:.*ftimetrace_0\.o(bj)?$ Parse: Module object, object Parsing, Prune object file cache, Sema1: Function add, object.add Sema1: Function fun, object.fun Sema1: Function id, object.id!int.id Sema1: Function uses, object.uses Sema1: Module object, object Sema1: Template Declaration id(T)(T t), object.id(T)(T t) Sema1: Template Instance id!int, object.id!int Sema2: add, object.add Sema2: fun, object.fun Sema2: id, object.id!int.id Sema2: uses, object.uses Sema3: add, object.add Sema3: fun, object.fun Sema3: id, object.id!int.id Sema3: uses, object.uses Semantic analysis, Write file(s), $r:.*ftimetrace_0\.o(bj)?$ --- */ module object; // Don't clutter time trace output with object.d void fun() { enum z = add(4, 8); } int add(int x, int y) { return x + y; } T id(T)(T t) { return T.init; } void uses() { int a = id!int(42); } ./ldc-1.42.0-src/tests/dmd/compilable/test13600.d0000644000175000017500000000024315205374125017742 0ustar fabiofabio// REQUIRED_ARGS: -g class Retry { alias bool delegate ( lazy void ) SuccessDecider; SuccessDecider success_decide; void on_retry ( ) { } } ./ldc-1.42.0-src/tests/dmd/compilable/test8922d.d0000644000175000017500000000052015205374125020037 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/bug8922.d void test() { static import imports.bug8922; static assert(!__traits(compiles, __traits(parent, imports))); static assert(!__traits(compiles, __traits(parent, bug8922))); enum x = __traits(parent, imports.bug8922).stringof; static assert(x == "package imports"); } ./ldc-1.42.0-src/tests/dmd/compilable/test22859.d0000644000175000017500000000204615205374125017765 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22859 private struct __InoutWorkaroundStruct {} @property T rvalueOf(T)(T val) { return val; } @property T rvalueOf(T)(inout __InoutWorkaroundStruct = __InoutWorkaroundStruct.init); @property ref T lvalueOf(T)(inout __InoutWorkaroundStruct = __InoutWorkaroundStruct.init); // taken from std.traits.isAssignable template isAssignable(Lhs, Rhs = Lhs) { enum isAssignable = __traits(compiles, lvalueOf!Lhs = rvalueOf!Rhs) && __traits(compiles, lvalueOf!Lhs = lvalueOf!Rhs); } // taken from std.meta.allSatisfy template allSatisfy(alias F, T...) { static foreach (Ti; T) { static if (!is(typeof(allSatisfy) == bool) && // not yet defined !F!(Ti)) { enum allSatisfy = false; } } static if (!is(typeof(allSatisfy) == bool)) // if not yet defined { enum allSatisfy = true; } } struct None{} class C1 { static if(allSatisfy!(isAssignable, None, C2)) {} } class C2 { static if(allSatisfy!(isAssignable, None, C1, C2)) {} } ./ldc-1.42.0-src/tests/dmd/compilable/b20045.d0000644000175000017500000000012015205374125017177 0ustar fabiofabioalias U = const ubyte[uint.sizeof]*; static assert (is(U == const(ubyte[4]*))); ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_1292.d0000644000175000017500000000032315205374125021151 0ustar fabiofabio// DISABLED: LDC_not_x86 void main() { fun(); } void fun() { double x0 = 0, x1 = 1; asm nothrow @nogc { movlpd qword ptr x0, XMM0; movhpd qword ptr x1, XMM0; } }./ldc-1.42.0-src/tests/dmd/compilable/test19187.d0000644000175000017500000000021115205374125017755 0ustar fabiofabio// EXTRA_FILES: imports/test19187.d import imports.test19187; void main() { enum test = __traits(compiles, imports.test19187.foo); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc10334.d0000644000175000017500000000254115205374125017700 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc10334; template Foo10334(T) if (Bar10334!()) {} /// template Foo10334(T) if (Bar10334!100) {} /// template Foo10334(T) if (Bar10334!3.14) {} /// template Foo10334(T) if (Bar10334!"str") {} /// template Foo10334(T) if (Bar10334!1.4i) {} /// template Foo10334(T) if (Bar10334!null) {} /// template Foo10334(T) if (Bar10334!true) {} /// template Foo10334(T) if (Bar10334!false) {} /// template Foo10334(T) if (Bar10334!'A') {} /// template Foo10334(T) if (Bar10334!int) {} /// template Foo10334(T) if (Bar10334!string) {} /// template Foo10334(T) if (Bar10334!([1,2,3])) {} /// template Foo10334(T) if (Bar10334!(Baz10334!())) {} /// template Foo10334(T) if (Bar10334!(Baz10334!T)) {} /// template Foo10334(T) if (Bar10334!(Baz10334!100)) {} /// template Foo10334(T) if (Bar10334!(.foo)) {} /// template Foo10334(T) if (Bar10334!(const int)) {} /// template Foo10334(T) if (Bar10334!(shared T)) {} /// template Test10334(T...) {} /// mixin Test10334!int a; /// mixin Test10334!(int,long) b; /// mixin Test10334!"str" c; /// ./ldc-1.42.0-src/tests/dmd/compilable/test23386.d0000644000175000017500000000026515205374125017762 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23386 // Segfault on enum member UDA inside template template E() { enum E : byte { @(1) none, } } alias T = E!(); ./ldc-1.42.0-src/tests/dmd/compilable/dip22.d0000644000175000017500000000050615205374125017313 0ustar fabiofabio// REQUIRED_ARGS: -de // EXTRA_FILES: imports/dip22.d import imports.dip22; class Foo : Base1, Base2 { void test() { static assert(typeof(bar()).sizeof == 2); static assert(baz == 2); static assert(T.sizeof == 2); } } void test() { bar(12); baz(12); 12.bar(); 12.baz(); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc24871.d0000644000175000017500000000047415205374125017716 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh import std.stdio; /// Example /// --- /// void main() { /// foreach (i; 0..10) { /// writeln("Hello, world!"); /// } /// } /// --- void main() { writeln("Hello, World!"); } ./ldc-1.42.0-src/tests/dmd/compilable/test20184.d0000644000175000017500000000022415205374125017746 0ustar fabiofabio// EXTRA_FILES: imports/h20184.h import imports.h20184; alias fun_signature = extern (C) int(); static assert(is(typeof(f20184) : fun_signature)); ./ldc-1.42.0-src/tests/dmd/compilable/named_arguments.d0000644000175000017500000000360115205374125021543 0ustar fabiofabio string fun(string x, string y, string z = "Z", string w = "W") { return x ~ y ~ z ~ w; } static assert(fun( "x", "y") == "xyZW"); static assert(fun( "x", "y", "z", "w") == "xyzw"); static assert(fun(x: "x", y: "y", z: "z", w: "w") == "xyzw"); static assert(fun(w: "w", z: "z", y: "y", x: "x") == "xyzw"); static assert(fun(y: "y", "z", x: "x") == "xyzW"); static assert(fun( "x", "y", w: "w") == "xyZw"); static assert(fun(x: "x", "y", z: "z") == "xyzW"); // Default arguments need not all be at the end anymore string fun2(string x = "x", string y, string z = "z") { return x ~ y ~ z; } static assert(fun2(y: "y") == "xyz"); struct SD { int x; int y; // The assumption that first parameter having a default implies all parameters have a default is no longer valid, // so this struct constructor shouldn't be mistaken for a default constructor. this(int x = 10, int y) { this.x = x; this.y = y; } } static assert(SD(y: 20) == SD(10, 20)); // UFCS static assert("x".fun("y", w: "w") == "xyZw"); // tuples alias AliasSeq(T...) = T; static assert("x".fun(x: AliasSeq!(), "y", w: "w") == "xyZw"); static assert(AliasSeq!("x", "y").fun(w: "w", z: AliasSeq!()) == "xyZw"); static assert(fun(y: AliasSeq!("y", "z", "w"), x: "x") == "xyzw"); // `new` expressions class C { int x, y; this(int x, int y) { this.x = x; this.y = y; } static C opCall(int x, int y) { return new C(x, y); } } struct S { int x, y; } static assert(new C(y: 3, x: 2).x == 2); static assert( C(y: 3, x: 2).x == 2); static assert(new S(y: 3, x: 2).x == 2); static assert( S(y: 3, x: 2).x == 2); // opCall struct Div { static int opCall(int numer, int denom) { return numer / denom; } } static assert(Div(denom: 3, numer: 6) == 2); struct Concat { string s = "s"; string opCall(string st0, string st1) { return s ~ st0 ~ st1; } } static assert(Concat.init("t0", "t1") == "st0t1"); ./ldc-1.42.0-src/tests/dmd/compilable/test15490.d0000644000175000017500000000033515205374125017755 0ustar fabiofabio// REQUIRED_ARGS: -o- -inline // PERMUTE_ARGS: // EXTRA_FILES: imports/imp15490a.d imports/imp15490b.d module test15490; import imports.imp15490a; import imports.imp15490b; void main() { regex(); listenTCP(); } ./ldc-1.42.0-src/tests/dmd/compilable/enumbasearithmetic.d0000644000175000017500000000045415205374125022246 0ustar fabiofabio//https://issues.dlang.org/show_bug.cgi?id=20777 struct FooInt { int i; auto opBinary(string op : "+")(int j) { return typeof(this)(i + j); } static @property FooInt max() { return typeof(this)(int.max); } } enum foolist { hi = FooInt(0), bye } ./ldc-1.42.0-src/tests/dmd/compilable/dmdcliflags.sh0000644000175000017500000001514315205374125021036 0ustar fabiofabio#!/usr/bin/env bash # these advanced CLI tests are too DMD-specific for LDMD # DISABLED: LDC GREP="$(command -v grep)" # grep -q can exit with a 141 on early exits function grep() { cat - | "$GREP" "$1" > /dev/null 2>&1 } ################################################################################ # -check ################################################################################ for w in "check" "check=" ; do output="$(! $DMD "-${w}" 2>&1)" echo "$output" | grep "Enable or disable specific checks:" echo "$output" | grep "=on Enable all assertion checking" echo "$output" | grep "Error: \`-check=\` requires an action" done for w in "check=?" "check=h" "check=help" ; do output="$($DMD "-${w}")" echo "$output" | grep "Enable or disable specific checks:" done output="$(! $DMD -check=foo 2>&1)" echo "$output" | grep "Error: switch \`-check=foo\` is invalid" echo "$output" | grep "Enable or disable specific checks:" echo "$output" | grep "=on Enable all assertion checking" output="$(! $DMD -checkf 2>&1)" echo "$output" | grep "Error: unrecognized switch '-checkf'" ################################################################################ # -checkaction ################################################################################ for w in "checkaction" "checkaction=" ; do output="$(! $DMD "-${w}" 2>&1)" echo "$output" | grep "Behavior on assert/boundscheck/finalswitch failure:" echo "$output" | grep "=D Usual D behavior of throwing an AssertError" echo "$output" | grep "Error: \`-check=\` requires a behavior" done for w in "checkaction=?" "checkaction=h" "checkaction=help" ; do output="$($DMD "-${w}")" echo "$output" | grep "Behavior on assert/boundscheck/finalswitch failure:" done output="$(! $DMD -checkaction=foo 2>&1)" echo "$output" | grep "Error: switch \`-checkaction=foo\` is invalid" echo "$output" | grep "Behavior on assert/boundscheck/finalswitch failure:" echo "$output" | grep "=D Usual D behavior of throwing an AssertError" output="$(! $DMD -checkactionf 2>&1)" echo "$output" | grep "Error: unrecognized switch '-checkactionf'" ################################################################################ # -mcpu ################################################################################ for w in "mcpu" "mcpu=" ; do output="$(! $DMD "-${w}" 2>&1)" echo "$output" | grep "CPU architectures supported by -mcpu=id:" echo "$output" | grep "=avx use AVX 1 instructions" echo "$output" | grep "Error: \`-mcpu=\` requires an architecture" done for w in "mcpu=?" "mcpu=h" "mcpu=help" ; do output="$($DMD "-${w}")" echo "$output" | grep "CPU architectures supported by -mcpu=id:" echo "$output" | grep "=avx use AVX 1 instructions" done output="$(! $DMD -mcpu=foo 2>&1)" echo "$output" | grep "Error: switch \`-mcpu=foo\` is invalid" echo "$output" | grep "CPU architectures supported by -mcpu=id:" echo "$output" | grep "=avx use AVX 1 instructions" output="$(! $DMD -mcpuf 2>&1)" echo "$output" | grep "Error: unrecognized switch '-mcpuf'" ################################################################################ # -transition ################################################################################ for w in "transition" "transition=" ; do output="$(! $DMD "-${w}" 2>&1)" echo "$output" | grep "Language transitions listed by -transition=name:" echo "$output" | grep "Error: \`-transition=\` requires a name" done for w in "transition=?" "transition=h" "transition=help" ; do output="$($DMD "-${w}")" echo "$output" | grep "Language transitions listed by -transition=name:" done output="$(! $DMD -transition=foo 2>&1)" echo "$output" | grep "Error: transition \`-transition=foo\` is invalid" echo "$output" | grep "Language transitions listed by -transition=name:" output="$(! $DMD -transition=123 2>&1)" echo "$output" | grep "Error: transition \`-transition=123\` is invalid" echo "$output" | grep "Language transitions listed by -transition=name:" output="$(! $DMD -transitionf 2>&1)" echo "$output" | grep "Error: unrecognized switch '-transitionf'" ################################################################################ # -color ################################################################################ output="$(! $DMD -color=foo 2>&1)" echo "$output" | grep "Error: switch \`-color=foo\` is invalid" echo "$output" | grep "Available options for \`-color\` are \`on\`, \`off\` and \`auto\`" ################################################################################ # -extern-std ################################################################################ for w in "extern-std" "extern-std=" ; do output="$(! $DMD "-${w}" 2>&1)" echo "$output" | grep "Available C++ standards:" echo "$output" | grep "=c++98 Sets \`__traits(getTargetInfo, \"cppStd\")\` to \`199711\`" echo "$output" | grep "Error: \`-extern-std=\` requires a standard" done for w in "extern-std=?" "extern-std=h" "extern-std=help" ; do output="$($DMD "-${w}")" echo "$output" | grep "Available C++ standards:" echo "$output" | grep "=c++98 Sets \`__traits(getTargetInfo, \"cppStd\")\` to \`199711\`" done output="$(! $DMD -extern-std=foo 2>&1)" echo "$output" | grep "Error: switch \`-extern-std=foo\` is invalid" echo "$output" | grep "Available C++ standards:" echo "$output" | grep "=c++98 Sets \`__traits(getTargetInfo, \"cppStd\")\` to \`199711\`" ################################################################################ # -profile ################################################################################ output="$(! $DMD -profile=foo 2>&1)" echo "$output" | grep "Error: switch \`-profile=foo\` is invalid" echo "$output" | grep "Only \`gc\` is allowed for \`-profile\`" ################################################################################ # -cov ################################################################################ output="$(! $DMD -cov=foo 2>&1)" echo "$output" | grep "Error: switch \`-cov=foo\` is invalid" echo "$output" | grep "Only a number between 0 and 100 can be passed to \`-cov=\`" ################################################################################ # -verrors ################################################################################ output="$(! $DMD -verrors=foo 2>&1)" echo "$output" | grep "Error: switch \`-verrors=foo\` is invalid" echo "$output" | grep "Only a number, \`spec\`, \`simple\`, or \`context\` are allowed for \`-verrors\`" ./ldc-1.42.0-src/tests/dmd/compilable/ddoc2.d0000644000175000017500000000137415205374125017372 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /** * Summary * * Description1 * * Description2 * * Description3 * * Macros: * WIKI = StdStream * meemie * See_Also: * Things to see also. * * And more things. */ /* */ module std.test; /// A base class for stream exceptions. class StreamException: Exception { /** Construct a StreamException with given error message msg. * Params: * msg = the $(RED red) $(BLUE blue) $(GREEN green) $(YELLOW yellow). * foo = next parameter which is a much longer * message spanning multiple * lines. */ this(string msg, int foo) { super(msg); } /********** stars ***************/ int stars; } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc5.d0000644000175000017500000000060715205374125017373 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /** Test module */ module test; /// class to test DDOC on members class TestMembers(TemplateArg) { public: /** a static method Params: idx = index */ static void PublicStaticMethod(int idx) { } } void main() { } ./ldc-1.42.0-src/tests/dmd/compilable/makedeps_exe.d0000644000175000017500000000165515205374125021033 0ustar fabiofabio/** REQUIRED_ARGS: -makedeps -Jcompilable/extra-files EXTRA_SOURCES: imports/makedeps_a.d LINK: TRANSFORM_OUTPUT: remove_lines(druntime) TEST_OUTPUT: --- $r:.*makedeps_exe_$0$?:windows=.exe$: \ $p:makedeps_exe.d$ \ $p:makedeps_a.d$ \ $p:makedeps-import.txt$ \ $p:makedeps-import-codemixin.txt$ --- **/ module makedeps_exe; // Test import statement import imports.makedeps_a; // Test import expression enum text = import("makedeps-import.txt"); static assert(text == "Imported text\x0a"); /*******************************/ // https://issues.dlang.org/show_bug.cgi?id=21844 enum bool failingModuleImport = __traits(compiles, ((){ import does.not.exist; })()); enum bool failingFileImport = __traits(compiles, ((){ return import("does.not.exists.txt");})()); enum bool workingFileImport = __traits(compiles, ((){ return import("makedeps-import-codemixin.txt");})()); static assert (workingFileImport); void main() { a_func(); } ./ldc-1.42.0-src/tests/dmd/compilable/issue20704.d0000644000175000017500000000076115205374125020123 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=20704 REQUIRED_ARGS: -preview=rvaluerefparam */ void f1(T)(const auto ref T arg = T.init) {} void f2(T)(const ref T arg = T.init) {} void f3(T)(const auto ref T arg = 0) {} void f4(T)(const ref T arg = 0) {} struct S { int _; } class C { int _; } void main () { int i; f1!int(i); f2!int(i); f3!int(i); f4!int(i); f1!int(); f2!int(); f3!int(); f4!int(); f1!S(); f2!S(); f1!C(); f2!C(); } ./ldc-1.42.0-src/tests/dmd/compilable/test6056a.d0000644000175000017500000000013515205374125020032 0ustar fabiofabioalias const(typeof('c')*) A; alias const(typeof(0)*) B; static assert(is(B == const(int*))); ./ldc-1.42.0-src/tests/dmd/compilable/test21742.d0000644000175000017500000000041315205374125017747 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21742 int foo()() { return 0; } struct B { int foo()() { return 0; } } static assert(is(typeof(foo) == void)); // failed, gagged error: expression B().foo()() has no type static assert(is(typeof(B().foo) == void)); ./ldc-1.42.0-src/tests/dmd/compilable/cppmangle_abitag.d0000644000175000017500000000430415205374125021650 0ustar fabiofabio// DISABLED: win32 win64 // REQUIRED_ARGS: -extern-std=c++11 /* * Test C++ abi-tag name mangling. * https://issues.dlang.org/show_bug.cgi?id=19949 */ import core.attribute; extern(C++): alias Tuple(A...) = A; enum foo_bar = gnuAbiTag("foo", "bar"); @foo_bar struct S { int i; this(int); } @foo_bar extern __gshared int a; static assert(a.mangleof == "_Z1aB3barB3foo"); extern __gshared S b; static assert(b.mangleof == "_Z1bB3barB3foo"); @foo_bar int f(); static assert(f.mangleof == "_Z1fB3barB3foov"); S gs(int); S gss(S, int); static assert(gs.mangleof == "_Z2gsB3barB3fooi"); static assert(gss.mangleof == "_Z3gss1SB3barB3fooi"); @foo_bar S fss(S, int); static assert(gs.mangleof == "_Z2gsB3barB3fooi"); T gt(T)(int); T gtt(T)(T, int); static assert(gt!S.mangleof == "_Z2gtI1SB3barB3fooET_i"); static assert(gtt!S.mangleof == "_Z3gttI1SB3barB3fooET_S1_i"); @foo_bar T ft(T)(int); // matches Clang and GCC <= 6 static assert(ft!S.mangleof == "_Z2ftB3barB3fooI1SB3barB3fooET_i"); @foo_bar T ftt(T)(T, int); // matches Clang and GCC <= 6 static assert(ftt!S.mangleof == "_Z3fttB3barB3fooI1SB3barB3fooET_S1_i"); // GCC >= 6 only @gnuAbiTag("ENN") enum E0 { a = 0xa, } E0 fe(); E0 fei(int i)(); static assert(fe.mangleof == "_Z2feB3ENNv"); static assert(fei!0.mangleof == "_Z3feiILi0EE2E0B3ENNv"); // Linux std::string // https://issues.dlang.org/show_bug.cgi?id=14956#c13 extern(C++, "std") { struct allocator(T); struct char_traits(CharT); extern(C++, "__cxx11") { @gnuAbiTag("cxx11") struct basic_string(CharT, Traits=char_traits!CharT, Allocator=allocator!CharT) { const char* data(); size_t length() const; } } alias string_ = basic_string!char; } string_* toString(const char*); static assert(toString.mangleof == "_Z8toStringB5cxx11PKc"); @gnuAbiTag("A", "B") { void fun0(); static assert(fun0.mangleof == "_Z4fun0B1AB1Bv"); } @gnuAbiTag("C", "D"): void fun1(); static assert(fun1.mangleof == "_Z4fun1B1CB1Dv"); void fun2(); static assert(fun2.mangleof == "_Z4fun2B1CB1Dv"); auto fun3() { @gnuAbiTag("Nested") extern(C++) struct T {} return T(); } static assert(fun3.mangleof == "_Z4fun3B1CB1DB6Nestedv"); ./ldc-1.42.0-src/tests/dmd/compilable/test20695.d0000644000175000017500000000074215205374125017762 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20695 struct Bar { this(const ref Bar o) {} string a; uint b; } struct Bar1 { @disable this(int a); this(const ref Bar1 o) {} string a; uint b; } struct Bar2 { this(const ref Bar2 o) {} @disable this(T)(T a) {} string a; uint b; } void main () { Bar b = { a: "Hello", b: 42 }; Bar c = Bar("Hello", 42); Bar1 b1 = { a: "Hello", b: 42 }; Bar2 b2 = { a: "Hello", b: 42 }; } ./ldc-1.42.0-src/tests/dmd/compilable/test23875.c0000644000175000017500000000176315205374125017770 0ustar fabiofabio/* DISABLED: win32 linux32 */ // https://issues.dlang.org/show_bug.cgi?id=23875 // https://issues.dlang.org/show_bug.cgi?id=23880 int __attribute__((vector_size(16))) neptune() { int __attribute__((vector_size (16))) v = { 4,1,2,3 }; return v; } __attribute__((__vector_size__(16))) int pluto(int i) { int __attribute__((__vector_size__ (16))) * p1; int * __attribute__((__vector_size__ (16))) p2; int __attribute__((__vector_size__ (16))) v1; __attribute__((__vector_size__ (16))) int v2; v1 = (__attribute__((__vector_size__ (16))) int) {4,1,2,3}; p1 = p2; *p1 = v1; v1 = (__attribute__((__vector_size__ (16))) int) v2; return i ? v1 : v2; } // https://issues.dlang.org/show_bug.cgi?id=24125 typedef int __i128 __attribute__ ((__vector_size__ (16), __may_alias__)); __i128 test1() { return (__i128){ 1, 2, 3, 4 }; } typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__)); __m128 test2() { return (__m128){ 1, 2, 3, 4 }; } ./ldc-1.42.0-src/tests/dmd/compilable/test19840.d0000644000175000017500000000033515205374125017760 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19840 struct G { ubyte[] I; alias I this; } auto M(ubyte[]) { G N; return N; } struct U { int V; } void X() { func((cast(U[])[].M)); } void func(U[]) {} ./ldc-1.42.0-src/tests/dmd/compilable/issue23567.d0000644000175000017500000000042015205374125020125 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23567 extern(C++) abstract class CCvar { public: pragma(printf) void func1(const(char)* pFormat, ...); pragma(printf) void func2(const(char)* pFormat, ...); } static assert(__traits(getVirtualIndex, CCvar.func2) == 1); ./ldc-1.42.0-src/tests/dmd/compilable/parens_inc.d0000644000175000017500000000053215205374125020513 0ustar fabiofabio// Test UnaryExp (expr)++ parsing void main(){ int[2] y; int *x = y.ptr; *(x)++=0; (*(x)--)=0; (*x++)=0; // ok int a = 1, b = 2; int*[] z = [&a, &b]; *(z[0])++=0; //ok (y[0])--; *x++=0; } void f() { int b; (b)++; int[] a = [1]; b = (a)[0]++; //ok (a[0])--; b = (int).init; //ok } ./ldc-1.42.0-src/tests/dmd/compilable/test7065.d0000644000175000017500000000230115205374125017667 0ustar fabiofabiovoid main() { align(1) struct X1 { ubyte b; int n; } static assert(X1.sizeof == 8); static assert(X1.b.offsetof == 0); static assert(X1.n.offsetof == 4); //X1 x1; //assert(cast(void*)&x1.b == cast(void*)&x1 + 0); //assert(cast(void*)&x1.n == cast(void*)&x1 + 1); struct Y1 { ubyte b; int n; } static assert(Y1.sizeof == 8); static assert(Y1.b.offsetof == 0); static assert(Y1.n.offsetof == 4); //Y1 y1; //assert(cast(void*)&y1.b == cast(void*)&y1 + 0); //assert(cast(void*)&y1.n == cast(void*)&y1 + 4); int local; align(1) struct X2 { ubyte b; int n; int f(){ return local; } } static assert(X2.sizeof == 8 + (void*).sizeof); static assert(X2.b.offsetof == 0); static assert(X2.n.offsetof == 4); //X2 x2; //assert(cast(void*)&x2.b == cast(void*)&x2 + 0); //assert(cast(void*)&x2.n == cast(void*)&x2 + 1); struct Y2 { ubyte b; int n; int f(){ return local; } } static assert(Y2.sizeof == 8 + (void*).sizeof); static assert(Y2.b.offsetof == 0); static assert(Y2.n.offsetof == 4); //Y2 y2; //assert(cast(void*)&y2.b == cast(void*)&y2 + 0); //assert(cast(void*)&y2.n == cast(void*)&y2 + 4); } ./ldc-1.42.0-src/tests/dmd/compilable/test55.d0000644000175000017500000000041215205374125017520 0ustar fabiofabio// COMPILE_SEPARATELY: // COMPILED_IMPORTS: imports/test55a.d // PERMUTE_ARGS: -dw // REQUIRED_ARGS: -d public import imports.test55a; class Queue { alias int ListHead; Arm a; } class MessageQueue : Queue { } class Queue2 { alias int ListHead; Arm2 a; } ./ldc-1.42.0-src/tests/dmd/compilable/test4375.d0000644000175000017500000001650215205374125017700 0ustar fabiofabio// REQUIRED_ARGS: -unittest // https://issues.dlang.org/show_bug.cgi?id=4375 // disallow dangling else void main() { if (true) { if (false) { assert(1); } else { assert(2); } } if (true) { if (false) assert(7); } else assert(8); if (true) { if (false) assert(9); else assert(10); } { if (true) assert(11); else assert(12); } { label1: if (true) assert(13); else assert(14); } if (true) foreach (i; 0 .. 5) { if (true) assert(17); else assert(18); } if (true) { foreach (i; 0 .. 5) if (true) assert(18.1); } else assert(18.2); if (true) assert(19); else assert(20); if (true) assert(21); else if (false) assert(22); else assert(23); version (A) { if (true) assert(26); } else assert(27); version (A) { if (true) assert(28); else assert(29); } version (A) assert(30); else version (B) assert(31); else assert(32); static if (true) { static if (true) assert(35); } else assert(36); static if (true) { static if (true) assert(37); else assert(38); } static if (true) assert(39); else static if (true) assert(40); else assert(41); switch (4) { case 0: if (true) assert(42); else assert(43); break; case 1: .. case 5: if (true) assert(44); else assert(45); break; default: if (true) assert(46); else assert(47); break; } // (o_O) switch (1) default: if (true) assert(113); else assert(114); // (o_O) final switch (1) case 1: if (true) assert(117); else assert(118); mixin(q{ if (true) assert(56); else assert(57); }); while (false) if (true) assert(66); else assert(67); if (true) while (false) assert(68); else assert(69); do if (true) assert(72); else assert(73); while (false); if (true) do if (true) assert(74); else assert(75); while (false); for ( if (true) // (o_O) assert(78); else assert(79); false; ) if (true) assert(80); else assert(81); if (true) for (if (true) assert(84); else assert(85); false;) assert(86); if (true) if (true) if (true) if (true) if (true) assert(87); auto x = new C; if (true) while (false) for (;;) scope (exit) synchronized (x) assert(88); else assert(89); if (true) while (false) for (;;) { scope (exit) synchronized (x) if (true) assert(90); else assert(89); } if (true) while (false) for (;;) scope (exit) synchronized (x) if (true) assert(90); else assert(89); else assert(12); with (x) if (false) assert(92); else assert(93); try if (true) assert(94); else assert(95); catch (Exception e) if (true) assert(96); else assert(97); finally if (true) assert(98); else assert(99); if (true) try if (true) assert(100); else assert(101); finally assert(102); if (true) try assert(109); catch(Exception e) if (true) assert(110); else assert(112); finally assert(111); static struct F { static if (true) int x; else int y; static if (true) { static if (false) int z; } else int w; static if (true) int t; else static if (false) int u; else int v; } if (true) if (true) assert(113); else assert(114); else assert(115); static if (true) static if (true) assert(116); else assert(117); else assert(118); } unittest { if (true) assert(50); else assert(51); } class C { invariant() { if (true) assert(58); else assert(59); } int f() in { if (true) assert(60); else assert(61); } out(res) { if (true) assert(62); else assert(63); } do { if (true) assert(64); else assert(65); return 0; } } enum q = q{ if(true) if(true) assert(54.1); else assert(55.2); }; static if (true) struct F0 {} else static if (true) struct F1 {} else struct F2 {} static if (true) { static if (false) struct F3 {} } else struct F4 {} version(A) { version(B) struct F5 {} } else struct F6 {} version(A) { version(B) struct F5a {} else struct F5b {} } version (C) struct F5c {} else struct F5d {} struct F7 { static if (true) int x; else float x; private: static if (true) int y; else float y; } template F8() { static if (true) int x; else float x; } static if (true) align(1) static if (false) struct F9 {} static if (true) align(1) { extern(C) pure static if (false) void F10(){} else void F11(){} } void f() { int[] x; static if (5 > 0) version (Y) scope (failure) foreach (i, e; x) while (i > 20) with (e) if (e < 0) synchronized(e) assert(1); else assert(2); else x = null; else x = null; } ./ldc-1.42.0-src/tests/dmd/compilable/issue20362.d0000644000175000017500000000023515205374125020117 0ustar fabiofabiovoid main() { string str; stringify((chars) {str ~= chars; }); } void stringify(scope void delegate(scope const char[]) sink) { sink("oops"); } ./ldc-1.42.0-src/tests/dmd/compilable/test21740.i0000644000175000017500000000042415205374125017754 0ustar fabiofabio// https://github.com/dlang/dmd/issues/21740 int x²; int \u2160; int \u2182; int \u00C0; int \u00C1; int \U000000C2; int wh\u00ff; int a\u00c4b\u0441\U000003b4e; int b\u3021𗘰\u3023e; int a\U000000aa[4]; typedef int \u0441b\U000003b4 ; int a\u00c4(\u0441b\U000003b4) { } ./ldc-1.42.0-src/tests/dmd/compilable/test9369.d0000644000175000017500000000002315205374125017677 0ustar fabiofabioDdoc --- a=1; --- ./ldc-1.42.0-src/tests/dmd/compilable/test21299a.d0000644000175000017500000000023515205374125020121 0ustar fabiofabio// EXTRA_SOURCES: imports/test21299/mtype.d imports/test21299/func.d imports/test21299/rootstringtable.d // REQUIRED_ARGS: -main // LINK: module test21299a; ./ldc-1.42.0-src/tests/dmd/compilable/test13582b.d0000644000175000017500000000031615205374125020116 0ustar fabiofabio// REQUIRED_ARGS: -de // EXTRA_FILES: imports/test13582.d module test13582b; deprecated void foo() { import imports.test13582; } deprecated struct S { import imports.test13582; } void main() { } ./ldc-1.42.0-src/tests/dmd/compilable/test23499.d0000644000175000017500000000026615205374125017770 0ustar fabiofabio// REQUIRED_ARGS: -inline // EXTRA_SOURCES: extra-files/build23499.d // EXTRA_FILES: imports/file23499.d // https://issues.dlang.org/show_bug.cgi?id=23499 import imports.file23499; ./ldc-1.42.0-src/tests/dmd/compilable/stc_traits.d0000644000175000017500000001167715205374125020565 0ustar fabiofabio// REQUIRED_ARGS: -preview=dip1000 -preview=in /* TEST_OUTPUT: --- 100 AliasSeq!() 101 AliasSeq!("return", "ref") 102 AliasSeq!("ref") 103 AliasSeq!() 104 AliasSeq!("ref") 105 AliasSeq!() 106 AliasSeq!() 107 AliasSeq!("ref") 108 AliasSeq!("ref") 109 AliasSeq!("ref") 110 AliasSeq!("ref") 111 AliasSeq!() 112 AliasSeq!("ref") 113 AliasSeq!("ref") 114 AliasSeq!("ref") 115 AliasSeq!("ref") 116 AliasSeq!() 117 AliasSeq!("ref") 118 AliasSeq!("ref") 119 AliasSeq!() 120 AliasSeq!("ref") 121 AliasSeq!() 122 AliasSeq!("ref") 123 AliasSeq!("in") 124 AliasSeq!("in") m AliasSeq!("ref") m-mixin AliasSeq!("ref") m AliasSeq!("ref") m-mixin AliasSeq!("ref") m AliasSeq!("ref") m-mixin AliasSeq!("ref") m AliasSeq!("return", "ref") m-mixin AliasSeq!("return", "ref") m AliasSeq!("ref") m-mixin AliasSeq!("ref") m AliasSeq!("ref") m-mixin AliasSeq!("ref") m AliasSeq!() m-mixin AliasSeq!() m AliasSeq!("ref") m-mixin AliasSeq!("ref") m AliasSeq!("ref") m-mixin AliasSeq!("ref") m AliasSeq!("ref") m-mixin AliasSeq!("ref") m AliasSeq!("ref") m-mixin AliasSeq!("ref") m AliasSeq!("ref") m-mixin AliasSeq!("ref") m AliasSeq!("ref") m-mixin AliasSeq!("ref") m AliasSeq!("in") m-mixin AliasSeq!("in") --- */ void func(int i) {} void func(return ref bool i) {} void func(ref float a, int b) {} void get(T : int)(ref T t) {} void get()(float t) {} void get(T)(ref T[] t) {} void funcautoi()(auto ref int i) {} void funcauto(T)(auto ref T a) {} void funcin(in int i) {} struct Foo { void foo(int i) {} void foo(ref bool i) {} static void sfoo(ref int i) {} } struct FooT(T) { void foo(ref T i) {} static void sfoo(ref T i) {} } class Bar { void bar(int i) {} void bar(ref bool i) {} static void sbar(ref int i) {} } class BarT(T) { void bar(ref T i) {} static void sbar(ref T i) {} } int i; template match(handlers...) { static foreach(h; handlers) { // should give the same result pragma(msg, "m ", __traits(getParameterStorageClasses, h(i), 0)); pragma(msg, "m-mixin ", __traits(getParameterStorageClasses, mixin("h(i)"), 0)); } enum match = (){}; } void funcT(T)(ref T t) {} void main() { int i; bool b; float f; int[] ia; Foo foo; FooT!int foot; Bar bar = new Bar; BarT!int bart = new BarT!int; ref int _foo(return ref const int* p, scope int* a, out int b, lazy int c); // From SPEC_RUNNABLE_EXAMPLE_COMPILE: int* p, a; int _b, c; static assert(__traits(getParameterStorageClasses, _foo(p, a, _b, c), 1)[0] == "scope"); static assert(__traits(getParameterStorageClasses, _foo(p, a, _b, c), 2)[0] == "out"); static assert(__traits(getParameterStorageClasses, _foo(p, a, _b, c), 3)[0] == "lazy"); #line 100 pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, func(0), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, func(b), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, func(f, i), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, func(f, i), 1)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, get(i), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, get(0.0), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, get(f), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, get(ia), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, mixin("get(i)"), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, Foo.sfoo(i), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, FooT!int.sfoo(i), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, foo.foo(0), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, foo.foo(b), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, foot.foo(i), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, Bar.sbar(i), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, BarT!int.sbar(i), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, bar.bar(0), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, bar.bar(b), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, bart.bar(i), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, funcautoi(10), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, funcautoi(i), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, funcauto(10), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, funcauto(i), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, funcin(1), 0)); pragma(msg, __LINE__, " ", __traits(getParameterStorageClasses, funcin(i), 0)); cast(void) match!( function(ref int i) => true, delegate(ref int i) => true, (ref int i) => true, (return ref int i) => &i, get, funcT, (int i) => true, FooT!int.sfoo, Foo.sfoo, BarT!int.sbar, Bar.sbar, funcautoi, funcauto, funcin, ); } ./ldc-1.42.0-src/tests/dmd/compilable/bug6963.d0000644000175000017500000000312215205374125017475 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: /* TEST_OUTPUT: --- output foo: 1e: pure nothrow @nogc @safe void(int x) output foo: 3e: pure nothrow @nogc @safe void(int x) --- */ alias void function(int) pure nothrow @safe @nogc FuncPtrType; void foo1a(X)(X x) {} void foo1b(X)(X x) {} void foo1c(X)(X x) {} void foo1d(X)(X x) {} void foo1e(X)(X x) {} // module level declaration with type inference auto fptr1 = &foo1a!int; static assert(is(typeof(fptr1) == FuncPtrType)); // array initializer auto fptrlist1 = [&foo1b!int]; static assert(is(typeof(fptrlist1) == FuncPtrType[])); // static assert static assert(is(typeof(&foo1c!int) == FuncPtrType)); // static if static if(is(typeof(&foo1d!int) PF)) static assert(is(PF == FuncPtrType)); else static assert(0); // pragma test pragma(msg, "output foo: 1e: ", typeof(foo1e!int).stringof); void foo2a(X)(X x) {} void foo2b(X)(X x) {} void foo2c(X)(X x) {} FuncPtrType fptr3 = &foo2a!int; // most similar to original issue FuncPtrType[] fptrlist3 = [&foo2b!int]; struct S{ FuncPtrType fp; } S s = { &foo2c!int }; void foo3a(X)(X x) {} void foo3b(X)(X x) {} void foo3c(X)(X x) {} void foo3d(X)(X x) {} void foo3e(X)(X x) {} void main() { auto fptr2 = &foo3a!int; static assert(is(typeof(fptr2) == FuncPtrType)); auto fptrlist2 = [&foo3b!int]; static assert(is(typeof(fptrlist2) == FuncPtrType[])); static assert(is(typeof(&foo1c!int) == FuncPtrType)); static if(is(typeof(&foo1d!int) PF)) static assert(is(PF == FuncPtrType)); else static assert(0); pragma(msg, "output foo: 3e: ", typeof(foo3e!int)); } ./ldc-1.42.0-src/tests/dmd/compilable/test18694.d0000644000175000017500000000015615205374125017767 0ustar fabiofabiostruct S { enum int x = 42; } static S dummy; pure int fun(int x) { return dummy.x + x; } void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/jsonc.i0000644000175000017500000000345015205374125017515 0ustar fabiofabio/* REQUIRED_ARGS: -o- -X -Xf- TRANSFORM_OUTPUT: sanitize_json TEST_OUTPUT: --- [ { "file": "VALUE_REMOVED_FOR_TEST", "kind": "module", "members": [ { "baseDeco": "i", "char": 9, "kind": "enum", "line": 68, "members": [ { "char": 17, "kind": "enum member", "line": 68, "name": "a" } ], "name": "E", "protection": "public" }, { "char": 21, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "alias", "line": 68, "name": "E", "originalType": "enum E", "protection": "public" }, { "baseDeco": "s", "char": 15, "kind": "enum", "line": 70, "members": [ { "char": 32, "kind": "enum member", "line": 70, "name": "a2" } ], "name": "E2", "protection": "public" }, { "char": 36, "deco": "VALUE_REMOVED_FOR_TEST", "kind": "alias", "line": 70, "name": "E2", "originalType": "const enum E2 : short", "protection": "public" } ] } ] --- */ // https://issues.dlang.org/show_bug.cgi?id=24108 typedef enum { a, } E; typedef const enum : short { a2, } E2; // C23 feature ./ldc-1.42.0-src/tests/dmd/compilable/test22725.c0000644000175000017500000000020215205374125017744 0ustar fabiofabio// REQUIRED_ARGS: -o- -H -Hd${RESULTS_DIR}/compilable // https://issues.dlang.org/show_bug.cgi?id=22728 typedef struct S { } S; ./ldc-1.42.0-src/tests/dmd/compilable/import_exp.d0000644000175000017500000000226015205374125020560 0ustar fabiofabio// REQUIRED_ARGS: -Jcompilable/imports/ // EXTRA_FILES: imports/imp16088.d imports/test21227/a..b.txt imports/test21227/a.txt imports/test21227/..foo/a.txt // https://issues.dlang.org/show_bug.cgi?id=16088 void bar(string x) {} auto foo() { import("imp16088.d").bar; } // https://issues.dlang.org/show_bug.cgi?id=21227 void test21227() { import("./test21227/a.txt").bar; import("test21227//a..b.txt").bar; import("test21227/..foo/a.txt").bar; version(Windows) { import(r".\test21227\a.txt").bar; import(r"test21227\\a..b.txt").bar; import(r"test21227\..foo\a.txt").bar; } } // Test that it's treated like a hex string, allowing implicit conversion to byte array // Can't test whole contents because line endings may vary enum expectedStart = "module imports.imp16088;"; immutable ubyte[] s0 = import("imp16088.d"); static assert(s0[0 .. expectedStart.length] == "module imports.imp16088;"); // https://issues.dlang.org/show_bug.cgi?id=24687 void foo(string path); void foo(const(ubyte[]) data); void bar1() { foo(import("imp16088.d")); } // matches both void bar2() { foo(cast(const(ubyte[])) import("imp16088.d")); } // matches both! ./ldc-1.42.0-src/tests/dmd/compilable/testparse.d0000644000175000017500000001214415205374125020406 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -o- /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=6719 static assert(__traits(compiles, mixin("(const(A))[0..0]")) == false); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=9232 struct Foo9232 { void bar(T)() {} void baz() {} } void test9232() { Foo9232 foo; (foo).bar!int(); // OK <- Error: found '!' when expecting ';' following statement ((foo)).bar!int(); // OK foo.bar!int(); // OK (foo).baz(); // OK } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=9401 struct S9401a { ~this() nothrow pure @safe { } } struct S9401b { @safe ~this() pure nothrow { } } void test9401() nothrow pure @safe { S9401a s1; S9401b s2; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=9649 class Outer9649 { class Inner { } } void test9649() { Outer9649 outer9649; (outer9649).new Inner(); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=9679 void test9679(inout int = 0) { if ( auto n = 1) { static assert(is(typeof(n) == int)); } if ( const n = 1) { static assert(is(typeof(n) == const int)); } if ( immutable n = 1) { static assert(is(typeof(n) == immutable int)); } if (shared n = 1) { static assert(is(typeof(n) == shared int)); } if (shared const n = 1) { static assert(is(typeof(n) == shared const int)); } if ( inout n = 1) { static assert(is(typeof(n) == inout int)); } if (shared inout n = 1) { static assert(is(typeof(n) == shared inout int)); } if ( const int n = 1) { static assert(is(typeof(n) == const int)); } if ( immutable int n = 1) { static assert(is(typeof(n) == immutable int)); } if (shared int n = 1) { static assert(is(typeof(n) == shared int)); } if (shared const int n = 1) { static assert(is(typeof(n) == shared const int)); } if ( inout int n = 1) { static assert(is(typeof(n) == inout int)); } if (shared inout int n = 1) { static assert(is(typeof(n) == shared inout int)); } if ( const(int) n = 1) { static assert(is(typeof(n) == const int)); } if ( immutable(int) n = 1) { static assert(is(typeof(n) == immutable int)); } if (shared (int) n = 1) { static assert(is(typeof(n) == shared int)); } if (shared const(int) n = 1) { static assert(is(typeof(n) == shared const int)); } if ( inout(int) n = 1) { static assert(is(typeof(n) == inout int)); } if (shared inout(int) n = 1) { static assert(is(typeof(n) == shared inout int)); } if (immutable(int)[] n = [1]) { static assert(is(typeof(n) == immutable(int)[])); } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=9901 template isGood9901(T) { enum isGood9901 = true; } void test9901() { string foo(R)(R data) if (isGood9901!R) { return ""; } foo(1); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=10199 void test10199() { goto label; label: } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12460 void f12460(T)() { static if (is(T == int)) { goto end; } end: } void test12460() { f12460!int(); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=11689 void test11689() { deprecated void foo() {} } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=11751 static assert(is(float == typeof(0x0.1p1F))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=11957 extern(C++) class C11957 { void x() {} } void test11957() { extern(C++) class D : C11957 { override void x() {} } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=13049 enum mangle13049(T) = T.mangleof; alias FP13049 = void function(scope int); // OK static assert(mangle13049!FP13049 == mangle13049!(void function(scope int))); // OK <- NG /***************************************************/ // was not covered until the **12th of March 2019** void testIfConditionWithSTCandType() { auto call(){return 0;} if (const size_t i = call()) {} } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=20791 extern(C++, "foo", ) struct S {} /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22019 void test22019() { final switch (1) { case 1,: case 2,3,: break; } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=23205 void test23205() { mixin template tpl() { int x; } mixin tpl!(); x = 123; } ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_names.d0000644000175000017500000001134615205374125020520 0ustar fabiofabio/+ REQUIRED_ARGS: -HC -c -o- PERMUTE_ARGS: TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler #pragma once #include #include #include #include struct Outer final { static Outer* outerPtr; static Middle::Inner* outerToInnerPtr; static Middle::InnerTmpl* outerToInnerTmplPtr; struct Middle final { static Outer* middleOuterPtr; static Middle* middlePtr; static Inner* middleInnerPtr; struct Inner final { static Outer* innerOuterPtr; static Middle* innerPtr; static Inner* innerInnerPtr; static InnerTmpl* innerInnerTmplPtr; Inner() { } }; template struct InnerTmpl final { static Outer* innerTmplOuterPtr; static Middle* innerTmplPtr; static Inner* innerTmplInnerPtr; static InnerTmpl* innerTmplInnerTmplPtr; InnerTmpl() { } }; Middle() { } }; template struct MiddleTmpl final { static MiddleTmpl* middleTmplPtr; static MiddleTmpl* middleTmplInnerTmplPtr; struct Inner final { static Inner* ptr; static MiddleTmpl* ptr2; Inner() { } }; template struct InnerTmpl final { static InnerTmpl* innerTmplPtr; static InnerTmpl* innerTmplPtrDiff; static MiddleTmpl* middleTmplInnerTmplPtr; static T a; static U bar(); InnerTmpl() { } }; MiddleTmpl() { } }; Outer() { } }; --- +/ extern(C++): struct Outer { __gshared Outer* outerPtr; __gshared Middle.Inner* outerToInnerPtr; __gshared Middle.InnerTmpl!int* outerToInnerTmplPtr; static struct Middle { __gshared Outer* middleOuterPtr; __gshared Middle* middlePtr; __gshared Inner* middleInnerPtr; static struct Inner { __gshared Outer* innerOuterPtr; __gshared Middle* innerPtr; __gshared Inner* innerInnerPtr; __gshared InnerTmpl!int* innerInnerTmplPtr; } static struct InnerTmpl(U) { __gshared Outer* innerTmplOuterPtr; __gshared Middle* innerTmplPtr; __gshared Inner* innerTmplInnerPtr; __gshared InnerTmpl* innerTmplInnerTmplPtr; } } static struct MiddleTmpl(T) { __gshared MiddleTmpl!T* middleTmplPtr; __gshared MiddleTmpl!T.Inner* middleTmplInnerTmplPtr; static struct Inner { __gshared Inner* ptr; __gshared MiddleTmpl!T.Inner* ptr2; } static struct InnerTmpl(U) { __gshared InnerTmpl* innerTmplPtr; __gshared InnerTmpl!char* innerTmplPtrDiff; __gshared MiddleTmpl!T.Inner* middleTmplInnerTmplPtr; __gshared T a; static U bar() { return U.init; } } } } /+ TEST_OUTPUT: --- extern Outer::Middle::Inner inner; extern Outer::Middle::InnerTmpl innerTmpl; extern Outer::MiddleTmpl::Inner middleTmpl; extern Outer::MiddleTmpl::InnerTmpl bothTmpl; --- +/ __gshared Outer.Middle.Inner inner; __gshared Outer.Middle.InnerTmpl!int innerTmpl; __gshared Outer.MiddleTmpl!int.Inner middleTmpl; __gshared Outer.MiddleTmpl!int.InnerTmpl!double bothTmpl; /+ TEST_OUTPUT: --- typedef Outer::MiddleTmpl::InnerTmpl FullTmplInst; template using FullTmpl = Outer::MiddleTmpl::InnerTmpl; --- +/ alias FullTmplInst = Outer.MiddleTmpl!int.InnerTmpl!double; alias FullTmpl = Outer.MiddleTmpl!int.InnerTmpl; /+ TEST_OUTPUT: --- extern void dotId(int32_t a = Outer::MiddleTmpl::InnerTmpl::a); --- +/ void dotId( int a = Outer.MiddleTmpl!int.InnerTmpl!double.a ) {} /+ TEST_OUTPUT: --- extern void castExp(double a = (double) Outer::MiddleTmpl::InnerTmpl::a); --- +/ void castExp( double a = Outer.MiddleTmpl!int.InnerTmpl!double.a ) {} /+ TEST_OUTPUT: --- extern void structLit(Outer::MiddleTmpl::InnerTmpl a = Outer::MiddleTmpl::InnerTmpl()); --- +/ void structLit( Outer.MiddleTmpl!int.InnerTmpl!double a = Outer.MiddleTmpl!int.InnerTmpl!double() ) {} /+ TEST_OUTPUT: --- extern void callExp(double a = Outer::MiddleTmpl::InnerTmpl::bar()); --- +/ void callExp( double a = Outer.MiddleTmpl!int.InnerTmpl!double.bar() ) {} ./ldc-1.42.0-src/tests/dmd/compilable/test21876.d0000644000175000017500000000033415205374125017761 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21876 auto test1() { int[0] a; return a; } auto test2() { static int[0] a; return a; } enum x = test1(); enum y = test2(); static assert(x == y && y == []); ./ldc-1.42.0-src/tests/dmd/compilable/ident_c11.d0000644000175000017500000000014615205374125020142 0ustar fabiofabio// REQUIRED_ARGS: -identifiers=c11 // verify that the C11 identifier set is applied. int ¨ide¯nt; ./ldc-1.42.0-src/tests/dmd/compilable/verrors_spec.d0000644000175000017500000000042415205374125021106 0ustar fabiofabio/* PERMUTE_ARGS: REQUIRED_ARGS: -verrors=simple -verrors=spec TEST_OUTPUT: --- (spec:1) compilable/verrors_spec.d(13): Error: cannot implicitly convert expression `& i` of type `int*` to `int` --- */ void foo(int i) { int p; bool b = __traits(compiles, {p = &i;}); } ./ldc-1.42.0-src/tests/dmd/compilable/struct_decls_20499.c0000644000175000017500000002557615205374125021655 0ustar fabiofabio// https://github.com/dlang/dmd/issues/20499 // // attribute((aligned())) is so we can tell if attributes are being applied. // typedef struct __attribute__((aligned(8))) S { int x, y; } S; _Static_assert(sizeof(struct S) == 8, "sizeof(S)"); _Static_assert(_Alignof(struct S) == 8, "_Alignof(S)"); typedef struct __attribute__((aligned(8))) Foo { int x, y; } *pFoo, Foo, FooB; _Static_assert(sizeof(struct Foo) == sizeof(struct S), "sizeof(Foo)"); _Static_assert(_Alignof(struct Foo) == _Alignof(struct S), "_Alignof(Foo)"); _Static_assert(sizeof(Foo) == sizeof(struct S), "sizeof(Foo)"); _Static_assert(_Alignof(Foo) == _Alignof(struct S), "_Alignof(Foo)"); _Static_assert(sizeof(FooB) == sizeof(struct S), "sizeof(FooB)"); _Static_assert(_Alignof(FooB) == _Alignof(struct S), "_Alignof(FooB)"); pFoo pf; _Static_assert(sizeof(*pf) == sizeof(struct S), "sizeof(*pf)"); _Static_assert(_Alignof(typeof(*pf)) == _Alignof(struct S), "_Alignof(*pf)"); typedef struct __attribute__((aligned(8))) { int x, y; } Baz, *pBaz, BazB; _Static_assert(sizeof(Baz) == sizeof(struct S), "sizeof(Baz)"); _Static_assert(sizeof(BazB) == sizeof(struct S), "sizeof(BazB)"); _Static_assert(_Alignof(Baz) == _Alignof(struct S), "_Alignof(Baz)"); _Static_assert(_Alignof(BazB) == _Alignof(struct S), "_Alignof(BazB)"); pBaz pb; _Static_assert(sizeof(*pb) == sizeof(struct S), "sizeof(*pb)"); _Static_assert(_Alignof(typeof(*pb)) == _Alignof(struct S), "_Alignof(*pb)"); typedef struct __attribute__((aligned(8))) { int x, y; } *pTux; pTux pt; _Static_assert(sizeof(*pt) == sizeof(struct S), "sizeof(*pt)"); _Static_assert(_Alignof(typeof(*pt)) == _Alignof(struct S), "_Alignof(*pt)"); typedef struct __attribute__((aligned(8))) { int x, y; } Qux; _Static_assert(sizeof(Qux) == sizeof(struct S), "sizeof(FooB)"); _Static_assert(_Alignof(Qux) == _Alignof(struct S), "_Alignof(FooB)"); struct Bar { struct S foo; }; _Static_assert(sizeof(struct Bar) == sizeof(struct S), "sizeof(Bar)"); _Static_assert(_Alignof(struct Bar) == _Alignof(struct S), "_Alignof(Bar)"); typedef struct __attribute__((aligned(8))) { int x, y; } *pLux; pLux pl; _Static_assert(sizeof(*pl) == sizeof(struct S), "sizeof(*pl)"); _Static_assert(_Alignof(typeof(*pl)) == _Alignof(struct S), "_Alignof(*pl)"); typedef struct __attribute__((aligned(8))) { int x, y; } ****pWux; pWux pw; _Static_assert(sizeof(****pw) == sizeof(struct S), "sizeof(****pw)"); _Static_assert(_Alignof(typeof(****pw)) == _Alignof(struct S), "_Alignof(****pw)"); struct __attribute__((aligned(8))) { int x, y; } f; _Static_assert(sizeof(f) == sizeof(struct S), "sizeof(f)"); _Static_assert(_Alignof(typeof(f)) == _Alignof(struct S), "_Alignof(f)"); struct __attribute__((aligned(8))) { int x, y; } fa[3]; _Static_assert(sizeof(fa[0]) == sizeof(struct S), "sizeof(fa[0])"); _Static_assert(_Alignof(typeof(fa[0])) == _Alignof(struct S), "_Alignof(fa[0])"); void locals(void){ // function local version // Use different values so we know we aren't just using globals typedef struct __attribute__((aligned(16))) S { int x, y[7]; } S; _Static_assert(sizeof(struct S) == 32, "sizeof(S)"); _Static_assert(_Alignof(struct S) == 16, "_Alignof(S)"); typedef struct __attribute__((aligned(16))) Foo { int x, y[7]; } *pFoo, Foo, FooB; _Static_assert(sizeof(struct Foo) == sizeof(struct S), "sizeof(Foo)"); _Static_assert(_Alignof(struct Foo) == _Alignof(struct S), "_Alignof(Foo)"); _Static_assert(sizeof(Foo) == sizeof(struct S), "sizeof(Foo)"); _Static_assert(_Alignof(Foo) == _Alignof(struct S), "_Alignof(Foo)"); _Static_assert(sizeof(FooB) == sizeof(struct S), "sizeof(FooB)"); _Static_assert(_Alignof(FooB) == _Alignof(struct S), "_Alignof(FooB)"); pFoo pf; _Static_assert(sizeof(*pf) == sizeof(struct S), "sizeof(*pf)"); _Static_assert(_Alignof(typeof(*pf)) == _Alignof(struct S), "_Alignof(*pf)"); typedef struct __attribute__((aligned(16))) { int x, y[7]; } Baz, *pBaz, BazB; _Static_assert(sizeof(Baz) == sizeof(struct S), "sizeof(Baz)"); _Static_assert(sizeof(BazB) == sizeof(struct S), "sizeof(BazB)"); _Static_assert(_Alignof(Baz) == _Alignof(struct S), "_Alignof(Baz)"); _Static_assert(_Alignof(BazB) == _Alignof(struct S), "_Alignof(BazB)"); pBaz pb; _Static_assert(sizeof(*pb) == sizeof(struct S), "sizeof(*pb)"); _Static_assert(_Alignof(typeof(*pb)) == _Alignof(struct S), "_Alignof(*pb)"); typedef struct __attribute__((aligned(16))) { int x, y[7]; } *pTux; pTux pt; _Static_assert(sizeof(*pt) == sizeof(struct S), "sizeof(*pt)"); _Static_assert(_Alignof(typeof(*pt)) == _Alignof(struct S), "_Alignof(*pt)"); typedef struct __attribute__((aligned(16))) { int x, y[7]; } Qux; _Static_assert(sizeof(Qux) == sizeof(struct S), "sizeof(FooB)"); _Static_assert(_Alignof(Qux) == _Alignof(struct S), "_Alignof(FooB)"); struct Bar { struct S foo; }; _Static_assert(sizeof(struct Bar) == sizeof(struct S), "sizeof(Bar)"); _Static_assert(_Alignof(struct Bar) == _Alignof(struct S), "_Alignof(Bar)"); typedef struct __attribute__((aligned(16))) { int x, y[7]; } *pLux; pLux pl; _Static_assert(sizeof(*pl) == sizeof(struct S), "sizeof(*pl)"); _Static_assert(_Alignof(typeof(*pl)) == _Alignof(struct S), "_Alignof(*pl)"); typedef struct __attribute__((aligned(16))) { int x, y[7]; } ****pWux; pWux pw; _Static_assert(sizeof(****pw) == sizeof(struct S), "sizeof(****pw)"); _Static_assert(_Alignof(typeof(****pw)) == _Alignof(struct S), "_Alignof(****pw)"); struct __attribute__((aligned(16))) { int x, y[7]; } f; _Static_assert(sizeof(f) == sizeof(struct S), "sizeof(f)"); _Static_assert(_Alignof(typeof(f)) == _Alignof(struct S), "_Alignof(f)"); // Verify shadowing works { typedef struct __attribute__((aligned(32))) S { int x, y[15]; } S; _Static_assert(sizeof(struct S) == 64, "sizeof(S)"); _Static_assert(_Alignof(struct S) == 32, "_Alignof(S)"); typedef struct __attribute__((aligned(32))) Foo { int x, y[15]; } *pFoo, Foo, FooB; _Static_assert(sizeof(struct Foo) == sizeof(struct S), "sizeof(Foo)"); _Static_assert(_Alignof(struct Foo) == _Alignof(struct S), "_Alignof(Foo)"); _Static_assert(sizeof(Foo) == sizeof(struct S), "sizeof(Foo)"); _Static_assert(_Alignof(Foo) == _Alignof(struct S), "_Alignof(Foo)"); _Static_assert(sizeof(FooB) == sizeof(struct S), "sizeof(FooB)"); _Static_assert(_Alignof(FooB) == _Alignof(struct S), "_Alignof(FooB)"); pFoo pf; _Static_assert(sizeof(*pf) == sizeof(struct S), "sizeof(*pf)"); _Static_assert(_Alignof(typeof(*pf)) == _Alignof(struct S), "_Alignof(*pf)"); typedef struct __attribute__((aligned(32))) { int x, y[15]; } Baz, *pBaz, BazB; _Static_assert(sizeof(Baz) == sizeof(struct S), "sizeof(Baz)"); _Static_assert(sizeof(BazB) == sizeof(struct S), "sizeof(BazB)"); _Static_assert(_Alignof(Baz) == _Alignof(struct S), "_Alignof(Baz)"); _Static_assert(_Alignof(BazB) == _Alignof(struct S), "_Alignof(BazB)"); pBaz pb; _Static_assert(sizeof(*pb) == sizeof(struct S), "sizeof(*pb)"); _Static_assert(_Alignof(typeof(*pb)) == _Alignof(struct S), "_Alignof(*pb)"); typedef struct __attribute__((aligned(32))) { int x, y[15]; } *pTux; pTux pt; _Static_assert(sizeof(*pt) == sizeof(struct S), "sizeof(*pt)"); _Static_assert(_Alignof(typeof(*pt)) == _Alignof(struct S), "_Alignof(*pt)"); typedef struct __attribute__((aligned(32))) { int x, y[15]; } Qux; _Static_assert(sizeof(Qux) == sizeof(struct S), "sizeof(FooB)"); _Static_assert(_Alignof(Qux) == _Alignof(struct S), "_Alignof(FooB)"); struct Bar { struct S foo; }; _Static_assert(sizeof(struct Bar) == sizeof(struct S), "sizeof(Bar)"); _Static_assert(_Alignof(struct Bar) == _Alignof(struct S), "_Alignof(Bar)"); typedef struct __attribute__((aligned(32))) { int x, y[15]; } *pLux; pLux pl; _Static_assert(sizeof(*pl) == sizeof(struct S), "sizeof(*pl)"); _Static_assert(_Alignof(typeof(*pl)) == _Alignof(struct S), "_Alignof(*pl)"); typedef struct __attribute__((aligned(32))) { int x, y[15]; } ****pWux; pWux pw; _Static_assert(sizeof(****pw) == sizeof(struct S), "sizeof(****pw)"); _Static_assert(_Alignof(typeof(****pw)) == _Alignof(struct S), "_Alignof(****pw)"); struct __attribute__((aligned(32))) { int x, y[15]; } f; _Static_assert(sizeof(f) == sizeof(struct S), "sizeof(f)"); _Static_assert(_Alignof(typeof(f)) == _Alignof(struct S), "_Alignof(f)"); } } void globals(void){ _Static_assert(sizeof(struct S) == 8, "sizeof(S)"); _Static_assert(_Alignof(struct S) == 8, "_Alignof(S)"); _Static_assert(sizeof(struct Foo) == sizeof(struct S), "sizeof(Foo)"); _Static_assert(_Alignof(struct Foo) == _Alignof(struct S), "_Alignof(Foo)"); _Static_assert(sizeof(Foo) == sizeof(struct S), "sizeof(Foo)"); _Static_assert(_Alignof(Foo) == _Alignof(struct S), "_Alignof(Foo)"); _Static_assert(sizeof(FooB) == sizeof(struct S), "sizeof(FooB)"); _Static_assert(_Alignof(FooB) == _Alignof(struct S), "_Alignof(FooB)"); pFoo pf; _Static_assert(sizeof(*pf) == sizeof(struct S), "sizeof(*pf)"); _Static_assert(_Alignof(typeof(*pf)) == _Alignof(struct S), "_Alignof(*pf)"); _Static_assert(sizeof(Baz) == sizeof(struct S), "sizeof(Baz)"); _Static_assert(sizeof(BazB) == sizeof(struct S), "sizeof(BazB)"); _Static_assert(_Alignof(Baz) == _Alignof(struct S), "_Alignof(Baz)"); _Static_assert(_Alignof(BazB) == _Alignof(struct S), "_Alignof(BazB)"); pBaz pb; _Static_assert(sizeof(*pb) == sizeof(struct S), "sizeof(*pb)"); _Static_assert(_Alignof(typeof(*pb)) == _Alignof(struct S), "_Alignof(*pb)"); pTux pt; _Static_assert(sizeof(*pt) == sizeof(struct S), "sizeof(*pt)"); _Static_assert(_Alignof(typeof(*pt)) == _Alignof(struct S), "_Alignof(*pt)"); _Static_assert(sizeof(Qux) == sizeof(struct S), "sizeof(FooB)"); _Static_assert(_Alignof(Qux) == _Alignof(struct S), "_Alignof(FooB)"); _Static_assert(sizeof(struct Bar) == sizeof(struct S), "sizeof(Bar)"); _Static_assert(_Alignof(struct Bar) == _Alignof(struct S), "_Alignof(Bar)"); pLux pl; _Static_assert(sizeof(*pl) == sizeof(struct S), "sizeof(*pl)"); _Static_assert(_Alignof(typeof(*pl)) == _Alignof(struct S), "_Alignof(*pl)"); pWux pw; _Static_assert(sizeof(****pw) == sizeof(struct S), "sizeof(****pw)"); _Static_assert(_Alignof(typeof(****pw)) == _Alignof(struct S), "_Alignof(****pw)"); Foo foo = {1, 2, 3}; struct Foo foo2 = {1, 2, 3}; } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc9903.d0000644000175000017500000000073315205374125017633 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /// sss struct S9903X {} /// Ditto struct S9903Y {} /// ccc class C9903X {} /// Ditto class C9903Y {} /// uuu union U9903X {} /// Ditto union U9903Y {} /// iii interface I9903X {} /// Ditto interface I9903Y {} /// eee enum E9903X { a } /// Ditto enum E9903Y { a } /// enum { a9903, /// ea b9903, /// Ditto c9903, /// ec } ./ldc-1.42.0-src/tests/dmd/compilable/test9057.d0000644000175000017500000000044415205374125017700 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -Icompilable/extra-files // EXTRA_FILES: extra-files/imp9057.d extra-files/imp9057_2.d struct Bug9057(T) { T x; } void test9507() { import imp9057; Bug9057!(BugInt) xxx; } void test9507_2() { import imp9057_2; Bug9057!(BugInt) xxx; } ./ldc-1.42.0-src/tests/dmd/compilable/issue21726.d0000644000175000017500000000027415205374125020127 0ustar fabiofabio// EXTRA_SOURCES: protection/issue21726/typecons.d // EXTRA_FILES: protection/issue21726/format/package.d protection/issue21726/package.d // https://issues.dlang.org/show_bug.cgi?id=21726 ./ldc-1.42.0-src/tests/dmd/compilable/test21861.d0000644000175000017500000000161615205374125017757 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21861 int f() { @("S") struct S {} @("U") union U {} @("C") class C {} // OK <- CTFE fails on this: @("E") enum E { X } // OK <- CTFE fails on this: @("f") int f(int x) { return x + 2; } // OK <- CTFE fails on this: @(&f) int a; @(1) @(2) int b = 4, c; @(3) extern(C) int d = 3; enum uda1 = __traits(getAttributes, a); enum uda2 = __traits(getAttributes, b); enum uda3 = __traits(getAttributes, c); // These are to trigger a compiler assert if parser is updated in the future static assert(!__traits(compiles, mixin("{ @(1) { int x; int y; } }"))); static assert(!__traits(compiles, mixin("{ @(1): int x; int y; }"))); // 3+2 1 2 4 1 3 return uda1[0](3) + uda2[0] + uda2[1] + b + uda3[0] + d; } static assert(f() == 16); ./ldc-1.42.0-src/tests/dmd/compilable/test23509.i0000644000175000017500000000025615205374125017764 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23509 int max(int a, int b) { return ({int _a = (a), _b = (b); _a > _b ? _a : _b; }); } _Static_assert(max(3,4) == 4, "1"); ./ldc-1.42.0-src/tests/dmd/compilable/test16340.d0000644000175000017500000000030115205374125017741 0ustar fabiofabio// REQUIRED_ARGS: -w version(unittest) template symsToStrs(fields...) { static if (fields.length == 0) enum symsToStrs = ["hello"]; else enum symsToStrs = ["world"]; } ./ldc-1.42.0-src/tests/dmd/compilable/testheader3.d0000644000175000017500000000066315205374125020612 0ustar fabiofabio/* EXTRA_SOURCES: extra-files/header3.d REQUIRED_ARGS: -o- -unittest -H -Hf${RESULTS_DIR}/compilable/testheader3.di PERMUTE_ARGS: -d -dw OUTPUT_FILES: ${RESULTS_DIR}/compilable/testheader3.di TEST_OUTPUT: --- === ${RESULTS_DIR}/compilable/testheader3.di // D import file generated from 'compilable/extra-files/header3.d' auto elseifchain() { bool a, b, c; if (a) { } else if (b) { } else if (c) { } } --- */ void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test18645.d0000644000175000017500000000015015205374125017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=18645 immutable INIT = 42; enum A { x = INIT, y } ./ldc-1.42.0-src/tests/dmd/compilable/test24504.c0000644000175000017500000000020515205374125017744 0ustar fabiofabio// REQUIRED_ARGS: -g typedef enum { HasIntAndUIntValuesInt = 0, HasIntAndUIntValuesUInt = 0x80000000 } HasIntAndUIntValues; ./ldc-1.42.0-src/tests/dmd/compilable/testDIP37a.d0000644000175000017500000000030615205374125020220 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -Icompilable/extra-files // COMPILED_IMPORTS: extra-files/pkgDIP37/datetime/package.d // COMPILED_IMPORTS: extra-files/pkgDIP37/datetime/common.d void main() { } ./ldc-1.42.0-src/tests/dmd/compilable/test24390.d0000644000175000017500000000127615205374125017761 0ustar fabiofabio// PERMUTE_ARGS: -O -inline // EXTRA_SOURCES: imports/test24390a.d imports/test24390b.d static if (__traits(compiles, __vector(int[4])) && __traits(compiles, __vector(byte[16]))) { import imports.test24390a; void main() { __vector(int[4]) mmA ; __vector(int[4]) mmB ; auto mask = _mm_cmpestrm(mmA, mmB); } __vector(int[4]) _mm_cmpestrm(__vector(int[4]) mmA, __vector(int[4]) mmB) { __vector(int[4]) R; for (int pos ; pos < 16; ++pos) { byte charK = (cast(__vector(byte[16]))mmA).array[pos]; __vector(int[4]) eqMask = _mm_set1_epi8(charK); R = R & eqMask; } return R; } } ./ldc-1.42.0-src/tests/dmd/compilable/test23497.d0000644000175000017500000000031415205374125017760 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23497 class A {} A getA(T t) { return t.a; } struct T { A _a; void k() {} auto a() in { k(); } do { return _a; } } ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_enum.d0000644000175000017500000000653215205374125020362 0ustar fabiofabio/+ REQUIRED_ARGS: -HC -c -o- PERMUTE_ARGS: TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler #pragma once #include #include #include #include enum : int32_t { Anon = 10 }; enum : bool { Anon2 = true }; static const char* const Anon3 = "wow"; enum class Enum { One = 0, Two = 1, }; extern const Enum constEnum; enum class EnumDefaultType { One = 1, Two = 2, }; enum class EnumWithType : int8_t { One = 1, Two = 2, }; enum { AnonOne = 1, AnonTwo = 2, }; enum : int64_t { AnonWithTypeOne = 1LL, AnonWithTypeTwo = 2LL, }; namespace EnumWithStringType { static const char* const One = "1"; static const char* const Two = "2"; }; namespace EnumWStringType { static const char16_t* const One = u"1"; }; namespace EnumDStringType { static const char32_t* const One = U"1"; }; namespace EnumWithImplicitType { static const char* const One = "1"; static const char* const Two = "2"; }; namespace { static const char* const AnonWithStringOne = "1"; static const char* const AnonWithStringTwo = "2"; }; enum : int32_t { AnonMixedOne = 1 }; enum : int64_t { AnonMixedTwo = 2LL }; static const char* const AnonMixedA = "a"; enum class STC { a = 1, b = 2, }; static STC const STC_D = (STC)3; struct Foo final { int32_t i; Foo() : i() { } Foo(int32_t i) : i(i) {} }; namespace MyEnum { static Foo const A = Foo(42); static Foo const B = Foo(84); }; static /* MyEnum */ Foo const test = Foo(42); struct FooCpp final { int32_t i; FooCpp() : i() { } FooCpp(int32_t i) : i(i) {} }; namespace MyEnumCpp { static FooCpp const A = FooCpp(42); static FooCpp const B = FooCpp(84); }; static /* MyEnum */ Foo const testCpp = Foo(42); extern const bool e_b; enum class opaque; enum class typedOpaque : int64_t; --- +/ extern(C++): enum Anon = 10; extern(C++) enum Anon2 = true; extern(C++) enum Anon3 = "wow"; enum Enum { One, Two } extern(C++) __gshared const(Enum) constEnum; enum EnumDefaultType : int { One = 1, Two = 2 } enum EnumWithType : byte { One = 1, Two = 2 } enum { AnonOne = 1, AnonTwo = 2 } enum : long { AnonWithTypeOne = 1, AnonWithTypeTwo = 2 } enum EnumWithStringType : string { One = "1", Two = "2" } enum EnumWStringType : wstring { One = "1" } enum EnumDStringType : dstring { One = "1" } enum EnumWithImplicitType { One = "1", Two = "2" } enum : string { AnonWithStringOne = "1", AnonWithStringTwo = "2" } enum { AnonMixedOne = 1, long AnonMixedTwo = 2, string AnonMixedA = "a" } enum STC { a = 1, b = 2, } extern(C++) enum STC_D = STC.a | STC.b; struct Foo { int i; } enum MyEnum { A = Foo(42), B = Foo(84) } extern(C++) enum test = MyEnum.A; extern(C++) struct FooCpp { int i; } enum MyEnumCpp { A = FooCpp(42), B = FooCpp(84) } extern(C++) enum testCpp = MyEnum.A; // currently unsupported enums extern(C++) enum b = [1, 2, 3]; extern(C++) enum c = [2: 3]; extern(C) void foo(); extern(C++) enum d = &foo; __gshared immutable bool e_b; extern(C++) enum e = &e_b; enum opaque; enum typedOpaque : long; enum arrayOpaque : int[4]; // Cannot be exported to C++ extern(D) enum hidden_d = 42; // Linkage prevents being exported to C++ ./ldc-1.42.0-src/tests/dmd/compilable/test23913.d0000644000175000017500000000025315205374125017753 0ustar fabiofabio// EXTRA_FILES: imports/library.c // https://issues.dlang.org/show_bug.cgi?id=23913 import imports.library; alias x = __traits(getMember, imports.library, "SomeEnum"); ./ldc-1.42.0-src/tests/dmd/compilable/version_d_optimized.d0000644000175000017500000000032615205374125022447 0ustar fabiofabio/+ ARG_SETS: -version=Unoptimized ARG_SETS: -O +/ version (Unoptimized) { version (D_Optimized) static assert(0); } else { version (D_Optimized) { /* expected */ } else static assert(0); } ./ldc-1.42.0-src/tests/dmd/compilable/rdeps7016.d0000644000175000017500000000077415205374125020035 0ustar fabiofabio/* PERMUTE_ARGS: REQUIRED_ARGS: -deps -Icompilable/extra-files COMPILED_IMPORTS: extra-files/rdeps7016a.d extra-files/rdeps7016b.d TRANSFORM_OUTPUT: remove_lines("druntime") TEST_OUTPUT: --- depsImport rdeps7016 ($p:rdeps7016.d$) : private : rdeps7016a ($p:rdeps7016a.d$) depsImport rdeps7016a ($p:rdeps7016a.d$) : private : rdeps7016b ($p:rdeps7016b.d$) depsImport rdeps7016b ($p:rdeps7016b.d$) : private : rdeps7016 ($p:rdeps7016.d$) --- */ module rdeps7016; import rdeps7016a; void main() { f(); } ./ldc-1.42.0-src/tests/dmd/compilable/test16273.d0000644000175000017500000000034215205374125017753 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16273 class A() { alias MyD = D!(); } class B { void f() {} alias MyA = A!(); } class C : B { override void f() {} } class D() : A!() { void g() { new C; } } ./ldc-1.42.0-src/tests/dmd/compilable/test15565.d0000644000175000017500000000005315205374125017755 0ustar fabiofabioalias X2 = X; extern (C++, ns) struct X {} ./ldc-1.42.0-src/tests/dmd/compilable/test20406.d0000644000175000017500000000026415205374125017747 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20406 struct S { @disable this(); this(int) {} this(ref S other) {} } void foo(S s) {} void main() { S s = S(3); foo(s); } ./ldc-1.42.0-src/tests/dmd/compilable/test16570.d0000644000175000017500000000020115205374125017745 0ustar fabiofabiostatic immutable int _a = 0; enum Regression { a = _a, } static assert(is(typeof(Regression.a) == immutable(Regression))); ./ldc-1.42.0-src/tests/dmd/compilable/test22894.c0000644000175000017500000000025215205374125017760 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22894 struct S { struct S *s; int *first; int **last; }; struct S my_S = { &my_S, 0, &my_S.first }; ./ldc-1.42.0-src/tests/dmd/compilable/previewall.d0000644000175000017500000000035715205374125020551 0ustar fabiofabio// ARG_SETS: -preview=all // ARG_SETS: -transition=all // ARG_SETS: -revert=all // TRANSFORM_OUTPUT: remove_lines(druntime) import core.stdc.stdio; void main (string[] args) { if (args.length == 42) printf("Hello World\n"); } ./ldc-1.42.0-src/tests/dmd/compilable/ice1524.d0000644000175000017500000000112615205374125017446 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=1524 // ICE(constfold.c) on using "is" with strings in CTFE /* 1524 PATCH Assertion failure: '0' on line 863 in file 'constfold.c' constfold.c @@ -845,9 +845,9 @@ Loc loc = e1->loc; int cmp; - if (e1->op == TOKnull && e2->op == TOKnull) + if (e1->op == TOKnull || e2->op == TOKnull) { - cmp = 1; + cmp = (e1->op == TOKnull && e2->op == TOKnull) ? 1 : 0; } else if (e1->op == TOKsymoff && e2->op == TOKsymoff) { */ bool isNull(string str) { return str is null; } const bool test = isNull("hello!"); ./ldc-1.42.0-src/tests/dmd/compilable/ice13819.d0000644000175000017500000000012215205374125017533 0ustar fabiofabio// REQUIRED_ARGS: -O auto f (double a) { return a % 2 != 0; } void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test22988.d0000644000175000017500000000041415205374125017765 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22988 enum a1 = 0; enum b1 = a1 ? 1 << a1 - 1 : 0; enum l = 0; enum int[l] a2 = []; enum b2 = l ? a2[l - 1] : 0; enum a3 = 0 ? 1 << -1 : 0; enum int[0] a4 = []; enum b4 = 0 ? a4[0] : 0; enum b5 = false ? (1 << -1) : 0; ./ldc-1.42.0-src/tests/dmd/compilable/gccasm2.c0000644000175000017500000000073515205374125017715 0ustar fabiofabiovoid test1() { asm goto (""); asm inline (""); asm volatile (""); } void test2() { asm volatile goto (""); asm volatile inline (""); asm inline volatile (""); asm inline goto (""); asm goto volatile (""); asm goto inline (""); asm volatile inline goto (""); asm volatile goto inline (""); asm inline volatile goto (""); asm inline goto volatile (""); asm goto volatile inline (""); asm goto inline volatile (""); } ./ldc-1.42.0-src/tests/dmd/compilable/test20136.d0000644000175000017500000000046715205374125017754 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20136 class Context { size_t[const(Key)] aa; bool checkAll; } struct Key { Context context; int i; bool opEquals(ref const Key other) const { if(context.checkAll && i != other.i) return false; return true; } } ./ldc-1.42.0-src/tests/dmd/compilable/test21753.d0000644000175000017500000000057515205374125017762 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21753 struct Sample { int function() func1; int function() func2; } void noth(Sample smpl)() { static assert(smpl.func1() == 0); static assert(smpl.func2() == 1); } void main() { enum s = Sample( { return 0; }, { return 1; } ); static assert(s.func1() == 0); static assert(s.func2() == 1); noth!(s)(); } ./ldc-1.42.0-src/tests/dmd/compilable/pr9471.d0000644000175000017500000000034515205374125017342 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/pr9471a.d imports/pr9471b.d imports/pr9471c.d imports/pr9471d.d import imports.pr9471a; import imports.pr9471b; static assert (__traits(getVirtualIndex, ClassDeclaration.isBaseOf) == 7); ./ldc-1.42.0-src/tests/dmd/compilable/test20063.d0000644000175000017500000000076615205374125017755 0ustar fabiofabio// DISABLED: LDC // REQUIRED_ARGS: -verrors=simple /* TEST_OUTPUT: --- compilable/test20063.d(11): Deprecation: function `test20063.main.f!(delegate () pure nothrow @safe => new C).f` function requires a dual-context, which is deprecated compilable/test20063.d(20): instantiated from here: `f!(delegate () pure nothrow @safe => new C)` --- */ struct S { void f(alias fun)() {} } auto handleLazily(T)(lazy T expr) {} void main() { class C {} S().f!(() => new C()).handleLazily; } ./ldc-1.42.0-src/tests/dmd/compilable/test17782.d0000644000175000017500000000012515205374125017760 0ustar fabiofabiovoid main() { string str = q"_DLANG 123 _DLANG"; assert( str == "123\n" ); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc9.d0000644000175000017500000000111215205374125017367 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh // https://issues.dlang.org/show_bug.cgi?id=273 /// Template Documentation (OK) template Template(T) { } /// Function Documentation (Not included at all by DDoc) void Function(T)(T x) { } /// Class Documentation (OK) class Class(T) { } /// Struct Documentation struct Struct(T) { } /// Union Documentation union Union(T) { } /// Template documentation with anonymous enum template TemplateWithAnonEnum(T) { enum { TemplateWithAnonEnum = 1 } } ./ldc-1.42.0-src/tests/dmd/compilable/test18199.d0000644000175000017500000000323015205374125017763 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=18199 // // struct initializer cases // // original error report struct Bla { int delegate(int, int) fun; } Bla bla1 = Bla((int a, int b) { return a + b; }); Bla bla2 = {(int a, int b) { return a + b; }}; // yielded error // additional error report with memberName:expression syntax struct Foo { int function(int) bar; int function(int) bar2; } Foo foo = { bar : function(x) { return 2 * x; }, // yielded error bar2 : (x) => 2 * x, }; struct MyStruct { int function() f; int delegate() d; } // confirm that ambiguous cases assume struct initializer MyStruct ambiguous_1 = {}; MyStruct ambiguous_2 = { { return 1 + 1; } }; // statement-holding function literal variants not covered above static MyStruct function_and_delegate_keywords = { function () { return 1 + 1; }, delegate () { return 1 + 1; } }; // // function literal initializer cases // alias IntFun = int function(); alias VoidFun = void function(); IntFun colon_at_top_level = { return 1 + 1; }; IntFun block_statement_only_with_nested_statement = { if (true) { return 1 + 1; } }; struct SomeStruct {} // previously these cases were incorrectly parsed as struct initializer VoidFun[] no_semicolon_statements = [ { asm {} }, { class Foo {} }, { debug(foo) {} }, { enum Foo { A } }, { final switch(5) {} }, { if (true) {} }, { interface Foo {} }, { pragma(inline) {} }, { scope(exit) {} }, { struct Foo {} }, { synchronized {} }, { try {} finally {} }, { union Foo {} }, { version(foo) {} }, { while (false) {} }, { with (SomeStruct) {} }, ]; ./ldc-1.42.0-src/tests/dmd/compilable/testcstuff2.c0000644000175000017500000003642115205374125020653 0ustar fabiofabio// check bugs in the expression parser // DISABLED: LDC // unsupported initializer lists /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21931 typedef long int T21931a; typedef T21931a T21931b; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21933 struct S21933 { void *opaque; }; int test21933(struct S21933 *); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21934 typedef int T21934 asm("realtype"); int init21934 asm("realsym") = 1; int var21934 asm("realvsym"); int fun21934() asm("realfun"); void test21934() { typedef int asmreg; register asmreg r1 asm("r1"); // asm ignored by C compiler, should be disallowed? asmreg r2 asm("r2"); register asmreg r3 asm("r3") = 3; // asm ignored by C compiler, should be disallowed? asmreg r4 asm("r4") = 4; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21937 __attribute__(()) int test21937a(); int test21937b() __attribute__(( , nothrow, hot, aligned(2), )); int test21937c() __attribute__((nothrow , leaf)) __attribute__((noreturn)); __attribute__((noinline)) void test21937d() { typedef int attr_var_t; attr_var_t attr_local __attribute__((unused)); } __attribute__((aligned)) int test21937e; int test21937f __attribute__((aligned)); struct __attribute__((packed)) S21937a { __attribute__((deprecated("msg"))) char c; int i __attribute__((deprecated)); }; struct S21937b { __attribute__((deprecated("msg"))) char c; int i __attribute__((deprecated)); } __attribute__((packed)); enum __attribute__((aligned)) E21937a { E21937a_A, }; enum E21937b { E21937b_A, } __attribute__((aligned)); typedef int T21937a __attribute__((unused)); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21945 typedef struct { long var; } S21945; S21945 test21945a; typedef enum { E21945_member, } E21945; E21945 test21945b; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21948 void test21948() { typedef int myint; typedef struct { int f; } mystruct; myint var1; myint var2 = 12; mystruct var3; // Uncomment when bug fixed https://issues.dlang.org/show_bug.cgi?id=21979 //mystruct var4 = { 34 }; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21963 union U21963 { int iv; float fv; }; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21965 struct { int var; }; typedef struct { int var; }; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21967 const int test21967a(void); const int *test21967b(void); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21968 struct S21968 { struct inner *data[16]; }; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21970 extern int test21970a; extern char *test21970b; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=24447 extern int x = 3; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21973 struct S21973 { int field; struct { int nested; }; }; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21977 int test21977a; _Thread_local int test21977b; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21982 struct S21982 { int field; }; struct S21982 test21982; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21992 void test21992(int var) { var = (var) & 1234; var = (var) * 1234; var = (var) + 1234; var = (var) - 1234; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22028 struct S22028 { struct nested { int field; }; const int cfield; _Static_assert(1 == 1, "ok"); }; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22060 struct S22060; typedef struct S22060 T22060a; struct S22060; typedef struct S22060 T22060b; struct S22060; struct S22060 { int _flags; }; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22061 union S22061 { int field; }; typedef union S22061 S22061; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22063 typedef struct S22063_t { int field; } S22063; void test22063() { // BUG: no definition of struct //struct S22063_t v1 = { 0 }; // BUG: cannot implicitly cast from integer to pointer. struct S22063_t *v2 = (struct S22063_t *)0; S22063 v3 = { 0 }; S22063 *v4 = (S22063 *)0; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22066 void test22066() { int var = 0; (var)++; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22067 void test22067() { union U { int value; char *ptr; char array[4]; } var; union U *pvar = &var; var.value = 0xabcdef; var.array[0]++; (*var.ptr)--; ++(*pvar).value; --(*pvar).array[3]; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22073 struct S22073a { int field; }; struct S22073b { const char *field; }; _Static_assert((struct S22073a){6789}.field == 6789, "ok"); _Static_assert((struct S22073b){"zxcv"}.field[2] == 'c', "ok"); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22079 struct S22079 { int a, b, c; }; _Static_assert(sizeof(struct S22079){1,2,3} == sizeof(int)*3, "ok"); _Static_assert(sizeof(struct S22079){1,2,3}.a == sizeof(int), "ok"); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22080 int F22080(const char *); int test22080() { int (*fun)(const char *) = &F22080; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22086 typedef union U22086 U22086; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22088 void test22088() { int *p; int i; p = i; i = p; void *pv; p = pv; pv = p; long long ll; ll = i; i = ll; char c; c = i; i = c; float f; f = i; i = f; double d; d = i; i = d; long double ld; ld = i; i = ld; c = ld; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22102 void fun22102(int var); typedef int int22102; void test22102() { int22102(var); fun22102(var); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22103 void test22103a(char *const argv[restrict]); void test22103b(char *const argv[restrict 4]); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22106 typedef struct S22106 { int field; } S22106_t; struct T22106 { struct S22106 f1; S22106_t f2; }; void testS22106() { struct S22106 v1; S22106_t v2; } int S22106; // not a redeclaration of 'struct S22106' /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22160 typedef struct testcstuff2 testcstuff2; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22182 int test22182a(int x) { return (int)(x); } typedef struct S22182 { int x; } S22182; int test22182b(S22182* b) { return ((S22182*)(b))->x; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22196 __attribute__((static, unsigned, long, const, extern, register, typedef, short, inline, _Noreturn, volatile, signed, auto, restrict, _Complex, _Thread_local, int, char, float, double, void, _Bool, _Atomic)) int test22196(); _Atomic(_Bool) atomicbool; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22245 struct S22245 { int i; }; int test22245() { struct S22245 s; return sizeof(s.i); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22262 void test22262(unsigned char *buf) { if (buf == 0) return; if (0 == buf) return; if (buf == 1) return; if (2 == buf) return; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22264 typedef int T22264; unsigned long test22264(crc, buf, len) unsigned long crc; const T22264 *buf; T22264 len; { return len; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22274 void test22274(compr, comprLen, uncompr, uncomprLen) unsigned *compr, *uncompr; signed comprLen, uncomprLen; { } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22375 typedef struct S22375S { unsigned short a, b, c, d; } S22375; static const S22375 s22375[10] = { {0, 0, 0, 0}, {4, 4, 8, 4}, {4, 5, 16, 8}, {4, 6, 32, 32}, {4, 4, 16, 16}, {8, 16, 32, 32}, {8, 16, 128, 128}, {8, 32, 128, 256}, {32, 128, 258, 1024}, {32, 258, 258, 4096} }; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22399 struct S22399a { unsigned short f1; }; struct S22399b { const struct S22399a *f1; }; const struct S22399a C22399[1] = { {12} }; const struct S22399b C22399b = {C22399}; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22400 typedef struct S22400 { unsigned short f1; } S22400_t; struct S22400b { const S22400_t *f1; }; const S22400_t C22400[1] = { {12} }; const struct S22400b C22400b = {C22400}; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22402 typedef struct { short c; } S22402a; typedef struct { S22402a *a; S22402a b[1]; } S22402b; int test22402a(S22402a *a, S22402a b[1]) { return a - b; } int test22402b(S22402b *s) { return s->a - s->b; } int test22402c(S22402a *a) { S22402a b[1]; return a - b; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22403 extern unsigned test22403a(const char *p); void test22403() { test22403a(0); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22404 typedef enum { E22404_FLAG } E22404; int test22404a(E22404 e); int test22404() { test22404a(E22404_FLAG); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22405 struct S22405 { int const * p; int *q; }; void test22405(struct S22405 *s) { s->p = (const int *)(s->q); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22406 int test22406(int a) { switch (a) { case 1: return -1; case 2: return -2; case 3: return -3; } return 0; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22407 typedef int (*T22407) (int a); int test22407(int a); T22407 table22407[1] = { test22407 }; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22409 struct S22409; typedef struct S22409 { int f1; } S22409_t; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22411 extern char * const var22411[10]; void test22411() { char *cptr; int *iptr; float *fptr; struct { int f1; int f2; } *sptr; void (*fnptr)(void); cptr = var22411[0]; iptr = var22411[1]; fptr = var22411[2]; sptr = var22411[3]; fnptr = var22411[4]; iptr = cptr; fptr = sptr; fnptr = iptr; cptr = fptr; sptr = fnptr; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22413 int test22413(void) { char msg[] = "ok"; return msg[0] | msg[1]; } /***************************************************/ int test(char *dest) { int x; return dest == x; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22512 extern char *tzname[]; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22584 long test22584(long, long); long test22584(long a, long b) { return a + b; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22602 void test22602() { unsigned char *data; data = (void *)"\0\0\xff\xff"; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22401 struct S22401 { const int *p; }; const int c22401[1] = {0}; const struct S22401 d22401 = {c22401}; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22841 void test22841() { int v22841; { unsigned v22841; } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22961 int main(argc, argv) int argc; char **argv; { return 0; } // https://issues.dlang.org/show_bug.cgi?id=23018 int xs[1]; struct { int x; } s, *sp; int fn(void); int i; _Static_assert( sizeof (xs)[0] == sizeof(int), "" ); _Static_assert( sizeof (sp)->x == sizeof(int), "" ); _Static_assert( sizeof (s).x == sizeof(int), "" ); _Static_assert( sizeof (fn)() == sizeof(int), "" ); _Static_assert( sizeof (i)++ == sizeof(int), "" ); // https://issues.dlang.org/show_bug.cgi?id=23143 enum E1; enum E1 { m3, m4 = m3 }; typedef enum E2 T1; enum E2 { m1, m2 = m1 }; /************************************************************/ // https://issues.dlang.org/show_bug.cgi?id=23725 #define __fldcw(addr) asm volatile("fldcw %0" : : "m" (*(addr))) static __inline void __fnldcw(unsigned short _cw, unsigned short _newcw) { __fldcw(&_newcw); } void test23725() { __fnldcw(1, 2); } /************************************************************/ // https://issues.dlang.org/show_bug.cgi?id=24070 typedef struct Typ Typ; typedef struct Field Field; struct Typ { struct Field { } (*fields)[1]; }; static void parse() { Typ* ty; void* fields = &ty->fields; } /************************************************************/ // https://issues.dlang.org/show_bug.cgi?id=24071 typedef enum { DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SVIDEO = 1, DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL = 0x80000000, } DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY; /************************************************************/ // https://issues.dlang.org/show_bug.cgi?id=24580 int ioctl(int __fd, unsigned __request, ...) __attribute__((overloadable)) __attribute__((enable_if(1, ""))) asm("ioctl"); ./ldc-1.42.0-src/tests/dmd/compilable/cet_disabled.d0000644000175000017500000000013715205374125020775 0ustar fabiofabio// Test for Intel CET protection disabled static assert(__traits(getTargetInfo, "CET") == 0); ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_AliasDeclaration_98.d0000644000175000017500000000067015205374125023132 0ustar fabiofabio/* REQUIRED_ARGS: -HC=verbose -extern-std=c++98 -o- TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler v$n$ #pragma once #include #include #include #include template struct TS final { TS() { } }; // Ignored dtoh_AliasDeclaration_98.TSD because `using` declarations require C++ 11 --- */ extern(C++): struct TS(T, U) {} alias TSD = TS; ./ldc-1.42.0-src/tests/dmd/compilable/issue20599.d0000644000175000017500000000027615205374125020140 0ustar fabiofabioimport core.stdc.config; enum A : cpp_long; enum B : cpp_longlong; enum C : cpp_long { a,b,c }; enum D : cpp_longlong { a,b,c }; enum : cpp_long { a,b,c }; enum : cpp_longlong { d,e,f }; ./ldc-1.42.0-src/tests/dmd/compilable/test17419.d0000644000175000017500000000275415205374125017767 0ustar fabiofabio// REQUIRED_ARGS: -d // https://issues.dlang.org/show_bug.cgi?id=17419 extern (C) int fooc(); alias aliasc = fooc; static assert(__traits(getLinkage, fooc) == "C"); static assert(__traits(getLinkage, aliasc) == "C"); extern (D) int food(); extern (C++) int foocpp(); extern (Windows) int foow(); extern (Objective-C) int fooobjc(); extern (System) int foos(); static assert(__traits(getLinkage, food) == "D"); static assert(__traits(getLinkage, foocpp) == "C++"); static assert(__traits(getLinkage, foow) == "Windows"); static assert(__traits(getLinkage, fooobjc) == "Objective-C"); static assert(__traits(getLinkage, foos) == "System"); extern (C) int global; static assert(__traits(getLinkage, global) == "C"); static assert(__traits(getLinkage, typeof(fooc)) == "C"); static assert(__traits(getLinkage, typeof(&fooc)) == "C"); void bar() { void nested() { } static assert(__traits(getLinkage, typeof(&nested)) == "D"); } class FooD {} interface FooDInterface {} extern (C++) class FooCpp {} extern (C++) struct FooCppStruct {} extern (C++) interface FooCppInterface {} static assert(__traits(getLinkage, FooD) == "D"); static assert(__traits(getLinkage, FooDInterface) == "D"); static assert(__traits(getLinkage, FooCpp) == "C++"); static assert(__traits(getLinkage, FooCppStruct) == "C++"); static assert(__traits(getLinkage, FooCppInterface) == "C++"); version (D_ObjectiveC) { extern (Objective-C) interface FooObjC {} static assert(__traits(getLinkage, FooObjC) == "Objective-C"); } ./ldc-1.42.0-src/tests/dmd/compilable/test13226.d0000644000175000017500000000136315205374125017752 0ustar fabiofabio// REQUIRED_ARGS: -o- // EXTRA_FILES: imports/a13226.d // PERMUTE_ARGS: -version=bug import imports.a13226; class C { // class C member m is not accessible version(bug) mixin(t!(typeof(this), "f")); else {} version(bug) mixin(u!(typeof(this), "v")); else {} void f() {} int v; // here is ok version(bug) {} else mixin(t!(typeof(this), "f")); version(bug) {} else mixin(u!(typeof(this), "v")); } struct S { // struct S member m is not accessible version(bug) mixin(t!(typeof(this), "f")); else {} version(bug) mixin(u!(typeof(this), "v")); else {} void f() {} int v; // here is ok version(bug) {} else mixin(t!(typeof(this), "f")); version(bug) {} else mixin(u!(typeof(this), "v")); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc9497a.d0000644000175000017500000000036615205374125020006 0ustar fabiofabio// EXTRA_SOURCES: extra-files/ddoc9497a.ddoc // PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /** foo function. Args: $(XYZ arg1, arg2) */ void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_454.d0000644000175000017500000000012015205374125021063 0ustar fabiofabioimport std.file; void main() { auto a = dirEntries("","",SpanMode.depth); } ./ldc-1.42.0-src/tests/dmd/compilable/ice20092.d0000644000175000017500000000014515205374125017527 0ustar fabiofabiovoid foo() { (void[1]).init.front; } void front(T)(T[] a) { static assert(is(T == void)); } ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_461.d0000644000175000017500000000061015205374125021065 0ustar fabiofabioimport std.stdio; void foo(bool[] err = null) { if (err !is null) { if (err[0]) { writeln(err); } else { writeln("Nothing to do."); } } else { writeln("Null input."); } } void main() { foo(); bool[] err = [false, false, false]; foo(err); err[0] = true; foo(err); } ./ldc-1.42.0-src/tests/dmd/compilable/test11559upgradeoptlink.d0000644000175000017500000000025715205374125022733 0ustar fabiofabio// REQUIRED_ARGS: -g string gen() { string m; foreach(i; 0..4096) m ~= "mixin(\"assert(0);\n\n\n\n\");\n"; return m; } void main() { mixin(gen()); } ./ldc-1.42.0-src/tests/dmd/compilable/test23589.d0000644000175000017500000000073015205374125017764 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23589 struct TemplStr(string Description_) {} template A() { bool member; alias THIS = typeof(this); static THIS staticInstance; static asSize() { return staticInstance.member; } } template B() { enum cols = columns(); enum cols_two = cols; TemplStr!(cols_two) tstr; } struct S { mixin A; mixin B; static string columns() { auto dummy = &asSize; return "as"; } } ./ldc-1.42.0-src/tests/dmd/compilable/test12511.d0000644000175000017500000000024315205374125017742 0ustar fabiofabio// EXTRA_FILES: imports/a12511.d module test12511; import imports.a12511; public class B { static void bar() { A.foo(0); } } void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/ice13792.d0000644000175000017500000000007115205374125017536 0ustar fabiofabioenum E; void main() { E* p; // ICE in glue layer } ./ldc-1.42.0-src/tests/dmd/compilable/test23145.d0000644000175000017500000000074315205374125017754 0ustar fabiofabio/* REQUIRED_ARGS: -wi */ // https://issues.dlang.org/show_bug.cgi?id=23145 #line 100 class D { C c; } class C { D d; int x=3; this(int i) scope @safe @nogc; this(D d) @safe @nogc; } C foo(D d) @nogc @safe { scope e = new C(1); // ok scope c = new C(d); // obsolete return c.d.c; } C bax(D d) @safe { scope e = new C(1); // ok scope c = new C(d); // obsolete return c.d.c; } void inferred(D d) { scope c = new C(d); // ok } ./ldc-1.42.0-src/tests/dmd/compilable/test22952.d0000644000175000017500000000037315205374125017760 0ustar fabiofabio/* REQUIRED_ARGS: -Icompilable/imports -mv=lib=pkg22952 EXTRA_FILES: imports/pkg22952/package.d */ // Issue 22952 - Compiler fails to find package.d modules via -mv map // https://issues.dlang.org/show_bug.cgi?id=22952 module test22952; import lib; ./ldc-1.42.0-src/tests/dmd/compilable/test17793.d0000644000175000017500000000033515205374125017765 0ustar fabiofabio// LDC: don't enforce -mcpu // required_args: -mcpu=avx2 import core.simd; static if (__traits(compiles, double4)) { double4 foo(); void test(double[4]); void main() { test(foo().array); } } ./ldc-1.42.0-src/tests/dmd/compilable/test62.d0000644000175000017500000000015215205374125017517 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/test62a.d import imports.test62a; struct S { } void main() { } ./ldc-1.42.0-src/tests/dmd/compilable/test19585.d0000644000175000017500000000032015205374125017760 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19585 struct S19585 { M2 stdin; } mixin template Handle(T, T invalid_value = T.init) {} struct M1 { mixin Handle!(size_t); } struct M2 { mixin Handle!(M1); } ./ldc-1.42.0-src/tests/dmd/compilable/test10992.d0000644000175000017500000000026015205374125017754 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -unittest unittest { } unittest { } unittest { } void main() { static assert(__traits(getUnitTests, mixin(__MODULE__)).length == 3); } ./ldc-1.42.0-src/tests/dmd/compilable/shared.d0000644000175000017500000000503015205374125017636 0ustar fabiofabio/* REQUIRED_ARGS: -preview=nosharedaccess TEST_OUTPUT: --- pure nothrow @nogc ref @safe shared(C1)(return ref shared(C1) c) pure nothrow @nogc ref @safe shared(int)(return ref shared(C3) c) --- */ ref shared(int) f(return ref shared int y) { return y; } // https://issues.dlang.org/show_bug.cgi?id=20908 struct S { int i = 2; } union U { int i = 1; bool b; } void test20908() { // shared locals (or struct members) should be able to be initialised: shared int x; ref shared(int) fun() { static shared(int) val; // return by reference return val; } ref shared(int) fun2() { static shared(int)* val; // transfer pointer to reference return *val; } ref shared(int) fun3() { static shared(int)*** val; // Multiple indirections return ***val; } shared S s; shared U u; } // Simple tests for `DotVarExp` // A `DotVarExp` is `a.b`. If `a` is a `shared ref`, // it is of type `shared(T)*` (as opposed to `shared(T*)`). // We should allow arbitrarily nested `DotVarExp` as long // as no shared memory is read, as in the case above // (we're just offsetting a pointer). struct C1 { int value; } struct C2 { C1 c1; } struct C3 { C2 c1; C2 c2; } ref shared(int) test_dotvarexp_1(return ref shared C1 c) { return c.value; } shared(int)* test_dotvarexp_2(return ref shared C1 c) { return &c.value; } shared(C2)* test_dotvarexp_3(return ref shared C3 c) { return &c.c1; } shared(C2)* test_dotvarexp_4(return ref shared C3 c) { return &c.c2; } ref shared(int) test_dotvarexp_5(return ref shared C3 c) { return c.c1.c1.value; } ref shared(int) test_dotvarexp_5(return ref shared(C3)[] c) { return c[0].c1.c1.value; } // Test `auto` inference auto ref test_inference_1(return ref shared C1 c) { return c; } pragma(msg, typeof(test_inference_1)); auto ref test_inference_2(return ref shared C3 c) { return c.c2.c1.value; } pragma(msg, typeof(test_inference_2)); // https://issues.dlang.org/show_bug.cgi?id=21793 struct Child { this(int) shared {} } struct Parent { shared Child ch; this(int i) shared { ch = shared Child(i); } } // https://issues.dlang.org/show_bug.cgi?id=23732 class Class {} void main() { auto b = new shared Class(); } // https://issues.dlang.org/show_bug.cgi?id=23790 bool cas(shared bool*, bool, bool) { return true; } struct Argh { bool locked; void lock() shared { while(!cas(&locked, false, true)) {} } } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc13645.d0000644000175000017500000000032515205374125017706 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /** Documentation comment on module */ deprecated("msg") @(1) module ddoc13645; ./ldc-1.42.0-src/tests/dmd/compilable/ddoc5446.d0000644000175000017500000000200115205374125017617 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // EXTRA_FILES: ddoc5446a.d ddoc5446b.d // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc5446; import ddoc5446a; private import ddoc5446b; /** */ alias A_Foo This_Foo; /** */ alias A_Foo_Alias This_Foo_Alias; /** */ alias int This_Int; /** */ alias A_Enum This_Enum; /** */ deprecated alias ddoc5446b.A_Enum_New A_Enum_New; struct Nested { } /** */ struct Bar { /** */ alias A_Foo Bar_A_Foo; /** */ alias A_Foo_Alias Bar_A_Foo_Alias; /** */ alias A_Int Bar_A_Int; /** */ alias This_Foo Bar_This_Foo; /** */ alias This_Foo_Alias Bar_This_Foo_Alias; /** */ alias This_Int Bar_This_Int; /** */ alias Nested Nested_Alias; /** */ alias .Nested Fake_Nested; /** */ struct Nested { /** */ alias Bar Bar_Nested_Bar_Alias; /** */ alias .Bar Bar_Alias; /** */ struct Bar { } } } ./ldc-1.42.0-src/tests/dmd/compilable/warn3882.d0000644000175000017500000000455215205374125017674 0ustar fabiofabio// PERMUTE_ARGS: -w -wi -debug @safe pure nothrow void strictVoidReturn(T)(T x) {} @safe pure nothrow void nonstrictVoidReturn(T)(ref T x) {} void test3882() { int x = 3; strictVoidReturn(x); nonstrictVoidReturn(x); } /******************************************/ // https://issues.dlang.org/show_bug.cgi?id=12619 extern (C) @system nothrow pure void* memcpy(void* s1, const void* s2, size_t n); // -> weakly pure void test12619() pure { ubyte[10] a, b; debug memcpy(a.ptr, b.ptr, 5); // memcpy call should have side effect } /******************************************/ // https://issues.dlang.org/show_bug.cgi?id=12760 struct S12760(T) { T i; this(T j) inout {} } struct K12760 { S12760!int nullable; this(int) { nullable = 0; // weak purity } } /******************************************/ // https://issues.dlang.org/show_bug.cgi?id=12909 int f12909(immutable(int[])[int] aa) pure nothrow { //aa[0] = []; // fix for https://issues.dlang.org/show_bug.cgi?id=13701 return 0; } void test12909() { immutable(int[])[int] aa; f12909(aa); // from 12910 const(int[])[int] makeAA() { return null; } // to make r-value makeAA().rehash(); } /******************************************/ // https://issues.dlang.org/show_bug.cgi?id=13899 const struct Foo13899 { int opApply(immutable int delegate(const ref int) pure nothrow dg) pure nothrow { return 0; } } void test13899() { foreach (x; Foo13899()) { } } import core.checkedint; // check inlining of checkedint with -wi T testCheckedSigned(T)(T x, T y) { bool overflow; T z = adds(x, y, overflow); z = subs(z, x, overflow); z = muls(z, x, overflow); z = negs(z, overflow); return z; } T testCheckedUnsigned(T)(T x, T y) { bool overflow; T z = addu(x, y, overflow); z = subu(z, x, overflow); z = mulu(z, x, overflow); return z; } void testCkeckedInt() { assert(testCheckedSigned!int(3,4) == -12); assert(testCheckedSigned!long(3,4) == -12); static if (is(cent)) assert(testCheckedSigned!cent(3,4) == -12); bool overflow; assert(mulu(cast(long)3, cast(uint)4, overflow) == 12); assert(testCheckedUnsigned!uint(3,4) == 12); assert(testCheckedUnsigned!ulong(3,4) == 12); static if (is(ucent)) assert(testCheckedUnsigned!ucent(3,4) == 12); } ./ldc-1.42.0-src/tests/dmd/compilable/test18216.d0000644000175000017500000000135415205374125017756 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=18216 struct Node { mixin Type!(); Pointer left; } mixin template Type() { alias Base = typeof(this); static struct Proxy { struct Node { Base m_payload; } static immutable default_value = Base.init; // just remove this will work } alias pNode = shared(Proxy.Node)*; static struct Pointer { Base* _ptr; auto ptr() { return cast(pNode) _ptr; } void opAssign(ref Pointer other) {} // just remove this will work alias getThis this; // just remove this will work ref auto getThis() return { return ptr.m_payload; } } } ./ldc-1.42.0-src/tests/dmd/compilable/test15326.d0000644000175000017500000000051515205374125017753 0ustar fabiofabio// REQUIRED_ARGS: -w -c -unittest version (unittest) private struct _NestedSym_ { static if ((void*).sizeof == 8) { int pointersize = 64; } else { int pointersize = 32; } version (X86_64) { string arch = "X86_64"; } else { string arch = "Not 64"; } } ./ldc-1.42.0-src/tests/dmd/compilable/issue16020.d0000644000175000017500000000222415205374125020113 0ustar fabiofabio// function type aliases 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)); // type suffixes alias FT = const(int)*(); static assert(is(FT* == const(int)* function())); alias FT2 = int*[2]() pure; static assert(is(FT2* == int*[2] function() pure)); ./ldc-1.42.0-src/tests/dmd/compilable/test21659.d0000644000175000017500000000043615205374125017763 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21659 // Compiler-recognized ident enum __c_ulonglong : ulong; private union EndianSwapper(T) { T value; ubyte[T.sizeof] array; static assert(T.sizeof == ulong.sizeof); } void main () { EndianSwapper!(__c_ulonglong) val; } ./ldc-1.42.0-src/tests/dmd/compilable/issue21813a.d0000644000175000017500000000041415205374125020261 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21813 Target.OS defaultTargetOS() { return Target.OS.linux; } struct Target { enum OS { linux } OS os = defaultTargetOS(); void deinitialize() { this = this.init; } @property isPOSIX() scope @nogc { } } ./ldc-1.42.0-src/tests/dmd/compilable/test23306.d0000644000175000017500000000012215205374125017742 0ustar fabiofabioclass A { @disable new(); } void main() { scope A a = new A(); } ./ldc-1.42.0-src/tests/dmd/compilable/test23870.i0000644000175000017500000000010515205374125017756 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23870 void test() { \ } ./ldc-1.42.0-src/tests/dmd/compilable/test9276.d0000644000175000017500000000043515205374125017703 0ustar fabiofabio// EXTRA_FILES: imports/test9276decl.d imports/test9276expr.d imports/test9276hash.d imports/test9276sem.d imports/test9276type.d imports/test9276util.d imports/test9276visitors.d // EXTRA_SOURCES: imports/test9276parser.d // This is a dummy module for compilable test void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test22543.d0000644000175000017500000000022415205374125017747 0ustar fabiofabio// https://github.com/dlang/dmd/issues/22543 enum int[string] aa = [ "a": 42, ]; int i = aa["a"]; void foo() { static int j = aa["a"]; } ./ldc-1.42.0-src/tests/dmd/compilable/test24295.d0000644000175000017500000000024115205374125017754 0ustar fabiofabio// REQUIRED_ARGS: -betterC int f() { int[] overlaps = new int[1]; overlaps[0] = 3; return overlaps[0]; } enum res_f = f(); static assert(res_f == 3); ./ldc-1.42.0-src/tests/dmd/compilable/fix21684.d0000644000175000017500000000012515205374125017563 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21684 struct S { int[100_000] a; } ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_VarDeclaration.d0000644000175000017500000000331015205374125022303 0ustar fabiofabio/* REQUIRED_ARGS: -HC -c -o- PERMUTE_ARGS: TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler #pragma once #include #include #include #include #ifdef CUSTOM_D_ARRAY_TYPE #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE #else /// Represents a D [] array template struct _d_dynamicArray final { size_t length; T *ptr; _d_dynamicArray() : length(0), ptr(NULL) { } _d_dynamicArray(size_t length_in, T *ptr_in) : length(length_in), ptr(ptr_in) { } T& operator[](const size_t idx) { assert(idx < length); return ptr[idx]; } const T& operator[](const size_t idx) const { assert(idx < length); return ptr[idx]; } }; #endif #if !defined(_d_real) #define _d_real long double #endif extern "C" int32_t z; extern int32_t t; struct S; struct S2; class C2; union U; union U2; extern "C" size_t v; extern nullptr_t typeof_null; extern nullptr_t inferred_null; extern int32_t i; extern _d_real r; extern int32_t si[4$?:32=u|64=LLU$]; extern const _d_dynamicArray< const int32_t > di; extern void* ii; extern const int32_t* const pi; extern int16_t(*func)(float , bool , ...); --- */ int x = 42; extern int y; extern (C) int z; extern (C++) __gshared int t; extern (C) struct S; extern (C++) struct S2; extern (C) class C; extern (C++) class C2; extern (C) union U; extern (C++) union U2; extern (C) size_t v; extern (C++) __gshared typeof(null) typeof_null = null; extern (C++) __gshared inferred_null = null; extern(C++): __gshared { int i; real r; int[4] si; const int[] di; int[int] ii; const int* pi; short function(float, bool, ...) func; } ./ldc-1.42.0-src/tests/dmd/compilable/ccompile.d0000644000175000017500000000121315205374125020162 0ustar fabiofabio /* REQUIRED_ARGS: -O */ // Adapted from DMC++ test file test3/ccompile.c struct HDS { char state; uint done; uint retry; uint[15] tests; } void funchds(char *p_adults) { int cupx, chemx; HDS *p_cup; for (cupx = 1, p_cup = null; cupx <= 48 ; cupx ++, p_cup ++) { for (chemx = 0; chemx < 15 ; chemx++) { if (p_cup.done) { if (p_cup.tests [chemx]) { *p_adults++ = 3; } if (p_cup.done && (p_cup.tests [chemx])) { *p_adults++ = 4; } } } } } ./ldc-1.42.0-src/tests/dmd/compilable/test8922c.d0000644000175000017500000000051515205374125020042 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/bug8922.d static import imports.bug8922; void test() { static assert(!__traits(compiles, __traits(parent, imports))); static assert(!__traits(compiles, __traits(parent, bug8922))); enum x = __traits(parent, imports.bug8922).stringof; static assert(x == "package imports"); } ./ldc-1.42.0-src/tests/dmd/compilable/mixin.d0000644000175000017500000000102215205374125017511 0ustar fabiofabio/* REQUIRED_ARGS: -mixin=${RESULTS_DIR}/runnable/mixin.mixin -o- OUTPUT_FILES: ${RESULTS_DIR}/runnable/mixin.mixin TEST_OUTPUT: ---- === ${RESULTS_DIR}/runnable/mixin.mixin // expansion at compilable/mixin.d(14) int x = 123; int y; int z = x + y; ---- https://issues.dlang.org/show_bug.cgi?id=1870 https://issues.dlang.org/show_bug.cgi?id=12790 */ #line 1 string get() { return "int x =\n 123;\r\n" ~ q{ int y; int z = x + y;}; } void main() { mixin(get()); } ./ldc-1.42.0-src/tests/dmd/compilable/test17942.d0000644000175000017500000000035415205374125017762 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=17942 alias AliasSeq(TList...) = TList; void test() { enum A = AliasSeq!(1); static assert(A[0] == 1); static assert(B[0] == 2); } enum B = AliasSeq!(2); enum C = AliasSeq!(); ./ldc-1.42.0-src/tests/dmd/compilable/ddoc12706.d0000644000175000017500000000026515205374125017706 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /// void test()(string[] args) if (args[$]) { } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc11823.d0000644000175000017500000000040115205374125017675 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc11823; /// file function name is _file, arg defaults to __FILE__ but not __something__ void file(string arg) { } ./ldc-1.42.0-src/tests/dmd/compilable/test23951.d0000644000175000017500000000054515205374125017761 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23951 struct S { int x; } struct T { S a; alias a this; } struct U { T t; } static assert(__traits(hasMember, T, "x")); static assert(__traits(hasMember, T.init, "x")); static assert(__traits(hasMember, U.init.t, "x")); static assert(__traits(hasMember, U.t, "a")); static assert(__traits(hasMember, U.t, "x")); ./ldc-1.42.0-src/tests/dmd/compilable/ddoc10870.d0000644000175000017500000000025715205374125017707 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /// interface I { /// void f(); } ./ldc-1.42.0-src/tests/dmd/compilable/test19203.d0000644000175000017500000000103315205374125017745 0ustar fabiofabio//https://issues.dlang.org/show_bug.cgi?id=19203 struct BoolWithErr { bool b; string error; alias b this; } struct Foo { int popBack() { return 0; } } struct Bar {} template hasPopBack(T) { static if (!is(typeof(T.init.popBack))) enum hasPopBack = BoolWithErr(false, T.stringof~" does not have popBack"); else enum hasPopBack = BoolWithErr(true,""); } void test() { static assert( hasPopBack!Foo); static assert(!hasPopBack!Bar); static assert( hasPopBack!Foo && !hasPopBack!Bar); } ./ldc-1.42.0-src/tests/dmd/compilable/staticforeach.d0000644000175000017500000004422115205374125021214 0ustar fabiofabio// REQUIRED_ARGS: -o- // EXTRA_FILES: imports/imp12242a1.d imports/imp12242a2.d // PERMUTE_ARGS: /* TEST_OUTPUT: --- 9 8 7 6 5 4 3 2 1 0 S(1, 2, 3, [0, 1, 2]) x0: 1 x1: 2 x2: 3 a: [0, 1, 2] (int[], char[], bool[], Object[]) [0, 0] x0: int x1: double x2: char test(0)→ 0 test(1)→ 1 test(2)→ 2 test(3)→ 3 test(4)→ 4 test(5)→ 5 test(6)→ 6 test(7)→ 7 test(8)→ 8 test(9)→ 9 test(10)→ -1 test(11)→ -1 test(12)→ -1 test(13)→ -1 test(14)→ -1 1 [1, 2, 3] 2 [1, 2, 3] 3 [1, 2, 3] 0 1 1 2 2 3 1 3 4 object Tuple tuple main front popFront empty back popBack Iota iota map to text all any join S s Seq Overloads Parameters forward foo A B C D E Types Visitor testVisitor staticMap arrayOf StaticForeachLoopVariable StaticForeachScopeExit StaticForeachReverseHiding UnrolledForeachReverse StaticForeachReverse StaticForeachByAliasDefault NestedStaticForeach TestAliasOutsideFunctionScope OpApplyMultipleStaticForeach OpApplyMultipleStaticForeachLowered RangeStaticForeach OpApplySingleStaticForeach TypeStaticForeach AliasForeach EnumForeach TestUninterpretable SeqForeachConstant SeqForeachBreakContinue TestStaticForeach testtest fun testEmpty bug17660 breakContinueBan MixinTemplate testToStatement bug17688 T foo2 T2 TestStaticForeach2 issue22007 1 2 3 2 3 4 0 1 1 2 2 3 --- */ module staticforeach; struct Tuple(T...){ T expand; alias expand this; } auto tuple(T...)(T t){ return Tuple!T(t); } /+struct TupleStaticForeach{ // should work, but is not the fault of the static foreach implementation. //pragma(msg, [tuple(1,"2",'3'),tuple(2,"3",'4')].map!((x)=>x)); static foreach(a,b,c;[tuple(1,"2",'3'),tuple(2,"3",'4')].map!((x)=>x)){ pragma(msg,a," ",b," ",c); } }+/ void main(){ static foreach(a,b,c;[tuple(1,"2",'3'),tuple(2,"3",'4')].map!((x)=>x)){ pragma(msg, a," ",b," ",c); } static struct S{ // (aggregate scope, forward referencing possible) static assert(stripA("123")==1); static assert(stripA([1],2)==2); static foreach(i;0..2){ mixin(`import imports.imp12242a`~text(i+1)~`;`); static assert(stripA("123")==1); static assert(stripA([1],2)==2); } static assert(stripA("123")==1); static assert(stripA([1],2)==2); } static foreach(i;0..2){ // (function scope, no forward referencing) mixin(`import imports.imp12242a`~text(i+1)~`;`); static assert(stripA("123")==1); static if(i) static assert(stripA([1],2)==2); } static assert(stripA("123")==1); static assert(stripA([1],2)==2); } auto front(T)(T[] a){ return a[0]; } auto popFront(T)(ref T[] a){ a=a[1..$]; } auto empty(T)(T[] a){ return !a.length; } auto back(T)(T[] a){ return a[$-1]; } auto popBack(T)(ref T[] a){ a=a[0..$-1]; } struct Iota(T){ T s,e; @property bool empty(){ return s>=e; } @property T front(){ return s; } @property T back(){ return cast(T)(e-1); } void popFront(){ s++; } void popBack(){ e--; } } auto iota(T)(T s, T e){ return Iota!T(s,e); } template map(alias a){ struct Map(R){ R r; @property front(){ return a(r.front); } @property back(){ return a(r.back); } @property bool empty(){ return r.empty; } void popFront(){ r.popFront(); } void popBack(){ r.popBack(); } } auto map(R)(R r){ return Map!R(r); } } template to(T:string){ string to(S)(S x)if(is(S:int)||is(S:size_t)||is(S:char)){ static if(is(S==char)) return cast(string)[x]; if(x<0) return "-"~to(-1 * x); if(x==0) return "0"; return (x>=10?to(x/10):"")~cast(char)(x%10+'0'); } } auto text(T)(T arg){ return to!string(arg); }; template all(alias a){ bool all(R)(R r){ foreach(x;r) if(!a(x)) return false; return true; } } template any(alias a){ bool any(R)(R r){ foreach(x;r) if(a(x)) return true; return false; } } auto join(R)(R r,string sep=""){ string a; int first=0; foreach(x;r){ if(first++) a~=sep; a~=x; } return a; } static foreach_reverse(x;iota(0,10).map!(to!string)){ pragma(msg, x); } // create struct members iteratively struct S{ static foreach(i;a){ mixin("int x"~to!string(i)~";"); } immutable int[] a = [0,1,2]; } enum s=S(1,2,3); pragma(msg, s); // loop over struct members static foreach(member;__traits(allMembers,S)){ pragma(msg, member,": ",mixin("s."~member)); } // print prime numbers using overload sets as state variables. /+ static assert(is(typeof(bad57))); static assert(!is(typeof(bad53))); static foreach(x;iota(2,100)){ static foreach(y;iota(2,x)){ static if(!(x%y)){ mixin("void bad"~to!string(x)~"();"); } } static if(!is(typeof(mixin("bad"~to!string(x))))){ static assert(iota(2,x).all!(y=>!!(x%y))); pragma(msg, x); }else{ static assert(iota(2,x).any!(y=>!(x%y))); } } +/ alias Seq(T...)=T; alias Overloads(alias a) = Seq!(__traits(getOverloads, __traits(parent, a), __traits(identifier, a))); template Parameters(alias f){ static if(is(typeof(f) P == function)) alias Parameters=P; } template forward(alias a){ enum x=2; static foreach(f;Overloads!a){ auto ref forward(Parameters!f args){ return f(args); } } enum y=3; } int foo(int x){ return x; } string foo(string x){ return x; } static assert(forward!foo(2)==2 && forward!foo("hi") == "hi"); // simple boilerplate-free visitor pattern static foreach(char T;'A'..'F'){ mixin("class "~T~q{{ void accept(Visitor v){ return v.visit(this); } }}); } alias Types = Seq!(mixin("Seq!("~iota('A','F').map!(to!string).join(", ")~")")); abstract class Visitor{ static foreach(T;Types){ abstract void visit(T); } } string testVisitor(){ string r; void writeln(T...)(T args){ static foreach(x;args) r~=x; r~='\n'; } class Visitor: .Visitor{ static foreach(T;Types){ override void visit(T){ writeln("visited: ",T.stringof); } } } void main(){ auto v=new Visitor; static foreach(T;Types){ v.visit(new T); } } main(); return r; } static assert(testVisitor()=="visited: A visited: B visited: C visited: D visited: E "); // iterative computation over AliasSeq: template staticMap(alias F,T...){ alias state0=Seq!(); static foreach(i,A;T){ mixin("alias state"~to!string(i+1)~" = Seq!(state"~to!string(i)~",F!A);"); } alias staticMap = Seq!(mixin("state"~to!string(T.length))); } alias arrayOf(T)=T[]; static assert(is(staticMap!(arrayOf,int,char,bool,Object)==Seq!(int[], char[], bool[], Object[]))); pragma(msg, staticMap!(arrayOf,int,char,bool,Object)); struct StaticForeachLoopVariable{ int x; static foreach(i;0..1){ mixin("enum x"~text(i)~" = i;"); } int y; static assert(__traits(allMembers, StaticForeachLoopVariable).length==3); static assert(!is(typeof(StaticForeachLoopVariable.i))); static assert(!is(typeof(__traits(getMember, StaticForeachLoopVariable, "i")))); } struct StaticForeachScopeExit{ static: int[] test(){ int[] r; scope(exit) r ~= 1234; { static foreach(i;0..5){ scope(exit) r ~= i; } r ~= 5; } return r; } static assert(test()==[5,4,3,2,1,0]); } struct StaticForeachReverseHiding{ static foreach(i;[0]){ enum i = 1; // TODO: disallow? static assert(i==0); } } struct UnrolledForeachReverse{ static: alias Seq(T...)=T; int[] test(){ int[] r; foreach_reverse(i;Seq!(0,1,2,3)){ r~=i; } return r; } static assert(test()==[3,2,1,0]); } struct StaticForeachReverse{ static: alias Seq(T...)=T; int[] test(){ int[] r; static foreach_reverse(i;0..4){ r~=i; } return r; } static assert(test()==[3,2,1,0]); int[] test2(){ int[] r; static foreach_reverse(i;[0,1,2,3]){ r~=i; } return r; } static assert(test2()==[3,2,1,0]); int[] test3(){ static struct S{ int opApplyReverse(scope int delegate(int) dg){ foreach_reverse(i;0..4) if(auto r=dg(i)) return r; return 0; } } int[] r; static foreach_reverse(i;S()){ r~=i; } return r; } static assert(test3()==[3,2,1,0]); int[] test4(){ int[] r; static foreach_reverse(i;Seq!(0,1,2,3)){ r~=i; } return r; } static assert(test()==[3,2,1,0]); } struct StaticForeachByAliasDefault{ static: alias Seq(T...)=T; int[] test(){ int a,b,c; static foreach(i,x;Seq!(a,b,c)) x=i; return [a,b,c]; } static assert(test()==[0,1,2]); int[] test2(){ int x=0; int foo(){ return ++x; } static foreach(y;Seq!foo) return [y,y,y]; } static assert(test2()==[1,2,3]); void test3(){ int x=0; int foo(){ return ++x; } static assert(!is(typeof({ static foreach(enum y;Seq!foo) return [y,y,y]; }))); } } struct NestedStaticForeach{ static: static foreach(i,name;["a"]){ static foreach(j,name2;["d"]){ mixin("enum int[] "~name~name2~"=[i, j];"); } } pragma(msg, ad); } struct TestAliasOutsideFunctionScope{ static: alias Seq(T...)=T; int a; static foreach(alias x;Seq!(a)){ } } struct OpApplyMultipleStaticForeach{ static: struct OpApply{ int opApply(scope int delegate(int,int) dg){ foreach(i;0..10) if(auto r=dg(i,i*i)) return r; return 0; } } static foreach(a,b;OpApply()){ mixin(`enum x`~cast(char)('0'+a)~"=b;"); } static foreach(i;0..10){ static assert(mixin(`x`~cast(char)('0'+i))==i*i); } } struct OpApplyMultipleStaticForeachLowered{ static: struct OpApply{ int opApply(scope int delegate(int,int) dg){ foreach(i;0..10) if(auto r=dg(i,i*i)) return r; return 0; } } static foreach(x;{ static struct S(T...){ this(T k){ this.x=k; } T x; } static s(T...)(T a){ return S!T(a); } typeof({ foreach(a,b;OpApply()){ return s(a,b); } assert(0);}())[] r; foreach(a,b;OpApply()) r~=s(a,b); return r; }()){ mixin(`enum x`~cast(char)('0'+x.x[0])~"=x.x[1];"); } static foreach(i;0..10){ static assert(mixin(`x`~cast(char)('0'+i))==i*i); } } struct RangeStaticForeach{ static: struct Range{ int x=0; this(int x){ this.x=x; } @property int front(){ return x; } void popFront(){ x += 2; } @property bool empty(){ return x>=10; } } static foreach(i;Range()){ mixin(`enum x`~cast(char)('0'+i)~"=i;"); } static foreach(i;0..5){ static assert(mixin(`x`~cast(char)('0'+2*i))==2*i); } static assert(!is(typeof({ struct S{ static foreach(i,k;Range()){} } }))); static foreach(k;Range()){} // ok } struct OpApplySingleStaticForeach{ static: struct OpApply{ int opApply(scope int delegate(int) dg){ foreach(i;0..10) if(auto r=dg(i)) return r; return 0; } } static foreach(b;OpApply()){ mixin(`enum x`~cast(char)('0'+b)~"=b;"); } static foreach(i;0..10){ static assert(mixin(`x`~cast(char)('0'+i))==i); } } struct TypeStaticForeach{ static: alias Seq(T...)=T; static foreach(i,alias T;Seq!(int,double,char)){ mixin(`T x`~cast(char)('0'+i)~";"); } pragma(msg, "x0: ",typeof(x0)); pragma(msg, "x1: ",typeof(x1)); pragma(msg, "x2: ",typeof(x2)); static assert(is(typeof(x0)==int)); static assert(is(typeof(x1)==double)); static assert(is(typeof(x2)==char)); } struct AliasForeach{ static: alias Seq(T...)=T; int[] test(){ int a,b,c; static foreach(x;Seq!(a,b,c,2)){ static if(is(typeof({x=2;}))) x=2; } int x,y,z; static foreach(alias k;Seq!(x,y,z,2)){ static if(is(typeof({k=2;}))) k=2; } int j,k,l; static assert(!is(typeof({ static foreach(ref x;Seq!(j,k,l,2)){ static if(is(typeof({x=2;}))) x=2; } }))); return [x,y,z]; } static assert(test()==[2,2,2]); } struct EnumForeach{ static: alias Seq(T...)=T; int a=1; int fun(){ return 1; } int gun(){ return 2; } int hun(){ return 3;} auto test(){ static foreach(i,enum x;Seq!(fun,gun,hun)){ static assert(i+1==x); } foreach(i,enum x;Seq!(fun,gun,hun)){ static assert(i+1==x); } } } struct TestUninterpretable{ static: alias Seq(T...)=T; auto test(){ int k; static assert(!is(typeof({ static foreach(x;[k]){} }))); static assert(!is(typeof({ foreach(enum x;[1,2,3]){} }))); static assert(!is(typeof({ foreach(alias x;[1,2,3]){} }))); foreach(enum x;Seq!(1,2,3)){} // ok foreach(alias x;Seq!(1,2,3)){} // ok static foreach(enum x;[1,2,3]){} // ok static foreach(alias x;[1,2,3]){} // ok static assert(!is(typeof({ static foreach(enum alias x;[1,2,3]){} }))); int x; static foreach(i;Seq!x){ } // ok static foreach(i,j;Seq!(1,2,x)){ } // ok static assert(!is(typeof({ static foreach(ref x;[1,2,3]){} }))); } } struct SeqForeachConstant{ static: alias Seq(T...)=T; static assert(!is(typeof({ foreach(x;Seq!1) x=2; }))); int test2(){ int r=0; foreach(x;Seq!(1,2,3)){ enum k=x; r+=k; } return r; } static assert(test2()==6); } struct SeqForeachBreakContinue{ static: alias Seq(T...)=T; int[] test(){ int[] r; foreach(i;Seq!(0,1,2,3,4,5)){ if(i==2) continue; if(i==4) break; r~=i; } return r; } static assert(test()==[0,1,3]); } struct TestStaticForeach{ static: int test(int x){ int r=0; label: switch(x){ static foreach(i;0..10){ case i: r=i; break label; // TODO: remove label when restriction is lifted } default: r=-1; break label; } return r; } static foreach(i;0..15){ pragma(msg, "test(",i,")→ ",test(i)); static assert(test(i)==(i<10?i:-1)); } enum x=[1,2,3]; static foreach(i;x){ mixin("enum x"~cast(char)('0'+i)~"="~cast(char)('0'+i)~";"); } static foreach(i;x){ pragma(msg, mixin("x"~cast(char)('0'+i))); pragma(msg,x); } int[] noBreakNoContinue(){ int[] r; static foreach(i;0..1){ // if(i==3) continue; // TODO: error? // if(i==7) break; // TODO: error? r~=i; } return r; } mixin("enum k=3;"); } static foreach(i,j;[1,2,3]){ pragma(msg, int(i)," ",j); } void testtest(){ static foreach(i,v;[1,2,3]){ pragma(msg, int(i)," ",v); static assert(i+1 == v); } } static foreach(i;Seq!(1,2,3,4,int)){ static if(!is(i) && i!=2){ pragma(msg, i); } } int fun(int x){ int r=0; label: switch(x){ static foreach(i;Seq!(0,1,2,3,4,5,6)){ static if (i < 5) case i: r=i; break label; // TODO: remove label when restriction is lifted } default: r=-1; break label; } return r; } static foreach(i;0..10) static assert(fun(i)==(i<5?i:-1)); static foreach(i;0..0) { } void testEmpty(){ static foreach(i;0..0) { } } auto bug17660(){ int x; static foreach (i; 0 .. 1) { return 3; } return x; } static assert(bug17660()==3); int breakContinueBan(){ static assert(!is(typeof({ for(;;){ static foreach(i;0..1){ break; } } }))); static assert(!is(typeof({ for(;;){ static foreach(i;0..1){ continue; } } }))); Louter1: for(;;){ static foreach(i;0..1){ break Louter1; } } Louter2: foreach(i;0..10){ static foreach(j;0..1){ continue Louter2; } return 0; } static foreach(i;0..1){ for(;;){ break; } // ok } return 1; } static assert(breakContinueBan()==1); mixin template MixinTemplate(){ static foreach(i;0..2){ mixin(`enum x`~cast(char)('0'+i)~"=i;"); } static foreach(i;[0,1]){ mixin(`enum y`~cast(char)('0'+i)~"=i;"); } } void testToStatement(){ mixin MixinTemplate; static assert(x0==0 && x1==1); static assert(y0==0 && y1==1); } void bug17688(){ final switch(1) static foreach(x;0..1){ int y=3; case 1: return; } static assert(!is(typeof(y))); } struct T{ enum n = 1; } T foo(T v)@nogc{ static foreach(x;0..v.n){ } return T.init; } T foo2(T v)@nogc{ static foreach(_;0..typeof(return).n){ } return T.init; } //https://issues.dlang.org/show_bug.cgi?id=18698 static foreach(m; __traits(allMembers, staticforeach)) { pragma(msg, m); } //https://issues.dlang.org/show_bug.cgi?id=20072 struct T2{ static foreach(i;0..1) struct S{} } static assert(is(__traits(parent,T2.S)==T2)); struct TestStaticForeach2 { static: // StringExp char[] test(string str)() { char[] s; static foreach (c; str) { s ~= c; } return s; } static assert(test!"tёstñ" == ['t', '\xd1', '\x91', 's', 't', '\xc3', '\xb1']); static foreach (c; "") { static assert(0); } // NullExp enum int[] a = null; static foreach (c; a) { static assert(0); } } //https://issues.dlang.org/show_bug.cgi?id=22007 void issue22007() { immutable int[32] array = 1; foreach (size_t a, int b; array) {} static foreach (size_t a, int b; array) { } } ./ldc-1.42.0-src/tests/dmd/compilable/test19656.d0000644000175000017500000000035715205374125017771 0ustar fabiofabio/* PERMUTE_ARGS: EXTRA_FILES: imports/test19656a.d imports/test19656b.d imports/test19656c.d */ import imports.test19656a; import imports.test19656c: Thud; class Foo { Foo[Foo] _map; void func (Thud ) { } void thunk () { } } ./ldc-1.42.0-src/tests/dmd/compilable/test15618.d0000644000175000017500000000044415205374125017760 0ustar fabiofabioclass Base { ~this() {} size_t x = 4; } interface Interface { int Method(); } class Derived : Base, Interface { size_t y = 5; int Method() { return 3; } } static assert(Derived.x.offsetof == (void*).sizeof * 2); static assert(Derived.y.offsetof == (void*).sizeof * 4); ./ldc-1.42.0-src/tests/dmd/compilable/ice11906.d0000644000175000017500000000034515205374125017535 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: nothrow /*extern(Windows) */export int GetModuleHandleA(const char* lpModuleName); void main() { /*extern(Windows) */int function(const char*) f; assert(f != &GetModuleHandleA); } ./ldc-1.42.0-src/tests/dmd/compilable/test4003.d0000644000175000017500000000023615205374125017661 0ustar fabiofabio// COMPILED_IMPORTS: imports/test4003a.d // EXTRA_FILES: imports/stdio4003.d imports/typecons4003.d // PERMUTE_ARGS: import imports.stdio4003; void main(){} ./ldc-1.42.0-src/tests/dmd/compilable/test16037.d0000644000175000017500000000055615205374125017760 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 */ // https://issues.dlang.org/show_bug.cgi?id=16037 @safe: void testXXX () @nogc { Object o; scope bool delegate (Object) alwaysFalse = (Object y) { return false; }; scope c1 = o !is null ? (Object y) { return o is y; } : alwaysFalse; } auto f() @nogc { int a; void g(){ a=1; } scope h=&g; h(); } ./ldc-1.42.0-src/tests/dmd/compilable/test21432.d0000644000175000017500000000076715205374125017757 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21432 auto issue21432() { enum int[] a = []; return a; } enum test21432a = issue21432; /////////////////////// double issue21432b(double r) { enum double[4] poly = [ 0x1.ffffffffffdbdp-2, 0x1.555555555543cp-3, 0x1.55555cf172b91p-5, 0x1.1111167a4d017p-7, ]; immutable r2 = r * r; return r + r2 * (poly[0] + r * poly[1]) + r2 * r2 * (poly[2] + r * poly[3]); } enum test21432b = issue21432b(-0x1p-1); ./ldc-1.42.0-src/tests/dmd/compilable/test23958.c0000644000175000017500000000020415205374125017757 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23958 #include int main() { char buf[8]; sprintf(buf, "%d", 123); } ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_functions.d0000644000175000017500000000724015205374125021423 0ustar fabiofabio/+ REQUIRED_ARGS: -HC -c -o- PERMUTE_ARGS: TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler #pragma once #include #include #include #include struct S final { int32_t i; int32_t get(int32_t , int32_t ); static int32_t get(); static const int32_t staticVar; void useVars(int32_t pi = i, int32_t psv = S::staticVar); struct Nested final { void useStaticVar(int32_t i = S::staticVar); Nested() { } }; S() : i() { } S(int32_t i) : i(i) {} }; extern "C" int32_t bar(int32_t x); extern "C" int32_t bar2(int32_t x); extern "C" int32_t bar4(int32_t x = 42); extern int32_t baz(int32_t x); extern int32_t baz2(int32_t x); extern int32_t baz4(int32_t x = 42); extern size_t baz5(size_t x = 42); extern size_t& bazRef(size_t& x); extern size_t bazOut(size_t& x); enum class E : int64_t { m = 1LL, }; enum class MS : uint8_t { dm = 0u, }; namespace MSN { static S const s = S(42); }; struct W1 final { MS ms; /* MSN */ S msn; W1() { } W1(MS ms, /* MSN */ S msn = S(42)) : ms(ms), msn(msn) {} }; struct W2 final { W1 w1; W2() : w1() { } W2(W1 w1) : w1(w1) {} }; extern W2 w2; extern void enums(uint64_t e = $?:32=1LLU|64=static_cast(E::m)$, uint8_t e2 = static_cast(w2.w1.ms), S s = static_cast(w2.w1.msn)); extern S s; extern void aggregates(int32_t a = s.i, int32_t b = s.get(1, 2), int32_t c = S::get(), int32_t d = S::staticVar); struct S2 final { S s; struct S3 final { static int32_t i; S3() { } }; S2() : s() { } S2(S s) : s(s) {} }; extern S2 s2; extern void chains(int32_t a = s2.s.i, int32_t b = S2::S3::i); extern S* ptr; extern int32_t(*f)(int32_t ); extern void special(int32_t a = ptr->i, int32_t b = ptr->get(1, 2), int32_t j = (*f)(1)); extern void variadic(int32_t __param_0_, ...); --- +/ int foo(int x) { return x * 42; } extern (C) int fun(); extern (C++) int fun2(); extern (C) int bar(int x) { return x * 42; } extern (C) static int bar2(int x) { return x * 42; } extern (C) private int bar3(int x) { return x * 42; } extern (C) int bar4(int x = 42) { return x * 42; } extern (C++) int baz(int x) { return x * 42; } extern (C++) static int baz2(int x) { return x * 42; } extern (C++) private int baz3(int x) { return x * 42; } extern (C++) int baz4(int x = 42) { return x * 42; } extern (C++) size_t baz5(size_t x = 42) { return x * 42; } extern (C++) ref size_t bazRef(return ref size_t x) { return x; } extern (C++) size_t bazOut(out size_t x) { return x; } extern (C++): enum E : long { m = 1 } enum MS : ubyte { dm } enum MSN : S { s = S(42) } struct W1 { MS ms; MSN msn; } struct W2 { W1 w1; } __gshared W2 w2; void enums(ulong e = E.m, ubyte e2 = w2.w1.ms, S s = w2.w1.msn) {} struct S { int i; int get(int, int); static int get(); __gshared const int staticVar; void useVars(int pi = i, int psv = staticVar) {} struct Nested { void useStaticVar(int i = staticVar) {} } } __gshared S s; void aggregates(int a = s.i, int b = s.get(1, 2), int c = S.get(), int d = S.staticVar) {} struct S2 { S s; static struct S3 { __gshared int i = 3; } } __gshared S2 s2; void chains(int a = s2.s.i, int b = S2.S3.i) {} __gshared S* ptr; __gshared int function(int) f; void special(int a = ptr.i, int b = ptr.get(1, 2), int j = f(1)) {} import core.stdc.stdarg; void variadic(int, ...) {} ./ldc-1.42.0-src/tests/dmd/compilable/line.d0000644000175000017500000000130115205374125017314 0ustar fabiofabiomodule line; static assert(__LINE__ == 3); int #line 10 x; static assert(__LINE__ == 12); version(Windows) { static assert(__FILE__ == "compilable\\line.d"); static assert(__FILE_FULL_PATH__[1..3] == ":\\"); } else { static assert(__FILE__ == "compilable/line.d"); static assert(__FILE_FULL_PATH__[0] == '/'); } static assert(__FILE_FULL_PATH__[$-__FILE__.length..$] == __FILE__); #line 100 "newfile.d" static assert(__LINE__ == 101); static assert(__FILE__ == "newfile.d"); static assert(__FILE_FULL_PATH__[$ - 9 .. $] == "newfile.d"); # line 200 static assert(__LINE__ == 201); static assert(__FILE__ == "newfile.d"); static assert(__FILE_FULL_PATH__[$ - 9 .. $] == "newfile.d"); ./ldc-1.42.0-src/tests/dmd/compilable/issue21905.d0000644000175000017500000000036215205374125020124 0ustar fabiofabiomodule issue21905; struct Conv { StaticIterable b; alias b this; } struct StaticIterable { static Conv b; alias b this; } void each(ref StaticIterable r) { return ; } void main() { StaticIterable s; each(s); } ./ldc-1.42.0-src/tests/dmd/compilable/valist.c0000644000175000017500000000012615205374125017672 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21974 typedef __builtin_va_list va_list; ./ldc-1.42.0-src/tests/dmd/compilable/cpp_abi_tag_unused.d0000644000175000017500000000046515205374125022212 0ustar fabiofabio/* DISABLED: win32 win64 REQUIRED_ARGS: -extern-std=c++11 */ #line 100 // Make sure that bad things don't happen if the user isn't using // `core.attribute`'s definition struct gnuAbiTag { string[] args; } extern(C++): @gnuAbiTag(["42"]) struct A {} __gshared A a; static assert(a.mangleof == "a"); ./ldc-1.42.0-src/tests/dmd/compilable/test12567b.d0000644000175000017500000000013415205374125020116 0ustar fabiofabio// REQUIRED_ARGS: // PERMUTE_ARGS: deprecated("message") module test12567b; void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test9435.d0000644000175000017500000000036615205374125017703 0ustar fabiofabio// EXTRA_FILES: test9434.d import test9434;//expression; enum TokenType { Dot } template Tok(string type) { enum Tok = TokenType.Dot; } template Semantic(T) { invariant(){} } template Semantic(T) if (is(T == BinaryExp!(Tok!"."))) { } ./ldc-1.42.0-src/tests/dmd/compilable/testdip1008.d0000644000175000017500000000076515205374125020367 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -preview=dip1008 int bar() { try { throw new Exception("message"); } catch (Exception e) { return 7; } } void throwQualifiers() @safe @nogc pure { throw new Exception("baz"); } bool testThrowQualifiers() { try { throwQualifiers(); } catch (Exception e) { return true; } return false; } void foo() { enum r = bar(); static assert(r == 7); static assert(testThrowQualifiers()); } ./ldc-1.42.0-src/tests/dmd/compilable/test21975.d0000644000175000017500000000037615205374125017767 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21975 struct Outer(T) { Inner!T inner; alias inner this; } struct Inner(T) { T t; } static assert(is(Outer!int : Inner!int)); // ok static assert(is(Outer!int : Inner!T, T)); // needs to compile ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_extern_type.d0000644000175000017500000000533115205374125021760 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=21219 REQUIRED_ARGS: -o- -HC TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler #pragma once #include #include #include #include #ifdef CUSTOM_D_ARRAY_TYPE #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE #else /// Represents a D [] array template struct _d_dynamicArray final { size_t length; T *ptr; _d_dynamicArray() : length(0), ptr(NULL) { } _d_dynamicArray(size_t length_in, T *ptr_in) : length(length_in), ptr(ptr_in) { } T& operator[](const size_t idx) { assert(idx < length); return ptr[idx]; } const T& operator[](const size_t idx) const { assert(idx < length); return ptr[idx]; } }; #endif #if !defined(_d_real) #define _d_real long double #endif class ClassFromStruct final { public: void foo(); ClassFromStruct() { } }; class ClassFromClass { public: virtual void foo(); }; struct StructFromStruct final { void foo(); StructFromStruct() { } }; struct StructFromClass { virtual void foo(); }; struct Floats final { float f; double d; _d_real r; double nan; double inf; double nInf; Floats() : f(1.23F), d(4.56), r(7.89L), nan(NAN), inf(INFINITY), nInf(-INFINITY) { } Floats(float f, double d = 4.56, _d_real r = 7.89L, double nan = NAN, double inf = INFINITY, double nInf = -INFINITY) : f(f), d(d), r(r), nan(nan), inf(inf), nInf(nInf) {} }; struct Null final { _d_dynamicArray< const char > null_; Null() : null_() { } Null(_d_dynamicArray< const char > null_) : null_(null_) {} }; struct Wrapper final { Null n1; Null n2; Wrapper() : n1(Null({ 5, "Hello" })), n2(Null({})) { } Wrapper(Null n1, Null n2 = Null({})) : n1(n1), n2(n2) {} }; extern const _d_dynamicArray< const char > helloWorld; --- */ extern (C++, class) struct ClassFromStruct { void foo() {} } extern (C++, class) class ClassFromClass { void foo() {} } extern (C++, struct) struct StructFromStruct { void foo() {} } extern (C++, struct) class StructFromClass { void foo() {} } extern(C++) struct Floats { float f = 1.23f; double d = 4.56; real r = 7.89L; double nan = double.nan; double inf = double.infinity; double nInf = -double.infinity; } extern (C++) struct Null { string null_ = null; } extern (C++) struct Wrapper { Null n1 = Null("Hello"); Null n2 = Null(null); } extern(C++) __gshared immutable string helloWorld = `"Hello\World!"`; ./ldc-1.42.0-src/tests/dmd/compilable/test23029.c0000644000175000017500000000034115205374125017746 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=23029 */ void print_const(const char*); void print(char*); int main(){ (void)_Generic("", char*: print, const char*: print_const )("hello"); } ./ldc-1.42.0-src/tests/dmd/compilable/dip22d.d0000644000175000017500000000030115205374125017450 0ustar fabiofabio// REQUIRED_ARGS: // EXTRA_FILES: imports/dip22d.d imports/dip22e.d // https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP22.md import imports.dip22d; import imports.dip22e; Foo foo; ./ldc-1.42.0-src/tests/dmd/compilable/test19540.d0000644000175000017500000000010315205374125017746 0ustar fabiofabioalias inst = templ!(); template templ(T = typeof(new class {})) {} ./ldc-1.42.0-src/tests/dmd/compilable/test23066.c0000644000175000017500000000036315205374125017753 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=23058 */ char s1[5] = "hello"; char s2[6] = "hello"; char s3[7] = "hello"; void test() { char s1[5] = "hello"; char s2[6] = "hello"; char s3[7] = "hello"; char s4[50] = "hello"; } ./ldc-1.42.0-src/tests/dmd/compilable/header18364.d0000644000175000017500000000101215205374125020222 0ustar fabiofabio/* REQUIRED_ARGS: -o- -Hf${RESULTS_DIR}/compilable/header18364.di PERMUTE_ARGS: OUTPUT_FILES: ${RESULTS_DIR}/compilable/header18364.di TEST_OUTPUT: --- === ${RESULTS_DIR}/compilable/header18364.di // D import file generated from 'compilable/header18364.d' module foo.bar.ba; nothrow pure @nogc @safe package(foo) { void foo(); nothrow pure @nogc @safe package(foo.bar) void foo2(); } --- */ module foo.bar.ba; @safe pure nothrow @nogc package(foo): void foo(); @safe pure nothrow @nogc package(foo.bar): void foo2(); ./ldc-1.42.0-src/tests/dmd/compilable/test23789.d0000644000175000017500000000050715205374125017770 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23789 // EXTRA_FILES: imports/c23789.i import imports.c23789; static assert(M128A.alignof == 64); static assert(_M128B.alignof == 32); static assert(M128B.alignof == 32); static assert(N128A.alignof == 64); static assert(_N128B.alignof == 32); static assert(N128B.alignof == 32); ./ldc-1.42.0-src/tests/dmd/compilable/ddocunittest.d0000644000175000017500000001762615205374125021117 0ustar fabiofabio// PERMUTE_ARGS: -unittest // REQUIRED_ARGS: -D -w -o- -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddocunittest; /* Insert test-cases for documented unittests feature here. */ /// foo function - 1 example int foo(int a, int b) { return a + b; } /// unittest { assert(foo(1, 1) == 2); } /// bar function - 1 example bool bar() { return true; } /// unittest { // documented assert(bar()); } /// placeholder unittest { } /// doo function - no examples void doo() { } /// private unittest { // undocumented doo(); } unittest { // undocumented doo(); } /** add function - 3 examples Examples: ---- assert(add(1, 1) == 2); ---- */ int add(int a, int b) { return a + b; } /// unittest { // documented assert(add(3, 3) == 6); assert(add(4, 4) == 8); } unittest { // undocumented assert(add(2, 2) + add(2, 2) == 8); } /// unittest { // documented assert(add(5, 5) == 10); assert(add(6, 6) == 12); } /// class Foo immutable pure nothrow class Foo { int x; /// unittest { // another foo example Foo foo = new Foo; } } /// unittest { Foo foo = new Foo; } pure { const { immutable { /// some class - 1 example class SomeClass {} } } } /// unittest { SomeClass sc = new SomeClass; } /// Outer - 1 example class Outer { /// Inner static class Inner { } /// unittest { Inner inner = new Inner; } } /// unittest { Outer outer = new Outer; } /** foobar - no examples */ void foobar() { } unittest { foobar(); } /** func - 4 examples Examples: --- foo(1); --- Examples: --- foo(2); --- */ void foo(int x) { } /// unittest { foo(2); } /// unittest { foo(4); } // ------------------------------------ // insert import declaration between documented function and unittests /// void fooImport() {} import core.stdc.stdio; /// test unittest { fooImport(); } /// void fooStaticImport() {} static import core.stdc.stdlib; /// test unittest { fooStaticImport(); } /// void fooSelectiveImport() {} import core.stdc.ctype : isalpha; /// test unittest { fooSelectiveImport(); } /// void fooRenamedImport() {} import io = core.stdc.stdio; /// test unittest { fooRenamedImport(); } /// This is a public import public import core.stdc.string; /// This is a mutiple public import public import core.stdc.stdarg, core.stdc.stdlib; /// This is a public selective import public import core.stdc.string : memcpy; /// This is a public selective renamed import public import core.stdc.string : copy = memcpy; /// This is a public multiple selective import public import core.stdc.string : memcpy, memcmp; /// This is a public multiple selective renamed import public import core.stdc.string : copy = memcpy, compare = memcmp; /// This is a public renamed import public import str = core.stdc.string; // This is a public import without a DDoc comment. // It should not be emitted to the documentation file. public import core.stdc.stdlib; // ------------------------------------ // documented unittest after conditional declarations static if (true) void fooConditionalDecl1a() {} /** */ unittest { int x1a; } /// static if (true) { void fooConditionalDecl1b() {} /** */ } unittest { int x1b; } /// static if (false) void fooConditionalDecl2a() {} /** */ unittest { int x2a; } /// static if (false) { void fooConditionalDecl2b() {} /** */ } unittest { int x2b; } /// static if (true) { void fooConditionalDecl3a() {} /** */ } else { void barConditionalDecl3a() {} /** */ } unittest { int x3a; } /// static if (true) { void fooConditionalDecl3b() {} /** */ } else { void barConditionalDecl3b() {} /** */ } unittest { int x3b; } /// static if (false) void fooConditionalDecl4a() {} /** */ else void barConditionalDecl4a() {} /** */ unittest { int x4a; } /// static if (false) { void fooConditionalDecl4b() {} /** */ } else { void barConditionalDecl4b() {} /** */ } unittest { int x4b; } /// static if (true) {} else void barConditionalDecl5a() {} /** */ unittest { int x5a; } /// static if (true) {} else { void barConditionalDecl5b() {} /** */ } unittest { int x5b; } /// static if (false) {} else void barConditionalDecl6a() {} /** */ /// unittest { int x6a; } static if (false) {} else { void barConditionalDecl6b() {} /** */ } /// unittest { int x6b; } // ------------------------------------ // https://issues.dlang.org/show_bug.cgi?id=9474 /// void foo9474() { } version(none) unittest { } /// Example unittest { foo9474(); } /// doc void bar9474() { } version(none) unittest { } /// Example unittest { bar9474(); } /// struct S9474 { } /// unittest { S9474 s; } /// auto autovar9474 = 1; /// unittest { int v = autovar9474; } /// auto autofun9474() { return 1; } /// unittest { int n = autofun9474(); } /// template Template9474() { /// Shouldn't link following unittest to here void foo() {} } /// unittest { alias Template9474!() T; } // ------------------------------------ // https://issues.dlang.org/show_bug.cgi?id=9713 /// void fooNoDescription() {} /// unittest { fooNoDescription(); } /// unittest { if (true) {fooNoDescription(); } /* comment */ } // ------------------------------------ /// test for https://issues.dlang.org/show_bug.cgi?id=9757 void foo9757() {} /// ditto void bar9757() {} /// ditto void baz9757() {} /// unittest { foo9757(); bar9757(); } /// unittest { bar9757(); foo9757(); } /// with template functions auto redBlackTree(E)(E[] elems...) { return 1; } /// ditto auto redBlackTree(bool allowDuplicates, E)(E[] elems...) { return 2; } /// ditto auto redBlackTree(alias less, E)(E[] elems...) if (__traits(compiles, (E a, E b) => mixin(less))) { return 3; } /// unittest { auto rbt1 = redBlackTree(0, 1, 5, 7); auto rbt2 = redBlackTree!string("hello", "world"); auto rbt3 = redBlackTree!true(0, 1, 5, 7, 5); auto rbt4 = redBlackTree!"a > b"(0, 1, 5, 7); } // ------------------------------------ // https://issues.dlang.org/show_bug.cgi?id=9758 /// test void foo(){} /// unittest { } // ------------------------------------ // https://issues.dlang.org/show_bug.cgi?id=10519 /// bool balancedParens10519(string, char, char) { return true; } /// unittest { auto s = "1 + (2 * (3 + 1 / 2)"; assert(!balancedParens10519(s, '(', ')')); } // ------------------------------------ // https://issues.dlang.org/show_bug.cgi?id=12097 /// declaration struct S12097 { /// method void foo() {} } /// ditto void f12097() {} /// ddoc code 1 unittest { int a = 1; } /// ditto struct T12097(T) {} /// ddoc code 2 unittest { int[] arr; } // ------------------------------------ // https://issues.dlang.org/show_bug.cgi?id=14594 /******************* * testA */ void fun14594a()() {} /// unittest { fun14594a(); } /******************* * testB */ void fun14594b()() {} /// ditto void fun14594b(T)(T) {} /// unittest { fun14594b(); fun14594b(1); } /******************* * testC */ void fun14594c()() {} /// unittest { fun14594c(); fun14594c(1); } /// ditto void fun14594c(T)(T) {} /******************* * testD */ void fun14594d()() {} /// unittest { fun14594d(); } /// ditto void fun14594d(T)(T) {} /// unittest { fun14594d(1); } /******************* * testE */ template fun14594e() { /// concatenated doc-comment fun14594e void fun14594e() {} /// ignored-unittest fun14594e unittest { fun14594e(); } } /// doc-unittest fun14594e unittest { fun14594e(); } /******************* * testF */ template fun14594f() { /// concatenated doc-comment fun14594f void fun14594f() {} /// ignored-unittest fun14594f unittest { fun14594f(); } } /// ditto template fun14594f(T) { /// ignored doc-comment fun14594f void fun14594f(T) {} /// ignored-unittest fun14594f unittest { fun14594f(1); } } /// doc-unittest fun14594f unittest { fun14594f(); } // ------------------------------------ void main() { } ./ldc-1.42.0-src/tests/dmd/compilable/test18474.d0000644000175000017500000000015715205374125017764 0ustar fabiofabioshared struct A { this(this); } struct B { A a; } void main() { shared B b1; auto b2 = b1; } ./ldc-1.42.0-src/tests/dmd/compilable/interpret4.d0000644000175000017500000000201415205374125020467 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=11717 enum int[4] A = [1,2,3,4]; enum int[4] B = [1,2,3,4]; enum int[4] C = A[] + B[]; static assert(C == [2, 4, 6, 8]); enum int[2] D1 = A[1..3] * B[2..4]; static assert(D1 == [6, 12]); enum int[2] D2 = A[1..3] * 6; static assert(D2 == [12, 18]); enum int[2] D3 = 5 - A[1..3]; static assert(D3 == [3, 2]); enum int[2][2] D4 = [D1, D2] + [D2, D3]; static assert(D4 == [[18, 30], [15, 20]]); enum int[2][2] D5 = [[18, 30], [15, 20]] + [12, 18]; static assert(D5 == [[30, 48], [27, 38]]); import core.simd; static if (__traits(compiles, int4)) { enum int4 D = [1,2,3,4]; enum int4 E = [1,2,3,4]; enum int4 F = D * E; static assert(F.array == [1, 4, 9, 16]); } // https://github.com/dlang/dmd/issues/20114 int* find(int[] arr, int needle) { foreach(ref a; arr) if(a == needle) return &a; return null; } enum int[int] aa = [0: 0]; enum int[] da = [0, 1, 2]; static assert(0 in aa); static assert(&da[1]); static assert(find(da, 1)); static assert(!find(da, 3)); ./ldc-1.42.0-src/tests/dmd/compilable/testcstuff3.d0000644000175000017500000000065215205374125020652 0ustar fabiofabio// EXTRA_FILES: imports/cstuff3.c import imports.cstuff3; static assert(squared(4) == 16); /* test case for issue #21094 */ string enum_to_str(E)(E v) if (is(E == enum)) { final switch (v) with(E) { static foreach (m; __traits(allMembers, E)) { case mixin(m): return m; } } } void testEnumSwitch() { auto str = enum_to_str(UPNG_EOK); assert(str == "UPNG_EOK"); } ./ldc-1.42.0-src/tests/dmd/compilable/test10726.d0000644000175000017500000000205115205374125017747 0ustar fabiofabio// PERMUTE_ARGS: public struct CirBuff(T) { private T[] data; private size_t head = 0; private size_t size = 0; public size_t length() const { return size; } public bool opEquals(CirBuff!T d) @trusted { if (length != d.length) return false; for (size_t i=0; i!=size; ++i) { if (this.data[(this.head+i) % this.data.length] != d.data[(d.head + i) % d.data.length]) { return false; } } return true; } } class Once { Foo!Bar _bar; } class Bar { static Once _once; mixin(sync!(Once, "_once")); } class Foo(T = int) { CirBuff!T _buff; } template sync(T, string U = "this", size_t ITER = 0) { static if (ITER == __traits(derivedMembers, T).length) enum sync = ""; else { enum string mem = __traits(derivedMembers, T)[ITER]; enum string sync = "static if(! __traits(isVirtualMethod, " ~ U ~ "." ~ mem ~ ")) { }" ~ sync!(T, U, ITER+1); } } ./ldc-1.42.0-src/tests/dmd/compilable/test23534.d0000644000175000017500000000020715205374125017751 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23534 enum E { a = 1, b = 2 } // `E.a` is not 0 static assert(!__traits(isZeroInit, E)); ./ldc-1.42.0-src/tests/dmd/compilable/d_ident_c99.d0000644000175000017500000000014615205374125020465 0ustar fabiofabio// REQUIRED_ARGS: -identifiers=c99 // verify that the C99 identifier set is applied. int ªideµnt; ./ldc-1.42.0-src/tests/dmd/compilable/test12567e.d0000644000175000017500000000007615205374125020126 0ustar fabiofabio// REQUIRED_ARGS: -o- deprecated("a" ~ "b") module fail12567; ./ldc-1.42.0-src/tests/dmd/compilable/test15550.d0000644000175000017500000000041715205374125017753 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: struct Vector(T, int N) { void opDispatch(string, U)(U) { } void baz(string, U)(U) { } } static assert(!is(typeof(Vector!(int, 2)._isMatrix))); static assert(!is(typeof(Vector!(int, 2).baz!"_isMatrix"))); ./ldc-1.42.0-src/tests/dmd/compilable/test22228.d0000644000175000017500000000027715205374125017757 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22228 // Note: fixed by reverting pull #11545 auto f() { immutable int i; auto p = (() => &i)(); return 0; } enum ctfeInvocation = f; ./ldc-1.42.0-src/tests/dmd/compilable/b9490.d0000644000175000017500000000110315205374125017134 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=9490 class A { int[1] arr; this() { assert(arr.length); assert((arr).length); } } class C { struct Foo { int a; void funcToo(){} } Foo foo; auto get(){return foo;} void test() { // Error: need 'this' to access member a (foo).a = 1; (foo).funcToo(); (get()).a = 2; } } struct S { int i; } struct S1 { S s; } void f(int) { } void main() { S1 s1; f(s1.s.tupleof); // OK f((s1.s).tupleof); // Error: need 'this' to access member s } ./ldc-1.42.0-src/tests/dmd/compilable/test14317.d0000644000175000017500000000036315205374125017753 0ustar fabiofabio // REQUIRED_ARGS: -O -profile -inline struct Range { private string s; char charAt(int unused1) { return s[0]; } } bool count(Range* r, int* unused2) { *unused2 = 0; int unused3; char c = r.charAt(0); return true; } ./ldc-1.42.0-src/tests/dmd/compilable/test17791.d0000644000175000017500000000112515205374125017761 0ustar fabiofabio// REQUIRED_ARGS: -de deprecated("A deprecated class") { class DepClass { } } class NewClass { } void main() { // test that a symbol (which is not likely to be deprecated) // is not depercated static assert(!__traits(isDeprecated, int)); // check that a class marked deprecated "isDeprecated" static assert(__traits(isDeprecated, DepClass)); // check that a class not marked deprecated is not deprecated static assert(!__traits(isDeprecated, NewClass)); // Check for expressions (18617) static assert(__traits(isDeprecated, { scope foo = new DepClass; })); } ./ldc-1.42.0-src/tests/dmd/compilable/test22807.c0000644000175000017500000000042715205374125017756 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22807 struct OldFashionedHeader { int n; // number of entries in buff char buff[1]; }; int peek(OldFashionedHeader *head){ if(head->n < 2) return 0; return head->buff[1]; // do not give array bounds error } ./ldc-1.42.0-src/tests/dmd/compilable/test6319.d0000644000175000017500000000016415205374125017675 0ustar fabiofabio// REQUIRED_ARGS: -debug int x; void main() pure { debug { { x = 0; } } } ./ldc-1.42.0-src/tests/dmd/compilable/test19409.d0000644000175000017500000000025415205374125017761 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19409 module test.foo; static if (__traits(compiles, __traits(identifier, test.foo))) {} // fails else { static assert(0); } ./ldc-1.42.0-src/tests/dmd/compilable/test1537.d0000644000175000017500000000351515205374125017675 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=1537 void foo(char[] s) { int x = -1; while (s.length) { char c = s[0]; if (c == '}') break; assert (c >= '0' && c <= '9', s[0..$]); if (x == -1) x = 0; } } /**************************************/ enum bug4732 = 42; static assert( __traits(identifier, bug4732) == "bug4732"); /**************************************/ template Compileable(int z) { bool OK=true;} int bug5245a(U)() { { enum T { a = 5 } T v; } { enum T { a = 6 } T w; } return 91; } int bug5245b(U)() { { struct T { int a = 2; } T v; } { union T { int a = 3; } T w; } return 91; } int bug5245c(U)() { { struct T { int a = 2; } T v; } { class T { int a = 3; } T w; } return 91; } int bug5245d(U)() { { enum T { a = 3 } T w; } { struct T { int a = 2; } T v; } return 91; } static assert(is(typeof(Compileable!(bug5245a!(int)()).OK))); static assert(is(typeof(Compileable!(bug5245b!(int)()).OK))); static assert(is(typeof(Compileable!(bug5245c!(int)()).OK))); static assert(is(typeof(Compileable!(bug5245d!(int)()).OK))); /**************************************/ class Bug5349(T) // segfault D2.051 { int x; static int g() { class B { int inner() { return x; // should not compile } } return (new B).inner(); } int y = g(); } static assert(!is(typeof(Bug5349!(int)))); /**************************************/ class Bug4033 {} class Template4033(T) { static assert(is(T : Bug4033)); } alias Template4033!(Z4033) Bla; class Z4033 : Bug4033 { } /**************************************/ struct Bug4322 { int[1] a = void; } void bug4322() { Bug4322 f = Bug4322(); Bug4322 g = Bug4322.init; } ./ldc-1.42.0-src/tests/dmd/compilable/noderef.d0000644000175000017500000000150515205374125020015 0ustar fabiofabio// PERMUTE_ARGS: // https://github.com/dlang/dmd/pull/5860 int[] bar() @safe; void foo(int[] a) @safe { static int[] as; bool b; b = a.ptr == null; b = null == (*&as).ptr; b = bar().ptr == null; b = a.ptr != null; b = null != (*&as).ptr; b = bar().ptr != null; b = a.ptr is null; b = null is (*&as).ptr; b = bar().ptr is null; b = a.ptr !is null; b = null !is (*&as).ptr; b = bar().ptr !is null; b = !a.ptr; b = !(*&as).ptr; b = !bar().ptr; b = cast(bool)a.ptr; b = cast(bool)(*&as).ptr; b = cast(bool)bar().ptr; b = a.ptr ? false : true; b = a.ptr < null; b = null < a.ptr; b = a.ptr && null || a.ptr; if (a.ptr) b = true; while (a.ptr) b = true; for (; a.ptr;) b = true; // ptrdiff_t d = a.ptr - a.ptr; } ./ldc-1.42.0-src/tests/dmd/compilable/ice20044.d0000644000175000017500000000017115205374125017523 0ustar fabiofabiostruct Algebraic(T...) { T t; } struct This; struct While(T) { T[] body; } alias Stmt = Algebraic!(While!(This)); ./ldc-1.42.0-src/tests/dmd/compilable/test23598.d0000644000175000017500000000235715205374125017773 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23598 alias AliasSeq(a...) = a; static if (1) { template sort(alias f, a...) { static if (a.length > 0) { alias x = f!(a[0]); alias sort = a; } else alias sort = a; } alias SortedItems = sort!(isDependencyOf, String); enum isDependencyOf(Item) = Item.DirectDependencies.length == 0; struct String { alias DirectDependencies = AliasSeq!(); enum l = SortedItems.length; // (3) } } /*****************************************************/ static if (1) { enum x = 1; enum y = 2; template f(T) { alias b = int; static if (x) { alias c = x; } else { alias c = y; } static if (is(typeof(c))) { } else { static assert(0); } } void g() { int x = f!int.c; } } /*****************************************************/ template forward(args...) { template fwd(alias arg) { alias fwd = arg; } alias Result = AliasSeq!(); static foreach (arg; args) Result = AliasSeq!(Result, fwd!arg); static if (Result.length == 1) alias forward = Result[0]; else alias forward = Result; } void func(int i, int j) { func(forward!(i, j)); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc9497b.d0000644000175000017500000000036615205374125020007 0ustar fabiofabio// EXTRA_SOURCES: extra-files/ddoc9497b.ddoc // PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /** foo function. Args: $(XYZ arg1, arg2) */ void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc10236.d0000644000175000017500000000320515205374125017677 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -verrors=simple -D -Dd${RESULTS_DIR}/compilable -wi -o- /* TEST_OUTPUT: --- compilable/ddoc10236.d(35): Warning: Ddoc: parameter count mismatch, expected 2, got 1 compilable/ddoc10236.d(47): Warning: Ddoc: function declaration has no parameter 'y' compilable/ddoc10236.d(59): Warning: Ddoc: function declaration has no parameter 'y' compilable/ddoc10236.d(59): Warning: Ddoc: parameter count mismatch, expected 1, got 2 compilable/ddoc10236.d(71): Warning: Ddoc: parameter count mismatch, expected 2, got 0 compilable/ddoc10236.d(71): Note that the format is `param = description` --- */ /*********************************** * foo_good does this. * Params: * x = is for this * and not for that * y = is for that */ void foo_good(int x, int y) { } /*********************************** * foo_count_mismatch does this. * Params: * x = is for this * and not for that */ void foo_count_mismatch(int x, int y) // Warning: Ddoc: parameter count mismatch { } /*********************************** * foo_no_param_y does this. * Params: * x = is for this * and not for that * y = is for that */ void foo_no_param_y(int x, int z) // Warning: Ddoc: function declaration has no parameter 'y' { } /*********************************** * foo_count_mismatch_no_param_y does this. * Params: * x = is for this * and not for that * y = is for that */ void foo_count_mismatch_no_param_y(int x) { } /*********************************** * foo_count_mismatch_wrong_format does this. * Params: * x : is for this * and not for that * y : is for that */ void foo_count_mismatch_wrong_format(int x, int y) { } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc_bom_UTF8.d0000644000175000017500000000063715205374125020754 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh int ruhred; /// This documents correctly. int rühred; /// This should too /** * BUG: The parameters are not listed under Params in the generated output * * Params: * ü = first * ş = second * ğ = third * */ int foo(int ü, int ş, int ğ) { return ğ; } ./ldc-1.42.0-src/tests/dmd/compilable/test23651.d0000644000175000017500000000134515205374125017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23651 template isCallable(alias callable) { static if (is(typeof(&callable!()))) enum bool isCallable = isCallable!(typeof(&callable!())); else enum bool isCallable = true; } string foo(); template FunctionTypeOf(alias func) if (isCallable!func) { alias FunctionTypeOf = typeof(foo); } template ReturnType(alias func) { static if (is(FunctionTypeOf!func R == return)) alias ReturnType = R; } template isAttrRange() { alias NameType = ReturnType!((string r) => r); //pragma(msg, "isAttrRange ", NameType, " ", string); static assert(is(NameType == string)); enum isAttrRange = is(NameType == string); } static assert(isAttrRange!()); ./ldc-1.42.0-src/tests/dmd/compilable/test16607.d0000644000175000017500000000053015205374125017753 0ustar fabiofabiostruct A(T) { T t; // causes A to be SIZEOKfwd b/c B (passed as T) isn't yet done // On the 2nd semantic pass through A, _scope of C got set again, // even though the struct was already done. struct C { } } struct B { A!B* a; // causes instantiation of A!B, but can finish semantic with A!B still being fwdref } ./ldc-1.42.0-src/tests/dmd/compilable/test20502.c0000644000175000017500000000016615205374125017744 0ustar fabiofabio// https://github.com/dlang/dmd/issues/20502 struct mg_str { }; void mg_str_s() { } #define mg_str(s) mg_str_s(s) ./ldc-1.42.0-src/tests/dmd/compilable/test7815.d0000644000175000017500000000305215205374125017676 0ustar fabiofabio// REQUIRED_ARGS: -o- mixin template Helpers() { static if (is(Flags!Move)) { Flags!Move flags; } else { pragma(msg, "X: ", __traits(derivedMembers, Flags!Move)); } } template Flags(T) { mixin({ int defs = 1; foreach (name; __traits(derivedMembers, Move)) { defs++; } if (defs) { return "struct Flags { bool x; }"; } else { return ""; } }()); } struct Move { int a; mixin Helpers!(); } enum a7815 = Move.init.flags; /+ This originally was an invalid case: When the Move struct member is analyzed: 1. mixin Helpers!() is instantiated. 2. In Helpers!(), static if and its condition is(Flags!Move)) evaluated. 3. In Flags!Move, string mixin evaluates and CTFE lambda. 4. __traits(derivedMembers, Move) tries to see the member of Move. 4a. mixin Helpers!() member is analyzed. 4b. `static if (is(Flags!Move))` in Helpers!() is evaluated 4c. The Flags!Move instantiation is already in progress, so it cannot be resolved. 4d. `static if` fails because Flags!Move cannot be determined as a type. 5. __traits(derivedMembers, Move) returns a 1-length tuple("a"). 6. The lambda in Flags!Move returns a string "struct Flags {...}", then Flags!Move is instantiated to a new struct Flags. 7. Finally Move struct does not have flags member, then the `enum a7815` definition will fail in its initializer. Now, static if will behave like a string mixin: it is invisible during its own expansion. +/ ./ldc-1.42.0-src/tests/dmd/compilable/needspkgmod.d0000644000175000017500000000043115205374125020670 0ustar fabiofabio// ARG_SETS: -i=imports.pkgmod313 // ARG_SETS: -i=imports.pkgmod313.mod // ARG_SETS: -i=-imports.pkgmod313.package,imports.pkgmod313 // ARG_SETS: -i=-imports.pkgmod313.package,imports.pkgmod313.mod // PERMUTE_ARGS: // LINK: import imports.pkgmod313.mod; void main() { bar(); } ./ldc-1.42.0-src/tests/dmd/compilable/scope_tuple_expansion.d0000644000175000017500000000063015205374125022777 0ustar fabiofabio// REQUIRED_ARGS: -preview=dip1000 // Reduced from `std.systime`. // Tuple expansion can trip up scope checking with errors like: // Error: scope variable `__tup4` assigned to `found` with longer lifetime struct Tuple(T...) { T t; alias t this; } Tuple!(int*, int) find(return scope int* x) @safe { assert(0); } void fromISOExtString(scope int* str) @safe { int* found = str.find()[0]; } ./ldc-1.42.0-src/tests/dmd/compilable/testfwdref.d0000644000175000017500000003242215205374125020552 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/fwdref9514.d imports/fwdref12201a.d /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=6766 class Foo6766 { this(int x) { } void test(Foo6766 foo = new Foo6766(1)) { } } struct Bar6766 { this(int x) { } void test(Bar6766 bar = Bar6766(1)) { } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=8609 struct Tuple8609(T) { T arg; } // ---- struct Foo8609a { Bar8609a b; } struct Bar8609a { int x; Tuple8609!(Foo8609a) spam() { return Tuple8609!(Foo8609a)(); } } // ---- struct Foo8609b { Bar8609b b; } struct Bar8609b { int x; Tuple8609!(Foo8609b[1]) spam() { return Tuple8609!(Foo8609b[1])(); } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=8698 interface IRoot8698a {} interface IClass8698a : IRoot8698a { } struct Struct8698a { } class Class8698a : IClass8698a { alias Struct8698a Value; } void test8698a(Class8698a.Value) { } //interface IRoot8698a {} // ---- //interface IRoot8698b {} interface IClass8698b : IRoot8698b { } struct Struct8698b { } class Class8698b : IClass8698b { alias Struct8698b Value; } void test8698b(Class8698b.Value) { } interface IRoot8698b {} /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=9514 template TStructHelpers9514a() { void opEquals(Foo9514a) { auto n = FieldNames9514a!(); } } struct Foo9514a { mixin TStructHelpers9514a!(); } import imports.fwdref9514 : find9514; // selective import without aliasing template FieldNames9514a() { static if (find9514!`true`([1])) enum int FieldNames9514a = 1; } // ---- template TStructHelpers9514b() { void opEquals(Foo9514b) { auto n = FieldNames9514b!(); } } struct Foo9514b { mixin TStructHelpers9514b!(); } import imports.fwdref9514 : foo9514 = find9514; // selective import with aliasing template FieldNames9514b() { static if (foo9514!`true`([1])) enum int FieldNames9514b = 1; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=10015 struct S10015(T) { alias X = int; } alias Y10015 = s10015.X; S10015!int s10015; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=10101 int front10101(int); mixin template reflectRange10101() { static if (is(typeof(this.front10101))) { int x; } } struct S10101(R) { R r_; typeof(r_.front10101) front10101() @property { return r_.front10101; } mixin reflectRange10101; } void test10101() { S10101!(int) s; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=11019 class A11019 { A11019 View() { return null; } } class B11019 : A11019 { override D11019 View() { return null; } } class D11019 : B11019 {} /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=11166 template Tup11166(T...) { alias Tup11166 = T; } struct S11166a { enum S11166a a = S11166a(0); enum S11166a b = S11166a(1); this(long value) { } long value; // only triggered when private and a template instance. private alias types = Tup11166!(a, b); } struct S11166b { enum S11166b a = S11166b(0); enum S11166b b = S11166b(1); // not at the last of members alias types = Tup11166!(a, b); this(long value) { } long value; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12152 class A12152 { alias Y = B12152.X; } class B12152 : A12152 { alias int X; } static assert(is(A12152.Y == int)); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12201 template T12201() { alias imports.fwdref12201a.FILE* FP; } struct S12201a { mixin T12201; import imports.fwdref12201a; } union U12201 { mixin T12201; import imports.fwdref12201a; } class C12201 { mixin T12201; import imports.fwdref12201a; } interface I12201 { mixin T12201; import imports.fwdref12201a; } template TI12201() { mixin T12201; import imports.fwdref12201a; } mixin template TM12201() { mixin T12201; import imports.fwdref12201a; } struct S12201b { alias ti = TI12201!(); mixin TM12201; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12531 struct Node12531(T) { T _val; } void test12531() { static struct Foo { Node12531!Foo* node; } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12543 class C12543; static assert(C12543.sizeof == (void*).sizeof); static assert(C12543.alignof == (void*).sizeof); static assert(C12543.mangleof == "C10testfwdref6C12543"); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=14010 enum E14010; static assert(E14010.mangleof == "E10testfwdref6E14010"); struct S14010; static assert(S14010.mangleof == "S10testfwdref6S14010"); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12983 alias I12983 = int; class B12983(T) { alias MyC = C12983!string; } class C12983(T) : B12983!float { void m() { f12983(0); } } alias MyB12983 = B12983!float; void f12983(); void f12983(I12983); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12984 class B12984a { alias MyD = D12984a!int; } class C12984a : B12984a { } class D12984a(T) { alias MyE = E12984a!float; } class E12984a(T) : D12984a!int { void m() { auto c = new C12984a(); } } static assert(__traits(classInstanceSize, B12984a) == (void*).sizeof * 2); static assert(__traits(classInstanceSize, C12984a) == (void*).sizeof * 2); // ---- class B12984b { int b; alias MyD = D12984b!int; } class C12984b : B12984b { int c; } class D12984b(T) { int d; alias MyE = E12984b!float; } class E12984b(T) : D12984b!int { int e; void m() { auto c = new C12984b(); } } static assert(__traits(classInstanceSize, B12984b) == (void*).sizeof * 2 + int.sizeof); static assert(__traits(classInstanceSize, C12984b) == (void*).sizeof * 2 + int.sizeof * 2); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=14390 class B14390a { alias MyD = D14390a!int; } class C14390a : B14390a { void f(int) {} } class D14390a(T) { alias MyE = E14390a!float; } class E14390a(T) : D14390a!int { void m() { auto c = new C14390a(); } } class B14390b { alias MyD = D14390b!int; } class C14390b : B14390b { static struct S {} } class D14390b(T) { alias MyE = E14390b!float; } class E14390b(T) : D14390b!int { void m() { auto c = new C14390b(); } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=13860 /* TEST_OUTPUT: --- pure nothrow @nogc @safe void() pure nothrow @nogc @safe void() --- */ struct Foo13860(Bar...) { Bar bars; auto baz(size_t d)() {} pragma(msg, typeof(baz!0)); } auto bar13860(S, R)(S s, R r) { pragma(msg, typeof(Foo13860!().baz!0)); } void test13860() { int[] x; int[] y; x.bar13860(y); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=14083 class NBase14083 { int foo(NA14083 a) { return 1; } int foo(NB14083 a) { return 2; } } class NA14083 : NBase14083 { int v; this(int v) { this.v = v; } } class NB14083 : NBase14083 { override int foo(NA14083 a) { return a.v; } } class TBase14083(T) { int foo(TA14083!T a) { return 1; } int foo(TB14083!T a) { return 2; } } class TA14083(T) : TBase14083!T { T v; this(T v) { this.v = v; } } class TB14083(T) : TBase14083!T { override int foo(TA14083!T a) { return a.v; } } static assert( { NA14083 na = new NA14083(10); NB14083 nb = new NB14083(); assert(na.foo(na) == 1); assert(na.foo(nb) == 2); assert(nb.foo(na) == 10); TA14083!int ta = new TA14083!int(10); TB14083!int tb = new TB14083!int(); assert(ta.foo(ta) == 1); assert(ta.foo(tb) == 2); assert(tb.foo(ta) == 10); return true; }()); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=14549 string foo14549(T)() { static if (T.tupleof.length >= 0) return ""; } class Frop14549 { mixin(foo14549!(typeof(this))); static if (__traits(compiles, undefined)) { } else { int bar = 0; } static if (!__traits(isVirtualMethod, this.bar)) {} } // ---- // regression case template Mix14549() { mixin(code14549!(typeof(this))); } template code14549(T) { enum string code14549 = q{ static if (!__traits(isVirtualMethod, "boo")) {} }; } class Bar14549 { mixin Mix14549; int boo; } // ---- // https://issues.dlang.org/show_bug.cgi?id=14609 // regression case interface Foo14609(T) { static if (is(T == int)) public int bar(); } class Frop14609 : Foo14609!int { public int bar() { return 0; } } /***************************************************/ // test case 1, comes from Phobos /* TEST_OUTPUT: --- +alias Alias12540 +anySatisfy, T.length == 1 +isStaticArray +T.stringof in StaticArrayTypeOf -T.stringof in StaticArrayTypeOf -isStaticArray +hasElaborateCpCtor S == struct or else -hasElaborateCpCtor S == struct or else -anySatisfy, T.length == 1 -alias Alias12540 --- */ template anySatisfy15726x(alias F, T...) { //static if (T.length == 1) //{ pragma(msg, "+anySatisfy, T.length == 1"); enum anySatisfy15726x = F!(T[0]); pragma(msg, "-anySatisfy, T.length == 1"); //} } template StaticArrayTypeOf15726x(T) { alias X = T; static if (is(X : E[n], E, size_t n)) { //alias StaticArrayTypeOf15726x = X; } else { pragma(msg, "+T.stringof in StaticArrayTypeOf"); // Fixed: T.stringof (T == Class12540) should not invoke // T.size() in ClassDeclaration.search(). static assert(0, T.stringof~" is not a static array type"); pragma(msg, "-T.stringof in StaticArrayTypeOf"); } } //enum bool isStaticArray(T) = is(StaticArrayTypeOf15726x!T); template isStaticArray15726x(T) { pragma(msg, "+isStaticArray"); enum bool isStaticArray15726x = is(StaticArrayTypeOf15726x!T); pragma(msg, "-isStaticArray"); } template hasElaborateCpCtor15726x(S) { static if (isStaticArray15726x!S && S.length) { //pragma(msg, "X+"); enum bool hasElaborateCpCtor15726x = hasElaborateCpCtor15726x!(typeof(S.init[0])); //pragma(msg, "X-"); } else { pragma(msg, "+hasElaborateCpCtor S == struct or else"); static if (is(S == struct)) { enum bool hasElaborateCpCtor15726x = true; //enum hasElaborateCpCtor15726x = hasMember!(S, "__postblit") // || anySatisfy15726x!(.hasElaborateCpCtor15726x, FieldTypeTuple!S); } else { enum bool hasElaborateCpCtor15726x = false; } pragma(msg, "-hasElaborateCpCtor S == struct or else"); } } struct VariantN15726x(AllowedTypesParam...) { alias AllowedTypes = AllowedTypesParam; static if (!AllowedTypes.length || anySatisfy15726x!(hasElaborateCpCtor15726x, AllowedTypes)) { } } template Algebraic15726x(T) { alias Algebraic15726x = VariantN15726x!(T); } void test15726x() { static struct DummyScope { pragma(msg, "+alias Alias12540"); alias Alias12540 = Algebraic15726x!Class12540; pragma(msg, "-alias Alias12540"); static class Class12540 { Alias12540 entity; } } } /***************************************************/ // test case 2, comes from Phobos struct RefCounted15726y(T) { struct RefCountedStore { struct Impl { T _payload; } Impl* _store; } RefCountedStore _refCounted; this(this) {} ~this() { _refCounted._store._payload.__xdtor(); } } struct RangeT15726y(A) { A[1] _outer_; alias RC = RangeT15726y!(const(A)); } struct Array15726y(T) { struct Payload { ~this(); } alias Data = RefCounted15726y!(Payload); Data _data; alias Range = RangeT15726y!Array15726y; } void test15726y() { alias Range = RangeT15726y!(Array15726y!int); Range r; r = r; // opAssign } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=15726 struct RC15726(T) { struct Impl { T _payload; } Impl* _store; ~this() { destroy15726a(_store._payload); } } // ---- struct Con15726a(T) { alias Stmt15726a = .Stmt15726a!T; } struct Stmt15726a(T) { alias Con15726a = .Con15726a!T; RC15726!Payload data; struct Payload { Con15726a con; } } Con15726a!int x15726a; void destroy15726a(T)(ref T obj) @trusted { auto buf = (cast(ubyte*)&obj)[0 .. T.sizeof]; } // ---- struct Util15726b(C, S) {} struct Con15726b(T) { alias Util15726b = .Util15726b!(Con15726b!T, Stmt15726b!T); } struct Stmt15726b(T) { struct Payload { Con15726b!T con; } RC15726!Payload data; } Con15726b!int x15726b; ./ldc-1.42.0-src/tests/dmd/compilable/b17651.d0000644000175000017500000000013615205374125017217 0ustar fabiofabio// REQUIRED_ARGS: -c -D -Ddtest_results/compilable /** Macros: Escapes=/a/b/ */ void foo() {} ./ldc-1.42.0-src/tests/dmd/compilable/vgc1.d0000644000175000017500000000326715205374125017242 0ustar fabiofabio// REQUIRED_ARGS: -vgc -o- // PERMUTE_ARGS: /***************** NewExp *******************/ struct S1 { } struct S2 { this(int); } struct S3 { this(int) @nogc; } /* TEST_OUTPUT: --- compilable/vgc1.d(25): vgc: `new` causes a GC allocation compilable/vgc1.d(27): vgc: `new` causes a GC allocation compilable/vgc1.d(28): vgc: `new` causes a GC allocation compilable/vgc1.d(30): vgc: `new` causes a GC allocation compilable/vgc1.d(31): vgc: `new` causes a GC allocation compilable/vgc1.d(32): vgc: `new` causes a GC allocation compilable/vgc1.d(34): vgc: `new` causes a GC allocation --- */ void testNew() { int* p1 = new int; int[] a1 = new int[3]; int[][] a2 = new int[][](2, 3); S1* ps1 = new S1(); S2* ps2 = new S2(1); S3* ps3 = new S3(1); Object o1 = new Object(); } /* TEST_OUTPUT: --- compilable/vgc1.d(51): vgc: `new` causes a GC allocation compilable/vgc1.d(53): vgc: `new` causes a GC allocation compilable/vgc1.d(54): vgc: `new` causes a GC allocation compilable/vgc1.d(56): vgc: `new` causes a GC allocation compilable/vgc1.d(57): vgc: `new` causes a GC allocation compilable/vgc1.d(58): vgc: `new` causes a GC allocation --- */ void testNewScope() { scope int* p1 = new int; scope int[] a1 = new int[3]; scope int[][] a2 = new int[][](2, 3); scope S1* ps1 = new S1(); scope S2* ps2 = new S2(1); scope S3* ps3 = new S3(1); scope Object o1 = new Object(); // no error scope o2 = new Object(); // no error scope Object o3; o3 = o2; // no error } /***************** DeleteExp *******************/ void testDelete(int* p, Object o, S1* s) { destroy(p); destroy(o); destroy(s); } ./ldc-1.42.0-src/tests/dmd/compilable/test18251.d0000644000175000017500000000054015205374125017751 0ustar fabiofabio// REQUIRED_ARGS: -unittest -de auto test18251(T)(T t) if (!__traits(isDeprecated, T)) { return T.init; } unittest { auto b = test18251(2); } deprecated auto test18251(T)(T t) // deprecated storage class got lost when expanding. if (__traits(isDeprecated, T)) { return T.init; } deprecated unittest { auto b = test18251(2 + 2i); } ./ldc-1.42.0-src/tests/dmd/compilable/test21680.d0000644000175000017500000000034315205374125017752 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21680 struct Unique { alias ValueType = typeof({ return field; }()); /* Error: need `this` for `field` of type `int` */ int field; static assert(is(ValueType == int)); } ./ldc-1.42.0-src/tests/dmd/compilable/fix21894.d0000644000175000017500000000035715205374125017575 0ustar fabiofabio// https://github.com/dlang/dmd/issues/21894 inout(int[]) test1(inout(int[]) a, int b) { return a ~ b; } inout(int[]) test2(inout(int[]) a, inout(int[]) b) { return a ~ b; } void main() { test1([1], 2); test2([1], [2]); } ./ldc-1.42.0-src/tests/dmd/compilable/b20758.d0000644000175000017500000000062415205374125017223 0ustar fabiofabiomodule b20758; template foo(A...) { } int attr() {return 1;} @attr int y; alias A = __traits(getAttributes, y); alias B = __traits(getOverloads, b20758, "attr"); static assert(__traits(isSame, foo!(A[0]), foo!(attr))); static assert(__traits(isSame, foo!(A), foo!(attr))); static assert(__traits(isSame, foo!(attr), foo!(B[0]))); static assert(__traits(isSame, foo!(attr), foo!(B))); void main() { } ./ldc-1.42.0-src/tests/dmd/compilable/test23168.d0000644000175000017500000000114415205374125017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23168 // Issue 23168 - [DIP1000] return scope wrongly rewritten for structs with no indirections @safe: struct Ptr { int* fun() return scope { return null; } } int* funf(ref return scope Ptr p) { return null; } int* use() { Ptr ptr; return ptr.fun; return funf(ptr); } // Prevent forward reference 'regression' // See https://github.com/dlang/dmd/pull/14232#issuecomment-1162906573 struct S { void f() scope {} alias x = _get_value; static if (true) int _get_value() {return 3;} else int _get_value() {return 4;} } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc6491.d0000644000175000017500000000041615205374125017630 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc6491; import core.cpuid; enum int c6491 = 4; /// test void bug6491a(int a = ddoc6491.c6491, string b = core.cpuid.vendor); ./ldc-1.42.0-src/tests/dmd/compilable/test21299d.d0000644000175000017500000000066315205374125020131 0ustar fabiofabio// REQUIRED_ARGS: -main // LINK: module test21299d; struct DefaultPredicates { struct IsEqual(T) { static opCall(in T, in T) { return 0; } } } void moveToEnd(T, Pred = DefaultPredicates.IsEqual!T)(T[] array, T element, Pred pred = Pred.init) { pred(array[0], element); } class Task { void removeTerminationHook(void delegate() hook) { moveToEnd([], hook); } } ./ldc-1.42.0-src/tests/dmd/compilable/b19829.d0000644000175000017500000000041015205374125017223 0ustar fabiofabiostatic assert(!__traits(isSame, (i){ return i,x.value; }, a => a.value)); static assert(!__traits(isSame, i => x[i].value, a => a.value)); static assert(!__traits(isSame, i => [i].value, a => a.value)); static assert(__traits(isSame, i => i.value, a => a.value)); ./ldc-1.42.0-src/tests/dmd/compilable/test22510.d0000644000175000017500000000034415205374125017744 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22510 struct S { int b; @disable this(this); this (scope ref inout S) inout { this.b = 0; } } void main() { auto scoped_s = S(4); auto heap_s = new S(42); } ./ldc-1.42.0-src/tests/dmd/compilable/testos.d0000644000175000017500000000016615205374125017716 0ustar fabiofabio/* PERMUTE_ARGS: -os=host -os=linux -os=osx -os=freebsd -os=solaris * DISABLED: win32 win64 LDC */ void test() { } ./ldc-1.42.0-src/tests/dmd/compilable/minimal2.d0000644000175000017500000000076415205374125020111 0ustar fabiofabio// DFLAGS: // REQUIRED_ARGS: -defaultlib= // EXTRA_SOURCES: extra-files/minimal/object.d // This test ensures that interfaces and classes can be used in a minimal // runtime as long as they only contain static members. // This should compile, but will not link and run properly without // a thread-local storage (TLS) implementation. interface I { static int i; } class A : I { static int a; } class B : A { static int b; } void main() { B.i = 32; B.a = 42; B.b = 52; } ./ldc-1.42.0-src/tests/dmd/compilable/testlambdacomp.d0000644000175000017500000001171115205374125021372 0ustar fabiofabio// EXTRA_FILES: imports/testlambda1.d imports/testlambda2.d module testlambdacomp; void test1() { static assert(__traits(isSame, (a, b) => a + b, (c, d) => c + d)); static assert(__traits(isSame, a => ++a, b => ++b)); static assert(!__traits(isSame, (int a, int b) => a + b, (a, b) => a + b)); static assert(__traits(isSame, (a, b) => a + b + 10, (c, d) => c + d + 10)); } class Y { static int r = 5; int x; this(int x) { this.x = x; } } class A { Y a; this(Y a) { this.a = a; } } void foo3(alias pred)() { static assert(!__traits(isSame, pred, (A x, A y) => ++x.a.x + (--y.a.x))); } void test2() { int b; static assert(!__traits(isSame, a => a + b, a => a + b)); int f() { return 3;} static assert(__traits(isSame, a => a + f(), a => a + f())); class A { Y a; this(Y a) { this.a = a; } } class B { int a; this(int a) { this.a = a; } } B q = new B(7); alias pred = (A a, A b) => ++a.a.x + (--b.a.x); foo3!pred(); static assert(!__traits(isSame, (A a) => ++a.a.x + 2, (A b) => ++b.a.x + 3)); static assert(__traits(isSame, pred, (A x, A y) => ++x.a.x + (--y.a.x))); static assert(!__traits(isSame, (B a) => ++a.a + 2, (B b) => ++b.a + 3)); static assert(__traits(isSame, (B a) => ++a.a, (B a) => ++a.a)); B cl = new B(7); static assert(!__traits(isSame, a => a + q.a, c => c + cl.a)); class C(G) { G a; this(int a) { this.a = a; } } static assert(!__traits(isSame, (C!int a) => ++a.a, (C!int a) => ++a.a)); struct X { int a; } static assert(__traits(isSame, (X a) => a.a + 2, (X b) => b.a + 2)); struct T(G) { G a; } static assert(!__traits(isSame, (T!int a) => ++a.a, (T!int a) => ++a.a)); } void test3() { enum q = 10; static assert(__traits(isSame, (a, b) => a + b + q, (c, d) => c + d + 10)); struct Bar { int a; } enum r1 = Bar(1); enum r2 = Bar(1); static assert(__traits(isSame, a => a + r1.a, b => b + r2.a)); enum X { A, B, C} static assert(__traits(isSame, a => a + X.A, a => a + 0)); } void foo(alias pred)() { static assert(__traits(isSame, pred, (c, d) => c + d)); static assert(__traits(isSame, (c, d) => c + d, pred)); } void bar(alias pred)() { static assert(__traits(isSame, pred, (c, d) => c < d + 7)); enum q = 7; static assert(__traits(isSame, pred, (c, d) => c < d + q)); int r = 7; static assert(!__traits(isSame, pred, (c, d) => c < d + r)); } void test4() { foo!((a, b) => a + b)(); bar!((a, b) => a < b + 7); } int bar() { return 2; } void testImportedFunctions(alias pred)() { // imports.testalambda1.bar != imports.testlambda2.bar import imports.testlambda2 : bar; static assert(!__traits(isSame, pred, (int a) => a + bar())); } void testLocalGlobalFunctionScopes(alias pred)() { // testlambdacomp.bar != testlambdacomp.test5.bar static assert(!__traits(isSame, pred, (int a) => a + bar())); // imports.testlambda1.bar != testlambdacomp.test5.bar import imports.testlambda1 : bar; static assert(!__traits(isSame, pred, (int a) => a + bar())); // functions imported from different modules are not equal testImportedFunctions!((int a) => a + bar())(); } // lambda functions which contain function calls void test5() { int bar() { return 3; } // functions in the same scope alias pred = a => a + bar(); alias pred2 = b => b + bar(); static assert(__traits(isSame, pred, pred2)); // functions in different scopes testLocalGlobalFunctionScopes!((int a) => a + bar())(); int foo(int a, int b) { return 2 + a + b; } // functions with different kind of parameters alias preda23 = a => a + foo(2, 3); alias predb23 = b => b + foo(2, 3); alias predc24 = c => c + foo(2, 4); alias predd23 = (int d) => d + foo(2, 3); alias prede23 = (int e) => e + foo(2, 3); alias predf24 = (int f) => f + foo(2, 4); static assert(__traits(isSame, preda23, predb23)); static assert(!__traits(isSame, predc24, predd23)); static assert(__traits(isSame, predd23, prede23)); static assert(!__traits(isSame, prede23, predf24)); // functions with function calls as parameters static assert(!__traits(isSame, (int a, int b) => foo(foo(1, a), foo(1, b)), (int a, int b) => foo(foo(1, a), foo(2, b)))); static assert(!__traits(isSame, (a, b) => foo(foo(1, a), foo(1, b)), (int a, int b) => foo(foo(1, a), foo(2, b)))); float floatFunc(float a, float b) { return a + b; } static assert(__traits(isSame, a => floatFunc(a, 1.0), b => floatFunc(b, 1.0))); static assert(!__traits(isSame, a => floatFunc(a, 1.0), b => floatFunc(b, 2.0))); } void main() { test1(); test2(); test3(); test4(); test5(); } ./ldc-1.42.0-src/tests/dmd/compilable/test22635.d0000644000175000017500000000033115205374125017750 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22635 // opCast prevent calling destructor for const this struct Foo { bool opCast(T : bool)() const { assert(0); } ~this() {} } struct Bar { const Foo foo; } ./ldc-1.42.0-src/tests/dmd/compilable/test19464.d0000644000175000017500000000022015205374125017753 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19464 typeof(a0) b0 = 3; immutable int a0 = 4; static assert(is(typeof(b0) == immutable(int))); ./ldc-1.42.0-src/tests/dmd/compilable/test23965.d0000644000175000017500000000021615205374125017761 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23965 // REQUIRED_ARGS: -de deprecated: struct S {} void fun() { S[] arr; arr ~= S(); } ./ldc-1.42.0-src/tests/dmd/compilable/test20021.d0000644000175000017500000000067215205374125017743 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20021 struct S { bool opCast(T : bool)() { return true; } S prop() {return this;} S prop(S newThis) {return this;} } struct T { bool opCast(T : bool)() { return false; } } void test20021() { static if (T.init) static assert(false); // ensure properties are resolved static if (!(true && T.init || (S.init.prop = S.init).prop)) static assert(false); } ./ldc-1.42.0-src/tests/dmd/compilable/test21244.c0000644000175000017500000000013115205374125017740 0ustar fabiofabio// https://github.com/dlang/dmd/issues/21244 int z = _Generic(1, int()(int): 3, int: 3); ./ldc-1.42.0-src/tests/dmd/compilable/fix22180.d0000644000175000017500000000020015205374125017545 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22180 align(8) { int x; } //pragma(msg, x.alignof); static assert(x.alignof == 8); ./ldc-1.42.0-src/tests/dmd/compilable/ddoc9155.d0000644000175000017500000000246415205374125017635 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc9155; /++ + Note: + test document note + 2nd line + Example: + --- + import std.stdio; //& + writeln("Hello world!"); + if (test) { + writefln("D programming language"); + } + + algorithm; + + xxx; //comment + yyy; + /* test + * comment + */ + + // Create MIME Base64 with CRLF, per line 76. +File f = File("./text.txt", "r"); +uint line = 0; + // The ElementType of data is not aggregation type +foreach (encoded; Base64.encoder(data)) + --- +/ /** -------------------------------------------------------- wstring ws; transcode("hello world",ws); // transcode from UTF-8 to UTF-16 -------------------------------------------------------- */ /** * Example: * --- * import std.stdio; //& * writeln("Hello world!"); * if (test) { * writefln("D programming language"); * } * * algorithm; * * xxx; //comment * yyy; * /+ test * + comment * +/ * --- */ /** ---- #!/usr/bin/env rdmd // Computes average line length for standard input. import std.stdio; ---- */ /** --- writefln(q"EOS This is a multi-line heredoc string EOS" ); --- */ void foo(){} ./ldc-1.42.0-src/tests/dmd/compilable/test23812.d0000644000175000017500000000346415205374125017760 0ustar fabiofabio// EXTRA_FILES: imports/imp23812.c import imports.imp23812; void callDefault() { funcDefault(); funcDefault2(); } static assert(!__traits(compiles, () nothrow { funcDefault(); } )); static assert(!__traits(compiles, () @nogc { funcDefault(); } )); static assert(!__traits(compiles, () pure { funcDefault(); } )); static assert(!__traits(compiles, () nothrow { funcDefault2(); } )); static assert(!__traits(compiles, () @nogc { funcDefault2(); } )); static assert(!__traits(compiles, () pure { funcDefault2(); } )); void callNothrow() nothrow { funcNothrow(); funcNothrow2(); } static assert(!__traits(compiles, () @nogc { funcNothrow(); } )); static assert(!__traits(compiles, () pure { funcNothrow(); } )); static assert(!__traits(compiles, () @nogc { funcNothrow2(); } )); static assert(!__traits(compiles, () pure { funcNothrow2(); } )); void callNogc() @nogc { funcNogc(); } static assert(!__traits(compiles, () nothrow { funcNogc(); } )); static assert(!__traits(compiles, () pure { funcNogc(); } )); void callPure() pure { funcPure(); } static assert(!__traits(compiles, () nothrow { funcPure(); } )); static assert(!__traits(compiles, () @nogc { funcPure(); } )); void callNothrowNogc() nothrow @nogc { funcNothrowNogc(); funcNothrowNogc2(); } static assert(!__traits(compiles, () pure { funcNothrowNogc(); } )); static assert(!__traits(compiles, () pure { funcNothrowNogc2(); } )); extern(C) void callbackDefault() { } extern(C) void callbackNothrow() nothrow { } void callFuncWithCallback() nothrow { funcWithCallback(&callbackNothrow); Callbacks callbacks; callbacks.f = &callbackNothrow; } static assert(!__traits(compiles, () { funcWithCallback(&callbackDefault); } )); static assert(!__traits(compiles, () { Callbacks callbacks; callbacks.f = &callbackDefault; } )); ./ldc-1.42.0-src/tests/dmd/compilable/issue19724.sh0000755000175000017500000000242115205374125020322 0ustar fabiofabio#! /usr/bin/env bash if [[ $OS != linux ]]; then exit 0; fi TEST_DIR=${OUTPUT_BASE} # create two libraries with the first depending on the second # so that if they're given the wrong order on the commandline, # linking would ordinarily fail D_LIBFILE1=$TEST_DIR/first.d D_LIBFILE2=$TEST_DIR/second.d D_LIB1=$TEST_DIR/libfirst.a D_LIB2=$TEST_DIR/libsecond.a # call from D D_FILE=$TEST_DIR/test.d APP=$TEST_DIR/test mkdir -p $TEST_DIR cat >$D_LIBFILE1 <$D_LIBFILE2 <$D_FILE <10 ? 10 : n) { mixin("enum x" ~ cast(char)('0' + i)); } static if (true) {} } alias F = size_t function (size_t a); ./ldc-1.42.0-src/tests/dmd/compilable/test17146.d0000644000175000017500000000031115205374125017747 0ustar fabiofabio// REQUIRED_ARGS: -O -inline // https://issues.dlang.org/show_bug.cgi?id=17146 struct S { int[] a; int b; } void foo() { S[] s = [S([],0)]; if (s[$-1] == S.init) {} } void bar() { foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/test9613.d0000644000175000017500000000165715205374125017705 0ustar fabiofabio// PERMUTE_ARGS: struct S9613 { int f( const(byte) a = const(byte).init, immutable(byte) b = immutable(byte).init, shared(byte) c = shared(byte).init, inout(byte) d = inout(byte).init, ) inout { assert(a == byte.init); assert(b == byte.init); assert(c == byte.init); assert(d == byte.init); static assert(const(byte).init == byte.init); static assert(immutable(byte).init == byte.init); static assert(shared(byte).init == byte.init); static assert(inout(byte).init == byte.init); return 0; } } void main() { static assert(const(byte).init == byte.init); static assert(immutable(byte).init == byte.init); static assert(shared(byte).init == byte.init); static assert(const(byte).init.sizeof == byte.sizeof); static assert(const(byte[2]).init[0] == byte.init); enum s = S9613(); enum v = s.f(); } ./ldc-1.42.0-src/tests/dmd/compilable/test20958.d0000644000175000017500000000007015205374125017756 0ustar fabiofabio// EXTRA_FILES: imports/u20958.d import imports.u20958; ./ldc-1.42.0-src/tests/dmd/compilable/test23912.d0000644000175000017500000000045715205374125017760 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23912 // REQUIRED_ARGS: -preview=dip1000 struct Test { string val; this(return scope string val) scope @safe {} ~this() scope @safe {} } void giver(scope string input) @safe { accepts(Test(input)); } void accepts(scope Test test) @safe {} ./ldc-1.42.0-src/tests/dmd/compilable/must_use_opopassign.d0000644000175000017500000000024615205374125022502 0ustar fabiofabioimport core.attribute; @mustuse struct S { ref S opOpAssign(string op)(S rhs) return { return this; } } void test() { S a, b; a += b; } ./ldc-1.42.0-src/tests/dmd/compilable/test22931.c0000644000175000017500000000011015205374125017741 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22931 void fn() { 0; } ./ldc-1.42.0-src/tests/dmd/compilable/testcstuff4.i0000644000175000017500000000051115205374125020652 0ustar fabiofabio /* cpp doesn't like this, so don't run preprocessor on this file */ /********************************/ #line 1050 "cstuff3.c" extra tokens ignored (should warn?) #line 1000 %:line 1010 # 1020 "cstuff3.c" 1 2 3 4 # 1030 struct S21944 { int var; #1040 "cstuff3.c" 3 4 }; _Static_assert(U'\U00011234' == 0x11234, "ok"); ./ldc-1.42.0-src/tests/dmd/compilable/test21668.d0000644000175000017500000000022715205374125017761 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21668 struct Opaque; void byPtr(Opaque*) {} void byRef(ref Opaque) {} // Fails void bySlice(Opaque[]) {} ./ldc-1.42.0-src/tests/dmd/compilable/test24338.d0000644000175000017500000000024515205374125017756 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24338 enum Foo: char[4] { elem = "test" } immutable a = [Foo.elem]; immutable b = [Foo.elem]; immutable c = a ~ b; ./ldc-1.42.0-src/tests/dmd/compilable/test15402.d0000644000175000017500000000014615205374125017746 0ustar fabiofabio// REQUIRED_ARGS: -de struct S { package int field; } void test() { S s; s.field = 1; } ./ldc-1.42.0-src/tests/dmd/compilable/test20499.d0000644000175000017500000000010615205374125017756 0ustar fabiofabio// https://github.com/dlang/dmd/issues/20499 import imports.imp20499; ./ldc-1.42.0-src/tests/dmd/compilable/test23105.d0000644000175000017500000000034615205374125017747 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23105 module test23105; static assert(is(mixin(`__traits(getMember, test23105, "object")`) == module)); static assert(is(__traits(getMember, test23105, "object") == module)); // Fixed ./ldc-1.42.0-src/tests/dmd/compilable/test20868.d0000644000175000017500000000027415205374125017764 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20868 // REQUIRED_ARGS: -preview=dip1000 void scoped (scope void delegate() dg) { static void delegate()[] dgs; dgs ~= dg; // error } ./ldc-1.42.0-src/tests/dmd/compilable/test17807.d0000644000175000017500000000050515205374125017760 0ustar fabiofabio// REQUIRED_ARGS: -o- -w int bug17807(){ int y=0; Lswitch: switch(2){ { case 0: break; } enum x=0; struct S{ enum x=0; } int foo(){ return 0; } default: y=x+S.x+foo(); static foreach(i;1..5) case i: break Lswitch; } return y; } ./ldc-1.42.0-src/tests/dmd/compilable/test21246.c0000644000175000017500000000032615205374125017750 0ustar fabiofabio// https://github.com/dlang/dmd/issues/21246 #define M1(x) _Generic(x, ( #define M2(a,b) _Generic(val, int(int) a #define M3(str,val) _Generic(val, M(F) struct{int foo;}: 0)(__FILE__, __func__, __LINE__, str, val) ./ldc-1.42.0-src/tests/dmd/compilable/test12567a.d0000644000175000017500000000012115205374125020111 0ustar fabiofabio// REQUIRED_ARGS: // PERMUTE_ARGS: deprecated module test12567a; void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test19081.d0000644000175000017500000000050515205374125017754 0ustar fabiofabiovoid main() { @(1) enum { A } /// comment @(1) enum X { A } @(2) enum Y; @(1) @(2) enum Z { A } struct Test { int test; } @Test(1) enum W { A } @(1) enum V: int { A } X a; static assert(__traits(getAttributes, X).length == 1); static assert(__traits(getAttributes, X)[0] == 1); } ./ldc-1.42.0-src/tests/dmd/compilable/chkformat.d0000644000175000017500000000073215205374125020352 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20643 // https://issues.dlang.org/show_bug.cgi?id=20644 // REQUIRED_ARGS: -verrors=simple /* TEST_OUTPUT: ---- compilable/chkformat.d(15): Deprecation: more format specifiers than 0 arguments ---- */ import core.stdc.stdio; void main() { // b20643 printf("%d \n"); // b20644 ubyte b; printf("%hhu \n", b); char c = '-'; printf("%c", c); short s; printf("%hd", s); printf("%hn", &s); } ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_windows.d0000644000175000017500000000111115205374125021074 0ustar fabiofabio/++ REQUIRED_ARGS: -HC -o- TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler #pragma once #include #include #include #include #ifndef _WIN32 #define EXTERN_SYSTEM_AFTER __stdcall #define EXTERN_SYSTEM_BEFORE #else #define EXTERN_SYSTEM_AFTER #define EXTERN_SYSTEM_BEFORE extern "C" #endif EXTERN_SYSTEM_BEFORE int32_t EXTERN_SYSTEM_AFTER exSystem(int32_t x); int32_t __stdcall exWindows(int32_t y); --- ++/ extern(System) int exSystem(int x) { return x; } extern(Windows) int exWindows(int y) { return y; } ./ldc-1.42.0-src/tests/dmd/compilable/cppmangle2.d0000644000175000017500000000036715205374125020430 0ustar fabiofabiomodule cppmangle2; extern(C++, Namespace18922) { struct Struct18922 { int i; } } extern(C++, std) { struct vector (T); } extern(C++, `Namespace18922`) { struct Struct18922 { int i; } } extern(C++, `std`) { struct vector (T); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc4.d0000644000175000017500000000024315205374125017366 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /** a */ enum { ONE } ./ldc-1.42.0-src/tests/dmd/compilable/ice10431a.d0000644000175000017500000000047315205374125017670 0ustar fabiofabiomixin ADT!(); struct Tuple(TL...) { TL expand; } template Seq(T...) { alias T Seq; } template ADT() { mixin(q{ struct ListI { private { size_t tag; union { Seq!(Tuple!()*, Tuple!(int,ListI,)*,) data; } } } }); } ./ldc-1.42.0-src/tests/dmd/compilable/test68.d0000644000175000017500000000042015205374125017523 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/test68a.d // https://issues.dlang.org/show_bug.cgi?id=4278 import imports.test68a; class Foo : OtherModuleClass { override void foo() { super.foo(); } } void main() { new Foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/test1353.d0000644000175000017500000000032015205374125017660 0ustar fabiofabio class A {} interface B {} interface C {} interface D(X) {} void fun() { class T : typeof(new A), .B, const(C), D!int {} version(none) { class U : int, float, __vector(int[3]) {} } } ./ldc-1.42.0-src/tests/dmd/compilable/test22593.d0000644000175000017500000000030015205374125017747 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22593 struct Foo(T){ this(Rhs, this This)(scope Rhs rhs){ } this(ref scope typeof(this) rhs){ } } struct Bar{ Foo!int foo; } ./ldc-1.42.0-src/tests/dmd/compilable/previewhelp.d0000644000175000017500000000376115205374125020733 0ustar fabiofabio/* ARG_SETS: -preview=? ARG_SETS: -preview=h TEST_OUTPUT: ---- Upcoming language changes listed by -preview=name: =all Enables all available upcoming language changes =dip25 implement Sealed References DIP [DEPRECATED] (https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md) =dip1000 implement Scoped Pointers DIP (https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1000.md) =dip1008 implement @nogc Throwable DIP (https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1008.md) =dip1021 implement Mutable Function Arguments DIP (https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1021.md) =bitfields add C-like bitfields (https://github.com/dlang/dlang.org/pull/3190) =fieldwise use fieldwise comparisons for struct equality (https://dlang.org/changelog/2.085.0.html#no-cmpsb) =fixAliasThis when a symbol is resolved, check alias this scope before going to upper scopes (https://github.com/dlang/dmd/pull/8885) =rvaluerefparam enable rvalue arguments to ref parameters (https://gist.github.com/andralex/e5405a5d773f07f73196c05f8339435a) =safer more safety checks by default (https://github.com/WalterBright/documents/blob/38f0a846726b571f8108f6e63e5e217b91421c86/safer.md) =nosharedaccess disable access to shared memory objects (https://dlang.org/spec/const3.html#shared) =in `in` on parameters means `scope const [ref]` and accepts rvalues (https://dlang.org/spec/function.html#in-params) =inclusiveincontracts 'in' contracts of overridden methods must be a superset of parent contract (https://dlang.org/changelog/2.095.0.html#inclusive-incontracts) =fixImmutableConv disallow `void[]` data from holding immutable data (https://dlang.org/changelog/2.101.0.html#dmd.fix-immutable-conv, https://issues.dlang.org/show_bug.cgi?id=17148) =systemVariables disable access to variables marked '@system' from @safe code (https://dlang.org/spec/attribute.html#system-variables) ---- */ ./ldc-1.42.0-src/tests/dmd/compilable/test17512.d0000644000175000017500000000055315205374125017754 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=17512 struct A { int _value; bool _hasValue; auto ref getOr(int alternativeValue) { return _hasValue ? _value : alternativeValue; } } A a; // https://issues.dlang.org/show_bug.cgi?id=18661 struct S0(T) { int a; auto ref immutable(int) getA() { return a; } } alias B = S0!int; ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_protection.d0000644000175000017500000000641515205374125021604 0ustar fabiofabio/** https://issues.dlang.org/show_bug.cgi?id=21218 REQUIRED_ARGS: -HC -o- TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler #pragma once #include #include #include #include struct S1 final { int32_t a; protected: int32_t b; int32_t c; int32_t d; private: int32_t e; public: S1() : a(), b(), c(), d(), e() { } S1(int32_t a, int32_t b = 0, int32_t c = 0, int32_t d = 0, int32_t e = 0) : a(a), b(b), c(c), d(d), e(e) {} }; class S2 final { public: int32_t af(); protected: int32_t bf(); int32_t cf(); int32_t df(); public: S2() { } }; class C1 { public: int32_t a; protected: int32_t b; int32_t c; int32_t d; private: int32_t e; }; struct C2 { virtual int32_t af(); protected: virtual int32_t bf(); int32_t cf(); int32_t df(); }; struct Outer final { private: int32_t privateOuter; public: struct PublicInnerStruct final { private: int32_t privateInner; public: int32_t publicInner; PublicInnerStruct() : privateInner(), publicInner() { } PublicInnerStruct(int32_t privateInner, int32_t publicInner = 0) : privateInner(privateInner), publicInner(publicInner) {} }; private: struct PrivateInnerClass final { private: int32_t privateInner; public: int32_t publicInner; PrivateInnerClass() : privateInner(), publicInner() { } PrivateInnerClass(int32_t privateInner, int32_t publicInner = 0) : privateInner(privateInner), publicInner(publicInner) {} }; public: class PublicInnerInterface { public: virtual void foo() = 0; }; private: enum class PrivateInnerEnum { A = 0, B = 1, }; public: typedef PrivateInnerEnum PublicAlias; Outer() : privateOuter() { } Outer(int32_t privateOuter) : privateOuter(privateOuter) {} }; --- */ module compilable.dtoh_protection; extern(C++) struct S1 { public int a; protected int b; package int c; package(compilable) int d; private int e; } extern(C++, class) struct S2 { public int af(); protected int bf(); package int cf(); package(compilable) int df(); private int ef(); } extern(C++) class C1 { public int a; protected int b; package int c; package(compilable) int d; private int e; } extern(C++, struct) class C2 { public int af(); protected int bf(); package int cf(); package(compilable) int df(); private int ef(); } extern(C++) struct Outer { private int privateOuter; static struct PublicInnerStruct { private int privateInner; int publicInner; } private static struct PrivateInnerClass { private int privateInner; int publicInner; } static interface PublicInnerInterface { void foo(); } private static enum PrivateInnerEnum { A, B } public alias PublicAlias = PrivateInnerEnum; } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc2273.d0000644000175000017500000000113315205374125017617 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh // REQUIRED_ARGS: -m32 module ddoc2273; interface A { } interface C { } interface D { } /// interface B : C, D { } /// class Foo : A, B { } /// MinType!(T1, T2, T) min(T1, T2, T...)(T1 a, T2 b, T xs) { } /// Templ!([1, 2, 3]) max(T...)() { } /// template Base64Impl(char Map62th, char Map63th, char Padding) { } /// int sqlite3_config(int,...); template staticIndexOf(T, TList...) { alias int staticIndexOf; } /// alias staticIndexOf IndexOf; void main() { } ./ldc-1.42.0-src/tests/dmd/compilable/test23076.d0000644000175000017500000000133115205374125017751 0ustar fabiofabio/* REQUIRED_ARGS: -O -inline */ // https://issues.dlang.org/show_bug.cgi?id=23076 struct S { int depthLow = 0; int depthHigh = 30000; void fun(int* pixels) { float b = depthLow; int depthA = cast(int)(b); int depthB = cast(short)(cast(float)depthHigh * cast(float)depthLow); pixels[depthA] = depthB; } } /**********************/ float mul3(float a, float b, float t) { return t * b * a; } class A { ushort depthLow = 0; ushort depthHigh = 30000; void fun(short* pixels) { short depthA = (cast(short)(mul3(depthHigh, depthLow, 0))); short depthB = (cast(short)(mul3(depthLow, depthHigh, 0))); pixels[depthA] = depthB; } } ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_StructDeclaration.d0000644000175000017500000001152515205374125023046 0ustar fabiofabio/* REQUIRED_ARGS: -HC -c -o- PERMUTE_ARGS: TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler #pragma once #include #include #include #include #ifdef CUSTOM_D_ARRAY_TYPE #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE #else /// Represents a D [] array template struct _d_dynamicArray final { size_t length; T *ptr; _d_dynamicArray() : length(0), ptr(NULL) { } _d_dynamicArray(size_t length_in, T *ptr_in) : length(length_in), ptr(ptr_in) { } T& operator[](const size_t idx) { assert(idx < length); return ptr[idx]; } const T& operator[](const size_t idx) const { assert(idx < length); return ptr[idx]; } }; #endif struct S final { int8_t a; int32_t b; int64_t c; _d_dynamicArray< int32_t > arr; private: ~S(); public: S() : a(), b(), c(), arr() { } S(int8_t a, int32_t b = 0, int64_t c = 0LL, _d_dynamicArray< int32_t > arr = {}) : a(a), b(b), c(c), arr(arr) {} }; struct S2 final { int32_t a; int32_t b; int64_t c; S d; S2(int32_t a); S2(char ) = delete; S2() : a(42), b(), c() { } }; struct S3 final { int32_t a; int32_t b; int64_t c; S3() : a(42), b(), c() { } }; struct S4 final { int32_t a; int64_t b; int32_t c; int8_t d; S4() : a(), b(), c(), d() { } S4(int32_t a, int64_t b = 0LL, int32_t c = 0, int8_t d = 0) : a(a), b(b), c(c), d(d) {} }; #pragma pack(push, 1) struct Aligned final { int8_t a; int32_t b; int64_t c; Aligned(int32_t a); Aligned() : a(), b(), c() { } }; #pragma pack(pop) struct Null final { void* field; Null() : field(nullptr) { } Null(void* field) : field(field) {} }; struct A final { int32_t a; S s; void baz(int32_t x = 42); struct { int32_t x; int32_t y; }; union { int32_t u1; char u2[4$?:32=u|64=LLU$]; }; struct Inner final { int32_t x; Inner() : x() { } Inner(int32_t x) : x(x) {} }; typedef Inner I; class C; A() : a(), s(), x(), y() { } A(int32_t a, S s = S(), int32_t x = 0, int32_t y = 0) : a(a), s(s), x(x), y(y) {} }; union U { int32_t i; char c; }; struct Array final { uint32_t length; private: _d_dynamicArray< char > data; char smallarray[1$?:32=u|64=LLU$]; public: Array() : length(), data() { } Array(uint32_t length, _d_dynamicArray< char > data = {}) : length(length), data(data) {} }; struct Params final { bool obj; Array ddocfiles; Params() : obj(true), ddocfiles() { } Params(bool obj, Array ddocfiles = Array()) : obj(obj), ddocfiles(ddocfiles) {} }; struct Loc final { static int32_t showColumns; void toChars(int32_t showColumns = Loc::showColumns); Loc() { } }; --- */ /* StructDeclaration has the following issues: * align different than 1 does nothing; we should support align(n), where `n` in [1, 2, 4, 8, 16] * align(n): inside struct definition doesn’t add alignment, but breaks generation of default ctors */ extern (C++) struct S { byte a; int b; long c; int[] arr; extern(D) ~this() {} } extern (C++) struct S2 { int a = 42; int b; long c; S d = void; this(int a) {} extern(D) this(int, int, long) {} @disable this(char); } extern (C) struct S3 { int a = 42; int b; long c; this(int a) {} } extern (C) struct S4 { int a; long b; int c; byte d; } extern (C++) align(1) struct Aligned { //align(1): byte a; int b; long c; this(int a) {} } extern (C++) struct Null { void* field = null; } extern (C++) struct A { int a; S s; extern (D) void foo(); extern (C) void bar() {} extern (C++) void baz(int x = 42) {} struct { int x; int y; } union { int u1; char[4] u2; } struct Inner { int x; } alias I = Inner; extern(C++) class C; } extern(C++) union U { int i; char c; } extern (C++) struct Array { uint length; private: char[] data; char[1] smallarray; } extern (C++) struct Params { bool obj = true; Array ddocfiles; } extern (C++) struct Loc { __gshared int showColumns; void toChars(int showColumns = Loc.showColumns) {} } ./ldc-1.42.0-src/tests/dmd/compilable/test24337.d0000644000175000017500000000034715205374125017760 0ustar fabiofabio/* TEST_OUTPUT: --- "ab"w x"11223344556677" --- */ // https://issues.dlang.org/show_bug.cgi?id=24337 immutable ushort[] y = cast(immutable ushort[]) "ab"w; immutable ulong[] z = x"00 11 22 33 44 55 66 77"; pragma(msg, y, " ", z); ./ldc-1.42.0-src/tests/dmd/compilable/test7754.d0000644000175000017500000000061215205374125017677 0ustar fabiofabio/* REQUIRED_ARGS: -H -Hd${RESULTS_DIR}/compilable PERMUTE_ARGS: -d -dw OUTPUT_FILES: ${RESULTS_DIR}/compilable/test7754.di TEST_OUTPUT: --- === ${RESULTS_DIR}/compilable/test7754.di // D import file generated from 'compilable/test7754.d' struct Foo(T) { shared static this() { } static this() { } } --- */ struct Foo(T) { shared static this() { } static this() { } } ./ldc-1.42.0-src/tests/dmd/compilable/test22254.d0000644000175000017500000000061515205374125017752 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22254 struct Template(T) { T t; } Template!Bar a; Template!Bar b; immutable struct Bar { } static assert(is(typeof(a) == typeof(b))); static assert(is(typeof(a) == Template!(immutable Bar))); Template!C c1; Template!C c2; immutable class C { } static assert(is(typeof(c1) == typeof(c2))); static assert(is(typeof(c1) == Template!(immutable C))); ./ldc-1.42.0-src/tests/dmd/compilable/test20344.d0000644000175000017500000000042215205374125017744 0ustar fabiofabio// https://github.com/dlang/dmd/issues/20334 // EXTRA_FILES: imports/imp20344.c import imports.imp20344; string s = X; const(char)* p = X; void takes_string(string){ } void takes_char_star(const(char)*){ } void test20344(){ takes_string(X); takes_char_star(X); } ./ldc-1.42.0-src/tests/dmd/compilable/ice13088.d0000644000175000017500000000030215205374125017531 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: struct X { void mfoo(this T)() {} } void test() { shared const X scx; scx.mfoo(); } struct Vec { int x; void sc() shared const {} } ./ldc-1.42.0-src/tests/dmd/compilable/test15785.d0000644000175000017500000000060615205374125017765 0ustar fabiofabio// REQUIRED_ARGS: -de // EXTRA_FILES: imports/test15785.d // PERMUTE_ARGS: import imports.test15785; class Derived : Base, IBase2 { override void foo() { super.foo(); bar(); // Base.bar(); // doesn't work yet due to a bug in checkAccess faz(); // IBase2.faz(); // doesn't work yet due to a bug in checkAccess } typeof(super).T t; } ./ldc-1.42.0-src/tests/dmd/compilable/test23966.d0000644000175000017500000000053115205374125017762 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23966 module test23966; @("gigi") void fun() {} @("mimi") void fun(int) {} @("hihi") void fun(int, int) {} @("bibi") void fun()(int, ulong) {} void main() { static foreach (t; __traits(getOverloads, test23966, "fun", true)) static foreach(attr; __traits(getAttributes, t)) {} } ./ldc-1.42.0-src/tests/dmd/compilable/testgotoskips.d0000644000175000017500000000130215205374125021310 0ustar fabiofabio/* Tests to defend against false positives from the goto skips over decl errors */ // https://issues.dlang.org/show_bug.cgi?id=23271 class A { private static A[] active; private void test() { foreach(a; active) { if(a is this) goto label; } // used to say Error: `goto` skips declaration of variable `s.A.test.__appendtmp4` at s.d(...) active ~= this; label: return; } } // https://github.com/dlang/dmd/issues/18018 int main () { string[string] aa; goto A; // line 4 aa["X"] = "Y"; // line 5 A: return 0; } ./ldc-1.42.0-src/tests/dmd/compilable/test324.d0000644000175000017500000000066615205374125017612 0ustar fabiofabio// DISABLED: LDC // REQUIRED_ARGS: -verrors=simple /* TEST_OUTPUT: --- compilable/test324.d(18): Deprecation: function `test324.main.doStuff!((i) { return i; } ).doStuff` function requires a dual-context, which is deprecated compilable/test324.d(24): instantiated from here: `doStuff!((i) { return i; } )` --- */ struct Foo { void doStuff(alias fun)() {} } void main() { Foo foo; foo.doStuff!( (i) { return i; })(); } ./ldc-1.42.0-src/tests/dmd/compilable/ctests2.c0000644000175000017500000001027215205374125017762 0ustar fabiofabio/*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22304 int * __attribute__((__always_inline__)) foo(void) { return 0; } /*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22312 typedef int Integer; typedef int Integer; /*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22333 enum E { oldval __attribute__((deprecated)) = 0, newval }; int fn (void) { return oldval; } /*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22342 void func(); void booc(int); void cooc(i) int i; { } void test22342() { func(3); booc(3); cooc(1, 3); } /*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22398 const int a; int b = a; /*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22415 int test22415(int a) { switch (a) { case 0: a = 1; case 1: return a; case 2: default: return -1; } } /*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22422 int foo22422(void *p __attribute__((align_value(64)))) { } /*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22432 struct S { int x; }; typedef int T; struct S F(struct S); void test22432() { struct S s; int x1 = (int)(s).x; int x2 = (T)(s).x; int x3 = (F)(s).x; struct S s1 = (F)(s); double d = 1.0; int x4 = (T)(d); int x5 = (T)(d)++; int x6 = (T)(d)--; struct S* p; int x7 = (T)(p)->x; int a[3]; int x8 = (T)(a)[1]++; } /*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22534 struct S22534 { int x; }; void test22534(struct S22534 *const p) { p->x = 1; } /*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22560 ;;; ; struct S22560 { int x; };;;; ; int func22560();;; ;;; /*************************************************/ // typeof() void testTypeof(void) { // general declarations short a; _Static_assert(sizeof(a) == sizeof(short), "1"); typeof(a) b; _Static_assert(sizeof(b) == sizeof(short), "2"); typeof(short) c; _Static_assert(sizeof(c) == sizeof(short), "3"); typeof(a + 1) d; _Static_assert(sizeof(d) == sizeof(int), "4"); // promoted typeof(a += 1) e; _Static_assert(sizeof(e) == sizeof(short), "5"); typeof(1, 1) f; _Static_assert(sizeof(f) == sizeof(int), "6"); typeof(_Generic(1, default: 0)) g; _Static_assert(sizeof(g) == sizeof(int), "7"); const typeof(a) h = (typeof(a))0; _Static_assert(sizeof(h) == sizeof(short), "8"); typeof(const short) i = h; _Static_assert(sizeof(i) == sizeof(short), "9"); // function parameters typeof(a) fun(typeof(a), typeof(h)); fun(a, h); _Static_assert(sizeof(fun(a, h)) == sizeof(short), "10"); // aggregate fields struct Foo { typeof(a) x; }; typeof(((struct Foo){0}).x) fa; _Static_assert(sizeof(fa) == sizeof(short), "11"); // typedefs typedef short Bar; Bar ta; _Static_assert(sizeof(ta) == sizeof(short), "12"); typeof(ta) tb; _Static_assert(sizeof(tb) == sizeof(short), "13"); typeof(Bar) tc; _Static_assert(sizeof(tc) == sizeof(short), "14"); // pointers typeof(&a) pa; _Static_assert(sizeof(pa) == sizeof(void*), "15"); typeof(*pa) pb; _Static_assert(sizeof(pb) == sizeof(short), "16"); } short testTypeofA; const typeof(testTypeofA) testTypeofB = 0; _Static_assert(sizeof(testTypeofB) == sizeof(short), "17"); /*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=23752 void *c23752 = &*((void*)(0)); /*************************************************/ // https://issues.dlang.org/show_bug.cgi?id=23767 const int arr23767[4]; void f23767(void) { int x = *(0 ? (void*)0 : arr23767); int y = *(1 ? arr23767 : (void*)(3-3)); int* p = (1 ? (void*)0 : (void*)0); } /*************************************************/ ./ldc-1.42.0-src/tests/dmd/compilable/test9766.d0000644000175000017500000000264215205374125017711 0ustar fabiofabio// PERMUTE_ARGS: size_t getAlign9766(size_t n) { return n; } struct S9766 { align(getAlign9766(1)): ubyte[5] pad1; ubyte var1; align(getAlign9766(2)): ubyte[5] pad2; ubyte var2; align(getAlign9766(4)): ubyte[5] pad3; ubyte var3; align(getAlign9766(8)): ubyte[5] pad4; ubyte var4; } static assert(S9766.pad1.offsetof == 0); static assert(S9766.var1.offsetof == 5); static assert(S9766.pad2.offsetof == 6); static assert(S9766.var2.offsetof == 12); static assert(S9766.pad3.offsetof == 16); static assert(S9766.var3.offsetof == 24); static assert(S9766.pad4.offsetof == 32); static assert(S9766.var4.offsetof == 40); union U9766 { struct { align(getAlign9766(1)): ubyte[5] pad1; ubyte var1; align(getAlign9766(2)): ubyte[5] pad2; ubyte var2; align(getAlign9766(4)): ubyte[5] pad3; ubyte var3; align(getAlign9766(8)): ubyte[5] pad4; ubyte var4; } } static assert(U9766.pad1.offsetof == 0); static assert(U9766.var1.offsetof == 5); static assert(U9766.pad2.offsetof == 6); static assert(U9766.var2.offsetof == 12); static assert(U9766.pad3.offsetof == 16); static assert(U9766.var3.offsetof == 24); static assert(U9766.pad4.offsetof == 32); static assert(U9766.var4.offsetof == 40); struct TestMaxAlign { align(1u << 15): ubyte a; ubyte b; } static assert(TestMaxAlign.b.offsetof == (1 << 15)); ./ldc-1.42.0-src/tests/dmd/compilable/defa.d0000644000175000017500000000043515205374125017273 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/defaa.d imports/defab.d imports/defac.d imports/defad.d module defa; private import imports.defaa; public abstract class A { Display d; int style; this() {} public this(A parent, int style) { this.style = style; d = parent.d; } } ./ldc-1.42.0-src/tests/dmd/compilable/test16002.d0000644000175000017500000000203515205374125017742 0ustar fabiofabio// EXTRA_FILES: imports/plainpackage/plainmodule.d imports/pkgmodule/package.d imports/pkgmodule/plainmodule.d module test.compilable.test16002; import imports.plainpackage.plainmodule; import imports.pkgmodule.plainmodule; struct MyStruct; alias a = imports.plainpackage; alias b = imports.pkgmodule.plainmodule; static assert(is(imports.plainpackage == package)); static assert(is(a == package)); static assert(!is(imports.plainpackage.plainmodule == package)); static assert(!is(b == package)); static assert(is(imports.pkgmodule == package)); static assert(!is(MyStruct == package)); static assert(!is(imports.plainpackage == module)); static assert(!is(a == module)); static assert(is(imports.plainpackage.plainmodule == module)); 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)); ./ldc-1.42.0-src/tests/dmd/compilable/riia_ctor.d0000644000175000017500000000115315205374125020345 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=17494 // REQUIRED_ARGS: -revert=dtorfields struct S { ~this() {} } class C { S s; this() nothrow {} } // https://issues.dlang.org/show_bug.cgi?id=17505 struct Array { int[] _payload; ~this() { import core.stdc.stdlib : free; free(_payload.ptr); } } class Scanner { Array arr; this() @safe {} } // https://issues.dlang.org/show_bug.cgi?id=17506 struct TreeMap { this() @disable; this(TTree tree) { this.tree = tree; } TTree tree; } struct TTree { this() @disable; this(int foo) {} ~this() {} } ./ldc-1.42.0-src/tests/dmd/compilable/test15712.d0000644000175000017500000000040315205374125017746 0ustar fabiofabio// REQUIRED_ARGS: -unittest // https://issues.dlang.org/show_bug.cgi?id=15712 // extern(C) attribute inside extern(C) unittest is incorrectly ignored extern(C): unittest { extern(C) static void foo() {} static assert(__traits(getLinkage, foo) == "C"); } ./ldc-1.42.0-src/tests/dmd/compilable/test20710.d0000644000175000017500000000044015205374125017741 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20710 // with empty array literal immutable A a = A(B([])); immutable B b = a.b; struct A { B b; } struct B { int[] c; } // with empty struct literal immutable C c = C(D()); immutable D d = c.d; struct C { D d; } struct D { } ./ldc-1.42.0-src/tests/dmd/compilable/ldc_aggregate.d0000644000175000017500000000023615205374125021143 0ustar fabiofabio union A { TypeInfo info; void[0] result; } struct B { TypeInfo info; void[0] result; } class C { TypeInfo info; void[0] result; } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc7656.d0000644000175000017500000000061715205374125017637 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc7656; /** -------- int x; // This is a $ comment (and here is some int y; // more information about that comment) -------- */ void main() { } /** (Regression check) Example: ---- assert(add(1, 1) == 2); ---- */ int add(int a, int b) { return a + b; } ./ldc-1.42.0-src/tests/dmd/compilable/issue21614.d0000644000175000017500000000030415205374125020115 0ustar fabiofabio// 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); } ./ldc-1.42.0-src/tests/dmd/compilable/test11225a.d0000644000175000017500000000020315205374125020100 0ustar fabiofabio/* EXTRA_FILES: imports/test11225b.d imports/test11225c.d TEST_OUTPUT: --- WORKS --- */ import imports.test11225b; interface I {} ./ldc-1.42.0-src/tests/dmd/compilable/cppmangle.d0000644000175000017500000013237315205374125020351 0ustar fabiofabio// EXTRA_FILES: cppmangle2.d // Test C++ name mangling. // https://issues.dlang.org/show_bug.cgi?id=4059 // https://issues.dlang.org/show_bug.cgi?id=5148 // https://issues.dlang.org/show_bug.cgi?id=7024 // https://issues.dlang.org/show_bug.cgi?id=10058 import core.stdc.stdio; version (CppRuntime_LLVM) version = CppMangle_Itanium; version (CppRuntime_GNU) version = CppMangle_Itanium; version (CppRuntime_Microsoft) version = CppMangle_MSVC; version (CppRuntime_Sun) version = CppMangle_Itanium; extern (C++) int foob(int i, int j, int k); class C { extern (C++) int bar(int i, int j, int k) { printf("this = %p\n", this); printf("i = %d\n", i); printf("j = %d\n", j); printf("k = %d\n", k); return 1; } } extern (C++) int foo(int i, int j, int k) { printf("i = %d\n", i); printf("j = %d\n", j); printf("k = %d\n", k); assert(i == 1); assert(j == 2); assert(k == 3); return 1; } void test1() { foo(1, 2, 3); auto i = foob(1, 2, 3); assert(i == 7); C c = new C(); c.bar(4, 5, 6); } version (CppMangle_Itanium) { static assert(foo.mangleof == "_Z3fooiii"); static assert(foob.mangleof == "_Z4foobiii"); static assert(C.bar.mangleof == "_ZN1C3barEiii"); } version (CppMangle_MSVC) { version (Win32) { static assert(foo.mangleof == "?foo@@YAHHHH@Z"); static assert(foob.mangleof == "?foob@@YAHHHH@Z"); static assert(C.bar.mangleof == "?bar@C@@UAEHHHH@Z"); } version (Win64) { static assert(foo.mangleof == "?foo@@YAHHHH@Z"); static assert(foob.mangleof == "?foob@@YAHHHH@Z"); static assert(C.bar.mangleof == "?bar@C@@UEAAHHHH@Z"); } } /****************************************/ extern (C++) interface D { int bar(int i, int j, int k); } extern (C++) D getD(); void test2() { D d = getD(); int i = d.bar(9,10,11); assert(i == 8); } version (CppMangle_Itanium) { static assert (getD.mangleof == "_Z4getDv"); static assert (D.bar.mangleof == "_ZN1D3barEiii"); } /****************************************/ extern (C++) int callE(E); extern (C++) interface E { int bar(int i, int j, int k); } class F : E { extern (C++) int bar(int i, int j, int k) { printf("F.bar: i = %d\n", i); printf("F.bar: j = %d\n", j); printf("F.bar: k = %d\n", k); assert(i == 11); assert(j == 12); assert(k == 13); return 8; } } void test3() { F f = new F(); int i = callE(f); assert(i == 8); } version (CppMangle_Itanium) { static assert (callE.mangleof == "_Z5callEP1E"); static assert (E.bar.mangleof == "_ZN1E3barEiii"); static assert (F.bar.mangleof == "_ZN1F3barEiii"); } /****************************************/ extern (C++) void foo4(char* p); void test4() { foo4(null); } version (CppMangle_Itanium) { static assert(foo4.mangleof == "_Z4foo4Pc"); } /****************************************/ extern(C++) { struct foo5 { int i; int j; void* p; } interface bar5{ foo5 getFoo(int i); } bar5 newBar(); } void test5() { bar5 b = newBar(); foo5 f = b.getFoo(4); printf("f.p = %p, b = %p\n", f.p, cast(void*)b); assert(f.p == cast(void*)b); } version (CppMangle_Itanium) { static assert(bar5.getFoo.mangleof == "_ZN4bar56getFooEi"); static assert (newBar.mangleof == "_Z6newBarv"); } /****************************************/ extern(C++) { struct S6 { int i; double d; } S6 foo6(); } extern (C) int foosize6(); void test6() { S6 f = foo6(); printf("%d %d\n", foosize6(), cast(int)S6.sizeof); assert(foosize6() == S6.sizeof); assert(f.i == 42); printf("f.d = %g\n", f.d); assert(f.d == 2.5); } version (CppMangle_Itanium) { static assert (foo6.mangleof == "_Z4foo6v"); } /****************************************/ extern (C) int foo7(); struct S { int i; long l; } void test7() { printf("%d %d\n", foo7(), cast(int)S.sizeof); assert(foo7() == S.sizeof); } /****************************************/ extern (C++) void foo8(const char *); void test8() { char c; foo8(&c); } version (CppMangle_Itanium) { static assert(foo8.mangleof == "_Z4foo8PKc"); } /****************************************/ // https://issues.dlang.org/show_bug.cgi?id=4059 struct elem9 { } extern(C++) void foobar9(elem9*, elem9*); void test9() { elem9 *a; foobar9(a, a); } version (CppMangle_Itanium) { static assert(foobar9.mangleof == "_Z7foobar9P5elem9S0_"); } /****************************************/ // https://issues.dlang.org/show_bug.cgi?id=5148 extern (C++) { void foo10(const char*, const char*); void foo10(const int, const int); void foo10(const char, const char); struct MyStructType { } void foo10(const MyStructType s, const MyStructType t); enum MyEnumType { onemember } void foo10(const MyEnumType s, const MyEnumType t); } void test10() { char* p; foo10(p, p); foo10(1,2); foo10('c','d'); MyStructType s; foo10(s,s); MyEnumType e; foo10(e,e); } // https://issues.dlang.org/show_bug.cgi?id=19504 extern(C++) struct Class19504 { pragma(mangle, "HOHOHO") ~this(); } static assert(Class19504.__xdtor.mangleof == "HOHOHO"); /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=10058 extern (C++) { void test10058a(void*) { } void test10058b(void function(void*)) { } void test10058c(void* function(void*)) { } void test10058d(void function(void*), void*) { } void test10058e(void* function(void*), void*) { } void test10058f(void* function(void*), void* function(void*)) { } void test10058g(void function(void*), void*, void*) { } void test10058h(void* function(void*), void*, void*) { } void test10058i(void* function(void*), void* function(void*), void*) { } void test10058j(void* function(void*), void* function(void*), void* function(void*)) { } void test10058k(void* function(void*), void* function(const (void)*)) { } void test10058l(void* function(void*), void* function(const (void)*), const(void)* function(void*)) { } } version (CppMangle_Itanium) { static assert(test10058a.mangleof == "_Z10test10058aPv"); static assert(test10058b.mangleof == "_Z10test10058bPFvPvE"); static assert(test10058c.mangleof == "_Z10test10058cPFPvS_E"); static assert(test10058d.mangleof == "_Z10test10058dPFvPvES_"); static assert(test10058e.mangleof == "_Z10test10058ePFPvS_ES_"); static assert(test10058f.mangleof == "_Z10test10058fPFPvS_ES1_"); static assert(test10058g.mangleof == "_Z10test10058gPFvPvES_S_"); static assert(test10058h.mangleof == "_Z10test10058hPFPvS_ES_S_"); static assert(test10058i.mangleof == "_Z10test10058iPFPvS_ES1_S_"); static assert(test10058j.mangleof == "_Z10test10058jPFPvS_ES1_S1_"); static assert(test10058k.mangleof == "_Z10test10058kPFPvS_EPFS_PKvE"); static assert(test10058l.mangleof == "_Z10test10058lPFPvS_EPFS_PKvEPFS3_S_E"); } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=11696 class Expression; struct Loc {} extern(C++) class CallExp { static void test11696a(Loc, Expression, Expression); static void test11696b(Loc, Expression, Expression*); static void test11696c(Loc, Expression*, Expression); static void test11696d(Loc, Expression*, Expression*); } version (CppMangle_Itanium) { static assert(CallExp.test11696a.mangleof == "_ZN7CallExp10test11696aE3LocP10ExpressionS2_"); static assert(CallExp.test11696b.mangleof == "_ZN7CallExp10test11696bE3LocP10ExpressionPS2_"); static assert(CallExp.test11696c.mangleof == "_ZN7CallExp10test11696cE3LocPP10ExpressionS2_"); static assert(CallExp.test11696d.mangleof == "_ZN7CallExp10test11696dE3LocPP10ExpressionS3_"); } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=13337 extern(C++, N13337a.N13337b.N13337c) { struct S13337{} void foo13337(S13337 s); } extern(C++, `N13337a`, `N13337b`, `N13337c`) { struct S13337_2{} void foo13337_2(S13337 s); void foo13337_3(S13337_2 s); } version (CppMangle_Itanium) { static assert(foo13337.mangleof == "_ZN7N13337a7N13337b7N13337c8foo13337ENS1_6S13337E"); static assert(foo13337_2.mangleof == "_ZN7N13337a7N13337b7N13337c10foo13337_2ENS1_6S13337E"); static assert(foo13337_3.mangleof == "_ZN7N13337a7N13337b7N13337c10foo13337_3ENS1_8S13337_2E"); } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=15789 extern (C++) void test15789a(T...)(T args); void test15789() { test15789a(0); } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=7030 extern(C++) { struct Struct7030 { void foo(int) const; void bar(int); static __gshared int boo; } } version (CppMangle_Itanium) { static assert(Struct7030.foo.mangleof == "_ZNK10Struct70303fooEi"); static assert(Struct7030.bar.mangleof == "_ZN10Struct70303barEi"); static assert(Struct7030.boo.mangleof == "_ZN10Struct70303booE"); } /****************************************/ // Special cases of Itanium mangling extern (C++, std) { struct pair(T1, T2) { void swap(ref pair other); } struct allocator(T) { uint fooa() const; uint foob(); } struct basic_string(T1, T2, T3) { uint fooa(); } struct basic_istream(T1, T2) { uint fooc(); } struct basic_ostream(T1, T2) { uint food(); } struct basic_iostream(T1, T2) { uint fooe(); } struct char_traits(T) { uint foof(); } struct vector (T); struct test18957 {} } extern (C++, `std`) { struct pair(T1, T2) { void swap(ref pair other); } struct allocator(T) { uint fooa() const; uint foob(); } struct basic_string(T1, T2, T3) { uint fooa(); } struct basic_istream(T1, T2) { uint fooc(); } struct basic_ostream(T1, T2) { uint food(); } struct basic_iostream(T1, T2) { uint fooe(); } struct char_traits(T) { uint foof(); } struct vector (T); struct Struct18957 {} } extern(C++) { // Nspace std.allocator!int func_18957_1(std.allocator!(int)* v); version (LDC) { // see below } else { // CPPNamespaceAttribute allocator!int func_18957_2(allocator!(int)* v); } X func_18957_2(X)(X* v); } extern (C++) { version (LDC) { // see below } else { void func_20413(pair!(int, float), pair!(float, int)); } } version (CppMangle_Itanium) { // https://issues.dlang.org/show_bug.cgi?id=17947 static assert(std.pair!(void*, void*).swap.mangleof == "_ZNSt4pairIPvS0_E4swapERS1_"); static assert(std.allocator!int.fooa.mangleof == "_ZNKSaIiE4fooaEv"); static assert(std.allocator!int.foob.mangleof == "_ZNSaIiE4foobEv"); static assert(std.basic_string!(char,int,uint).fooa.mangleof == "_ZNSbIcijE4fooaEv"); static assert(std.basic_string!(char, std.char_traits!char, std.allocator!char).fooa.mangleof == "_ZNSs4fooaEv"); static assert(std.basic_istream!(char, std.char_traits!char).fooc.mangleof == "_ZNSi4foocEv"); static assert(std.basic_ostream!(char, std.char_traits!char).food.mangleof == "_ZNSo4foodEv"); static assert(std.basic_iostream!(char, std.char_traits!char).fooe.mangleof == "_ZNSd4fooeEv"); static assert(func_18957_1.mangleof == `_Z12func_18957_1PSaIiE`); static assert(func_18957_2!(std.allocator!int).mangleof == `_Z12func_18957_2ISaIiEET_PS1_`); version (LDC) { /* Cannot instantiate templates in `extern(C++, "std")`, as the mangled function names * collide with those from `extern(C++, std)` (with different struct types). * See https://github.com/ldc-developers/ldc/issues/2782. */ } else { static assert(pair!(void*, void*).swap.mangleof == "_ZNSt4pairIPvS0_E4swapERS1_"); static assert(allocator!int.fooa.mangleof == "_ZNKSaIiE4fooaEv"); static assert(allocator!int.foob.mangleof == "_ZNSaIiE4foobEv"); static assert(basic_string!(char,int,uint).fooa.mangleof == "_ZNSbIcijE4fooaEv"); static assert(basic_string!(char, char_traits!char, allocator!char).fooa.mangleof == "_ZNSs4fooaEv"); static assert(basic_istream!(char, char_traits!char).fooc.mangleof == "_ZNSi4foocEv"); static assert(basic_ostream!(char, char_traits!char).food.mangleof == "_ZNSo4foodEv"); static assert(basic_iostream!(char, char_traits!char).fooe.mangleof == "_ZNSd4fooeEv"); static assert(func_18957_2!(allocator!int).mangleof == `_Z12func_18957_2ISaIiEET_PS1_`); static assert(func_20413.mangleof == `_Z10func_20413St4pairIifES_IfiE`); } } /**************************************/ alias T36 = int ********** ********** ********** **********; extern (C++) void test36(T36, T36*) { } version (CppMangle_Itanium) { static assert(test36.mangleof == "_Z6test36PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPiPS12_"); } /*****************************************/ // https://issues.dlang.org/show_bug.cgi?id=17772 extern(C++, SPACE) int test37(T)(){ return 0;} extern(C++, `SPACE`) int test37(T)(){ return 0;} version (CppMangle_Itanium) // all non-Windows machines { static assert(SPACE.test37!int.mangleof == "_ZN5SPACE6test37IiEEiv"); static assert(test37!int.mangleof == "_ZN5SPACE6test37IiEEiv"); } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=15388 extern (C++) void test15388(typeof(null)); version (CppMangle_Itanium) { static assert(test15388.mangleof == "_Z9test15388Dn"); } version (CppMangle_MSVC) { static assert(test15388.mangleof == "?test15388@@YAX$$T@Z"); } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=14086 extern (C++) class Test14086 { this(); ~this(); } extern (C++) class Test14086_2 { final ~this(); } extern (C++) struct Test14086_S { this(int); ~this(); } version (CppMangle_Itanium) { static assert(Test14086.__ctor.mangleof == "_ZN9Test14086C1Ev"); static assert(Test14086.__dtor.mangleof == "_ZN9Test14086D1Ev"); static assert(Test14086_2.__dtor.mangleof == "_ZN11Test14086_2D1Ev"); static assert(Test14086_S.__ctor.mangleof == "_ZN11Test14086_SC1Ei"); static assert(Test14086_S.__dtor.mangleof == "_ZN11Test14086_SD1Ev"); } version (CppMangle_MSVC) { version (Win32) { static assert(Test14086.__ctor.mangleof == "??0Test14086@@QAE@XZ"); static assert(Test14086.__dtor.mangleof == "??1Test14086@@UAE@XZ"); static assert(Test14086_2.__dtor.mangleof == "??1Test14086_2@@QAE@XZ"); static assert(Test14086_S.__ctor.mangleof == "??0Test14086_S@@QAE@H@Z"); static assert(Test14086_S.__dtor.mangleof == "??1Test14086_S@@QAE@XZ"); } version (Win64) { static assert(Test14086.__ctor.mangleof == "??0Test14086@@QEAA@XZ"); static assert(Test14086.__dtor.mangleof == "??1Test14086@@UEAA@XZ"); static assert(Test14086_2.__dtor.mangleof == "??1Test14086_2@@QEAA@XZ"); static assert(Test14086_S.__ctor.mangleof == "??0Test14086_S@@QEAA@H@Z"); static assert(Test14086_S.__dtor.mangleof == "??1Test14086_S@@QEAA@XZ"); } } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=18888 extern (C++) struct T18888(T) { void fun(); } extern (C++) struct S18888(alias arg = T18888) { alias I = T18888!(arg!int); } version (CppMangle_Itanium) { static assert(S18888!().I.fun.mangleof == "_ZN6T18888IS_IiEE3funEv"); } version (CppMangle_MSVC) { version (Win32) { static assert(S18888!().I.fun.mangleof == "?fun@?$T18888@U?$T18888@H@@@@QAEXXZ"); } version (Win64) { static assert(S18888!().I.fun.mangleof == "?fun@?$T18888@U?$T18888@H@@@@QEAAXXZ"); } } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=18890 extern (C++) class C18890 { ~this() {} } extern (C++) class C18890_2 { ~this() {} extern (C++) struct Agg { ~this() {} } Agg s; } void test18890() { version (CppMangle_Itanium) { static assert(C18890.__dtor.mangleof == "_ZN6C18890D1Ev"); static assert(C18890.__xdtor.mangleof == "_ZN6C18890D1Ev"); static assert(C18890_2.__dtor.mangleof == "_ZN8C18890_26__dtorEv"); static assert(C18890_2.__xdtor.mangleof == "_ZN8C18890_2D1Ev"); } version (CppMangle_MSVC) { version (Win32) { static assert(C18890.__dtor.mangleof == "??1C18890@@UAE@XZ"); static assert(C18890.__xdtor.mangleof == "??_GC18890@@UAEPAXI@Z"); static assert(C18890_2.__dtor.mangleof == "?__dtor@C18890_2@@UAEXXZ"); static assert(C18890_2.__xdtor.mangleof == "??_GC18890_2@@UAEPAXI@Z"); } version (Win64) { static assert(C18890.__dtor.mangleof == "??1C18890@@UEAA@XZ"); static assert(C18890.__xdtor.mangleof == "??_GC18890@@UEAAPEAXI@Z"); static assert(C18890_2.__dtor.mangleof == "?__dtor@C18890_2@@UEAAXXZ"); static assert(C18890_2.__xdtor.mangleof == "??_GC18890_2@@UEAAPEAXI@Z"); } } } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=18891 extern (C++) class C18891 { ~this(); extern (C++) struct Agg { ~this() {} } Agg s; } void test18891() { version (CppMangle_Itanium) { static assert(C18891.__dtor.mangleof == "_ZN6C18891D1Ev"); static assert(C18891.__xdtor.mangleof == "_ZN6C18891D1Ev"); } version (CppMangle_MSVC) { version (Win32) { static assert(C18891.__dtor.mangleof == "??1C18891@@UAE@XZ"); static assert(C18891.__xdtor.mangleof == "??_GC18891@@UAEPAXI@Z"); } version (Win64) { static assert(C18891.__dtor.mangleof == "??1C18891@@UEAA@XZ"); static assert(C18891.__xdtor.mangleof == "??_GC18891@@UEAAPEAXI@Z"); } } } /**************************************/ // Test C++ operator mangling extern (C++) struct TestOperators { int opCast(T)(); int opBinary(string op)(int x); int opUnary(string op)(); int opOpAssign(string op)(int x); int opIndex(int x); bool opEquals(int x); int opCall(int, float); int opAssign(int); } version (CppMangle_Itanium) { static assert(TestOperators.opUnary!"*".mangleof == "_ZN13TestOperatorsdeEv"); static assert(TestOperators.opUnary!"++".mangleof == "_ZN13TestOperatorsppEv"); static assert(TestOperators.opUnary!"--".mangleof == "_ZN13TestOperatorsmmEv"); static assert(TestOperators.opUnary!"-".mangleof == "_ZN13TestOperatorsngEv"); static assert(TestOperators.opUnary!"+".mangleof == "_ZN13TestOperatorspsEv"); static assert(TestOperators.opUnary!"~".mangleof == "_ZN13TestOperatorscoEv"); static assert(TestOperators.opBinary!">>".mangleof == "_ZN13TestOperatorsrsEi"); static assert(TestOperators.opBinary!"<<".mangleof == "_ZN13TestOperatorslsEi"); static assert(TestOperators.opBinary!"*".mangleof == "_ZN13TestOperatorsmlEi"); static assert(TestOperators.opBinary!"-".mangleof == "_ZN13TestOperatorsmiEi"); static assert(TestOperators.opBinary!"+".mangleof == "_ZN13TestOperatorsplEi"); static assert(TestOperators.opBinary!"&".mangleof == "_ZN13TestOperatorsanEi"); static assert(TestOperators.opBinary!"/".mangleof == "_ZN13TestOperatorsdvEi"); static assert(TestOperators.opBinary!"%".mangleof == "_ZN13TestOperatorsrmEi"); static assert(TestOperators.opBinary!"^".mangleof == "_ZN13TestOperatorseoEi"); static assert(TestOperators.opBinary!"|".mangleof == "_ZN13TestOperatorsorEi"); static assert(TestOperators.opOpAssign!"*".mangleof == "_ZN13TestOperatorsmLEi"); static assert(TestOperators.opOpAssign!"+".mangleof == "_ZN13TestOperatorspLEi"); static assert(TestOperators.opOpAssign!"-".mangleof == "_ZN13TestOperatorsmIEi"); static assert(TestOperators.opOpAssign!"/".mangleof == "_ZN13TestOperatorsdVEi"); static assert(TestOperators.opOpAssign!"%".mangleof == "_ZN13TestOperatorsrMEi"); static assert(TestOperators.opOpAssign!">>".mangleof == "_ZN13TestOperatorsrSEi"); static assert(TestOperators.opOpAssign!"<<".mangleof == "_ZN13TestOperatorslSEi"); static assert(TestOperators.opOpAssign!"&".mangleof == "_ZN13TestOperatorsaNEi"); static assert(TestOperators.opOpAssign!"|".mangleof == "_ZN13TestOperatorsoREi"); static assert(TestOperators.opOpAssign!"^".mangleof == "_ZN13TestOperatorseOEi"); static assert(TestOperators.opCast!int.mangleof == "_ZN13TestOperatorscviEv"); static assert(TestOperators.opAssign.mangleof == "_ZN13TestOperatorsaSEi"); static assert(TestOperators.opEquals.mangleof == "_ZN13TestOperatorseqEi"); static assert(TestOperators.opIndex.mangleof == "_ZN13TestOperatorsixEi"); static assert(TestOperators.opCall.mangleof == "_ZN13TestOperatorsclEif"); } version (CppMangle_MSVC) { version (Win32) { static assert(TestOperators.opUnary!"*".mangleof == "??DTestOperators@@QAEHXZ"); static assert(TestOperators.opUnary!"++".mangleof == "??ETestOperators@@QAEHXZ"); static assert(TestOperators.opUnary!"--".mangleof == "??FTestOperators@@QAEHXZ"); static assert(TestOperators.opUnary!"-".mangleof == "??GTestOperators@@QAEHXZ"); static assert(TestOperators.opUnary!"+".mangleof == "??HTestOperators@@QAEHXZ"); static assert(TestOperators.opUnary!"~".mangleof == "??STestOperators@@QAEHXZ"); static assert(TestOperators.opBinary!">>".mangleof == "??5TestOperators@@QAEHH@Z"); static assert(TestOperators.opBinary!"<<".mangleof == "??6TestOperators@@QAEHH@Z"); static assert(TestOperators.opBinary!"*".mangleof == "??DTestOperators@@QAEHH@Z"); static assert(TestOperators.opBinary!"-".mangleof == "??GTestOperators@@QAEHH@Z"); static assert(TestOperators.opBinary!"+".mangleof == "??HTestOperators@@QAEHH@Z"); static assert(TestOperators.opBinary!"&".mangleof == "??ITestOperators@@QAEHH@Z"); static assert(TestOperators.opBinary!"/".mangleof == "??KTestOperators@@QAEHH@Z"); static assert(TestOperators.opBinary!"%".mangleof == "??LTestOperators@@QAEHH@Z"); static assert(TestOperators.opBinary!"^".mangleof == "??TTestOperators@@QAEHH@Z"); static assert(TestOperators.opBinary!"|".mangleof == "??UTestOperators@@QAEHH@Z"); static assert(TestOperators.opOpAssign!"*".mangleof == "??XTestOperators@@QAEHH@Z"); static assert(TestOperators.opOpAssign!"+".mangleof == "??YTestOperators@@QAEHH@Z"); static assert(TestOperators.opOpAssign!"-".mangleof == "??ZTestOperators@@QAEHH@Z"); static assert(TestOperators.opOpAssign!"/".mangleof == "??_0TestOperators@@QAEHH@Z"); static assert(TestOperators.opOpAssign!"%".mangleof == "??_1TestOperators@@QAEHH@Z"); static assert(TestOperators.opOpAssign!">>".mangleof == "??_2TestOperators@@QAEHH@Z"); static assert(TestOperators.opOpAssign!"<<".mangleof == "??_3TestOperators@@QAEHH@Z"); static assert(TestOperators.opOpAssign!"&".mangleof == "??_4TestOperators@@QAEHH@Z"); static assert(TestOperators.opOpAssign!"|".mangleof == "??_5TestOperators@@QAEHH@Z"); static assert(TestOperators.opOpAssign!"^".mangleof == "??_6TestOperators@@QAEHH@Z"); static assert(TestOperators.opCast!int.mangleof == "??BTestOperators@@QAEHXZ"); static assert(TestOperators.opAssign.mangleof == "??4TestOperators@@QAEHH@Z"); static assert(TestOperators.opEquals.mangleof == "??8TestOperators@@QAE_NH@Z"); static assert(TestOperators.opIndex.mangleof == "??ATestOperators@@QAEHH@Z"); static assert(TestOperators.opCall.mangleof == "??RTestOperators@@QAEHHM@Z"); } version (Win64) { static assert(TestOperators.opUnary!"*".mangleof == "??DTestOperators@@QEAAHXZ"); static assert(TestOperators.opUnary!"++".mangleof == "??ETestOperators@@QEAAHXZ"); static assert(TestOperators.opUnary!"--".mangleof == "??FTestOperators@@QEAAHXZ"); static assert(TestOperators.opUnary!"-".mangleof == "??GTestOperators@@QEAAHXZ"); static assert(TestOperators.opUnary!"+".mangleof == "??HTestOperators@@QEAAHXZ"); static assert(TestOperators.opUnary!"~".mangleof == "??STestOperators@@QEAAHXZ"); static assert(TestOperators.opBinary!">>".mangleof == "??5TestOperators@@QEAAHH@Z"); static assert(TestOperators.opBinary!"<<".mangleof == "??6TestOperators@@QEAAHH@Z"); static assert(TestOperators.opBinary!"*".mangleof == "??DTestOperators@@QEAAHH@Z"); static assert(TestOperators.opBinary!"-".mangleof == "??GTestOperators@@QEAAHH@Z"); static assert(TestOperators.opBinary!"+".mangleof == "??HTestOperators@@QEAAHH@Z"); static assert(TestOperators.opBinary!"&".mangleof == "??ITestOperators@@QEAAHH@Z"); static assert(TestOperators.opBinary!"/".mangleof == "??KTestOperators@@QEAAHH@Z"); static assert(TestOperators.opBinary!"%".mangleof == "??LTestOperators@@QEAAHH@Z"); static assert(TestOperators.opBinary!"^".mangleof == "??TTestOperators@@QEAAHH@Z"); static assert(TestOperators.opBinary!"|".mangleof == "??UTestOperators@@QEAAHH@Z"); static assert(TestOperators.opOpAssign!"*".mangleof == "??XTestOperators@@QEAAHH@Z"); static assert(TestOperators.opOpAssign!"+".mangleof == "??YTestOperators@@QEAAHH@Z"); static assert(TestOperators.opOpAssign!"-".mangleof == "??ZTestOperators@@QEAAHH@Z"); static assert(TestOperators.opOpAssign!"/".mangleof == "??_0TestOperators@@QEAAHH@Z"); static assert(TestOperators.opOpAssign!"%".mangleof == "??_1TestOperators@@QEAAHH@Z"); static assert(TestOperators.opOpAssign!">>".mangleof == "??_2TestOperators@@QEAAHH@Z"); static assert(TestOperators.opOpAssign!"<<".mangleof == "??_3TestOperators@@QEAAHH@Z"); static assert(TestOperators.opOpAssign!"&".mangleof == "??_4TestOperators@@QEAAHH@Z"); static assert(TestOperators.opOpAssign!"|".mangleof == "??_5TestOperators@@QEAAHH@Z"); static assert(TestOperators.opOpAssign!"^".mangleof == "??_6TestOperators@@QEAAHH@Z"); static assert(TestOperators.opCast!int.mangleof == "??BTestOperators@@QEAAHXZ"); static assert(TestOperators.opAssign.mangleof == "??4TestOperators@@QEAAHH@Z"); static assert(TestOperators.opEquals.mangleof == "??8TestOperators@@QEAA_NH@Z"); static assert(TestOperators.opIndex.mangleof == "??ATestOperators@@QEAAHH@Z"); static assert(TestOperators.opCall.mangleof == "??RTestOperators@@QEAAHHM@Z"); } } import cppmangle2; extern(C++, Namespace18922) { // Nspace void func18922(cppmangle2.Namespace18922.Struct18922) {} // CPPNamespaceAttribute void func18922_1(Struct18922) {} } extern(C++, `Namespace18922`) { // Nspace void func18922_2(cppmangle2.Namespace18922.Struct18922) {} // CPPNamespaceAttribute void func18922_3(Struct18922) {} } version (CppMangle_Itanium) { static assert(func18922.mangleof == "_ZN14Namespace189229func18922ENS_11Struct18922E"); static assert(func18922_1.mangleof == "_ZN14Namespace1892211func18922_1ENS_11Struct18922E"); static assert(func18922_2.mangleof == "_ZN14Namespace1892211func18922_2ENS_11Struct18922E"); static assert(func18922_3.mangleof == "_ZN14Namespace1892211func18922_3ENS_11Struct18922E"); } else version (CppMangle_MSVC) { static assert(func18922.mangleof == "?func18922@Namespace18922@@YAXUStruct18922@1@@Z"); static assert(func18922_1.mangleof == "?func18922_1@Namespace18922@@YAXUStruct18922@1@@Z"); static assert(func18922_2.mangleof == "?func18922_2@Namespace18922@@YAXUStruct18922@1@@Z"); static assert(func18922_3.mangleof == "?func18922_3@Namespace18922@@YAXUStruct18922@1@@Z"); } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=18957 // extern(C++) doesn't mangle 'std' correctly on posix systems version (CppMangle_Itanium) { // https://godbolt.org/z/C5T2LQ /+ namespace std { struct test18957 {}; } void test18957(const std::test18957& t) {} +/ extern (C++) void test18957(ref const(Struct18957) t) {} static assert(test18957.mangleof == "_Z9test18957RKSt11Struct18957"); } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=19043 // Incorrect mangling for extern(C++) const template parameter on windows extern(C++) struct test19043(T) {} extern(C++) void test19043a(test19043!(const(char)) a) {} extern(C++) void test19043b(T)(T a) {} version (CppMangle_MSVC) { static assert(test19043a.mangleof == "?test19043a@@YAXU?$test19043@$$CBD@@@Z"); static assert(test19043b!(test19043!(const(char))).mangleof == "??$test19043b@U?$test19043@$$CBD@@@@YAXU?$test19043@$$CBD@@@Z"); } // https://issues.dlang.org/show_bug.cgi?id=16479 // Missing substitution while mangling C++ template parameter for functions version (CppMangle_Itanium) extern (C++) { // Make sure aliases are still resolved alias Alias16479 = int; Alias16479 func16479_0 (FuncT1) (FuncT1, Alias16479); static assert(func16479_0!(int).mangleof == `_Z11func16479_0IiEiT_i`); // Simple substitution on return type FuncT1* func16479_1 (FuncT1) (); static assert(func16479_1!(int).mangleof == `_Z11func16479_1IiEPT_v`); // Simple substitution on parameter void func16479_2 (FuncT1) (FuncT1); static assert(func16479_2!(int).mangleof == `_Z11func16479_2IiEvT_`); // Make sure component substition is prefered over template parameter FuncT1* func16479_3 (FuncT1) (FuncT1); static assert(func16479_3!(int).mangleof == `_Z11func16479_3IiEPT_S0_`); struct Array16479 (Arg) { Arg* data; } struct Array16479_2 (Arg, int Size) { Arg[Size] data; } struct Value16479 (int Value1, int Value2) { int data; } // Make sure template parameter substitution happens on templated return Array16479!(FuncT2) func16479_4 (FuncT1, FuncT2) (FuncT1); static assert(func16479_4!(int, float).mangleof == `_Z11func16479_4IifE10Array16479IT0_ET_`); // Make sure template parameter substitution happens with values Value16479!(Value2, Value1)* func16479_5 (int Value1, int Value2) (); static assert(func16479_5!(1, 1).mangleof == `_Z11func16479_5ILi1ELi1EEP10Value16479IXT0_EXT_EEv`); // But make sure it's not substituting *too many* values Value16479!(1, 1)* func16479_6 (int Value1, int Value2) (); static assert(func16479_6!(1, 1).mangleof == `_Z11func16479_6ILi1ELi1EEP10Value16479ILi1ELi1EEv`); // Or too many types Array16479!(int) func16479_7 (FuncT1, FuncT2) (FuncT1); static assert(func16479_7!(int, int).mangleof == `_Z11func16479_7IiiE10Array16479IiET_`); // Also must check the parameters for template param substitution void func16479_8 (FuncT1) (Array16479!(FuncT1)); static assert(func16479_8!(int).mangleof == `_Z11func16479_8IiEv10Array16479IT_E`); // And non-substitution void func16479_9 (FuncT1) (Array16479!(int)); static assert(func16479_9!(int).mangleof == `_Z11func16479_9IiEv10Array16479IiE`); // Now let's have a bit of fun with alias parameters, // starting with C functions // TODO: Why is this mangled by g++: /* extern "C" { void externC16479 (int); } template void func16479_10 (); void foo () { func16479_10(); } */ extern (C) void externC16479 (int); void func16479_10 (alias Print) (); static assert(func16479_10!(externC16479).mangleof == `_Z12func16479_10IXadL_Z12externC16479EEEvv`); /** * Let's not exclude C++ functions * Note: * Passing a function as template parameter has an implicit * `&` operator prepended to it, so the following code: * --- * void CPPPrinter16479(const char*); * template void func16479_11 (); * void foo () { func16479_11(); } * --- * Gets mangled as `func16479_11<&CPPPrinter16479>()` would, * which means the expression part of the template argument is * mangled as `XadL_Z[...]E` not `XL_Z[...]E` * (expressions always begin with a code anyway). */ extern(C++) void CPPPrinter16479(const(char)*); extern(C++, Namespace16479) void CPPPrinterNS16479(const(char)*); extern(C++, `Namespace16479`) void CPPPrinterNS16479_1(const(char)*); void func16479_11 (alias Print) (); static assert(func16479_11!(CPPPrinter16479).mangleof == `_Z12func16479_11IXadL_Z15CPPPrinter16479PKcEEEvv`); static assert(func16479_11!(CPPPrinterNS16479).mangleof == `_Z12func16479_11IXadL_ZN14Namespace1647917CPPPrinterNS16479EPKcEEEvv`); static assert(func16479_11!(CPPPrinterNS16479_1).mangleof == `_Z12func16479_11IXadL_ZN14Namespace1647919CPPPrinterNS16479_1EPKcEEEvv`); // Functions are fine, but templates are finer // --- // template class Container, typename T, int Val> // Container func16479_12 (); // --- Container!(T, Val) func16479_12 (alias Container, T, int Val) (); static assert(func16479_12!(Array16479_2, int, 42).mangleof == `_Z12func16479_12I12Array16479_2iLi42EET_IT0_XT1_EEv`); // Substitution needs to happen on the most specialized type // Iow, `ref T identity (T) (ref T v);` should be mangled as // `_Z8identityIiET_*S1_*`, not as `_Z8identityIiET_*RS0_*` ref FuncT1 func16479_13_1 (FuncT1) (ref FuncT1); FuncT1* func16479_13_2 (FuncT1) (FuncT1*); void func16479_13_3 (FuncT1) (FuncT1*, FuncT1*); FuncT1** func16479_13_4 (FuncT1) (FuncT1*, FuncT1); FuncT1 func16479_13_5 (FuncT1) (FuncT1*, FuncT1**); static assert(func16479_13_1!(int).mangleof == `_Z14func16479_13_1IiERT_S1_`); static assert(func16479_13_2!(float).mangleof == `_Z14func16479_13_2IfEPT_S1_`); static assert(func16479_13_3!(int).mangleof == `_Z14func16479_13_3IiEvPT_S1_`); static assert(func16479_13_4!(int).mangleof == `_Z14func16479_13_4IiEPPT_S1_S0_`); static assert(func16479_13_5!(int).mangleof == `_Z14func16479_13_5IiET_PS0_PS1_`); // Opaque types result in a slightly different AST vector!T* func16479_14 (T) (T v); static assert(func16479_14!(int).mangleof == `_Z12func16479_14IiEPSt6vectorIT_ES1_`); struct Foo16479_15 (T); struct Baguette16479_15 (T); struct Bar16479_15 (T); struct FooBar16479_15 (A, B); void inst16479_15_2 (A, B) (); void inst16479_15_3 (A, B, C) (); static assert(inst16479_15_2!(Bar16479_15!int, int).mangleof == `_Z14inst16479_15_2I11Bar16479_15IiEiEvv`); static assert(inst16479_15_2!(int, Bar16479_15!int).mangleof == `_Z14inst16479_15_2Ii11Bar16479_15IiEEvv`); static assert(inst16479_15_2!(Bar16479_15!int, FooBar16479_15!(Bar16479_15!int, Foo16479_15!(Bar16479_15!(Foo16479_15!int)))).mangleof == `_Z14inst16479_15_2I11Bar16479_15IiE14FooBar16479_15IS1_11Foo16479_15IS0_IS3_IiEEEEEvv`); static assert(inst16479_15_3!(int, Bar16479_15!int, FooBar16479_15!(Bar16479_15!int, Foo16479_15!(Bar16479_15!(Foo16479_15!int)))).mangleof == `_Z14inst16479_15_3Ii11Bar16479_15IiE14FooBar16479_15IS1_11Foo16479_15IS0_IS3_IiEEEEEvv`); static import cppmangle2; cppmangle2.Struct18922* func16479_16_1 (T) (T*); static assert(func16479_16_1!int.mangleof == `_Z14func16479_16_1IiEPN14Namespace1892211Struct18922EPT_`); T* func16479_16_2 (T) (T*); static assert(func16479_16_2!int.mangleof == `_Z14func16479_16_2IiEPT_S1_`); static assert(func16479_16_2!(cppmangle2.vector!int).mangleof == `_Z14func16479_16_2ISt6vectorIiEEPT_S3_`); static assert(func16479_16_2!(cppmangle2.vector!int).mangleof == func16479_16_2!(cppmangle2.vector!int).mangleof); cppmangle2.vector!T* func16479_16_3 (T) (T*); static assert(func16479_16_3!int.mangleof == `_Z14func16479_16_3IiEPSt6vectorIiEPT_`); extern(C++, `fakestd`) { extern (C++, `__1`) { struct allocator16479 (T); struct vector16479(T, alloc = allocator16479!T); } } vector16479!(T, allocator16479!T)* func16479_17_1(T)(); vector16479!(T)* func16479_17_2(T)(); static assert(func16479_17_1!int.mangleof == `_Z14func16479_17_1IiEPN7fakestd3__111vector16479IT_NS1_14allocator16479IS3_EEEEv`); static assert(func16479_17_2!int.mangleof == `_Z14func16479_17_2IiEPN7fakestd3__111vector16479IT_NS1_14allocator16479IS3_EEEEv`); // Make sure substitution takes place everywhere in template arg list extern(C++, "ns") void func16479_18_1(T, X)(int, X, T, float); extern(C++, "ns") void func16479_18_2(T, X)(X, int, T, float); static assert(func16479_18_1!(double, char).mangleof == `_ZN2ns14func16479_18_1IdcEEviT0_T_f`); static assert(func16479_18_2!(double, char).mangleof == `_ZN2ns14func16479_18_2IdcEEvT0_iT_f`); } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=19278 // extern(C++, "name") doesn't accept expressions extern(C++, "hello" ~ "world") { void test19278(); } enum NS = "lookup"; extern(C++, (NS)) { void test19278_2(); } alias AliasSeq(Args...) = Args; alias Tup = AliasSeq!("hello", "world"); extern(C++, (Tup)) { void test19278_3(); __gshared size_t test19278_var; } extern(C++, (AliasSeq!(Tup, "yay"))) { void test19278_4(); } version (CppMangle_MSVC) { version (Win64) { static assert(test19278.mangleof == "?test19278@helloworld@@YAXXZ"); static assert(test19278_2.mangleof == "?test19278_2@lookup@@YAXXZ"); static assert(test19278_3.mangleof == "?test19278_3@world@hello@@YAXXZ"); static assert(test19278_4.mangleof == "?test19278_4@yay@world@hello@@YAXXZ"); static assert(test19278_var.mangleof == "?test19278_var@world@hello@@3_KA"); } } else version (CppMangle_Itanium) { static assert(test19278.mangleof == "_ZN10helloworld9test19278Ev"); static assert(test19278_2.mangleof == "_ZN6lookup11test19278_2Ev"); static assert(test19278_3.mangleof == "_ZN5hello5world11test19278_3Ev"); static assert(test19278_4.mangleof == "_ZN5hello5world3yay11test19278_4Ev"); static assert(test19278_var.mangleof == "_ZN5hello5world13test19278_varE"); } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=18958 // Issue 18958 - extern(C++) wchar, dchar mangling not correct version (Posix) enum __c_wchar_t : dchar; else version (Windows) enum __c_wchar_t : wchar; alias wchar_t = __c_wchar_t; extern (C++) void test_char_mangling(char, wchar, dchar, wchar_t); version (CppMangle_Itanium) { static assert(test_char_mangling.mangleof == "_Z18test_char_manglingcDsDiw"); } version (CppMangle_MSVC) { version (Win64) { static assert(test_char_mangling.mangleof == "?test_char_mangling@@YAXD_S_U_W@Z"); } } // https://github.com/dlang/dmd/pull/10021/files#r294055424 version (CppMangle_Itanium) { extern(C++, PR10021_NS) struct PR10021_Struct(T){} extern(C++) void PR10021_fun(int i)(PR10021_Struct!int); static assert(PR10021_fun!0.mangleof == `_Z11PR10021_funILi0EEvN10PR10021_NS14PR10021_StructIiEE`); } // https://github.com/dlang/dmd/pull/10021#discussion_r294095749 version (CppMangle_Itanium) { extern(C++, "a", "b") struct PR10021_Struct2 { void func(); void func2(PR10021_Struct2*); } static assert(PR10021_Struct2.func.mangleof == `_ZN1a1b15PR10021_Struct24funcEv`); static assert(PR10021_Struct2.func2.mangleof == `_ZN1a1b15PR10021_Struct25func2EPS1_`); } /// https://issues.dlang.org/show_bug.cgi?id=20022 version (CppMangle_Itanium) { extern(C++, `ns20022`) enum Enum20022_1 { A = 1, } extern(C++) void fun20022_1(Enum20022_1); extern(C++, `ns20022`) void fun20022_2(Enum20022_1); extern(C++, ns20022) { enum Enum20022_2 { A = 1, } void fun20022_5(Enum20022_1); void fun20022_6(Enum20022_2); } extern(C++) void fun20022_3(Enum20022_2); extern(C++, `ns20022`) void fun20022_4(Enum20022_2); static assert(fun20022_1.mangleof == `_Z10fun20022_1N7ns2002211Enum20022_1E`); static assert(fun20022_2.mangleof == `_ZN7ns2002210fun20022_2ENS_11Enum20022_1E`); static assert(fun20022_3.mangleof == `_Z10fun20022_3N7ns2002211Enum20022_2E`); static assert(fun20022_4.mangleof == `_ZN7ns2002210fun20022_4ENS_11Enum20022_2E`); static assert(fun20022_5.mangleof == `_ZN7ns2002210fun20022_5ENS_11Enum20022_1E`); static assert(fun20022_6.mangleof == `_ZN7ns2002210fun20022_6ENS_11Enum20022_2E`); } // https://issues.dlang.org/show_bug.cgi?id=20094 version (CppMangle_Itanium) { extern(C++, "ns20094") { struct xvector20094 (T) {} alias V20094 = xvector20094!(ubyte); } extern(C++) void test20094(xvector20094!(V20094)* v); static assert(test20094.mangleof == `_Z9test20094PN7ns2009412xvector20094INS0_IhEEEE`); } // https://issues.dlang.org/show_bug.cgi?id=20223 version (CppMangle_Itanium) { extern(C++) { int test20223_1(T)(int function(const(T)* value)); int test20223_2(T)(int function(ref const(T) value)); struct Struct20223_1 {} struct Struct20223_2 {} int test20223_3(ref const Struct20223_1, Struct20223_2*, Struct20223_2*); int test20223_4(ref const Struct20223_1, const ref Struct20223_2, Struct20223_2*); struct Struct20223_3 (T) {} void test20223_5(ref Struct20223_1, ref Struct20223_3!(const(char)*), ref Struct20223_3!(const(char)*)); } static assert(test20223_1!int.mangleof == `_Z11test20223_1IiEiPFiPKT_E`); static assert(test20223_2!int.mangleof == `_Z11test20223_2IiEiPFiRKT_E`); static assert(test20223_1!(int*).mangleof == `_Z11test20223_1IPiEiPFiPKT_E`); static assert(test20223_2!(int*).mangleof == `_Z11test20223_2IPiEiPFiRKT_E`); static assert(test20223_3.mangleof == `_Z11test20223_3RK13Struct20223_1P13Struct20223_2S3_`); static assert(test20223_4.mangleof == `_Z11test20223_4RK13Struct20223_1RK13Struct20223_2PS2_`); static assert(test20223_5.mangleof == `_Z11test20223_5R13Struct20223_1R13Struct20223_3IPKcES5_`); } // https://issues.dlang.org/show_bug.cgi?id=20224 version (CppMangle_Itanium) { extern(C++) public int test20224_1(T)(set20224!T set); // ok extern(C++) public int test20224_2(T)(ref set20224!T set); // segfault extern(C++) struct set20224 (T) { void test () { test20224_1!T(this); test20224_2!T(this); // segfaults } } extern(D) void func20224 () { set20224!int x; } } /**************************************/ version (CppMangle_Itanium) { extern (C++) struct Loc2 {}; extern (C++) class FuncDeclaration { static FuncDeclaration create(ref const Loc2, ref const Loc2); }; extern (C++) FuncDeclaration FuncDeclaration_create(ref const Loc2, ref const Loc2); static assert(FuncDeclaration_create.mangleof == `_Z22FuncDeclaration_createRK4Loc2S1_`); static assert(FuncDeclaration.create.mangleof == `_ZN15FuncDeclaration6createERK4Loc2S2_`); } enum Enum19542 = func19542!(int).mangleof; extern(C++, `bar`) { void func19542(T)(); } // https://issues.dlang.org/show_bug.cgi?id=20700 // Only testing on WIn64 because the mangling includes 'E', // and the bug can be tested on either platform version (CppMangle_MSVC) version (Win64) extern(C++) { void test20700_1(Struct20700); extern(C++, class) struct Struct20700 {} void test20700_2(Struct20700); // Note: Needs to be `V` (`class`), not `U` (`struct`) static assert(test20700_1.mangleof == `?test20700_1@@YAXVStruct20700@@@Z`); static assert(test20700_2.mangleof == `?test20700_2@@YAXVStruct20700@@@Z`); // Test that the scope is not "sticky" on the arguments void test20700_3(TStruct20700_1!DefaultClass20700_1); extern(C++, class) struct TStruct20700_1 (T1, T2 = DefaultStruct20700_1) {} extern(C++, class) struct DefaultStruct20700_1 {} extern(C++, struct) class DefaultClass20700_1 {} static assert(test20700_3.mangleof == `?test20700_3@@YAXV?$TStruct20700_1@PEAUDefaultClass20700_1@@VDefaultStruct20700_1@@@@@Z`); // Each test needs to be independent symbol to trigger a new semantic pass void test20700_4(TStruct20700_2!(DefaultClass20700_2, DefaultStruct20700_2)); extern(C++, struct) class TStruct20700_2 (T1, T2 = DefaultClass20700_2) {} extern(C++, class) struct DefaultStruct20700_2 {} extern(C++, struct) class DefaultClass20700_2 {} static assert(test20700_4.mangleof == `?test20700_4@@YAXPEAU?$TStruct20700_2@PEAUDefaultClass20700_2@@VDefaultStruct20700_2@@@@@Z`); } /*****************************************/ alias noreturn = typeof(*null); extern (C++) { alias fpcpp = noreturn function(); int funccpp(fpcpp); version (CppMangle_Itanium) static assert(funccpp.mangleof == "_Z7funccppPFvvE"); version (CppMangle_MSVC) { version (Win32) static assert(funccpp.mangleof == "?funccpp@@YAHP6AXXZ@Z"); version (Win64) static assert(funccpp.mangleof == "?funccpp@@YAHP6AXXZ@Z"); } } /*****************************************/ extern(C++) enum _LIBNAME = "library"; extern(C++) enum _DEBUG = _LIBNAME.length && 'd' == _LIBNAME[$-1]; ./ldc-1.42.0-src/tests/dmd/compilable/empty_file.d0000644000175000017500000000000015205374125020515 0ustar fabiofabio./ldc-1.42.0-src/tests/dmd/compilable/depsOutput21238_foo.d0000644000175000017500000000617615205374125022023 0ustar fabiofabio/* PERMUTE_ARGS: REQUIRED_ARGS: -deps -Jcompilable/imports EXTRA_SOURCES: imports/depsOutput21238_bar.d imports/depsOutput21238_baz_moduleimport.d imports/depsOutput21238_baz_stringimport.d imports/depsOutput21238_qux.d TRANSFORM_OUTPUT: remove_lines("druntime") TEST_OUTPUT: --- depsImport depsOutput21238_foo (compilable$?:windows=\\|/$depsOutput21238_foo.d) : private : imports.depsOutput21238_baz_moduleimport (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_baz_moduleimport.d) depsImport imports.depsOutput21238_baz_moduleimport (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_baz_moduleimport.d) : private : imports.depsOutput21238_qux (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_qux.d) depsImport depsOutput21238_foo (compilable$?:windows=\\|/$depsOutput21238_foo.d) : private : imports.depsOutput21238_baz_stringimport (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_baz_stringimport.d) depsFile imports.depsOutput21238_baz_stringimport (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_baz_stringimport.d) : depsOutput21238_qux.d $r:\(.*depsOutput21238_qux.d\)$ depsImport depsOutput21238_foo (compilable$?:windows=\\|/$depsOutput21238_foo.d) : private : imports.depsOutput21238_baz_cond (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_baz_cond.d) depsVersion imports.depsOutput21238_baz_cond (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_baz_cond.d) : qux depsImport depsOutput21238_foo (compilable$?:windows=\\|/$depsOutput21238_foo.d) : private : imports.depsOutput21238_baz_pragmalib (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_baz_pragmalib.d) depsLib imports.depsOutput21238_baz_pragmalib (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_baz_pragmalib.d) : qux depsImport imports.depsOutput21238_bar (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_bar.d) : private : imports.depsOutput21238_baz_moduleimport (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_baz_moduleimport.d) depsImport imports.depsOutput21238_bar (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_bar.d) : private : imports.depsOutput21238_baz_stringimport (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_baz_stringimport.d) depsImport imports.depsOutput21238_bar (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_bar.d) : private : imports.depsOutput21238_baz_cond (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_baz_cond.d) depsImport imports.depsOutput21238_bar (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_bar.d) : private : imports.depsOutput21238_baz_pragmalib (compilable$?:windows=\\|/$imports$?:windows=\\|/$depsOutput21238_baz_pragmalib.d) --- */ module depsOutput21238_foo; import imports.depsOutput21238_baz_moduleimport; alias x_moduleimport = t_moduleimport!(); import imports.depsOutput21238_baz_stringimport; alias x_stringimport = t_stringimport!(); import imports.depsOutput21238_baz_cond; alias x_cond = t_cond!(); import imports.depsOutput21238_baz_pragmalib; alias x_pragmalib = t_pragmalib!(); ./ldc-1.42.0-src/tests/dmd/compilable/ddoc_markdown_quote.d0000644000175000017500000000266415205374125022432 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // TEST_OUTPUT_FILE: extra-files/ddoc_markdown_quote.html // OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_quote.html /++ # Quote Blocks > “It seems to me that most of the ‘new’ programming languages fall into one of two categories: Those from academia with radical new paradigms and those from large corporations with a focus on RAD and the web. Maybe it’s time for a new language born out of practical experience implementing compilers.” -- Michael > Great, just what I need.. another D in programming. -- Segfault > To D, or not to D. -- Willeam NerdSpeare > "What I am going to tell you about is what we teach our programming students in the third or fourth year of graduate school... It is my task to convince you not to turn away because you don't understand it. You see my programming students don't understand it... That is because I don't understand it. Nobody does." -- Richard Deeman Here's a bit of text between quotes. > This is a quote > > And this is a nested quote > This is a quote with a > symbol in it > This is a quote with a continuation > This quote - is ended by this list > This quote ### is ended by this heading > This quote is ended by a thematic break: ____ > This quote ``` is ended by this code ``` > ### Some things inside a quote block: > ___ > --- > Some code > --- > - a list +/ module test.compilable.ddoc_markdown_code; ./ldc-1.42.0-src/tests/dmd/compilable/ddoc13.d0000644000175000017500000000074215205374125017452 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /// struct doc struct Bug4107(T) { /// templated function doc void foo(U)(U u) { } } /// alpha struct Bug4107b(T) { /// beta struct B(U) { /// gamma struct C(V) { /// delta struct D(W) { /// epsilon B!W e(X)(C!V c, X[] x...) {} } } } } ./ldc-1.42.0-src/tests/dmd/compilable/ice10486.d0000644000175000017500000000010115205374125017525 0ustar fabiofabiovoid main() { typeof(null) null_; int[1] sarr = null_; } ./ldc-1.42.0-src/tests/dmd/compilable/stdcheaders.c0000644000175000017500000000461315205374125020666 0ustar fabiofabio/* Do a smoke test of the C Standard headers. * Many platforms do not support all the C Standard headers. */ #include #include #include #include #ifndef _MSC_VER // C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\fenv.h(68): Error: variable `stdcheaders._Fenv1` extern symbols cannot have initializers #ifndef __FreeBSD__ // /usr/include/fenv.h(341): Error: use `.` for member lookup, not `->` #include #endif #endif #include #include #include #include #include #include #ifndef _MSC_VER // C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt\corecrt_math.h(93): Error: reinterpretation through overlapped field `f` is not allowed in CTFE float x = NAN; #endif #ifndef _MSC_VER // setjmp.h(51): Error: missing tag `identifier` after `struct #include #endif #if !(defined(__linux__) && defined(__aarch64__)) // /usr/include/linux/types.h(12): Error: __int128 not supported #include #endif #include #include #ifndef __linux__ #ifndef _MSC_VER #ifndef __APPLE__ // /Applications/Xcode-14.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include/stdatomic.h(80): Error: type-specifier is missing #include #endif #endif #endif #include #include #include #include #ifndef _MSC_VER // ucrt\corecrt_malloc.h(58): Error: extended-decl-modifier expected #include #endif #include #include #ifndef _MSC_VER // C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\tgmath.h(33): Error: no type for declarator before `)` #ifndef __clang__ // Apple: /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/tgmath.h(39): Error: named parameter required before `...` // OpenBSD: /usr/lib/clang/13.0.0/include/tgmath.h(34): Error: named parameter required before `...` // Linux: /tmp/clang/lib/clang/15.0.3/include/tgmath.h(34): Error: named parameter required before `...` #include #endif #endif #ifndef __linux__ #ifndef __APPLE__ #ifndef __OpenBSD__ #ifndef _MSC_VER #include #endif #endif #endif #endif #include #ifndef __APPLE__ // no uchar.h #include #endif #include #include ./ldc-1.42.0-src/tests/dmd/compilable/test21299c.d0000644000175000017500000000025315205374125020123 0ustar fabiofabio// EXTRA_SOURCES: imports/test21299/mtype.d imports/test21299/func.d imports/test21299/rootstringtable.d // COMPILE_SEPARATELY: // LINK: module test21299c; void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test12567d.d0000644000175000017500000000016615205374125020125 0ustar fabiofabio// REQUIRED_ARGS: -d // EXTRA_FILES: imports/a12567.d // PERMUTE_ARGS: import imports.a12567; void main() { foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/test22895.c0000644000175000017500000000011315205374125017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22895 double x = 1.e6 + 1.E3; ./ldc-1.42.0-src/tests/dmd/compilable/ddoc17697.d0000644000175000017500000000113515205374125017721 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /*** * See: * http://www.fooa.com/test1 * http://www.fooa.com/_test1 * https://www.foob.com/test1 * $(LINK http://www.fooc.com/test1) * $(LINK2 http://www.food.com/test1, test1) */ /** Also piggyback a few tests for https://github.com/dlang/dmd/pull/6989 not_a_tag_because_it_does_not_start_with_uppercase: not_a_tag_because_no_whitespace_after_colon:x TagGalore: yes this is a tag MoreTag: yes the above is also a tag */ module test1; int a; ./ldc-1.42.0-src/tests/dmd/compilable/test9919.d0000644000175000017500000000027315205374125017707 0ustar fabiofabio// REQUIRED_ARGS: -o- // EXTRA_FILES: imports/test9919a.d imports/test9919b.d imports/test9919c.d module test9919; public { import imports.test9919a; import imports.test9919b; } ./ldc-1.42.0-src/tests/dmd/compilable/test9701.d0000644000175000017500000000411715205374125017675 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=9701 // REQUIRED_ARGS: -verrors=simple /* TEST_OUTPUT: --- compilable/test9701.d(69): Deprecation: enum member `test9701.Enum.value7` is deprecated compilable/test9701.d(69): Deprecation: enum member `test9701.Enum.value8` is deprecated - message --- */ template AliasSeq(TList...) { alias AliasSeq = TList; } enum { uda4, uda5, uda6, uda8, uda9 } enum Enum { value0, @("uda1") value1, @("uda2", "uda3", 42) value2, @uda4 value3, @uda5 @uda6 value4, @("uda7") @uda8 value5, @uda9 @("uda10") value6, deprecated value7, deprecated("message") value8, } @("uda0") enum { value0, @("uda1") value1, @("uda2") @("uda3") value2, @uda4 value3, @uda5 @uda6 value4, @("uda7") @uda8 value5, @uda9 @("uda10") value6 } static assert(__traits(getAttributes, Enum.value0).length == 0); static assert(__traits(getAttributes, Enum.value1) == AliasSeq!("uda1")); static assert(__traits(getAttributes, Enum.value2) == AliasSeq!("uda2", "uda3", 42)); static assert(__traits(getAttributes, Enum.value3) == AliasSeq!(uda4)); static assert(__traits(getAttributes, Enum.value4) == AliasSeq!(uda5, uda6)); static assert(__traits(getAttributes, Enum.value5) == AliasSeq!("uda7", uda8)); static assert(__traits(getAttributes, Enum.value6) == AliasSeq!(uda9, "uda10")); static assert(__traits(isDeprecated, Enum.value7)); static assert(__traits(isDeprecated, Enum.value8)); static assert(__traits(getAttributes, value0) == AliasSeq!("uda0")); static assert(__traits(getAttributes, value1) == AliasSeq!("uda0", "uda1")); static assert(__traits(getAttributes, value2) == AliasSeq!("uda0", "uda2", "uda3")); static assert(__traits(getAttributes, value3) == AliasSeq!("uda0", uda4)); static assert(__traits(getAttributes, value4) == AliasSeq!("uda0", uda5, uda6)); static assert(__traits(getAttributes, value5) == AliasSeq!("uda0", "uda7", uda8)); static assert(__traits(getAttributes, value6) == AliasSeq!("uda0", uda9, "uda10")); // Test that messages are correctly displayed static assert(Enum.value7 != Enum.value8); ./ldc-1.42.0-src/tests/dmd/compilable/test19970.d0000644000175000017500000000042515205374125017764 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19970 enum void* p = cast(void*)0; static assert(p is null); static assert(ctfeLocal(p)); static assert(ctfeGlobal()); bool ctfeGlobal () { return p is null; } bool ctfeLocal (const void* ptr) pure { return ptr is null; } ./ldc-1.42.0-src/tests/dmd/compilable/testInference.d0000644000175000017500000005625115205374125021201 0ustar fabiofabio /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=6265 pure nothrow @safe int h6265() { return 1; } int f6265a(alias g)() { return g(); } pure nothrow @safe int i6265a() { return f6265a!h6265(); } int f6265b()() { return h6265(); } pure nothrow @safe int i6265b() { return f6265b(); } pure nothrow @safe int i6265c() { return { return h6265(); }(); } /***************************************************/ // Make sure a function is not infered as pure if it isn't. int fNPa() { return 1; } int gNPa()() { return fNPa(); } static assert( __traits(compiles, function int () { return gNPa(); })); static assert(!__traits(compiles, function int () pure { return gNPa(); })); static assert(!__traits(compiles, function int () nothrow { return gNPa(); })); static assert(!__traits(compiles, function int () @safe { return gNPa(); })); /***************************************************/ // Need to ensure the comment in Expression::checkPurity is not violated. void fECPa() { void g()() { void h() { } h(); } static assert( is(typeof(&g!()) == void delegate() pure nothrow @nogc @safe)); static assert(!is(typeof(&g!()) == void delegate())); } void fECPb() { void g()() { void h() { } fECPb(); } static assert(!is(typeof(&g!()) == void delegate() pure)); static assert( is(typeof(&g!()) == void delegate())); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=5635 pure bool foo5635(R = int)(string x) { bool result = false; foreach (dchar d; x) result = true; return result; } void test5635() { foo5635("hi"); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=5936 auto bug5936c(R)(R i) @safe pure nothrow { return true; } static assert( bug5936c(0) ); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=6351 void bug6351(alias dg)() { dg(); } void test6351() { void delegate(int[] a...) deleg6351 = (int[] a...){}; alias bug6351!(deleg6351) baz6531; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=6359 void impure6359() nothrow @safe @nogc {} void throwable6359() pure @safe @nogc {} void system6359() pure nothrow @nogc {} void gcable6359() pure nothrow @safe {} int global6359; void f6359() pure nothrow @safe @nogc { static assert(!__traits(compiles, impure6359())); static assert(!__traits(compiles, throwable6359())); static assert(!__traits(compiles, system6359())); static assert(!__traits(compiles, gcable6359())); static assert(!__traits(compiles, global6359++)); static assert(!__traits(compiles, { impure6359(); }())); static assert(!__traits(compiles, { throwable6359(); }())); static assert(!__traits(compiles, { system6359(); }())); static assert(!__traits(compiles, { gcable6359(); }())); static assert(!__traits(compiles, { global6359++; }())); } void g6359()() pure nothrow @safe @nogc { static assert(!__traits(compiles, impure6359())); static assert(!__traits(compiles, throwable6359())); static assert(!__traits(compiles, system6359())); static assert(!__traits(compiles, gcable6359())); static assert(!__traits(compiles, global6359++)); static assert(!__traits(compiles, { impure6359(); }())); static assert(!__traits(compiles, { throwable6359(); }())); static assert(!__traits(compiles, { system6359(); }())); static assert(!__traits(compiles, { gcable6359(); }())); static assert(!__traits(compiles, { global6359++; }())); } // attribute inference is not affected by the expressions inside __traits(compiles) void h6359()() { static assert( __traits(compiles, impure6359())); static assert( __traits(compiles, throwable6359())); static assert( __traits(compiles, system6359())); static assert( __traits(compiles, gcable6359())); static assert( __traits(compiles, global6359++)); static assert( __traits(compiles, { impure6359(); }())); static assert( __traits(compiles, { throwable6359(); }())); static assert( __traits(compiles, { system6359(); }())); static assert( __traits(compiles, { gcable6359(); }())); static assert( __traits(compiles, { global6359++; }())); } void test6359() pure nothrow @safe @nogc { f6359(); g6359(); h6359(); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=7017 template map7017(fun...) if (fun.length >= 1) { auto map7017() { struct Result { this(int dummy){} // impure member function -> inferred to pure by fixing https://issues.dlang.org/show_bug.cgi?id=10329 } return Result(0); // impure call -> inferred to pure by fixing https://issues.dlang.org/show_bug.cgi?id=10329 } } int foo7017(immutable int x) pure nothrow { return 1; } void test7017a() pure { int bar7017(immutable int x) pure nothrow { return 1; } static assert(__traits(compiles, map7017!((){})())); static assert(__traits(compiles, map7017!q{ 1 }())); static assert(__traits(compiles, map7017!foo7017())); static assert(__traits(compiles, map7017!bar7017())); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=7017 (little simpler cases) auto map7017a(alias fun)() { return fun(); } // depends on purity of fun auto map7017b(alias fun)() { return; } // always pure auto map7017c(alias fun)() { return yyy7017(); } // always impure int xxx7017() pure { return 1; } int yyy7017() { return 1; } void test7017b() pure { static assert( __traits(compiles, map7017a!xxx7017() )); static assert(!__traits(compiles, map7017a!yyy7017() )); static assert( __traits(compiles, map7017b!xxx7017() )); static assert( __traits(compiles, map7017b!yyy7017() )); static assert(!__traits(compiles, map7017c!xxx7017() )); static assert(!__traits(compiles, map7017c!yyy7017() )); } /***************************************************/ // Test case from std.process auto escapeArgumentImpl(alias allocator)() { return allocator(); } auto escapeShellArgument(alias allocator)() { return escapeArgumentImpl!allocator(); } pure string escapeShellArguments() { char[] allocator() { return new char[1]; } /* Both escape!allocator and escapeImpl!allocator are impure, * but they are nested template function that instantiated here. * Then calling them from here doesn't break purity. */ return escapeShellArgument!allocator(); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=8234 void test8234() { immutable int x = 0; alias FP = typeof({ enum e = x; return e; }); static assert(is(FP : int function())); auto fp = { enum e = x; return e; }; static assert(is(typeof(fp) : int function())); alias DG = typeof({ auto e = x; return e; }); static assert(is(DG : int delegate())); auto dg = { auto e = x; return e; }; static assert(is(typeof(dg) : int delegate())); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=8504 import core.demangle : demangle; void foo8504()() { static assert(typeof(foo8504!()).stringof == "void()"); static assert(typeof(foo8504!()).mangleof == "FZv"); // static assert(demangle(foo8504!().mangleof) == "void testInference.foo8504!().foo8504()"); } auto toDelegate8504a(F)(auto ref F fp) { return fp; } F toDelegate8504b(F)(auto ref F fp) { return fp; } extern(C) void testC8504() {} void test8504() { static assert(typeof(foo8504!()).stringof == "pure nothrow @nogc @safe void()"); static assert(typeof(foo8504!()).mangleof == "FNaNbNiNfZv"); static assert(demangle(foo8504!().mangleof) == "pure nothrow @nogc @safe void testInference.foo8504!().foo8504()"); auto fp1 = toDelegate8504a(&testC8504); auto fp2 = toDelegate8504b(&testC8504); static assert(is(typeof(fp1) == typeof(fp2))); static assert(typeof(fp1).stringof == "extern (C) void function()"); static assert(typeof(fp2).stringof == "extern (C) void function()"); static assert(typeof(fp1).mangleof == "PUZv"); static assert(typeof(fp2).mangleof == "PUZv"); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=8751 alias bool delegate(in int) pure Bar8751; Bar8751 foo8751a(immutable int x) pure { return y => x > y; // OK } Bar8751 foo8751b(const int x) pure { return y => x > y; // error -> OK } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=8793 alias bool delegate(in int) pure Dg8793; alias bool function(in int) pure Fp8793; Dg8793 foo8793fp1(immutable Fp8793 f) pure { return x => (*f)(x); } // OK Dg8793 foo8793fp2( const Fp8793 f) pure { return x => (*f)(x); } // OK Dg8793 foo8793dg1(immutable Dg8793 f) pure { return x => f(x); } // OK Dg8793 foo8793dg2( const Dg8793 f) pure { return x => f(x); } // OK <- error Dg8793 foo8793pfp1(immutable Fp8793* f) pure { return x => (*f)(x); } // OK Dg8793 foo8793pdg1(immutable Dg8793* f) pure { return x => (*f)(x); } // OK Dg8793 foo8793pfp2(const Fp8793* f) pure { return x => (*f)(x); } // OK <- error Dg8793 foo8793pdg2(const Dg8793* f) pure { return x => (*f)(x); } // OK <- error // general case for the hasPointer type Dg8793 foo8793ptr1(immutable int* p) pure { return x => *p == x; } // OK Dg8793 foo8793ptr2(const int* p) pure { return x => *p == x; } // OK <- error /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=9072 struct A9072(T) { this(U)(U x) {} ~this() {} } void test9072() { A9072!int a = A9072!short(); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=5933 // https://issues.dlang.org/show_bug.cgi?id=8504 // Template attribute inferrence doesn't work int foo5933()(int a) { return a*a; } struct S5933 { double foo()(double a) { return a * a; } } // outside function static assert(typeof(foo5933!()).stringof == "pure nothrow @nogc @safe int(int a)"); static assert(typeof(S5933.init.foo!()).stringof == "pure nothrow @nogc @safe double(double a)"); void test5933() { // inside function static assert(typeof(foo5933!()).stringof == "pure nothrow @nogc @safe int(int a)"); static assert(typeof(S5933.init.foo!()).stringof == "pure nothrow @nogc @safe double(double a)"); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=9148 void test9148a() pure { static int g; int x; void foo1() /+pure+/ { static assert(!__traits(compiles, g++)); x++; } void foo2() pure { static assert(!__traits(compiles, g++)); x++; } foo1(); static assert(is(typeof(&foo1) == void delegate() pure nothrow @nogc @safe)); foo2(); static assert(is(typeof(&foo2) == void delegate() pure nothrow @nogc @safe)); void bar1() immutable /+pure+/ { static assert(!__traits(compiles, g++)); static assert(!__traits(compiles, x++)); } void bar2() immutable pure { static assert(!__traits(compiles, g++)); static assert(!__traits(compiles, x++)); } bar1(); static assert(is(typeof(&bar1) == void delegate() pure immutable nothrow @nogc @safe)); bar2(); static assert(is(typeof(&bar2) == void delegate() pure immutable nothrow @nogc @safe)); struct S { void foo1() /+pure+/ { static assert(!__traits(compiles, g++)); x++; } void foo2() pure { static assert(!__traits(compiles, g++)); x++; } void bar1() immutable /+pure+/ { static assert(!__traits(compiles, g++)); static assert(!__traits(compiles, x++)); } void bar2() immutable pure { static assert(!__traits(compiles, g++)); static assert(!__traits(compiles, x++)); } } S sm; sm.foo1(); static assert(is(typeof(&sm.foo1) == void delegate() pure)); sm.foo2(); static assert(is(typeof(&sm.foo2) == void delegate() pure)); immutable S si; si.bar1(); static assert(is(typeof(&si.bar1) == void delegate() pure immutable)); si.bar2(); static assert(is(typeof(&si.bar2) == void delegate() pure immutable)); } // ---- // inheritance of pure and @safe void test9148b() pure nothrow @nogc @safe { void nf() {} static assert(is(typeof(&nf) == void delegate() pure nothrow @nogc @safe)); struct NS { void mf() {} static void sf() {} } NS ns; static assert(is(typeof(&ns.mf) == void delegate() pure nothrow @nogc @safe)); static assert(is(typeof(&NS.sf) == void function() pure nothrow @nogc @safe)); static void sf() {} static assert(is(typeof(&sf) == void function() pure nothrow @nogc @safe)); static struct SS { void mf() {} static void sf() {} } SS ss; static assert(is(typeof(&ss.mf) == void delegate() pure nothrow @nogc @safe)); static assert(is(typeof(&SS.sf) == void function() pure nothrow @nogc @safe)); } void impureSystem9148b() {} void func9148b()() { void bar() // do not inherit PUREfwdref { static assert(is(typeof(&bar) == void delegate())); impureSystem9148b(); } static assert(is(typeof(&bar) == void delegate())); } static assert(is(typeof(&func9148b!()) == void function() pure nothrow @nogc @safe)); // ---- // from fail_compilation/fail283.d pure int double_sqr9148c(int x) { int y = x; void do_sqr() pure { y *= y; } do_sqr(); return y; } void test9148c() { assert(double_sqr9148c(10) == 100); } // ---- // from fail_compilation/fail348.d void test9148d() pure { void g() // implicitly marked as 'pure' { void h() pure { // i() and j() are implicitly marked as 'pure' void i() { } void j() { i(); g(); } // can call i() and g() } } } void test9148e() { int x; static assert(is(typeof((int a){ return a + x; }) == int delegate(int) pure nothrow @nogc @safe)); auto dg = (int a){ return a + x; }; static assert(is(typeof(dg) == int delegate(int) pure nothrow @nogc @safe)); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12912 struct S12912(alias fun) { void f() { fun(); } } class C12912 { int n; void f() pure { S12912!(() => n) s; // Here lambda should be inferred to weak purity. s.f(); // And this call will be a pure member function call. } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=10002 void impure10002() {} void remove10002(alias pred, bool impure = false, Range)(Range range) { pred(range[0]); static if (impure) impure10002(); } class Node10002 { Node10002 parent; Node10002[] children; void foo() pure { parent.children.remove10002!(n => n is parent)(); remove10002!(n => n is parent)(parent.children); static assert(!__traits(compiles, parent.children.remove10002x!(n => n is parent, true)())); static assert(!__traits(compiles, remove10002x!(n => n is parent, true)(parent.children))); Node10002 p; p.children.remove10002!(n => n is p)(); remove10002!(n => n is p)(p.children); static assert(!__traits(compiles, p.children.remove10002x!(n => n is p, true)())); static assert(!__traits(compiles, remove10002x!(n => n is p, true)(p.children))); } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=10148 void fa10148() {} // fa is @system auto fb10148(T)() { struct A(S) { // [4] Parent function fb is already inferred to @safe, then // fc is forcely marked @safe on default until 2.052. // But fc should keep attribute inference ability // by overriding the inherited @safe-ty from its parent. void fc(T2)() { // [5] During semantic3 process, fc is not @safe on default. static assert(is(typeof(&fc) == void delegate())); fa10148(); } // [1] this is now inferred to @safe by implementing https://issues.dlang.org/show_bug.cgi?id=7511 this(S a) {} } // [2] A!int(0) is now calling @safe function, then fb!T also be inferred to @safe return A!int(0); } void test10148() { fb10148!int.fc!int; // [0] instantiate fb // [3] instantiate fc // [6] After semantic3 done, fc!int is deduced to @system. static assert(is(typeof(&fb10148!int.fc!int) == void delegate() @system)); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=10289 void test10289() { void foo(E)() { throw new E(""); } void bar(E1, E2)() { throw new E1(""); throw new E2(""); } void baz(E1, E2)(bool cond) { if (cond) throw new E1(""); else throw new E2(""); } import core.exception; static class MyException : Exception { this(string) @safe pure nothrow { super(""); } } static assert( __traits(compiles, () nothrow { foo!Error(); })); static assert( __traits(compiles, () nothrow { foo!AssertError(); })); static assert(!__traits(compiles, () nothrow { foo!Exception(); })); static assert(!__traits(compiles, () nothrow { foo!MyException(); })); static assert( __traits(compiles, () nothrow { bar!(Error, Exception)(); })); static assert(!__traits(compiles, () nothrow { bar!(Exception, Error)(); })); static assert(!__traits(compiles, () nothrow { baz!(Error, Exception)(); })); static assert(!__traits(compiles, () nothrow { baz!(Exception, Error)(); })); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=10296 void foo10296()() { int[3] a; void bar()() { a[1] = 2; } bar(); static assert(typeof(bar!()).stringof == "pure nothrow @nogc @safe void()"); // nothrow @safe void() } pure void test10296() { foo10296(); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12025 struct Foo12025 { int[5] bar; } void test12025a() pure { enum n1 = typeof(Foo12025.bar).length; // OK enum n2 = Foo12025.bar .length; // OK <- error auto x1 = typeof(Foo12025.bar).length; // OK auto x2 = Foo12025.bar .length; // OK <- error } void test12025b() pure { static int[5] bar; enum n1 = typeof(bar).length; // OK enum n2 = bar .length; // OK <- error auto x1 = typeof(bar).length; // OK auto x2 = bar .length; // OK <- error } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12542 int logOf12542(T)(T n) { if (n) return 1 + logOf12542(n/2); return 0; } void test12542() @safe nothrow pure { int log = logOf12542(9); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12704 void foo12704() @system; alias FP12704 = typeof(function() { foo12704(); }); static assert(is(FP12704 == void function() @system)); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12970 @system { @safe void f12970a() {} } @system { void f12970b() @safe {} } static assert(is(typeof(&f12970a) == void function() @safe)); static assert(is(typeof(&f12970b) == void function() @safe)); @system { @trusted void f12970c() {} } @system { void f12970d() @trusted {} } static assert(is(typeof(&f12970c) == void function() @trusted)); static assert(is(typeof(&f12970d) == void function() @trusted)); @safe { @system void f12970e() {} } @safe { void f12970f() @system {} } static assert(is(typeof(&f12970e) == void function() @system)); static assert(is(typeof(&f12970f) == void function() @system)); @safe { @trusted void f12970g() {} } @safe { void f12970h() @trusted {} } static assert(is(typeof(&f12970g) == void function() @trusted)); static assert(is(typeof(&f12970h) == void function() @trusted)); @trusted { @safe void f12970i() {} } @trusted { void f12970j() @safe {} } static assert(is(typeof(&f12970i) == void function() @safe)); static assert(is(typeof(&f12970j) == void function() @safe)); @trusted { @system void f12970k() {} } @trusted { void f12970l() @system {} } static assert(is(typeof(&f12970k) == void function() @system)); static assert(is(typeof(&f12970l) == void function() @system)); /***************************************************/ // Parsing prefix STC_FUNCATTR for variable declaration __gshared immutable pure nothrow @property @nogc @safe void function() prefix_qualified_fp1; __gshared{immutable{pure{nothrow{@property{@nogc{@safe{void function() prefix_qualified_fp2;}}}}}}} static assert(typeof(prefix_qualified_fp1).stringof == typeof(prefix_qualified_fp2).stringof); static assert(typeof(prefix_qualified_fp1).stringof == "immutable(void function() pure nothrow @nogc @property @safe)"); const pure nothrow @property @nogc @safe void function()[] prefix_qualified_fp_array1; const{pure{nothrow{@property{@nogc{@safe{void function()[] prefix_qualified_fp_array2;}}}}}} static assert(typeof(prefix_qualified_fp_array1).stringof == typeof(prefix_qualified_fp_array2).stringof); static assert(typeof(prefix_qualified_fp_array1).stringof == "const(void function() pure nothrow @nogc @property @safe[])"); /***************************************************/ // Parsing prefix, intermediate, or postfix @safe for alias declaration @safe alias void function() AliasDecl_FP1; alias @safe void function() AliasDecl_FP2; // is not @safe alias void function() @safe AliasDecl_FP3; static assert(AliasDecl_FP1.stringof == "void function() @safe"); static assert(AliasDecl_FP2.stringof == "void function()"); static assert(AliasDecl_FP3.stringof == "void function() @safe"); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=13217 void writeln13217(string) {} nothrow void a13217(T)(T x) { try { () { writeln13217("a"); } (); } catch (Exception e) {} } void test13217() { a13217(1); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=13840 struct Foo13840 { int opApply(int delegate(int)) { return 0; } } void func13840() { } void test13840() nothrow { try { foreach (i; Foo13840()) // generated delegate is throwable { func13840(); // throwable function call } } catch(Throwable) {} } /***************************************************/ // https://github.com/dlang/dmd/pull/20685 struct T1 { int a; inout this(ref inout T1 t) @nogc nothrow pure { a = t.a; } } struct S1 { T1 t; // generate copy constructor, infer @nogc nothrow pure } void test1() @nogc nothrow pure { S1 s; S1 t = s; } ./ldc-1.42.0-src/tests/dmd/compilable/test16563.d0000644000175000017500000000020215205374125017750 0ustar fabiofabiovoid test16563() { align(1) struct S { uint i; ubyte b; static assert(S.sizeof == 5); } } ./ldc-1.42.0-src/tests/dmd/compilable/iconv_class_array.d0000644000175000017500000000113215205374125022070 0ustar fabiofabio@safe pure: class X { this(int x) @safe pure { this.x = x; } int x; } class Y : X { this(int x) @safe pure { super(x); } int x; } static void fm(X[] xs) {} static void fc(const(X)[] xs) {} static void fi(immutable(X)[] xs) {} static void f2m(X[2] xs) {} static void f2mr(ref X[2] xs) {} void test() { Y[] y = [new Y(42), new Y(43)]; immutable(Y)[] yi = [new Y(42), new Y(43)]; static assert(!__traits(compiles, { fm(y); })); fc(y); fc(yi); fi(yi); Y[2] y2 = [new Y(42), new Y(43)]; f2m(y2); static assert(!__traits(compiles, { f2mr(y2); })); } ./ldc-1.42.0-src/tests/dmd/compilable/pragmamangle1.d0000644000175000017500000001376415205374125021121 0ustar fabiofabio// Tests for pragma mangle module pragmamangle; version (Posix): // Itanium C++ ABI only string ctfe_function() { return "mangle_" ~ "ctfe_" ~ "function"; } immutable string const_variable = "mangle_const"; // This mangle string doesn't propagate to tests that use type_symbol. pragma(mangle, "Q_should_mangle_string_propagate") struct type_symbol { } class template_symbol(T) { } /* 1. Overrides the default mangling for a symbol. */ pragma(mangle, "mangle_function") void test_fun1(); static assert(test_fun1.mangleof == "mangle_function"); pragma(mangle, "mangle_attribute") extern(C) { nothrow { void test_pokeattr1(); } } static assert(test_pokeattr1.mangleof == "mangle_attribute"); /* 2a. For variables and functions there must be one AssignExpression and it * must evaluate at compile time to a string literal */ pragma(mangle, ctfe_function) void test_fun2a1(); static assert(test_fun2a1.mangleof == "mangle_ctfe_function"); pragma(mangle, const_variable) void test_fun2a2(); static assert(test_fun2a2.mangleof == "mangle_const"); pragma(mangle, ctfe_function) int test_var2a1; static assert(test_var2a1.mangleof == "mangle_ctfe_function"); pragma(mangle, const_variable) int test_var2a2; static assert(test_var2a2.mangleof == "mangle_const"); /* 2b. For aggregates there may be one or two AssignExpressions, one of which * must evaluate at compile time to a string literal and one which must * evaluate to a symbol. * [UNDOCUMENTED] The pragma(mangle) attribute only gets applied to the * encoded parameters types of extern(C++) functions. */ pragma(mangle, "mangle_struct") extern(C++) { struct S1 { } } extern(C++) void test_struct2b1(S1); extern(D) void externD_struct2b1(S1); static assert(test_struct2b1.mangleof == "_Z14test_struct2b113mangle_struct"); static assert(externD_struct2b1.mangleof == "_D12pragmamangle17externD_struct2b1FSQBj2S1Zv"); pragma(mangle, type_symbol, "mangle_struct") struct S2 { } extern(C++) void test_struct2b3(S2); extern(D) void externD_struct2b3(S2); static assert(test_struct2b3.mangleof == "_Z14test_struct2b313mangle_struct"); static assert(externD_struct2b3.mangleof == "_D12pragmamangle17externD_struct2b3FSQBj2S2Zv"); pragma(mangle, "mangle_struct", type_symbol) struct S3 { } extern(C++) void test_struct2b4(S3); extern(D) void externD_struct2b4(S3); static assert(test_struct2b4.mangleof == "_Z14test_struct2b413mangle_struct"); static assert(externD_struct2b4.mangleof == "_D12pragmamangle17externD_struct2b4FSQBj2S3Zv"); // Repeat struct tests on classes. pragma(mangle, "mangle_class") extern(C++) { class C1 { } } extern(C++) void test_class2b1(C1); extern(D) void externD_class2b1(C1); static assert(test_class2b1.mangleof == "_Z13test_class2b1P12mangle_class"); static assert(externD_class2b1.mangleof == "_D12pragmamangle16externD_class2b1FCQBi2C1Zv"); pragma(mangle, type_symbol, "mangle_class") class C2 { } extern(C++) void test_class2b3(C2); extern(D) void externD_class2b3(C2); static assert(test_class2b3.mangleof == "_Z13test_class2b3P12mangle_class"); static assert(externD_class2b3.mangleof == "_D12pragmamangle16externD_class2b3FCQBi2C2Zv"); pragma(mangle, "mangle_class", type_symbol) class C3 { } extern(C++) void test_class2b4(C3); extern(D) void externD_class2b4(C3); static assert(test_class2b4.mangleof == "_Z13test_class2b4P12mangle_class"); static assert(externD_class2b4.mangleof == "_D12pragmamangle16externD_class2b4FCQBi2C3Zv"); /* 2c. If that symbol is a TemplateInstance, the aggregate is treated as a * template that has the signature and arguments of the TemplateInstance. */ template T1(C) { pragma(mangle, C, "mangle_template") struct T1 { } } extern(C++) void test_template2c3(T1!(template_symbol!int)); extern(C++) void test_template2c4(T1!(template_symbol!float)); extern(C++) void test_template2c5(T1!(type_symbol)); static assert(test_template2c3.mangleof == "_Z16test_template2c315mangle_templateIiE"); static assert(test_template2c4.mangleof == "_Z16test_template2c415mangle_templateIfE"); static assert(test_template2c5.mangleof == "_Z16test_template2c515mangle_template"); template T2(C) { pragma(mangle, "mangle_template", C) struct T2 { } } extern(C++) void test_template2c6(T2!(template_symbol!int)); extern(C++) void test_template2c7(T2!(template_symbol!float)); extern(C++) void test_template2c8(T2!(type_symbol)); static assert(test_template2c6.mangleof == "_Z16test_template2c615mangle_templateIiE"); static assert(test_template2c7.mangleof == "_Z16test_template2c715mangle_templateIfE"); static assert(test_template2c8.mangleof == "_Z16test_template2c815mangle_template"); /* 2d. The identifier of the symbol is used when no string is supplied. */ pragma(mangle, type_symbol) struct I1 { } extern(C++) void test_struct2d1(I1); static assert(test_struct2d1.mangleof == "_Z14test_struct2d111type_symbol"); pragma(mangle, type_symbol) class I2 { } extern(C++) void test_class2d1(I2); static assert(test_class2d1.mangleof == "_Z13test_class2d1P11type_symbol"); template I3(C) { pragma(mangle, C) struct I3 { } } extern(C++) void test_template2d1(I3!(template_symbol!int)); extern(C++) void test_template2d2(I3!(template_symbol!float)); extern(C++) void test_template2d3(I3!(type_symbol)); static assert(test_template2d1.mangleof == "_Z16test_template2d115template_symbolIiE"); static assert(test_template2d2.mangleof == "_Z16test_template2d215template_symbolIfE"); static assert(test_template2d3.mangleof == "_Z16test_template2d311type_symbol"); // ??? No template arguments encoded. pragma(mangle, template_symbol!float) struct I4 { } extern(C++) void test_template2d4(I4); static assert(test_template2d4.mangleof == "_Z16test_template2d415template_symbol"); /* 3. It only applies to function and variable symbols. Other symbols are * ignored. */ pragma(mangle, "mangle_alias") alias ignored_alias = int; pragma(mangle, "mangle_enum") enum ignored_enum { a = 1 } pragma(mangle, "mangle_mixed_ignored") { enum test_ignored1 { b } void test_not_ignored(); alias test_ignored2 = int delegate(int); } static assert(test_not_ignored.mangleof == "mangle_mixed_ignored"); ./ldc-1.42.0-src/tests/dmd/compilable/uda.d0000644000175000017500000000061115205374125017141 0ustar fabiofabio/************************************************/ // https://issues.dlang.org/show_bug.cgi?id=15180 // [REG2.069.0-b1] Segfault with empty struct used as UDA struct foo { } @foo bar () { } /************************************************/ // https://issues.dlang.org/show_bug.cgi?id=23241 alias feynman = int; enum get = __traits(getAttributes, feynman); static assert(get.length == 0); ./ldc-1.42.0-src/tests/dmd/compilable/cmain.d0000644000175000017500000000101415205374125017455 0ustar fabiofabio/+ ARG_SETS: -version=A ARG_SETS: -version=B ARG_SETS: -version=C ARG_SETS: -version=D ARG_SETS: -version=E +/ extern(C): version (A) int main() { return 0; } else version (B) int main(const int, const(char*)*) { return 0; } else version (C) void main(const int, const char**, const char**) {} else: enum Length : int; enum Char : char; enum CharPtr : char*; enum CharPtrPtr : char**; version (D) void main(const Length, const Char**) {} else version (E) void main(const Length, const CharPtr*, const CharPtrPtr) {} ./ldc-1.42.0-src/tests/dmd/compilable/testcdefines.i0000644000175000017500000000025715205374125021063 0ustar fabiofabio// REQUIRED_ARGS: -vcg-ast -o- // OUTPUT_FILES: compilable/testcdefines.i.cg // TEST_OUTPUT_FILE: extra-files/testcdefines.i.cg #undef _ATFILE_SOURCE #define _ATFILE_SOURCE 1 ./ldc-1.42.0-src/tests/dmd/compilable/test21255.d0000644000175000017500000000030315205374125017744 0ustar fabiofabiomodule test21255; void decodeA()(int i) { } void decodeB()(string s) { } alias decode = decodeA; alias decode = decodeB; void foo(alias A)() { A(1); A("hello"); } void main() { foo!decode; } ./ldc-1.42.0-src/tests/dmd/compilable/issue16472.d0000644000175000017500000000147615205374125020136 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16472 enum e() = 0; template t(alias v = e!()) {} //Error alias dummy = t!(e!()); template E(F){ enum E { K = F(1) } } struct S(F = float, alias e_ = E!double.K) {} S!float x; // Error: E!double.K is used as a type alias T = E!double.K; struct S2(F = float, alias e_ = T) {} S2!float y; // alias makes it okay... struct S3(F = float, alias e_ = (E!double.K)) {} S3!float z; // just putting parens make it okay as well... wat!? // for coverage template G(T) { struct G { alias I = int; static int i; } } struct H(F = float, alias e_ = G!double) {} H!float a; struct H1(F = float, alias e_ = G!double.I) {} H1!float b; // https://issues.dlang.org/show_bug.cgi?id=21795 // struct H2(F = float, alias e_ = G!double.i) {} // H2!float c; ./ldc-1.42.0-src/tests/dmd/compilable/test20151a.d0000644000175000017500000000014715205374125020105 0ustar fabiofabio// EXTRA_FILES: imports/test20151a/b/c/c.d module imports.test20151a; import imports.test20151a.b.c.c; ./ldc-1.42.0-src/tests/dmd/compilable/test15292.d0000644000175000017500000000032515205374125017754 0ustar fabiofabiostruct NullableRef15292(T) { inout(T) get() inout { assert(false); } alias get this; } struct S15292 { NullableRef15292!S15292 n; } void main() { S15292 s; assert(s == s); } ./ldc-1.42.0-src/tests/dmd/compilable/ice10040.d0000644000175000017500000000034415205374125017520 0ustar fabiofabiostruct MsgProc1 { mixin MsgMixin; } struct MsgProc2 { mixin MsgMixin; } struct MsgHeader {} template MsgMixin() { mixin(mixinMembers!(MsgHeader.init)); } string mixinMembers(T ...)() { struct Op {} return null; } ./ldc-1.42.0-src/tests/dmd/compilable/test23936.i0000644000175000017500000000113415205374125017764 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?ide=23936 #pragma pack(push,16) typedef struct AAATAG { int LastExceptionFromRip; } AAA; #pragma pack(pop) #pragma pack(push, 16) typedef struct { long long val; } BBB; #pragma pack(pop) __pragma(pack(push,16)) typedef struct XXXTAG { int LastExceptionFromRip; } XXX; __pragma(pack(pop)) __pragma(pack(push, 16)) typedef struct { long long val; } YYY; __pragma(pack(pop)) _Static_assert(_Alignof(AAA) == 16, "1"); _Static_assert(_Alignof(BBB) == 16, "2"); _Static_assert(_Alignof(XXX) == 16, "3"); _Static_assert(_Alignof(YYY) == 16, "4"); ./ldc-1.42.0-src/tests/dmd/compilable/test8959.d0000644000175000017500000000322115205374125017706 0ustar fabiofabio/* TEST_OUTPUT: --- U1 = int U2 = int V1 = long, K1 = string V2 = long, K2 = string TL1 = (int, string) TL2 = (int, string) U3 = int U4 = int V3 = long, K3 = string V4 = long, K4 = string TL3 = (int, string) TL4 = (int, string) --- */ static if (is(int* == U1*, U1)) { pragma(msg, "U1 = ", U1); } static if (is(int* : U2*, U2)) { pragma(msg, "U2 = ", U2); } static assert(is(int* == U*, U)); static assert(is(int* : U*, U)); alias AA = long[string]; static if (is(AA == V1[K1], V1, K1)) { pragma(msg, "V1 = ", V1, ", K1 = ", K1); } static if (is(AA : V2[K2], V2, K2)) { pragma(msg, "V2 = ", V2, ", K2 = ", K2); } static assert(is(AA == V[K], V, K)); static assert(is(AA : V[K], V, K)); class B(TL...) {} class C(TL...) : B!TL {} alias X = C!(int, string); static if (is(X == C!TL1, TL1...)) { pragma(msg, "TL1 = ", TL1); } static if (is(X : B!TL2, TL2...)) { pragma(msg, "TL2 = ", TL2); } static assert(is(X == C!TL, TL...)); static assert(is(X : B!TL, TL...)); void test8959() { static if (is(int* == U3*, U3)) { pragma(msg, "U3 = ", U3); } static if (is(int* : U4*, U4)) { pragma(msg, "U4 = ", U4); } static assert(is(int* == U*, U)); static assert(is(int* : U*, U)); static if (is(AA == V3[K3], V3, K3)) { pragma(msg, "V3 = ", V3, ", K3 = ", K3); } static if (is(AA : V4[K4], V4, K4)) { pragma(msg, "V4 = ", V4, ", K4 = ", K4); } static assert(is(AA == V[K], V, K)); static assert(is(AA : V[K], V, K)); static if (is(X == C!TL3, TL3...)) { pragma(msg, "TL3 = ", TL3); } static if (is(X : B!TL4, TL4...)) { pragma(msg, "TL4 = ", TL4); } static assert(is(X == C!TL, TL...)); static assert(is(X : B!TL, TL...)); } ./ldc-1.42.0-src/tests/dmd/compilable/test16525.d0000644000175000017500000000051115205374125017751 0ustar fabiofabiostatic immutable templ(alias var) = 1234; struct D { int memvar; } extern(C++) struct CPP { int memvar; } void test() { static assert(templ!(D.memvar) == 1234); static assert(templ!(CPP.memvar) == 1234); // ICE: root cause, C++ member variables have no mangling enum CPPmemvar = CPP.memvar.mangleof; } ./ldc-1.42.0-src/tests/dmd/compilable/test20423.c0000644000175000017500000000055115205374125017744 0ustar fabiofabio// https://github.com/dlang/dmd/issues/20423 #include #include #include void foo(double * pm, ...) { va_list ap; double * targ; va_start(ap, pm); for (int i=1; ; i++) { va_arg(ap, int); targ = va_arg(ap, double*); if (targ == NULL) { break; } } va_end(ap); } ./ldc-1.42.0-src/tests/dmd/compilable/debuginfo.d0000644000175000017500000000046115205374125020335 0ustar fabiofabio// REQUIRED_ARGS: -g struct Bug7127a { const(Bug7127a)* self; } struct Bug7127b { void function(const(Bug7127b) self) foo; } void main() { Bug7127a a; Bug7127b b; } // https://issues.dlang.org/show_bug.cgi?id=13975 static immutable int a = 8; enum Bar { aa = a } void foo(Bar bar) {} ./ldc-1.42.0-src/tests/dmd/compilable/test23002.c0000644000175000017500000000017715205374125017744 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=23002 */ typedef int x; struct S { x x; }; struct T { x *x; }; union U { x x; }; ./ldc-1.42.0-src/tests/dmd/compilable/test20717.d0000644000175000017500000000032315205374125017750 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20717 /* TEST_OUTPUT: --- false --- */ pragma(msg, is(typeof({ struct S { struct Foo {} struct Bar() {} alias Bar = Foo; } }))); ./ldc-1.42.0-src/tests/dmd/compilable/test21806.d0000644000175000017500000000110015205374125017742 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21806 void main() { ubyte[16] arr; static assert(is(typeof( fun(arr[])) == char)); static assert(is(typeof(funtp(arr[])) == char)); static assert(is(typeof( bar(arr[])) == char)); } // functions char fun(ubyte[] arr) { return 'X'; } int fun(ubyte[16] arr) { return 123; } // function templates char funtp()(ubyte[] arr) { return 'X'; } int funtp(size_t N)(ubyte[N] arr) { return 123; } // original case with 'in' char bar()(in ubyte[] arr) { return 'X'; } int bar(size_t N)(in ubyte[N] arr) { return 123; } ./ldc-1.42.0-src/tests/dmd/compilable/must_use_opassign.d0000644000175000017500000000023015205374125022134 0ustar fabiofabioimport core.attribute; @mustuse struct S { ref S opAssign(S rhs) return { return this; } } void test() { S a, b; a = b; } ./ldc-1.42.0-src/tests/dmd/compilable/obsolete_body.d0000644000175000017500000000006515205374125021224 0ustar fabiofabio/* REQUIRED_ARGS: -w */ void test() in { } body { } ./ldc-1.42.0-src/tests/dmd/compilable/test12009.d0000644000175000017500000000072315205374125017747 0ustar fabiofabiostruct RefCounted(T) { struct RefCountedStore { private struct Impl { T _payload; } private Impl* _store; } RefCountedStore _refCounted; ~this() { import core.stdc.stdlib : free; } } struct GroupBy(R) { struct SharedInput { Group unused; } struct Group { private RefCounted!SharedInput _allGroups; } } void main() { GroupBy!(int[]) g1; } ./ldc-1.42.0-src/tests/dmd/compilable/mixintype.d0000644000175000017500000000157515205374125020430 0ustar fabiofabio alias Int = mixin("int"); alias Lint = mixin("Int"); int test1(mixin("int")* p) { mixin("int")[] a = [1]; mixin("int[]") b = [1]; mixin("int[] c = [1];"); 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)); } ./ldc-1.42.0-src/tests/dmd/compilable/test22865.d0000644000175000017500000000116015205374125017756 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22865 // Test that safety errors inside speculative scopes don't affect attribute inference void main() @safe { foo(); } __gshared int g; auto foo() { alias x0 = typeof(g++); alias x1 = typeof(cast(int*) 0); auto x2 = __traits(compiles, g++); enum x3 = __traits(compiles, (cast(int*) 0)); debug { g++; const x4 = cast(int*) 0; asm { } } } // Test that safety violations still occur if the function is inside the __traits(compiles) static assert(!__traits(compiles, { void f() @safe { g++; } })); ./ldc-1.42.0-src/tests/dmd/compilable/test12593.d0000644000175000017500000000037015205374125017755 0ustar fabiofabioint[R] aa; // Place before the declaration of key struct struct R { int opCmp(ref const R) const { return 0; } //bool opEquals(ref const R) const { return true; } //size_t toHash() const nothrow @safe { return 0; } } void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/issue24174.d0000644000175000017500000000101515205374125020121 0ustar fabiofabio/* TEST_OUTPUT: --- true false --- */ bool func1() { struct BtMatcher { uint pc = 0; } BtMatcher matcher; with (matcher) { goto StartLoop; StartLoop: goto SecondLabel; SecondLabel: return true; } } bool func2() { try { throw new Exception("a"); return true; } catch (Exception e) { goto StartA; StartA: goto StartB; StartB: return false; } } pragma(msg, func1()); pragma(msg, func2()); ./ldc-1.42.0-src/tests/dmd/compilable/test16013b.d0000644000175000017500000000045015205374125020105 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16013 S s; /* Only this line has changed from above. */ struct RefCounted { void opAssign(RefCounted rhs) {} void opAssign(S rhs) {} S refCountedPayload() { return S.init; } alias refCountedPayload this; } struct S { RefCounted s; } ./ldc-1.42.0-src/tests/dmd/compilable/test19320.d0000644000175000017500000000031315205374125017745 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19320 // REQUIRED_ARGS: -O -cov auto staticArray(U, T)(T) { U[] theArray = void; return theArray; } void main() { staticArray!(int, int)(3); } ./ldc-1.42.0-src/tests/dmd/compilable/test23679.d0000644000175000017500000000013715205374125017765 0ustar fabiofabio// DISABLED: win32 // https://issues.dlang.org/show_bug.cgi?id=23679 ubyte [0x7fff_ffffU] arr; ./ldc-1.42.0-src/tests/dmd/compilable/test21267.c0000644000175000017500000000023015205374125017745 0ustar fabiofabio// https://github.com/dlang/dmd/issues/21267 static inline __forceinline int square(int x) { return x * x; } int doSquare(int x) { return square(x); } ./ldc-1.42.0-src/tests/dmd/compilable/profilegc_typename.d0000644000175000017500000000032615205374125022247 0ustar fabiofabio// REQUIRED_ARGS: -profile=gc // DISABLED: LDC // -profile=gc not supported struct T(string s) {} alias TypeWithQuotes = T!q"EOS `"'}])> EOS"; void foo() { TypeWithQuotes[] arr; arr ~= TypeWithQuotes(); } ./ldc-1.42.0-src/tests/dmd/compilable/issue15795.d0000644000175000017500000000024315205374125020134 0ustar fabiofabiomodule issue15795; template Foo(T : int) {} template Bar(T) {} alias Bar = Foo; alias bi = Bar!int; alias fi = Foo!int; static assert(__traits(isSame, bi, fi)); ./ldc-1.42.0-src/tests/dmd/compilable/sw_transition_complex.d0000644000175000017500000001651415205374125023033 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -verrors=simple -unittest -verrors=0 /* TEST_OUTPUT: --- compilable/sw_transition_complex.d(15): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead compilable/sw_transition_complex.d(16): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead compilable/sw_transition_complex.d(17): Deprecation: use of complex type `cfloat` is deprecated, use `std.complex.Complex!(float)` instead compilable/sw_transition_complex.d(19): Deprecation: use of imaginary type `ireal` is deprecated, use `real` instead compilable/sw_transition_complex.d(20): Deprecation: use of imaginary type `idouble` is deprecated, use `double` instead compilable/sw_transition_complex.d(21): Deprecation: use of imaginary type `ifloat` is deprecated, use `float` instead --- */ creal c80value; cdouble c64value; cfloat c32value; ireal i80value; idouble i64value; ifloat i32value; /* TEST_OUTPUT: --- compilable/sw_transition_complex.d(34): Deprecation: use of complex type `creal*` is deprecated, use `std.complex.Complex!(real)` instead compilable/sw_transition_complex.d(35): Deprecation: use of complex type `cdouble*` is deprecated, use `std.complex.Complex!(double)` instead compilable/sw_transition_complex.d(36): Deprecation: use of complex type `cfloat*` is deprecated, use `std.complex.Complex!(float)` instead compilable/sw_transition_complex.d(38): Deprecation: use of imaginary type `ireal*` is deprecated, use `real` instead compilable/sw_transition_complex.d(39): Deprecation: use of imaginary type `idouble*` is deprecated, use `double` instead compilable/sw_transition_complex.d(40): Deprecation: use of imaginary type `ifloat*` is deprecated, use `float` instead --- */ creal* c80pointer; cdouble* c64pointer; cfloat* c32pointer; ireal* i80pointer; idouble* i64pointer; ifloat* i32pointer; /* TEST_OUTPUT: --- compilable/sw_transition_complex.d(53): Deprecation: use of complex type `creal[]*` is deprecated, use `std.complex.Complex!(real)` instead compilable/sw_transition_complex.d(54): Deprecation: use of complex type `cdouble[]*` is deprecated, use `std.complex.Complex!(double)` instead compilable/sw_transition_complex.d(55): Deprecation: use of complex type `cfloat[]*` is deprecated, use `std.complex.Complex!(float)` instead compilable/sw_transition_complex.d(57): Deprecation: use of imaginary type `ireal[]*` is deprecated, use `real` instead compilable/sw_transition_complex.d(58): Deprecation: use of imaginary type `idouble[]*` is deprecated, use `double` instead compilable/sw_transition_complex.d(59): Deprecation: use of imaginary type `ifloat[]*` is deprecated, use `float` instead --- */ creal[]* c80arrayp; cdouble[]* d64arrayp; cfloat[]* c32arrayp; ireal[]* i80arrayp; idouble[]* i64arrayp; ifloat[]* i32arrayp; /* TEST_OUTPUT: --- compilable/sw_transition_complex.d(72): Deprecation: use of complex type `creal[4][]*` is deprecated, use `std.complex.Complex!(real)` instead compilable/sw_transition_complex.d(73): Deprecation: use of complex type `cdouble[4][]*` is deprecated, use `std.complex.Complex!(double)` instead compilable/sw_transition_complex.d(74): Deprecation: use of complex type `cfloat[4][]*` is deprecated, use `std.complex.Complex!(float)` instead compilable/sw_transition_complex.d(76): Deprecation: use of imaginary type `ireal[4][]*` is deprecated, use `real` instead compilable/sw_transition_complex.d(77): Deprecation: use of imaginary type `idouble[4][]*` is deprecated, use `double` instead compilable/sw_transition_complex.d(78): Deprecation: use of imaginary type `ifloat[4][]*` is deprecated, use `float` instead --- */ creal[4][]* c80sarrayp; cdouble[4][]* c64sarrayp; cfloat[4][]* c32sarrayp; ireal[4][]* i80sarrayp; idouble[4][]* i64sarrayp; ifloat[4][]* i32sarrayp; /* TEST_OUTPUT: --- compilable/sw_transition_complex.d(96): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead compilable/sw_transition_complex.d(97): Deprecation: use of complex type `creal*` is deprecated, use `std.complex.Complex!(real)` instead compilable/sw_transition_complex.d(98): Deprecation: use of complex type `creal[]` is deprecated, use `std.complex.Complex!(real)` instead compilable/sw_transition_complex.d(99): Deprecation: use of complex type `creal[4]` is deprecated, use `std.complex.Complex!(real)` instead compilable/sw_transition_complex.d(101): Deprecation: use of imaginary type `ireal` is deprecated, use `real` instead compilable/sw_transition_complex.d(102): Deprecation: use of imaginary type `ireal*` is deprecated, use `real` instead compilable/sw_transition_complex.d(103): Deprecation: use of imaginary type `ireal[]` is deprecated, use `real` instead compilable/sw_transition_complex.d(104): Deprecation: use of imaginary type `ireal[4]` is deprecated, use `real` instead --- */ alias C14488 = creal; alias I14488 = ireal; C14488 calias1; C14488* calias2; C14488[] calias3; C14488[4] calias4; I14488 ialias1; I14488* ialias2; I14488[] ialias3; I14488[4] ialias4; /* TEST_OUTPUT: --- compilable/sw_transition_complex.d(115): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead compilable/sw_transition_complex.d(116): Deprecation: use of imaginary type `idouble` is deprecated, use `double` instead compilable/sw_transition_complex.d(117): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead compilable/sw_transition_complex.d(118): Deprecation: use of complex type `cdouble[]` is deprecated, use `std.complex.Complex!(double)` instead --- */ auto cauto = 1 + 0i; auto iauto = 1i; size_t c64sizeof = (cdouble).sizeof; TypeInfo c64ti = typeid(cdouble[]); /* TEST_OUTPUT: --- compilable/sw_transition_complex.d(128): Deprecation: use of complex type `creal*` is deprecated, use `std.complex.Complex!(real)` instead compilable/sw_transition_complex.d(128): Deprecation: use of imaginary type `ireal` is deprecated, use `real` instead compilable/sw_transition_complex.d(132): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead --- */ void test14488a(creal *p, real r, ireal i) { } creal test14488b() { return 1 + 0i; } // Forward referenced types shouldn't cause errors during test for complex or imaginary. enum E; struct S; void test14488c(E *e, S *s) { } // https://issues.dlang.org/show_bug.cgi?id=18212 // Usage of cfloat,cdouble,cfloat,ifloat,idouble,ireal shouldn't trigger an error in deprecated code deprecated void test18212(creal c){} deprecated unittest { ireal a = 2i; creal b = 2 + 3i; } deprecated struct Foo { ifloat a = 2i; cfloat b = 2f + 2i; } // https://issues.dlang.org/show_bug.cgi?id=18218 static assert(__traits(isDeprecated, cfloat)); static assert(__traits(isDeprecated, cdouble)); static assert(__traits(isDeprecated, creal)); static assert(__traits(isDeprecated, ifloat)); static assert(__traits(isDeprecated, idouble)); static assert(__traits(isDeprecated, ireal)); static assert(!__traits(isDeprecated, float)); static assert(!__traits(isDeprecated, double)); static assert(!__traits(isDeprecated, real)); static assert(!__traits(isDeprecated, int)); static assert(!__traits(isDeprecated, long)); static assert(!__traits(isDeprecated, ubyte)); static assert(!__traits(isDeprecated, char)); static assert(!__traits(isDeprecated, bool)); static assert(!__traits(isDeprecated, S)); ./ldc-1.42.0-src/tests/dmd/compilable/test23258.d0000644000175000017500000000031415205374125017753 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23258 struct SumType(Types...) { this(Types[0]) { } this(Types[1]) { } } alias A2 = SumType!(C1[], C2[]); class C1 { } class C2 { } ./ldc-1.42.0-src/tests/dmd/compilable/test22323.d0000644000175000017500000000031215205374125017741 0ustar fabiofabio// REQUIRED_ARGS: -preview=dip1000 struct Schema { int[int] tables; } struct S(Schema s) { void g() { cast(void)s.tables; } } auto makeSchema() => Schema([0: 0]); alias Row = S!(makeSchema()); ./ldc-1.42.0-src/tests/dmd/compilable/alignas.c0000644000175000017500000000052315205374125020007 0ustar fabiofabio// Test _Alignas int printf(const char *, ...); _Alignas(4) _Alignas(8) _Alignas(0) int x = 5; _Static_assert(_Alignof(x) == 8, "in"); _Alignas(int) short y = 6; _Static_assert(_Alignof(y) == 4, "in"); struct S { _Alignas(2) char d; _Alignas(int) char c; }; struct S s = { 1, 2 }; _Static_assert(sizeof(struct S) == 8, "in"); ./ldc-1.42.0-src/tests/dmd/compilable/test20280.d0000644000175000017500000000025115205374125017743 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -Icompilable/extra-files // EXTRA_FILES: extra-files/test20280a.d module test20280; import test20280a; alias Charlie = Foxtrot!(0); ./ldc-1.42.0-src/tests/dmd/compilable/test1547.d0000644000175000017500000000034015205374125017667 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=1547 struct A { int b; static A opCall(int k) { A a; a.b = k; return a; } } void fun(A k = 2) {} void main() { A a = 7; fun(); } ./ldc-1.42.0-src/tests/dmd/compilable/test21543.d0000644000175000017500000000246315205374125017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21543 class B { Nullable!B data; alias data this; } void test1() { B b; Nullable!B n; } struct Nullable(T) { T payload; void opAssign()(T) { move(payload); } inout(T) get_() inout { return payload; } alias get_ this; } // another version with chain of 3 alias this struct C { Nullable2 data; alias data this; } void test2() { C c; Nullable2 n2 = &c; Nullable3 n3 = &c; // these are to check a sane -vcg-ast output fn1(c); fn1(n2); fn1(n3); fn2(c); fn2(n2); fn2(n3); fn3(c); fn3(n2); fn3(n3); } void fn1(C x) {} void fn2(Nullable2 x) {} void fn3(Nullable3 x) {} struct Nullable2 { Nullable3 payload; this(C* c) { payload = Nullable3(c); } void opAssign()(Nullable3) { move(payload); } inout(Nullable3) get_() inout { return payload; } alias get_ this; } struct Nullable3 { C* payload; this(C* c) { payload = c; } void opAssign()(C) { move(payload); } inout(C) get_() inout { return *payload; } alias get_ this; } T move(T)(ref T source) { return source; } T move(T)(T source) { return source; } ./ldc-1.42.0-src/tests/dmd/compilable/ctfe_math.d0000644000175000017500000000142215205374125020323 0ustar fabiofabio// COMPILABLE_MATH_TEST // Test CTFE builtins for std.math functions. import std.math; void main() { static assert(isClose(sin(2.0L), 0.9092974268)); static assert(isClose(cos(2.0), -0.4161468365)); static assert(isClose(tan(2.0f), -2.185040f, 1e-5)); static assert(isClose(sqrt(2.0L), 1.4142135623)); static assert(fabs(-2.0) == 2.0); static assert(ldexp(2.5f, 3) == 20.0f); static assert(isNaN(real.init)); static assert(isNaN(double.nan)); static assert(!isNaN(float.infinity)); static assert(isInfinity(real.infinity)); static assert(isInfinity(-double.infinity)); static assert(!isInfinity(float.nan)); static assert(isFinite(1.0L)); static assert(!isFinite(double.infinity)); static assert(!isFinite(float.nan)); } ./ldc-1.42.0-src/tests/dmd/compilable/issue24399.d0000644000175000017500000000023715205374125020137 0ustar fabiofabio// REQUIRED_ARGS: -main // LINK: template rt_options() { __gshared string[] rt_options = []; string[] rt_options_tls = []; } alias _ = rt_options!(); ./ldc-1.42.0-src/tests/dmd/compilable/paranoia_ctfe.d0000644000175000017500000000047015205374125021166 0ustar fabiofabio/* EXTRA_SOURCES: ../runnable/extra-files/paranoia.d REQUIRED_ARGS: -o- -version=CTFE ARG_SETS: -version=Single ARG_SETS: -version=Double ARG_SETS: -version=Extended TODO: Achieve 0 defects/flaws! TEST_OUTPUT: ---- 0 failures 0 serious defects $n$ defects/flaws ---- */ module test.compilable.paranoia_ctfe; ./ldc-1.42.0-src/tests/dmd/compilable/test16013a.d0000644000175000017500000000047715205374125020115 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16013 struct Impl { S _payload; } /* Only this line has changed from above. */ struct RefCounted { void opAssign(RefCounted rhs) {} void opAssign(S rhs) {} S refCountedPayload() { return S.init; } alias refCountedPayload this; } struct S { RefCounted s; } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc_markdown_breaks.d0000644000175000017500000000066515205374125022543 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // TEST_OUTPUT_FILE: extra-files/ddoc_markdown_breaks.html // OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_breaks.html /++ # Thematic Breaks Some text before *** Some text in between ____________________ Some text after --- This is a code block --- But this is a thematic break: - - - ## Not Thematic Breaks - - __ ** +/ module ddoc_markdown_lists; ./ldc-1.42.0-src/tests/dmd/compilable/test19097.d0000644000175000017500000000174415205374125017771 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 */ // Related to: https://github.com/dlang/dmd/pull/8504 @safe: void betty()(ref int* r, return scope int* p) { r = p; // infer `scope` for r } void boop()(ref int* r, scope int* p) { r = p; // infer `scope` for r, `return` for p } void foo(scope int* pf) { scope int* rf; betty(rf, pf); boop(rf, pf); } // https://issues.dlang.org/show_bug.cgi?id=22801 struct Wrapper { int* ptr; this(return ref int var) @safe { this.ptr = &var; } } void main() @safe { int i; auto w = Wrapper(i); auto wt = WrapperT!()(i); } void assign(ref scope int* x, return ref int y) @safe { x = &y; } // https://issues.dlang.org/show_bug.cgi?id=22967 // inference of `return ref` when assigned to first parameter struct WrapperT() { int* ptr; this(ref int var) @safe { this.ptr = &var; } static void assignInferred(ref scope int* xi, ref int yi) @safe { xi = &yi; } } ./ldc-1.42.0-src/tests/dmd/compilable/traits_getFunctionAttributes.d0000644000175000017500000001531615205374125024322 0ustar fabiofabio module traits_getFunctionAttributes; alias tuple(T...) = T; void test_getFunctionAttributes() { struct S { int noF() { return 0; } int constF() const { return 0; } int immutableF() immutable { return 0; } int inoutF() inout { return 0; } int sharedF() shared { return 0; } int x; ref int refF() return { return x; } int propertyF() @property { return 0; } int nothrowF() nothrow { return 0; } int nogcF() @nogc { return 0; } int systemF() @system { return 0; } int trustedF() @trusted { return 0; } int safeF() @safe { return 0; } int pureF() pure { return 0; } int liveF() @live { return 0; } } static assert(__traits(getFunctionAttributes, S.noF) == tuple!("@system")); static assert(__traits(getFunctionAttributes, typeof(S.noF)) == tuple!("@system")); static assert(__traits(getFunctionAttributes, S.constF) == tuple!("const", "@system")); static assert(__traits(getFunctionAttributes, typeof(S.constF)) == tuple!("const", "@system")); static assert(__traits(getFunctionAttributes, S.immutableF) == tuple!("immutable", "@system")); static assert(__traits(getFunctionAttributes, typeof(S.immutableF)) == tuple!("immutable", "@system")); static assert(__traits(getFunctionAttributes, S.inoutF) == tuple!("inout", "@system")); static assert(__traits(getFunctionAttributes, typeof(S.inoutF)) == tuple!("inout", "@system")); static assert(__traits(getFunctionAttributes, S.sharedF) == tuple!("shared", "@system")); static assert(__traits(getFunctionAttributes, typeof(S.sharedF)) == tuple!("shared", "@system")); static assert(__traits(getFunctionAttributes, S.refF) == tuple!("return", "ref", "@system")); static assert(__traits(getFunctionAttributes, typeof(S.refF)) == tuple!("return", "ref", "@system")); static assert(__traits(getFunctionAttributes, S.propertyF) == tuple!("@property", "@system")); static assert(__traits(getFunctionAttributes, typeof(&S.propertyF)) == tuple!("@property", "@system")); static assert(__traits(getFunctionAttributes, S.nothrowF) == tuple!("nothrow", "@system")); static assert(__traits(getFunctionAttributes, typeof(S.nothrowF)) == tuple!("nothrow", "@system")); static assert(__traits(getFunctionAttributes, S.nogcF) == tuple!("@nogc", "@system")); static assert(__traits(getFunctionAttributes, typeof(S.nogcF)) == tuple!("@nogc", "@system")); static assert(__traits(getFunctionAttributes, S.systemF) == tuple!("@system")); static assert(__traits(getFunctionAttributes, typeof(S.systemF)) == tuple!("@system")); static assert(__traits(getFunctionAttributes, S.trustedF) == tuple!("@trusted")); static assert(__traits(getFunctionAttributes, typeof(S.trustedF)) == tuple!("@trusted")); static assert(__traits(getFunctionAttributes, S.safeF) == tuple!("@safe")); static assert(__traits(getFunctionAttributes, typeof(S.safeF)) == tuple!("@safe")); static assert(__traits(getFunctionAttributes, S.pureF) == tuple!("pure", "@system")); static assert(__traits(getFunctionAttributes, typeof(S.pureF)) == tuple!("pure", "@system")); static assert(__traits(getFunctionAttributes, S.liveF) == tuple!("@live", "@system")); static assert(__traits(getFunctionAttributes, typeof(S.liveF)) == tuple!("@live", "@system")); int pure_nothrow() nothrow pure { return 0; } static ref int static_ref_property() @property { return *(new int); } ref int ref_property() @property { return *(new int); } void safe_nothrow() @safe nothrow { } void live_nothrow() nothrow @live { } static assert(__traits(getFunctionAttributes, pure_nothrow) == tuple!("pure", "nothrow", "@nogc", "@safe")); static assert(__traits(getFunctionAttributes, typeof(pure_nothrow)) == tuple!("pure", "nothrow", "@nogc", "@safe")); static assert(__traits(getFunctionAttributes, static_ref_property) == tuple!("pure", "nothrow", "@property", "ref", "@safe")); static assert(__traits(getFunctionAttributes, typeof(&static_ref_property)) == tuple!("pure", "nothrow", "@property", "ref", "@safe")); static assert(__traits(getFunctionAttributes, ref_property) == tuple!("pure", "nothrow", "@property", "ref", "@safe")); static assert(__traits(getFunctionAttributes, typeof(&ref_property)) == tuple!("pure", "nothrow", "@property", "ref", "@safe")); static assert(__traits(getFunctionAttributes, safe_nothrow) == tuple!("pure", "nothrow", "@nogc", "@safe")); static assert(__traits(getFunctionAttributes, typeof(safe_nothrow)) == tuple!("pure", "nothrow", "@nogc", "@safe")); static assert(__traits(getFunctionAttributes, live_nothrow) == tuple!("pure", "nothrow", "@nogc", "@live", "@safe")); static assert(__traits(getFunctionAttributes, typeof(live_nothrow)) == tuple!("pure", "nothrow", "@nogc", "@live", "@safe")); struct S2 { int pure_const() const pure { return 0; } int pure_sharedconst() const shared pure { return 0; } } static assert(__traits(getFunctionAttributes, S2.pure_const) == tuple!("const", "pure", "@system")); static assert(__traits(getFunctionAttributes, typeof(S2.pure_const)) == tuple!("const", "pure", "@system")); static assert(__traits(getFunctionAttributes, S2.pure_sharedconst) == tuple!("const", "shared", "pure", "@system")); static assert(__traits(getFunctionAttributes, typeof(S2.pure_sharedconst)) == tuple!("const", "shared", "pure", "@system")); static assert(__traits(getFunctionAttributes, (int a) { }) == tuple!("pure", "nothrow", "@nogc", "@safe")); static assert(__traits(getFunctionAttributes, typeof((int a) { })) == tuple!("pure", "nothrow", "@nogc", "@safe")); auto safeDel = delegate() @safe { }; static assert(__traits(getFunctionAttributes, safeDel) == tuple!("pure", "nothrow", "@nogc", "@safe")); static assert(__traits(getFunctionAttributes, typeof(safeDel)) == tuple!("pure", "nothrow", "@nogc", "@safe")); auto trustedDel = delegate() @trusted { }; static assert(__traits(getFunctionAttributes, trustedDel) == tuple!("pure", "nothrow", "@nogc", "@trusted")); static assert(__traits(getFunctionAttributes, typeof(trustedDel)) == tuple!("pure", "nothrow", "@nogc", "@trusted")); auto systemDel = delegate() @system { }; static assert(__traits(getFunctionAttributes, systemDel) == tuple!("pure", "nothrow", "@nogc", "@system")); static assert(__traits(getFunctionAttributes, typeof(systemDel)) == tuple!("pure", "nothrow", "@nogc", "@system")); } void bug19706() { struct S { static int fImpl(Ret)() { return Ret.init; } // tells us: `fImpl!int` is @system static assert(__traits(getFunctionAttributes, fImpl!int) == tuple!("pure", "nothrow", "@nogc", "@safe")); } } ./ldc-1.42.0-src/tests/dmd/compilable/betterc.d0000644000175000017500000000055115205374125020023 0ustar fabiofabio/* REQUIRED_ARGS: -betterC */ // https://issues.dlang.org/show_bug.cgi?id=17787 version (D_BetterC) { } else { static assert(0); } // -betterC does not support `ModuleInfo`, `TypeInfo`, or exception handling version (D_ModuleInfo) { static assert(0); } version (D_Exceptions) { static assert(0); } version (D_TypeInfo) { static assert(0); } ./ldc-1.42.0-src/tests/dmd/compilable/test19295.d0000644000175000017500000000022515205374125017762 0ustar fabiofabiostruct S1(T...) { auto fun() { static assert(__traits(compiles, &T[0])); } } struct S2 { void gun() {} S1!gun overloaded; } ./ldc-1.42.0-src/tests/dmd/compilable/test21514.d0000644000175000017500000000252615205374125017753 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21514 // REQUIRED_ARGS: -verrors=simple // DISABLED: win32 win64 /* TEST_OUTPUT: --- compilable/test21514.d(17): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead compilable/test21514.d(17): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead compilable/test21514.d(18): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead compilable/test21514.d(18): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead compilable/test21514.d(20): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead compilable/test21514.d(20): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead compilable/test21514.d(21): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead compilable/test21514.d(21): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead --- */ extern(C++) cdouble cpp_cadd1(cdouble c) { return c + 1; } extern(C++) creal cpp_cadd1l(creal c) { return c + 1; } cdouble cadd1(cdouble c) { return cpp_cadd1(c); } creal cadd1(creal c) { return cpp_cadd1l(c); } ./ldc-1.42.0-src/tests/dmd/compilable/fix17635.d0000644000175000017500000000032615205374125017567 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=17635 alias T = immutable int; T** f(const T** input) pure { T** output; return output; } void main() { T i; T* p = &i; immutable T** r = f(&p); } ./ldc-1.42.0-src/tests/dmd/compilable/test24280.i0000644000175000017500000000050415205374125017755 0ustar fabiofabio// EXTRA_SOURCES: imports/test24280b.i struct timespec { int s; }; /* https://issues.dlang.org/show_bug.cgi?id=24303 */ typedef struct {} Slice; struct Lang { Slice *slices; }; void langmap(struct Lang *self) { Slice slice = *self->slices; } /* https://issues.dlang.org/show_bug.cgi?id=24306 */ struct T; ./ldc-1.42.0-src/tests/dmd/compilable/testheader1.d0000644000175000017500000000040415205374125020601 0ustar fabiofabio/* EXTRA_SOURCES: extra-files/header1.d REQUIRED_ARGS: -o- -unittest -H -Hf${RESULTS_DIR}/compilable/testheader1.di -ignore PERMUTE_ARGS: -d -dw OUTPUT_FILES: ${RESULTS_DIR}/compilable/testheader1.di TEST_OUTPUT_FILE: extra-files/header1.di */ void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test22892.c0000644000175000017500000000013515205374125017756 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22892 char buf[1]; void fn() { char c = *buf; } ./ldc-1.42.0-src/tests/dmd/compilable/compile1.d0000644000175000017500000005544015205374125020113 0ustar fabiofabio// COMPILABLE_MATH_TEST // PERMUTE_ARGS: // REQUIRED_ARGS: -verrors=simple // EXTRA_FILES: imports/a12506.d /* TEST_OUTPUT: --- compilable/compile1.d(231): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead --- */ /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=1748 // class template with stringof struct S1748(T) {} static assert(S1748!int.stringof == "S1748!int"); class C1748(T) {} static assert(C1748!int.stringof == "C1748!int"); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=2354 // pragma + single semicolon DeclarationBlock version(all) pragma(inline, true); else pragma(inline, false); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=2438 alias void delegate() Dg2438; alias typeof(Dg2438.ptr) CP2438a; alias typeof(Dg2438.funcptr) FP2438a; static assert(is(CP2438a == void*)); static assert(is(FP2438a == void function())); alias typeof(Dg2438.init.ptr) CP2438b; alias typeof(Dg2438.init.funcptr) FP2438b; static assert(is(CP2438b == void*)); static assert(is(FP2438b == void function())); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=4225 struct Foo4225 { enum x = Foo4225(); static Foo4225 opCall() { return Foo4225.init; } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=5996 // ICE(expression.c) template T5996(T) { auto bug5996() { if (anyOldGarbage) {} return 2; } } static assert(!is(typeof(T5996!(int).bug5996()))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=8532 // segfault(mtype.c) - type inference + pure auto segfault8532(Y, R ...)(R r, Y val) pure { return segfault8532(r, val); } static assert(!is(typeof( segfault8532(1,2,3)))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=8982 // ICE(ctfeexpr.c) __parameters with error in default value template ice8982(T) { void bug8982(ref const int v = 7){} static if (is(typeof(bug8982) P == __parameters)) { enum eval8982 = ((P[0..1] g) => g[0])(); } } static assert(!is(ice8982!(int))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=8801 // ICE assigning to __ctfe static assert(!is(typeof( { bool __ctfe= true; }))); static assert(!is(typeof( { __ctfe |= true; }))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=5932 // https://issues.dlang.org/show_bug.cgi?id=6675 // ICE(s2ir.c), ICE(glue.c) void bug3932(T)() { static assert( 0 ); func5932( 7 ); } void func5932(T)( T val ) { void onStandardMsg() { foreach( t; T ) { } } } static assert(!is(typeof( { bug3932!(int)(); }() ))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=6650 // ICE(glue.c) or wrong-code auto bug6650(X)(X y) { X q; q = "abc"; return y; } static assert(!is(typeof(bug6650!(int)(6)))); static assert(!is(typeof(bug6650!(int)(18)))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=14710 // VC-built DMD crashes on templated variadic function IFTI void bug14710a(T)(T val, T[] arr...) { } void bug14710b() { bug14710a("", ""); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=6661 // Templates instantiated only through is(typeof()) shouldn't cause errors template bug6661(Q) { int qutz(Q y) { Q q = "abc"; return 67; } static assert(qutz(13).sizeof!=299); const Q blaz = 6; } static assert(!is(typeof(bug6661!(int).blaz))); template bug6661x(Q) { int qutz(Q y) { Q q = "abc"; return 67; } } // should pass, but doesn't in current //static assert(!is(typeof(bug6661x!(int)))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=6599 // ICE(constfold.c) or segfault string bug6599extraTest(string x) { return x ~ "abc"; } template Bug6599(X) { class Orbit { Repository repository = Repository(); } struct Repository { string fileProtocol = "file://"; string blah = bug6599extraTest("abc"); string source = fileProtocol ~ "/usr/local/orbit/repository"; } } static assert(!is(typeof(Bug6599!int))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=8422 // TypeTuple of tuples can't be read at compile time template TypeTuple8422(TList...) { alias TList TypeTuple8422; } struct S8422 { int x; } void test8422() { enum a = S8422(1); enum b = S8422(2); enum c = [1,2,3]; foreach(t; TypeTuple8422!(b, a)) { enum u = t; } foreach(t; TypeTuple8422!(c)) { enum v = t; } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=6096 // ICE(el.c) with -O cdouble c6096; int bug6096() { if (c6096) return 0; return 1; } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=7681 // Segfault static assert( !is(typeof( (){ undefined ~= delegate(){}; return 7; }()))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=8639 // Buffer overflow void t8639(alias a)() {} void bug8639() { t8639!({auto r = -real.max;})(); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=7751 // Segfault static assert( !is(typeof( (){ bar[]r; r ~= []; return 7; }()))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=7639 // Segfault static assert( !is(typeof( (){ enum foo = [ str : "functions", ]; }))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=11991 void main() { int Throwable; int object; try { } catch(.object.Throwable) { } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=11939 void test11939() { scope(failure) { import object : Object; } throw new Exception(""); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=5796 template A(B) { pragma(lib, "missing ;") enum X = 0; } static assert(!is(typeof(A!(int)))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=6720 void bug6720() { } static assert(!is(typeof( cast(bool)bug6720() ))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=1099 template Mix1099(int a) { alias typeof(this) ThisType; static assert (ThisType.init.tupleof.length == 2); } struct Foo1099 { mixin Mix1099!(0); int foo; mixin Mix1099!(1); int bar; mixin Mix1099!(2); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=8788 // super() and return class B8788 { this ( ) { } } class C8788(int test) : B8788 { this ( int y ) { // TESTS WHICH SHOULD PASS static if (test == 1) { if (y == 3) { super(); return; } super(); return; } else static if (test == 2) { if (y == 3) { super(); return; } super(); } else static if (test == 3) { if (y > 3) { if (y == 7) { super(); return; } super(); return; } super(); } else static if (test == 4) { if (y > 3) { if (y == 7) { super(); return; } else if (y> 5) super(); else super(); return; } super(); } // TESTS WHICH SHOULD FAIL else static if (test == 5) { if (y == 3) { super(); return; } return; // no super } else static if (test == 6) { if (y > 3) { if (y == 7) { super(); return; } super(); } super(); // two calls } else static if (test == 7) { if (y == 3) { return; // no super } super(); } else static if (test == 8) { if (y > 3) { if (y == 7) { return; // no super } super(); return; } super(); } else static if (test == 9) { if (y > 3) { if (y == 7) { super(); return; } else if (y> 5) super(); else return; // no super return; } super(); } } } static assert( is(typeof( { new C8788!(1)(0); } ))); static assert( is(typeof( { new C8788!(2)(0); } ))); static assert( is(typeof( { new C8788!(3)(0); } ))); static assert( is(typeof( { new C8788!(4)(0); } ))); static assert(!is(typeof( { new C8788!(5)(0); } ))); static assert(!is(typeof( { new C8788!(6)(0); } ))); static assert(!is(typeof( { new C8788!(7)(0); } ))); static assert(!is(typeof( { new C8788!(8)(0); } ))); static assert(!is(typeof( { new C8788!(9)(0); } ))); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=4967 // https://issues.dlang.org/show_bug.cgi?id=7058 enum Bug7058 bug7058 = { 1.5f, 2}; static assert(bug7058.z == 99); struct Bug7058 { float x = 0; float y = 0; float z = 99; } /***************************************************/ void test12094() { auto n = null; int *a; int[int] b; int[] c; auto u = true ? null : a; auto v = true ? null : b; auto w = true ? null : c; auto x = true ? n : a; auto y = true ? n : b; auto z = true ? n : c; a = n; b = n; c = n; } /***************************************************/ template test8163(T...) { struct Point { T fields; } enum N = 2; // N>=2 triggers the bug extern Point[N] bar(); void foo() { Point[N] _ = bar(); } } alias test8163!(long) _l; alias test8163!(double) _d; alias test8163!(float, float) _ff; alias test8163!(int, int) _ii; alias test8163!(int, float) _if; alias test8163!(ushort, ushort, ushort, ushort) _SSSS; alias test8163!(ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte) _BBBBBBBB; alias test8163!(ubyte, ubyte, ushort, float) _BBSf; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=4757 auto foo4757(T)(T) { static struct Bar(T) { void spam() { foo4757(1); } } return Bar!T(); } void test4757() { foo4757(1); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=9348 void test9348() { @property Object F(int E)() { return null; } assert(F!0 !is null); assert(F!0 !in [new Object():1]); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=9690 @disable { void dep9690() {} void test9690() { dep9690(); // OK void inner() { dep9690(); // OK <- NG } } } /+ LDC_FIXME: See discussion at D-Programming-Language/dmd#2175. /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=9987 static if (is(object.ModuleInfo == struct)) { struct ModuleInfo {} static assert(!is(object.ModuleInfo == ModuleInfo)); static assert(object.ModuleInfo.sizeof != ModuleInfo.sizeof); } static if (is(object.ModuleInfo == class)) { class ModuleInfo {} static assert(!is(object.ModuleInfo == ModuleInfo)); static assert(__traits(classInstanceSize, object.ModuleInfo) != __traits(classInstanceSize, ModuleInfo)); } +/ /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=10158 class Outer10158 { static struct Inner { int f; } void test() { static assert( Inner.f .offsetof == 0); // OK <- NG static assert((Inner.f).offsetof == 0); // OK } } void test10158() { static assert(Outer10158.Inner.f.offsetof == 0); // OK } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=10326 class C10326 { int val; invariant { assert(val == 0); } invariant() { assert(val == 0); } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=11042 static if ((true || error) == true ) {} else { static assert(0); } static if ((false && error) == false) {} else { static assert(0); } static assert ((true || error) == true ); static assert ((false && error) == false); int f11042a1()() if ((true || error) == true ) { return 0; } enum x11042a1 = f11042a1(); int f11042b1()() if ((false && error) == false) { return 0; } enum x11042b1 = f11042b1(); static if (is(typeof(true || error)) == false) {} else { static assert(0); } static if (is(typeof(false && error)) == false) {} else { static assert(0); } static assert (is(typeof(true || error)) == false); static assert (is(typeof(false && error)) == false); int f11042a2()() if (is(typeof(true || error)) == false) { return 0; } enum x11042a2 = f11042a2(); int f11042b2()() if (is(typeof(false && error)) == false) { return 0; } enum x11042b2 = f11042b2(); static if (__traits(compiles, true || error) == false) {} else { static assert(0); } static if (__traits(compiles, false && error) == false) {} else { static assert(0); } static assert (__traits(compiles, true || error) == false); static assert (__traits(compiles, false && error) == false); int f11042a3()() if (__traits(compiles, true || error) == false) { return 0; } enum x11042a3 = f11042a3(); int f11042b3()() if (__traits(compiles, false && error) == false) { return 0; } enum x11042b3 = f11042b3(); // https://issues.dlang.org/show_bug.cgi?id=24699 enum T24699(bool cond) = cond; enum b24699a = T24699!(true || error); enum b24699b = T24699!(false && error); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=11554 enum E11554; static assert(is(E11554 == enum)); struct Bro11554(N...) {} static assert(!is(E11554 unused : Bro11554!M, M...)); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12302 template isCallable12302(T...) if (T.length == 1) { static if (is(typeof(& T[0].opCall) == delegate)) enum bool isCallable12302 = true; else static if (is(typeof(& T[0].opCall) V : V*) && is(V == function)) enum bool isCallable12302 = true; else enum bool isCallable12302 = true; } class A12302 { struct X {} X x; auto opDispatch(string s, TArgs...)(TArgs args) { mixin("return x."~s~"(args);"); } } A12302 func12302() { return null; } enum b12302 = isCallable12302!func12302; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12476 template A12476(T) { } struct S12476(T) { alias B = A12476!T; } class C12476(T) { alias B = A12476!T; } struct Bar12476(alias Foo) { Foo!int baz; alias baz this; } alias Identity12476(alias A) = A; alias sb12476 = Identity12476!(Bar12476!S12476.B); alias cb12476 = Identity12476!(Bar12476!C12476.B); static assert(__traits(isSame, sb12476, A12476!int)); static assert(__traits(isSame, cb12476, A12476!int)); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12506 import imports.a12506; private bool[9] r12506a = f12506!(i => true)(); // OK private immutable bool[9] r12506b = f12506!(i => true)(); // OK <- error /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12555 class A12555(T) { Undef12555 error; } static assert(!__traits(compiles, { class C : A12555!C { } })); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=11622 class A11622(T) { B11622!T foo() { return new B11622!T; } } class B11622(T) : T { } static assert(!__traits(compiles, { class C : A11622!C { } })); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12688 void writeln12688(A...)(A) {} struct S12688 { int foo() @property { return 1; } } void test12688() { S12688 s; s.foo.writeln12688; // ok (s.foo).writeln12688; // ok <- ng } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12703 struct S12703 { this(int) {} } final class C12703 { S12703 s = S12703(1); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=12799 struct A12799 { int a; enum C = A12799.sizeof; enum D = C; // OK <- Error } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=13236 enum bug13286 = is(typeof({ struct S { S x; } })); /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=13280 struct S13280 { alias U = ubyte; alias T1 = ubyte[this.sizeof]; // ok alias T2 = const U[this.sizeof]; // ok alias T3 = const ubyte[this.sizeof]; // ok <- error } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=13481 mixin template Mix13481(void function() callback) { static this() { callback(); } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=13564 class E13564(T) { int pos; } class C13564(T) { struct S { ~this() { C13564!int c; c.element.pos = 0; } } E13564!T element; } void test13564() { auto c = new C13564!int(); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=14166 struct Proxy14166(T) { T* ptr; ref deref() { return *ptr; } alias deref this; } struct Test14166 { auto opIndex() { return this; } auto opIndex(int) { return 1; } } template Elem14166a(R) { alias Elem14166a = typeof(R.init[][0]); } template Elem14166b(R) { alias Elem14166b = typeof(R.init[0]); } void test14166() { alias T = Proxy14166!Test14166; static assert(is(Elem14166a!T == int)); // rejects-valid case static assert(is(Elem14166b!T == int)); // regression case } // other related cases struct S14166 { int x; double y; int[] a; S14166 opUnary(string op : "++")() { return this; } } S14166 s14166; struct X14166 { this(int) { } X14166 opAssign(int) { return this; } } X14166[int] aa14166; ref X14166[int] makeAA14166() { return aa14166; } struct Tup14166(T...) { T field; alias field this; } Tup14166!(int, int) tup14166; Tup14166!(int, int) makeTup14166() { return tup14166; } alias TT14166(T...) = T; static assert(is(typeof((s14166.x += 1) = 2) == int)); // ok <- error static assert(is(typeof(s14166.a.length += 2) == size_t)); // ok <- error static assert(is(typeof(s14166++) == S14166)); // ok <- error static assert(is(typeof(s14166.x ^^ 2) == int)); // ok <- error static assert(is(typeof(s14166.y ^^= 2.5) == double)); // ok <- error static assert(is(typeof(makeAA14166()[0] = 1) == X14166)); // ok <- error static assert(is(typeof(tup14166.field = makeTup14166()) == TT14166!(int, int))); // ok <- error /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=14388 @property immutable(T)[] idup14388(T)(T[] a) { alias U = immutable(T); U[] res; foreach (ref e; a) res ~= e; return res; } struct Data14388(A14388 a) { auto foo() { return Data14388!a.init; // [B] } } struct A14388 { struct Item {} immutable(Item)[] items; this(int dummy) { items = [Item()].idup14388; } } void test14388() { auto test = Data14388!(A14388(42)).init.foo(); // [A] /* * A(42) is interpreter to a struct literal A([immutable(Item)()]). * The internal VarDeclaration with STCmanifest for the Data's template parameteter 'a' * calls syntaxCopy() on its ((ExpInitializer *)init)->exp in VarDeclaration::semantic(), * and 'immutable(Item)()'->syntaxCopy() had incorrectly removed the qualifier. * Then, the arguments of two Data template instances at [A] and [B] had become unmatch, * and the second instantiation had created the AST duplication. */ } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=15163 void function() func15164(int[] arr) { return () { }; } void test15163() { auto arr = [[0]]; func15164(arr[0])(); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=3438 import core.vararg; struct S3438_1 { this(int x, int y = 1) { } } struct S3438_2 { this(int x, ...) { } } struct S3438_3 { this(int x, int[] arr...) { } } struct S3438_4 { this(...) { } } struct S3438_5 { this(int[] arr...) { } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=15362 void func15362() { assert(true); assert(true,); assert(true, "So true"); assert(true, "Very, very true",); static assert(true); static assert(true,); static assert(true, "So true"); static assert(true, "Very, very true",); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=15799 interface I15799 { void funA(); void funB(int n) in { assert(n); }; // Semicolon is not a part of function declaration. It's an empty declaration. } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=21163 struct B21163 { void function(scope int) fp; } B21163 b21163 = { (scope int x){} }; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=11624 interface I11624 { void foo(); } static assert(!__traits(compiles, { static class C11624 : I11624 { } })); ./ldc-1.42.0-src/tests/dmd/compilable/test9565.d0000644000175000017500000000617315205374125017711 0ustar fabiofabio// REQUIRED_ARGS: -o- -m32 // PERMUTE_ARGS: template TypeTuple(T...) { alias TypeTuple = T; } bool startsWith(string s, string m) { return s[0 .. m.length] == m; } void main() { enum string castPrefix = "cast(" ~ size_t.stringof ~ ")"; // TypeSArray static assert((int[10]).stringof == "int[10]", T.stringof); int[] arr; // IndexExp { // index == IntegerExp static assert((arr[ 4 ]).stringof == "arr[4]"); static assert((arr[ 4U ]).stringof == "arr[4]"); static assert((arr[ 4L ]).stringof == "arr[4]"); static assert((arr[ 4LU]).stringof == "arr[4]"); // index == UAddExp static assert((arr[+4 ]).stringof == "arr[4]"); static assert((arr[+4U ]).stringof == "arr[4]"); static assert((arr[+4L ]).stringof == "arr[4]"); static assert((arr[+4LU]).stringof == "arr[4]"); // index == NegExp static assert((arr[-4 ]).stringof == "arr[" ~ castPrefix ~ "-4]"); static assert((arr[-4U ]).stringof == "arr[cast(size_t)4294967292]"); static assert((arr[int.min] ).stringof == "arr[" ~ castPrefix ~ "-2147483648]"); static if (is(size_t == ulong)) { static assert((arr[-4L ]).stringof == "arr[" ~ castPrefix ~ "-4L]"); static assert((arr[-4LU]).stringof == "arr[-4LU]"); // IntegerLiteral needs suffix if the value is greater than long.max static assert((arr[long.max + 0]).stringof == "arr[9223372036854775807]"); static assert((arr[long.max + 1]).stringof == "arr[" ~ castPrefix ~ "(9223372036854775807L + 1L)]"); } foreach (Int; TypeTuple!(byte, ubyte, short, ushort, int, uint, long, ulong)) { enum Int p4 = +4; enum string result1 = (arr[p4]).stringof; static assert(result1 == "arr[4]"); enum string result2 = (arr[cast(Int)+4]).stringof; static assert(result2 == "arr[4]"); } foreach (Int; TypeTuple!(byte, short, int, long)) { // keep "cast(Type)" in the string representation enum Int m4 = -4; static if (is(typeof({ size_t x = m4; }))) { enum string result1 = (arr[m4]).stringof; static assert(result1.startsWith("arr[" ~ castPrefix)); } else static assert(!__traits(compiles, arr[m4])); enum string result2 = (arr[cast(Int)-4]).stringof; static assert(result2.startsWith("arr[" ~ castPrefix)); } } // SliceExp { // lwr,upr == IntegerExp static assert((arr[4 .. 8 ]).stringof == "arr[4..8]"); static assert((arr[4U .. 8U ]).stringof == "arr[4..8]"); static assert((arr[4L .. 8L ]).stringof == "arr[4..8]"); static assert((arr[4LU .. 8LU]).stringof == "arr[4..8]"); // lwr,upr == UAddExp static assert((arr[+4 .. +8 ]).stringof == "arr[4..8]"); static assert((arr[+4U .. +8U ]).stringof == "arr[4..8]"); static assert((arr[+4L .. +8L ]).stringof == "arr[4..8]"); static assert((arr[+4LU .. +8LU]).stringof == "arr[4..8]"); } } ./ldc-1.42.0-src/tests/dmd/compilable/aliasassign.d0000644000175000017500000000676315205374125020704 0ustar fabiofabiotemplate AliasSeq(T...) { alias AliasSeq = T; } template Unqual(T) { static if (is(T U == const U)) alias Unqual = U; else static if (is(T U == immutable U)) alias Unqual = U; else alias Unqual = T; } template staticMap(alias F, T...) { alias A = AliasSeq!(); static foreach (t; T) A = AliasSeq!(A, F!t); // what's tested alias staticMap = A; } alias TK = staticMap!(Unqual, int, const uint); //pragma(msg, TK); static assert(is(TK == AliasSeq!(int, uint))); /**************************************************/ template reverse(T...) { alias A = AliasSeq!(); static foreach (t; T) A = AliasSeq!(t, A); // what's tested alias reverse = A; } enum X2 = 3; alias TK2 = reverse!(int, const uint, X2); //pragma(msg, TK2); static assert(TK2[0] == 3); static assert(is(TK2[1] == const(uint))); static assert(is(TK2[2] == int)); /**************************************************/ template Tp(Args...) { alias Tp = AliasSeq!(int, 1, "asd", Args); static foreach (arg; Args) { Tp = AliasSeq!(4, Tp, "zxc", arg, Tp, 5, 4, int, Tp[0..2]); } } void fun(){} alias a1 = Tp!(char[], fun, x => x); static assert( __traits(isSame, a1, AliasSeq!(4, 4, 4, int, 1, "asd", char[], fun, x => x, "zxc", char[], int, 1, "asd", char[], fun, x => x, 5, 4, int, int, 1, "zxc", fun, 4, int, 1, "asd", char[], fun, x => x, "zxc", char[], int, 1, "asd", char[], fun, x => x, 5, 4, int, int, 1, 5, 4, int, 4, int, "zxc", x => x, 4, 4, int, 1, "asd", char[], fun, x => x, "zxc", char[], int, 1, "asd", char[], fun, x => x, 5, 4, int, int, 1, "zxc", fun, 4, int, 1, "asd", char[], fun, x => x, "zxc", char[], int, 1, "asd", char[], fun, x => x, 5, 4, int, int, 1, 5, 4, int, 4, int, 5, 4, int, 4, 4))); template Tp2(Args...) { alias Tp2 = () => 1; static foreach (i; 0..Args.length) Tp2 = AliasSeq!(Tp2, Args[i]); } const x = 8; static assert( __traits(isSame, Tp2!(2, float, x), AliasSeq!(() => 1, 2, float, x))); enum F(int i) = i * i; template staticMap2(alias fun, args...) { alias staticMap2 = AliasSeq!(); static foreach (i; 0 .. args.length) staticMap2 = AliasSeq!(fun!(args[i]), staticMap2, fun!(args[i])); } enum a2 = staticMap2!(F, 0, 1, 2, 3, 4); struct Cmp(T...){} // isSame sucks static assert(is(Cmp!a2 == Cmp!(16, 9, 4, 1, 0, 0, 1, 4, 9, 16))); template Tp3() { alias aa1 = int; static foreach (t; AliasSeq!(float, char[])) aa1 = AliasSeq!(aa1, t); static assert(is(aa1 == AliasSeq!(int, float, char[]))); alias aa2 = AliasSeq!int; static foreach (t; AliasSeq!(float, char[])) aa2 = AliasSeq!(aa2, t); static assert(is(aa2 == AliasSeq!(int, float, char[]))); alias aa3 = AliasSeq!int; aa3 = AliasSeq!(float, char); static assert(is(aa3 == AliasSeq!(float, char))); } alias a3 = Tp3!(); template Tp4() // Uses slow path because overload { alias AliasSeq(T...) = T; alias AliasSeq(alias f, T...) = T; alias aa4 = int; aa4 = AliasSeq!(aa4, float); static assert(is(aa4 == AliasSeq!(int, float))); } alias a4 = Tp4!(); template Tp5() // same tp overloaded, still uses fast path { alias AliasSeq2(T...) = T; alias AliasSeq = AliasSeq2; alias AliasSeq = AliasSeq2; alias aa5 = int; aa5 = AliasSeq!(aa5, float); static assert(is(aa5 == AliasSeq!(int, float))); } alias a5 = Tp5!(); ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_821.d0000644000175000017500000000012415205374125021065 0ustar fabiofabio// EXTRA_SOURCES: imports/ldc_github_821a.d import imports.ldc_github_821a; S* s; ./ldc-1.42.0-src/tests/dmd/compilable/test21743.d0000644000175000017500000000063615205374125017757 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21743 struct A { int foo(int a) { return a; } string foo()(string b) { return b; } } alias ov = __traits(getOverloads, A.init, "foo", true); // member function works static assert(ov[0](1) == 1); // member template used to fail with the gagged error: // 'need this for foo of type pure nothrow @nogc @safe string(string b)' static assert(ov[1]("a") == "a"); ./ldc-1.42.0-src/tests/dmd/compilable/vgc3.d0000644000175000017500000000223515205374125017236 0ustar fabiofabio// REQUIRED_ARGS: -vgc -o- // PERMUTE_ARGS: /***************** AssignExp *******************/ /* TEST_OUTPUT: --- compilable/vgc3.d(16): vgc: setting `length` may cause a GC allocation compilable/vgc3.d(17): vgc: setting `length` may cause a GC allocation compilable/vgc3.d(18): vgc: setting `length` may cause a GC allocation --- */ void testArrayLength(int[] a) { a.length = 3; a.length += 1; a.length -= 1; } /***************** CallExp *******************/ void barCall(); /* TEST_OUTPUT: --- --- */ void testCall() { auto fp = &barCall; (*fp)(); barCall(); } /****************** Closure ***********************/ @nogc void takeDelegate2(scope int delegate() dg) {} @nogc void takeDelegate3( int delegate() dg) {} /* TEST_OUTPUT: --- compilable/vgc3.d(51): vgc: using closure causes GC allocation compilable/vgc3.d(63): vgc: using closure causes GC allocation --- */ auto testClosure1() { int x; int bar() { return x; } return &bar; } void testClosure2() { int x; int bar() { return x; } takeDelegate2(&bar); // no error } void testClosure3() { int x; int bar() { return x; } takeDelegate3(&bar); } ./ldc-1.42.0-src/tests/dmd/compilable/test23039.c0000644000175000017500000000031015205374125017743 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=23039 */ const int x = 1; void fn1() { char x[x]; } //struct S1 { char x[x]; }; typedef int y; void fn3() { void(*y)(y); } //struct S3 { void(*y)(y); }; ./ldc-1.42.0-src/tests/dmd/compilable/test12523.d0000644000175000017500000000043715205374125017752 0ustar fabiofabiovoid test12523(inout(int)) { void check(T)() { T[] a; foreach (ref e; a) static assert(is(typeof(e) == T)); } check!(int)(); check!(inout(int))(); check!(inout(const(int)))(); check!(const(int))(); check!(immutable(int))(); } ./ldc-1.42.0-src/tests/dmd/compilable/README.md0000644000175000017500000000153215205374125017505 0ustar fabiofabio# Tests for successful compilation Each D file will be compiled and the compilation is expected to succeed. Any diagnostic emitted must match the predefined diagnostic in the test file, otherwise the test will fail. ## Purpose The point of these files is to test that the compiler successfully emits code without unexpected diagnostics or potential crashes. A further aim is that when the compiler does fail these tests, the test case should be crafted to make debugging the compiler as straightforward as practical. ## Remarks Test in this directory are not linked by default because linking is expensive and usually not necessary to reproduce an error. A test may specify the `LINK` test parameter to enforce the linking. Refer to [test/README.md](../README.md) for general information and the [test guidelines](../README.md#test-coding-practices). ./ldc-1.42.0-src/tests/dmd/compilable/test22758.c0000644000175000017500000000016215205374125017757 0ustar fabiofabio // https://issues.dlang.org/show_bug.cgi?id=22758 void foo(unsigned* aData){ unsigned s = (aData[0]) & 1; } ./ldc-1.42.0-src/tests/dmd/compilable/test13123.d0000644000175000017500000000107515205374125017746 0ustar fabiofabioauto inferNothrow() in { } out { } do { return 1; } auto dontInferNothrowIn() in { throw new Exception(null); } do { return 1; } auto dontInferNothrowOut() out { throw new Exception(null); } do { return 1; } enum isNothrow(Attr...) = (Attr.length >= 1) && (Attr[0] == "nothrow" || isNothrow!(Attr[1 .. $])); static assert(isNothrow!(__traits(getFunctionAttributes, inferNothrow))); static assert(!isNothrow!(__traits(getFunctionAttributes, dontInferNothrowIn))); static assert(!isNothrow!(__traits(getFunctionAttributes, dontInferNothrowOut))); ./ldc-1.42.0-src/tests/dmd/compilable/test21830.d0000644000175000017500000000056715205374125017757 0ustar fabiofabio// REQUIRED_ARGS: -de -unittest deprecated struct OldS21830 { } struct NewS21830 { } static if (1) { auto test21830(T)(T t) if (is(T == NewS21830)) { return T.init; } } deprecated auto test21830(T)(T t) if (is(T == OldS21830)) { return T.init; } unittest { auto b = test21830(NewS21830()); // error here about using test21830!OldS21830 } ./ldc-1.42.0-src/tests/dmd/compilable/header18365.d0000644000175000017500000000121015205374125020223 0ustar fabiofabio/* REQUIRED_ARGS: -c -o- -Hf${RESULTS_DIR}/compilable/header18365.di PERMUTE_ARGS: OUTPUT_FILES: ${RESULTS_DIR}/compilable/header18365.di TEST_OUTPUT: --- === ${RESULTS_DIR}/compilable/header18365.di // D import file generated from 'compilable/header18365.d' struct FullCaseEntry { dchar[3] seq; ubyte n; ubyte size; ubyte entry_len; auto pure nothrow @nogc @property @trusted value() const return { return seq[0..entry_len]; } } --- */ struct FullCaseEntry { dchar[3] seq; ubyte n, size; ubyte entry_len; @property auto value() const @trusted pure nothrow @nogc return { return seq[0 .. entry_len]; } } ./ldc-1.42.0-src/tests/dmd/compilable/test23622.c0000644000175000017500000000017115205374125017746 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23622 int FP_NAN = 0; #define FP_NAN 0 enum E { ENUM = 0 }; #define ENUM 0 ./ldc-1.42.0-src/tests/dmd/compilable/test23407.i0000644000175000017500000000073015205374125017756 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23407 struct Foo { int x; }; _Static_assert(sizeof(struct Foo) == sizeof(int), ""); void one(void){ struct Foo { int y, z; }; struct Foo f = {0}; _Static_assert(sizeof(struct Foo) == 2*sizeof(int), ""); } void two(void){ struct Foo { int y, z; } f ; _Static_assert(sizeof(f) == 2*sizeof(int), ""); _Static_assert(sizeof(struct Foo) == 2*sizeof(int), ""); // fails } ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_421.d0000644000175000017500000000032315205374125021062 0ustar fabiofabioint main() { import core.simd; float[16] a = 1.0; float4 t = 0, k = 2; auto b = cast(float4[])a; for (size_t i = 0; i < b.length; i++) t += b[i] * k; return cast(int)t.array[2]; }./ldc-1.42.0-src/tests/dmd/compilable/test20000.d0000644000175000017500000000041715205374125017735 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20000 interface A { int a(); } interface B { int b(); } class C {} bool isA(Object x) @safe { return cast(A) x !is null; } bool isA(B x) @safe { return cast(A) x !is null; } bool isA(C x) @safe { return cast(A) x !is null; } ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_355.d0000644000175000017500000000025415205374125021073 0ustar fabiofabiostruct S { uint x; } template MakeS(uint x) { const MakeS = S(x); } struct S2 { alias .MakeS MakeS; } void f() { S2 s2; auto n = s2.MakeS!(0); //////////// XXX }./ldc-1.42.0-src/tests/dmd/compilable/test8038.d0000644000175000017500000000016415205374125017675 0ustar fabiofabiotemplate t(T){alias T t;} t!(#line 10 t!( int, ) ) i; t!( t!(#line 10 int, ) ) j; ./ldc-1.42.0-src/tests/dmd/compilable/inliner2.d0000644000175000017500000000062315205374125020115 0ustar fabiofabio// REQUIRED_ARGS: -O -inline struct Cent { ulong lo; // low 64 bits ulong hi; // high 64 bits } pure bool tst(Cent c) { return c.hi || c.lo; } pure Cent dec(Cent c); pure Cent shl(Cent c, uint n); pure Cent udivmod(Cent c1, Cent c2, out Cent modulus) { ulong v1 = shl(c2, 3).hi; Cent quotient; if (tst(quotient)) quotient = dec(quotient); return quotient; } ./ldc-1.42.0-src/tests/dmd/compilable/test23862.d0000644000175000017500000000030315205374125017752 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23862 enum E { A, B } void test(E e) { with (e) switch (e) { case A: case B: default: break; } } ./ldc-1.42.0-src/tests/dmd/compilable/ctfesimd.d0000644000175000017500000000720215205374125020171 0ustar fabiofabioversion (D_SIMD) { import core.simd; // https://issues.dlang.org/show_bug.cgi?id=19627 enum int[4] fail19627 = cast(int[4])int4(0); // https://issues.dlang.org/show_bug.cgi?id=19628 enum ice19628a = int4.init[0]; enum ice19628b = int4.init.array[0]; enum ice19628c = (cast(int[4])int4.init.array)[0]; enum ice19628d = (cast(int[4])int4.init)[0]; // https://issues.dlang.org/show_bug.cgi?id=19629 enum fail19629a = int4(0)[0]; enum fail19629b = int4(0).array[0]; enum fail19629c = (cast(int[4])int4(0).array)[0]; enum fail19628d = (cast(int[4])int4(0))[0]; // https://issues.dlang.org/show_bug.cgi?id=19630 // enum fail19630a = int4.init[1..2]; enum fail19630b = int4.init.array[1..2]; enum fail19630c = (cast(int[4])int4.init.array)[1..2]; // enum fail19630d = int4(0)[1..2]; enum fail19630e = int4(0).array[1..2]; enum fail19630f = (cast(int[4])int4(0).array)[1..2]; enum fail19630g = (cast(int[4])int4.init)[1..2]; enum fail19630h = (cast(int[4])int4(0))[1..2]; // Same tests as above, but use access via enum. enum int4 V1 = int4.init; enum int[4] V2 = int4.init.array; enum int[4] V3 = cast(int[4])int4.init; enum int[4] V4 = cast(int[4])int4.init.array; enum int4 V5 = int4(0); enum int[4] V6 = int4(0).array; enum int[4] V7 = cast(int[4])int4(0); enum int[4] V8 = cast(int[4])int4(0).array; // CTFE index tests enum I1 = V1[0]; static assert(I1 == 0); enum I2 = V2[0]; static assert(I2 == 0); enum I3 = V3[0]; static assert(I3 == 0); enum I4 = V4[0]; static assert(I4 == 0); enum I5 = V5[0]; static assert(I5 == 0); enum I6 = V6[0]; static assert(I6 == 0); enum I7 = V7[0]; static assert(I7 == 0); enum I8 = V8[0]; static assert(I8 == 0); // CTFE slice tests // enum S1 = V1[1..2]; static assert(S1 == [0]); enum S2 = V2[1..2]; static assert(S2 == [0]); enum S3 = V3[1..2]; static assert(S3 == [0]); enum S4 = V4[1..2]; static assert(S4 == [0]); // enum S5 = V5[1..2]; static assert(S5 == [0]); enum S6 = V6[1..2]; static assert(S6 == [0]); enum S7 = V7[1..2]; static assert(S7 == [0]); enum S8 = V8[1..2]; static assert(S8 == [0]); // Same tests as above, but use access via immutable. //immutable int4 v1 = int4.init; // Cannot cast to immutable at compile time immutable int[4] v2 = int4.init.array; immutable int[4] v3 = cast(int[4])int4.init; immutable int[4] v4 = cast(int[4])int4.init.array; //immutable int4 v5 = int4(0); // Cannot cast to immutable at compile time immutable int[4] v6 = int4(0).array; immutable int[4] v7 = cast(int[4])int4(0); immutable int[4] v8 = cast(int[4])int4(0).array; // CTFE index tests //immutable i1 = v1[0]; static assert(i1 == 0); immutable i2 = v2[0]; static assert(i2 == 0); immutable i3 = v3[0]; static assert(i3 == 0); immutable i4 = v4[0]; static assert(i4 == 0); //immutable i5 = v5[0]; static assert(i5 == 0); immutable i6 = v6[0]; static assert(i6 == 0); immutable i7 = v7[0]; static assert(i7 == 0); immutable i8 = v8[0]; static assert(i8 == 0); // CTFE slice tests //immutable s1 = v1[1..2]; static assert(s1 == [0]); immutable s2 = v2[1..2]; static assert(s2 == [0]); immutable s3 = v3[1..2]; static assert(s3 == [0]); immutable s4 = v4[1..2]; static assert(s4 == [0]); //immutable s5 = v5[1..2]; static assert(s5 == [0]); immutable s6 = v6[1..2]; static assert(s6 == [0]); immutable s7 = v7[1..2]; static assert(s7 == [0]); immutable s8 = v8[1..2]; static assert(s8 == [0]); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc13270.d0000644000175000017500000000070715205374125017704 0ustar fabiofabio// PERMUTE_ARGS: -w // REQUIRED_ARGS: -o- -D -Dd${RESULTS_DIR}/compilable // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc13270; /** * My overloaded function. * * Params: * task = String description of stuff to do. * tasks = Array of descriptions of stuff to do. * maxJobs = Max parallel jobs to run while doing stuff. */ void doStuff(string task) {} /// ditto void doStuff(string[] tasks, int maxJobs) {} ./ldc-1.42.0-src/tests/dmd/compilable/ice13403.d0000644000175000017500000000016515205374125017527 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -o- // EXTRA_FILES: imports/ice13403a.d import imports.ice13403a; void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test17541.d0000644000175000017500000000051315205374125017752 0ustar fabiofabio/* EXTRA_SOURCES: imports/test17541_2.d imports/test17541_3.d */ // https://issues.dlang.org/show_bug.cgi?id=17541 module one; import two; import three; struct BB { enum MAX_NUM_FIBERS = 4096; TWOR!1 t; TT!(int) tt; auto foo() { tt.insertabcdefg(1); } } BB bb; @nogc bar() { bb.foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/named_arguments_auto_ref.d0000644000175000017500000000203215205374125023424 0ustar fabiofabio/** TEST_OUTPUT: --- Call 0 (x: true, y: false) Call 1 Call 2 (x: false, y: false) Call 3 (x: false, y: true) Call 4 --- As of writing this test, template function instances store the function arguments from the call site. When looking in cache for an existing template instantiation, matching template arguments isn't sufficient: `auto ref` parameters being ref or not also create different template instances. This test checks that the special logic for it still works with named arguments. */ void autoref()(auto ref int x, auto ref int y) { pragma(msg, "(x: ", __traits(isRef, x), ", y: ", __traits(isRef, y), ")"); } void main() { int REF = 0; enum NOT = 0; pragma(msg, "Call 0"); autoref(y: NOT, x: REF); // new instance pragma(msg, "Call 1"); autoref(x: REF, y: NOT); // existing instance pragma(msg, "Call 2"); autoref(x: NOT, y: NOT); // new instance pragma(msg, "Call 3"); autoref(x: NOT, y: REF); // new instance pragma(msg, "Call 4"); autoref(y: REF, x: NOT); // existing instance } ./ldc-1.42.0-src/tests/dmd/compilable/ice6538.d0000644000175000017500000000136015205374125017460 0ustar fabiofabio /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=6538 template allSatisfy(alias F, T...) { enum bool allSatisfy = true; } template isIntegral(T) { enum bool isIntegral = true; } void foo(I...)(I sizes) if (allSatisfy!(isIntegral, sizes)) {} void test6538a() { foo(42, 86); } void bar(T1, T2)(T1 t1, T2 t2) if (allSatisfy!(isIntegral, t1, t2)) {} void test6538b() { bar(42, 86); } /**************************************/ // https://issues.dlang.org/show_bug.cgi?id=9361 template Sym(alias A) { enum Sym = true; } struct S { void foo()() if (Sym!(this)) {} void bar()() { static assert(Sym!(this)); } // OK } void test9361a() { S s; s.foo(); // fail s.bar(); // OK } ./ldc-1.42.0-src/tests/dmd/compilable/testcontracts.d0000644000175000017500000000516615205374125021302 0ustar fabiofabio// COMPILED_IMPORTS: imports/testcontracts.d import imports.testcontracts; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=3602 class Derived3602 : Base3602 { override void method(int x, int y) in { assert(x > 0); assert(y > 0); } do { } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=5230 class Derived5230 : Base5230 { override int method() { return 69; } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=17502 class Foo17502 { auto foo() out {} do {} auto bar() out { assert (__result > 5); } do { return 6; } auto bar_2() out (res) { assert (res > 5); } do { return 6; } int concrete() out { assert(__result > 5); } do { return 6; } int concrete_2() out(res) { assert (res > 5); } do { return 6; } void void_foo() out {} do {} auto void_auto() out {} do {} } /***************************************************/ // Order of declaration: (A), (C : B), (B : A) class A17502 { int method(int p) in { assert(p > 5); } out(res) { assert(res > 5); } do { return p; } } class C17502 : B17502 { override int method(int p) in { assert(p > 3); } do { return p * 2; } } class B17502 : A17502 { override int method(int p) in { assert(p > 2); } do { return p * 3; } } /***************************************************/ // Order of declaration: (X : Y), (Y : Z), (Z) class X17502 : Y17502 { override int method(int p) in { assert(p > 3); } do { return p * 2; } } class Y17502 : Z17502 { override int method(int p) in { assert(p > 2); } do { return p * 3; } } class Z17502 { int method(int p) in { assert(p > 5); } out(res) { assert(res > 5); } do { return p; } } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=17893 final class Foo17893(T) { extern(C) void maythrow(); void bar() in { maythrow(); } do { } } Foo17893!int foo17893; /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=15984 alias Bar15984 = extern (C) void function(void*); final class C15984 { void foo(Bar15984 bar) in { assert(bar); } do {} } ./ldc-1.42.0-src/tests/dmd/compilable/test22559.i0000644000175000017500000000060315205374125017764 0ustar fabiofabio// https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html int alpha(char c) { switch (c) { case 'A' ... 'Z': return 1; case 'a' ... 'z': return 1; default: return 0; } } _Static_assert(alpha('A') == 1, "1"); _Static_assert(alpha('B') == 1, "2"); _Static_assert(alpha('z') == 1, "3"); _Static_assert(alpha('z' + 1) == 0, "3"); _Static_assert(alpha('0') == 0, "4"); ./ldc-1.42.0-src/tests/dmd/compilable/test18670.d0000644000175000017500000000027715205374125017765 0ustar fabiofabio// REQUIRED_ARGS: -preview=dip1000 // https://issues.dlang.org/show_bug.cgi?id=18670 void foo() { new OVERLAPPED; } union OVERLAPPED { uint OffsetHigh; uint Pointer; } ./ldc-1.42.0-src/tests/dmd/compilable/test11847.d0000644000175000017500000000073315205374125017761 0ustar fabiofabio// REQUIRED_ARGS: -Icompilable/imports // EXTRA_FILES: imports/pkg11847/mod11847.d imports/pkg11847/package.d import pkg11847; import pkg11847.mod11847; void main() { static assert(pkg11847.func() == 1); static assert(pkg11847.mod11847.func() == 2); // This correctly won't compile. // Error: pkg11847.mod11847.func at imports/pkg11847/mod11847.d(3) conflicts with pkg11847.func at imports/pkg11847/package.d(3) static assert(!__traits(compiles, func())); } ./ldc-1.42.0-src/tests/dmd/compilable/pragmainline2.d0000644000175000017500000000447515205374125021134 0ustar fabiofabio/* DISABLED: LDC // FIXME - LLVM complains: `Attributes 'noinline and alwaysinline' are incompatible!` REQUIRED_ARGS: -verrors=simple -inline -wi TEST_OUTPUT: --- compilable/pragmainline2.d(14): Warning: cannot inline function `pragmainline2.foo` compilable/pragmainline2.d(22): Warning: cannot inline function `pragmainline2.f1t` compilable/pragmainline2.d(25): Warning: cannot inline function `pragmainline2.f2t` --- */ pragma(inline, true): pragma(inline, false): pragma(inline) void foo() { pragma(inline, false); pragma(inline); pragma(inline, true); // this last one will affect to the 'foo' asm { nop; } } pragma(inline, true) void f1t() { asm { nop; } } // cannot inline pragma(inline, false) void f1f() { asm { nop; } } pragma(inline) void f1d() { asm { nop; } } void f2t() { pragma(inline, true); asm { nop; } } // cannot inline void f2f() { pragma(inline, false); asm { nop; } } void f2d() { pragma(inline); asm { nop; } } void main() { foo(); f1t(); f1f(); f1d(); f2t(); f2f(); f2d(); } /* TEST_OUTPUT: --- compilable/pragmainline2.d(50): Warning: cannot inline function `pragmainline2.jazz` compilable/pragmainline2.d(63): Warning: cannot inline function `pragmainline2.metal` --- */ pragma(inline, true) auto jazz() { static struct U { int a = 42; float b; ~this(){} // __dtor: inline not allowed } U u; return u.a; } pragma(inline, true) auto metal() { class U // class : inline not allowed { int a = 42; float b; } return (new U).a; } void music() { auto f = jazz(); auto b = metal(); } // test inlining in core.internal.convert for hash generation bool test_toUByte() { import core.internal.convert; const(ubyte)[] ubarr; int[] iarr = [1, 2, 3]; ubarr = toUbyte(iarr); char[] carr = [1, 2, 3]; ubarr = toUbyte(carr); long lng = 42; ubarr = toUbyte(lng); char ch = 42; ubarr = toUbyte(ch); static if(is(__vector(int[4]))) { __vector(int[4]) vint = [1, 2, 3, 4]; ubarr = toUbyte(vint); } enum E { E1, E2, E3 } E eval = E.E1; ubarr = toUbyte(eval); void delegate() dg; ubarr = toUbyte(dg); struct S { int x; } S sval; ubarr = toUbyte(sval); return true; } static assert(test_toUByte()); ./ldc-1.42.0-src/tests/dmd/compilable/test25.d0000644000175000017500000000025715205374125017524 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/test25a.d imports/test25b.d import imports.test25a, imports.test25b; import core.stdc.stdio; void main() { printf("hello\n"); } ./ldc-1.42.0-src/tests/dmd/compilable/test22955.c0000644000175000017500000000017315205374125017760 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22955 _Static_assert( sizeof(void*) < 8 || _Alignof(__uint128_t) == 16, "" ); ./ldc-1.42.0-src/tests/dmd/compilable/test20963.c0000644000175000017500000000025415205374125017755 0ustar fabiofabio// https://github.com/dlang/dmd/issues/20963 void cdind() { struct ABC { int y; } *p; { struct ABC { int x; } abc; abc.x = 1; } } ./ldc-1.42.0-src/tests/dmd/compilable/test23207.i0000644000175000017500000000017115205374125017753 0ustar fabiofabio#define Bugzilla 23207 #define _FEATURES_H 1 # 101 "/usr/include/features.h" 3 4 #undef __USE_ISOC11 #undef __USE_ISOC99 ./ldc-1.42.0-src/tests/dmd/compilable/test18775.d0000644000175000017500000000045315205374125017767 0ustar fabiofabio// REQUIRED_ARGS: -de struct Foo { } struct Bar { deprecated @property Foo foo() { return Foo.init; } alias foo this; } void test(Bar bar) { } void main() { Bar bar; // test lookup will be satisfied via ufcs, not alias, so it must not deprecation warn foo! bar.test; } ./ldc-1.42.0-src/tests/dmd/compilable/test9278a.d0000644000175000017500000000033215205374125020042 0ustar fabiofabio// PERMUTE_ARGS: // Works fine here struct datum { float num = 0.0; } datum emitOne() { datum t; return t; } const dataArr = [emitOne()]; // A very bad day //struct datum { float num = 0.0; } void main(){} ./ldc-1.42.0-src/tests/dmd/compilable/test23327.d0000644000175000017500000000022015205374125017744 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23327 // EXTRA_FILES: imports/format23327.d imports/format23327/write.d import imports.format23327; ./ldc-1.42.0-src/tests/dmd/compilable/test18367.sh0000755000175000017500000000060015205374125020150 0ustar fabiofabio#!/usr/bin/env bash # dmd should not segfault on -X with libraries, but no source files out=$(! "$DMD" -conf= -X foo${LIBEXT} 2>&1) echo "$out" | grep 'Error: cannot determine JSON filename, use `-Xf=` or provide a source file' out=$(! "$DMD" -conf= -Xi=compilerInfo 2>&1) echo "$out" | grep 'Error: cannot determine JSON filename, use `-Xf=` or provide a source file' ./ldc-1.42.0-src/tests/dmd/compilable/test17441.d0000644000175000017500000000050515205374125017752 0ustar fabiofabio// EXTRA_FILES: imports/test17441foo/package.d imports/test17441foo/bar.d import m1 = imports.test17441foo.bar; import m2 = imports.test17441foo; alias p = __traits(parent, m1); enum e(alias thing) = thing.stringof; static assert(e!m1 == m1.stringof); static assert(e!m2 == m2.stringof); static assert( e!p == p.stringof ); ./ldc-1.42.0-src/tests/dmd/compilable/test22501.d0000644000175000017500000000040715205374125017744 0ustar fabiofabio// https://github.com/dlang/dmd/issues/22501 struct A { ubyte[16] bytes; enum something = A(cast(ubyte[16])[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]); @nogc nothrow pure bool isB() const { return bytes[0..12] == something.bytes[0..12]; } } ./ldc-1.42.0-src/tests/dmd/compilable/test15464.d0000644000175000017500000000026515205374125017760 0ustar fabiofabioclass C15464 { static immutable field = 0; } struct S15464 { this(int i) { } } void issue15464(T)() @S15464(T.field) { } void main() { issue15464!C15464(); } ./ldc-1.42.0-src/tests/dmd/compilable/test16225.d0000644000175000017500000000027715205374125017757 0ustar fabiofabio// REQUIRED_ARGS: -O -m64 // PERMUTE_ARGS: // https://issues.dlang.org/show_bug.cgi?id=16225 struct C { hash_t foo( ) { int y; return ((cast(ubyte*)&y)[1]); } } ./ldc-1.42.0-src/tests/dmd/compilable/test9554.d0000644000175000017500000000133015205374125017675 0ustar fabiofabio// REQUIRED_ARGS: -o- module pkg.test9554; alias mod = pkg.test9554; template Test(alias name) { enum Test = name; } void fun() {} static assert(fun.stringof == Test!(fun.stringof)); static assert(fun.stringof == "fun()"); static assert(fun.mangleof == Test!(fun.mangleof)); static assert(fun.mangleof == "_D3pkg8test95543funFZv"); static assert(mod.stringof == Test!(mod.stringof)); static assert(mod.stringof == "module test9554"); static assert(mod.mangleof == Test!(mod.mangleof)); static assert(mod.mangleof == "3pkg8test9554"); static assert(pkg.stringof == Test!(pkg.stringof)); static assert(pkg.stringof == "package pkg"); static assert(pkg.mangleof == Test!(pkg.mangleof)); static assert(pkg.mangleof == "3pkg"); ./ldc-1.42.0-src/tests/dmd/compilable/test17468.d0000644000175000017500000000031015205374125017755 0ustar fabiofabio// PERMUTE_ARGS: struct S { const char* path; @disable this(); this(const(char)* path) { this.path = path; } } const S CONST_S = S("/tmp".ptr); ./ldc-1.42.0-src/tests/dmd/compilable/noreturn.c0000644000175000017500000000027015205374125020244 0ustar fabiofabio// Test attribute "noreturn" __attribute__(( noreturn, noreturn )) int foo(); __attribute__(( noreturn )) int bar() { return 3; } int test() { foo(); bar(); return 4; } ./ldc-1.42.0-src/tests/dmd/compilable/shortened_methods.d0000644000175000017500000000232515205374125022112 0ustar fabiofabio// N.B. Shortened methods are no longer under a preview flag class A { int _x = 34; // short syntax works in all contexts @property x() => _x; @property x(int v) => _x = v; // including with contracts @property y() in(true) => _x; // or other auto returns auto foo() @safe => assert(0); // or normal method defintions bool isNull() => this is null; this() {} this(int x) { _x = x; } this(float y) => this(cast(int) y); } class B : A{ // short syntax also overrides the same as long syntax override bool isNull() => this !is null; this(float y) => super(y); } static assert((new A).x == 34); string test() => "hello"; // works at any scope static assert(test() == "hello"); // works normally static assert(is(typeof(&test) == string function())); // same normal type struct S(T) {} void func() { int a; int nested() => a; // and at nested scopes too // Issue 24088 - https://issues.dlang.org/show_bug.cgi?id=24088 S!int f() => S!int(); } struct T { void inc() {} this(this) => inc(); // https://github.com/dlang/dmd/issues/21576 this(int) => inc(); this(byte) { return inc(); } void free() {} ~this() => free(); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc7795.d0000644000175000017500000000051615205374125017641 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc7795; struct TimeValue { this(int hour, int minute, int second = 0, int ms = 0) {} } /// struct DateTime { /// this(int x, TimeValue t = TimeValue(0, 0)) {} } void main() { } ./ldc-1.42.0-src/tests/dmd/compilable/test24560.d0000644000175000017500000000022215205374126017747 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24560 class C { } struct S { static void fun(C heur = new C) { } } void main() { S.fun(); } ./ldc-1.42.0-src/tests/dmd/compilable/test24760.d0000644000175000017500000000022515205374126017754 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24760 long f(int e = 0, uint[] optional...) => optional.length; long f0() => f(); // compiler segfaults ./ldc-1.42.0-src/tests/dmd/compilable/ddoc_markdown_emphasis.d0000644000175000017500000000131015205374126023072 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // TEST_OUTPUT_FILE: extra-files/ddoc_markdown_emphasis.html // OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_emphasis.html /++ Markdown Emphasis: *emphasized text* *emphasized text on more than one line* **strongly emphasized text** *in*seperable ***tricky** emphasis* *more **tricky emphasis*** *tricky**unspaced*** *more**tricky**unspaced* *highly **nested *emphasis* in this** line* $(B *inside a macro*) *$(B outside a macro)* **The following aren't Markdown emphasis:** a * not emphasis* a*"not either"* *nor this * *jumping $(B into a macro*) $(B *jumping) out of a macro* +/ module ddoc_markdown_emphasis; ./ldc-1.42.0-src/tests/dmd/compilable/test23431.d0000644000175000017500000000031315205374126017744 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23431 // REQUIRED_ARGS: -lowmem void test23431() { int a; try { throw new Exception("test1"); a++; } finally { } } ./ldc-1.42.0-src/tests/dmd/compilable/test15578.d0000644000175000017500000000036115205374126017764 0ustar fabiofabio// DISABLED: LDC // broken for dmd, too: https://issues.dlang.org/show_bug.cgi?id=15943 __gshared private: int j; extern(C++, ns) int k; void f() { j = 0; // works as expected k = 0; // Error: variable foo.ns.k is private } ./ldc-1.42.0-src/tests/dmd/compilable/test19936.d0000644000175000017500000000051315205374126017765 0ustar fabiofabio// REQUIRED_ARGS: -de struct Bla { deprecated("bla") int get() { return 5; } alias get this; } void main() { Bla[] blaArray; // ~= should not try to call `.get`, because there's no indication that // `blaArray` has any kind of opAppendAssign related overload in the first place. blaArray ~= Bla(); } ./ldc-1.42.0-src/tests/dmd/compilable/test19557.d0000644000175000017500000000031015205374126017757 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19557 // Error: redundant linkage `extern (C++)` extern(C++, "ns") extern(C++, class) struct test {} extern(C++, class) extern(C++, "ns") struct test2 {} ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_266.d0000644000175000017500000000026415205374126021076 0ustar fabiofabiotemplate Tuple(Stuff ...) { alias Stuff Tuple; } struct S { int i; alias Tuple!i t; void a() { auto x = t; } void b() { auto x = t; } } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc9369.d0000644000175000017500000000035515205374126017642 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_SOURCES: extra-files/ddoc9369.ddoc // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /** Sample: --- a=1; writeln(&a); ! ? --- */ void foo() { } ./ldc-1.42.0-src/tests/dmd/compilable/test17752.d0000644000175000017500000000036615205374126017765 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=17752 // REQUIRED_ARGS: -de void main (string[] args) { switch (args.length) { // initialization not done on purpose is allowed int x = void; default: break; } } ./ldc-1.42.0-src/tests/dmd/compilable/test15371.d0000644000175000017500000000041615205374126017754 0ustar fabiofabio// EXTRA_FILES: imports/test15371.d import imports.test15371; void main() { A a; static assert(__traits(hasMember, A, "a")); static assert(__traits(getOverloads, A, "fun").length == 3); static assert(__traits(compiles, __traits(getMember, a, "a") )); } ./ldc-1.42.0-src/tests/dmd/compilable/test17215.d0000644000175000017500000000017015205374126017750 0ustar fabiofabio// REQUIRED_ARGS: -O version (X86_64): alias vec = __vector(int[4]); vec binop(vec a) { vec b = a; return b; } ./ldc-1.42.0-src/tests/dmd/compilable/betterCarray.d0000644000175000017500000000104115205374126021016 0ustar fabiofabio/* REQUIRED_ARGS: -betterC PERMUTE_ARGS: */ import core.stdc.stdio; extern (C) int main() { printf("hello world\n"); int[3] a; foo(a[], 3); return 0; } int foo(int[] a, int i) { return a[i]; } /**********************************************/ // https://issues.dlang.org/show_bug.cgi?id=19234 void issue19234() { static struct A {} A[10] a; A[10] b; b[] = a[]; } /**********************************************/ // https://issues.dlang.org/show_bug.cgi?id=22922 void issue22922() { int[] x = []; } ./ldc-1.42.0-src/tests/dmd/compilable/isreturnonstack.d0000644000175000017500000000024515205374126021632 0ustar fabiofabio struct S { int[10] a; } int test1(); S test2(); static assert(__traits(isReturnOnStack, test1) == false); static assert(__traits(isReturnOnStack, test2) == true); ./ldc-1.42.0-src/tests/dmd/compilable/test10752.d0000644000175000017500000000025215205374126017750 0ustar fabiofabio// EXTRA_FILES: imports/test10752.d import imports.test10752; void main() { static assert(!__traits(compiles, priv)); static assert(!__traits(compiles, priv)); } ./ldc-1.42.0-src/tests/dmd/compilable/test22421.d0000644000175000017500000000057115205374126017750 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22421 alias AliasSeq(T...) = T; template staticMap(alias fun, args...) { alias staticMap = AliasSeq!(); static foreach(arg; args) staticMap = AliasSeq!(staticMap, fun!arg); } template id(alias what) { enum id = __traits(identifier, what); } enum A { a } static assert(staticMap!(id, A.a) == AliasSeq!("a")); ./ldc-1.42.0-src/tests/dmd/compilable/test23586.d0000644000175000017500000000075115205374126017765 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23586 int test23686a(int x) { switch(x) { case 0: goto Bar; Bar: default: auto y = 6; return y; } } int test23686b(int x) { switch(x) { case 0: Bar: case 1: case 2: auto y = 7; return y; default: goto Bar; } } static assert(test23686a(0) == 6); static assert(test23686b(3) == 7); ./ldc-1.42.0-src/tests/dmd/compilable/issue21328.d0000644000175000017500000000014315205374126020121 0ustar fabiofabio static foreach(i; 1 .. 5) void foo(float[i] arr) { () { float x = arr[0]; } (); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc9037.d0000644000175000017500000000034115205374126017625 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc9037; /** Example: ---- D d = d; ---- ---- D d = d; ---- */ void test9037() { } ./ldc-1.42.0-src/tests/dmd/compilable/test18385b.d0000644000175000017500000000076515205374126020135 0ustar fabiofabio/* Previous implementation raised errors because it was not aware of the special treatment for extern(C) member funtions: Member functions receive D name mangling... Some arguments in favour of this inconsistencies - static => useful for callbacks - non-static => doesn't exists in C anyways */ extern(C) struct ExternC { void foo() {} void foo(int) {} static void bar() {} static void bar(int) {} } #line 100 void main() { ExternC.bar(); ExternC.bar(1); ExternC c; c.foo(); c.foo(1); } ./ldc-1.42.0-src/tests/dmd/compilable/test23068.d0000644000175000017500000000060315205374126017754 0ustar fabiofabio/* DISABLED: osx LDC REQUIRED_ARGS: -vasm -betterC -checkaction=halt TEST_OUTPUT: --- main: 0000: 0F 0B ud2 0002: 31 C0 xor EAX,EAX 0004: C3 ret --- */ // Issue 23068 - [betterC] BetterC does not respect -checkaction=halt // https://issues.dlang.org/show_bug.cgi?id=23068 extern(C) void main() { assert(0); } ./ldc-1.42.0-src/tests/dmd/compilable/test18000.d0000644000175000017500000000033715205374126017746 0ustar fabiofabio// REQUIRED_ARGS: -preview=dip1000 // https://issues.dlang.org/show_bug.cgi?id=18000 struct File { @safe @nogc: ~this() scope { } void* f; } void test() @safe @nogc { scope File x; x = File(); } ./ldc-1.42.0-src/tests/dmd/compilable/backendfloatoptim.d0000644000175000017500000000030515205374126022057 0ustar fabiofabio// REQUIRED_ARGS: -O -inline //https://issues.dlang.org/show_bug.cgi?id=20143 real fun(int x) { return 0.0; } double bug() { // value passed to fun is irrelevant return 0.0 / fun(420); } ./ldc-1.42.0-src/tests/dmd/compilable/test11137.d0000644000175000017500000000011215205374126017741 0ustar fabiofabio// REQUIRED_ARGS: -ofC:\test.exeC:\test.exe module test; void main() { } ./ldc-1.42.0-src/tests/dmd/compilable/test22214.d0000644000175000017500000000032115205374126017741 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22214 struct S { struct T { } } void main() { const S s; static if (__traits(compiles, { auto t = s.T; })) { auto t = s.T; } } ./ldc-1.42.0-src/tests/dmd/compilable/test13193.d0000644000175000017500000000400315205374126017750 0ustar fabiofabio// REQUIRED_ARGS: -O -inline -c final class SharedLib { void getSymbol() {return getSymbolImpl();} void getSymbolImpl() {return getSymbol_();} /* add more intermediate functions to go slower */ void getSymbol_() {} } void test13193() { SharedLib ssllib; void bindFunc() {ssllib.getSymbol();} bindFunc(); /* add more of these to go slower */ bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); /* 10 */ bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); /* 20 */ bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); /* 30 */ bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); /* 40 */ bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); /* 50 */ bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); /* 60 */ bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); /* 70 */ bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); /* 80 */ bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); /* 90 */ bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); bindFunc(); /* 100 */ } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc18361.d0000644000175000017500000000134015205374126017705 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh // REQUIRED_ARGS: -d // Test notes: 'main' is the symbol being documented (DDOC_AUTO_PSYMBOL), // 'arguments' is a parameter (DDOC_AUTO_PARAM), and 'false' is a keyword // (DDOC_AUTO_KEYWORD). /** * The main thing this program does is nothing, and I do _not want to hear any * false arguments about that! * * Macros: * DDOC_AUTO_PSYMBOL = $0 * DDOC_AUTO_KEYWORD = $0 * DDOC_AUTO_PARAM = $0 * DDOC_AUTO_PSYMBOL_SUPPRESS = HALPIMBEINGSUPPRESSED $0 * * DDOC = $(BODY) * DDOC_DECL = $0 * DDOC_MEMBER_HEADER = * DDOC_MODULE_MEMBERS = $0 * DDOC_MEMBER = $0 */ void main(string[] arguments) { } ./ldc-1.42.0-src/tests/dmd/compilable/test22842.c0000644000175000017500000000254315205374126017757 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22842 /*******************************/ typedef int (myfunc)(); myfunc fun; /*******************************/ int town(); typedef int (funky)(); funky town; /*******************************/ typedef int (mudd)(); static mudd ville; int job() { return ville(); } int ville() // inherits "static" from declaration. { return 0; } /*******************************/ typedef int (skyy)(); void high() { skyy asdf; } /*******************************/ void low() { typedef int (down)(); } typedef int down; down dd; int low2() { dd = 1; } /***********************************************************************/ // https://issues.dlang.org/show_bug.cgi?id=22876 int mint1() { int a = 0; // dmd gives 1, other compilers -1 // bug disappears if the parentheses around (a) are removed return - (a) - 1; } _Static_assert(mint1() == -1, "1"); int mint2() { int *a, *b; // Error: incompatible types for `(a) - (cast(char*)b)`: `int*` and `char*` // works if the parentheses around (a) are removed long diff = (char*)(a) - (char*)b; } void mint3() { int *p; // Error: `p` is not of integral type, it is a `int*` // Error: `cast(int*)1` is not of integral type, it is a `int*` // works if parentheses around (p) are removed unsigned x = (unsigned)(p) & 1; } ./ldc-1.42.0-src/tests/dmd/compilable/test21330.d0000644000175000017500000000056215205374126017746 0ustar fabiofabio/* REQUIRED_ARGS: -unittest TEST_OUTPUT: --- AliasSeq!(__unittest_L14_C5_1, __unittest_L14_C5_2) AliasSeq!(__unittest_L14_C5_2) --- */ // https://issues.dlang.org/show_bug.cgi?id=21330 module test21330; mixin template Test() { unittest { } } mixin Test; mixin Test tm; pragma(msg, __traits(getUnitTests, test21330)); pragma(msg, __traits(getUnitTests, tm)); ./ldc-1.42.0-src/tests/dmd/compilable/makedeps_obj.d0000644000175000017500000000100515205374126021012 0ustar fabiofabio/** REQUIRED_ARGS: -makedeps -Jcompilable/extra-files TRANSFORM_OUTPUT: remove_lines(druntime) TEST_OUTPUT: --- $r:.*makedeps_obj_$0.o$?:windows=bj$: \ $p:makedeps_obj.d$ \ $p:makedeps_a.d$ \ $p:makedeps-import-codemixin.txt$ \ $p:makedeps-import.txt$ --- **/ module makedeps_obj; // Test import statement import imports.makedeps_a; // Test mixin import expression enum text = import("makedeps-import-codemixin.txt"); mixin(text); static assert(text2 == "Imported text\x0a"); void func() { a_func(); } ./ldc-1.42.0-src/tests/dmd/compilable/ice9663.d0000644000175000017500000000015615205374126017465 0ustar fabiofabio// REQUIRED_ARGS: -wi void main() { int[1] a; int[] b = [1]; a = 1; b[] = a; b = a; } ./ldc-1.42.0-src/tests/dmd/compilable/test19108.d0000644000175000017500000000025715205374126017761 0ustar fabiofabio// REQUIRED_ARGS: -ignore // https://issues.dlang.org/show_bug.cgi?id=19108 pragma(unknown_global); void main() { pragma(unknown_local); // Error: unrecognized pragma } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc6.d0000644000175000017500000000054415205374126017375 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /** * */ struct MyStruct(T) { static if( true ) { void MyStruct() {} } } void main() { } /+ 23 C:\code\d\bugs>dmd -D -o- 148_1.d 148_1.d(6): Error: static if conditional cannot be at global scope +/ ./ldc-1.42.0-src/tests/dmd/compilable/test23173.d0000644000175000017500000000031415205374126017750 0ustar fabiofabio// REQUIRED_ARGS: -o- // https://issues.dlang.org/show_bug.cgi?id=23173 mixin("long l = ", long.min, ";"); static assert(mixin(long.min) == long.min); static assert(is(typeof(mixin(long.min)) == long)); ./ldc-1.42.0-src/tests/dmd/compilable/test8675.d0000644000175000017500000000030715205374126017704 0ustar fabiofabioclass MyError : Error { this(string msg) { super(msg); } } void foo() nothrow { throw new Error("Some error"); } void bar() nothrow { throw new MyError("Some error"); } ./ldc-1.42.0-src/tests/dmd/compilable/testclidflags.sh0000755000175000017500000000131715205374126021417 0ustar fabiofabio#!/usr/bin/env bash # LDC doesn't print the DFLAGS environment variable as part of -v output # DISABLED: LDC # Windows-WSL: Export DFLAGS s.t. the windows executable sees the required changes export WSLENV="DFLAGS" unset DFLAGS # Force DMD to print the -v menu by passing an invalid object file # It will fail with "no object files to link", but print the log # On OSX DMD terminates with a successful exit code, so `|| true` is used. ( "$DMD" -conf= -v foo.d 2> /dev/null || true) | grep -q "DFLAGS (none)" ( DFLAGS="-O -D" "$DMD" -conf= -v foo.d 2> /dev/null || true) | grep -q "DFLAGS -O -D" ( DFLAGS="-O '-Ifoo bar' -c" "$DMD" -conf= -v foo.d 2> /dev/null || true) | grep -q "DFLAGS -O '-Ifoo bar' -c" ./ldc-1.42.0-src/tests/dmd/compilable/fix21945.d0000644000175000017500000000014015205374126017561 0ustar fabiofabio// REQUIRED_ARGS: -preview=dip1000 void assertEq(scope int[][3] x) @safe { bool b = x == x; } ./ldc-1.42.0-src/tests/dmd/compilable/test19227.d0000644000175000017500000000106615205374126017762 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19227 // REQUIRED_ARGS: -verrors=simple /* TEST_OUTPUT: --- compilable/test19227.d(17): Deprecation: use of complex type `cfloat` is deprecated, use `std.complex.Complex!(float)` instead Deprecation: use of complex type `const(cfloat)` is deprecated, use `std.complex.Complex!(float)` instead --- */ struct S { float f; } struct T { cfloat cf; } void main() { static assert(S.init is S.init); static assert(S.init != S.init); static assert(T.init is T.init); static assert(T.init != T.init); } ./ldc-1.42.0-src/tests/dmd/compilable/test19014.d0000644000175000017500000000033115205374126017746 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19014 import core.stdc.config; void main() { if (true) { static import core.stdc.math; } static assert(!__traits(compiles, core.stdc.math.cos(0))); } ./ldc-1.42.0-src/tests/dmd/compilable/test20789.d0000644000175000017500000000164715205374126017774 0ustar fabiofabio// REQUIRED_ARGS: -de module compilable.test20789; struct S(bool deprecateFunction, bool deprecateAlias) { static if (deprecateFunction) deprecated string get() { return "foo"; } else string get() { return "foo"; } static if (deprecateAlias) deprecated alias get this; else alias get this; } void main() { void normalFun() { static assert( is(S!(false, false) : string)); static assert(!is(S!(false, true ) : string)); static assert(!is(S!(true , false) : string)); static assert(!is(S!(true , true ) : string)); } deprecated void deprecatedFun() { // deprecations are allowed in a deprecated scope. static assert(is(S!(false, false) : string)); static assert(is(S!(false, true ) : string)); static assert(is(S!(true , false) : string)); static assert(is(S!(true , true ) : string)); } } ./ldc-1.42.0-src/tests/dmd/compilable/test19804.d0000644000175000017500000000022015205374126017752 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19804 struct A { float e; } void foo(A[1] a) { void bar(A[1] a) { a[] = null; } bar(a); } ./ldc-1.42.0-src/tests/dmd/compilable/test19292.d0000644000175000017500000000035315205374126017762 0ustar fabiofabio// 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); } ./ldc-1.42.0-src/tests/dmd/compilable/test23380.d0000644000175000017500000000035715205374126017757 0ustar fabiofabio// REQUIRED_ARGS: -preview=dip1000 // https://issues.dlang.org/show_bug.cgi?id=23380 // Issue 23380 - [dip1000] class parameter should not be treated as ref qua lifetime @safe void test(scope Object o0, scope Object o1) { o1 = o0; } ./ldc-1.42.0-src/tests/dmd/compilable/test20181.d0000644000175000017500000000024115205374126017743 0ustar fabiofabiomodule test20181; struct InversionList { ubyte[] byCodepoint() { return null; } } void main() { static foreach (ch; InversionList().byCodepoint) { } } ./ldc-1.42.0-src/tests/dmd/compilable/test24594.c0000644000175000017500000000102415205374126017756 0ustar fabiofabio#include struct S1 { uint32_t a; uint64_t b; } __attribute__((packed)); _Static_assert(sizeof(S1) == 12, "S1 size"); _Static_assert(&((struct S1*)0)->b == 4, "S1::b offset"); struct __attribute__((packed)) S2 { uint8_t a; uint16_t b; }; _Static_assert(sizeof(S2) == 3, "S2 size"); _Static_assert(&((struct S2*)0)->b == 1, "S2::b offset"); struct __attribute__((packed)) S3 { uint32_t a; uint8_t b; }; _Static_assert(sizeof(S3) == 5, "S3 size"); _Static_assert(&((struct S3*)0)->b == 4, "S3::b offset"); ./ldc-1.42.0-src/tests/dmd/compilable/scope.d0000644000175000017500000001327515205374126017514 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1000 */ struct Cache { ubyte[1] v; ubyte[] set(ubyte[1] v) return { return this.v[] = v[]; } } /*********************************/ // https://github.com/dlang/dmd/pull/9220 @safe: struct OnlyResult { private this(Values)(scope ref Values values) { this.s = values; } string s; } auto only(Values)(Values vv) { return OnlyResult(vv); } void test() @nogc @safe pure { only(null); } /************************************/ // https://github.com/dlang/dmd/pull/9220 auto callWrappedOops(scope string dArgs) { string callWrappedImpl() { return dArgs; } } /************************************/ struct Constant { int* member; this(Repeat!(int*) grid) @safe { foreach(ref x; grid) member = x; foreach(ref x; grid) x = member; } int* foo(return scope Repeat!(int*) grid) @safe { foreach(ref x; grid) x = member; foreach(ref x; grid) return x; return null; } alias Repeat(T...) = T; } /************************************/ // https://issues.dlang.org/show_bug.cgi?id=19387 struct C { void* u; this(this) @safe { } } struct S { C c; } void foo(scope S s) @safe { } void bar(scope S s) @safe { foo(s); } /************************************/ // https://issues.dlang.org/show_bug.cgi?id=20675 struct D { int pos; char* p; } void test(scope ref D d) @safe { D[] da; da ~= D(d.pos, null); } /************************************/ void withEscapes() { static D get() @safe; with (get()) { } } /************************************/ // https://issues.dlang.org/show_bug.cgi?id=20682 int f1_20682(return scope ref D d) @safe { return d.pos; } ref int f2_20682(return ref scope D d) @safe { return d.pos; } void test_20682(scope ref D d) @safe { int[] a; a ~= f1_20682(d); a ~= f2_20682(d); a ~= cast(int) d.p; } // Phobos failure void formattedWrite(immutable char[2] args) @safe { scope immutable char[] val = args; } void ctfeRead(const ubyte[2] array) @safe { short result; foreach_reverse (b; array) result = cast(short) ((result << 8) | b); foreach (b; array) result = cast(short) ((result << 8) | b); } void demangle() @safe { static struct DotSplitter { const(char)[] s; @safe: @property bool empty() const { return !s.length; } @property const(char)[] front() const return { immutable i = indexOfDot(); return s; } void popFront() {} private ptrdiff_t indexOfDot() const { return -1; } } foreach (comp; DotSplitter("")) { const copy = comp; } } void fileCtor() @safe { static struct S { int i; } // static S get() // { // return S(); // } with (S()) { int* ptr = &i; } } // Missing test coverage int*[4] testArray() @safe { return typeof(return).init; } /************************************/ // https://issues.dlang.org/show_bug.cgi?id=21209 void testForeach(T)(const(T)[] ts) { static int g; g++; // force impure for https://issues.dlang.org/show_bug.cgi?id=20150 foreach (c; ts) { } foreach_reverse(c0; ts) { foreach(c1; ts) { } } } @safe void main21209() { char[10] cs; float[10] fs; testForeach(cs); testForeach(fs); } struct S23669 { string[] a; @safe void reserve() scope { a.length += 1; } } /************************************/ // Calling `hasPointers` in escape.d at some point caused // a "circular `typeof` definition" error in std.typecons // https://github.com/dlang/dmd/pull/16719 struct Unique { int* p; alias ValueType = typeof({ return p; } ()); static if (is(ValueType == int*)) {} } // Without handling tuple expansion in escape.d, this error occurs: // Error: returning `(ref Tuple!(int, int) __tup2 = this.tuple.get();) , &__tup2.__expand_field_0` escapes a reference to local variable `__tup2` struct Tuple(Types...) { Types expand; ref Tuple!Types get() { return this; } } struct S2 { Tuple!(int, int) tuple; int* f() return { return &tuple.get().expand[0]; } } /************************************/ // https://issues.dlang.org/show_bug.cgi?id=23300 auto array(Range)(Range r) { int[] result; foreach (e; r) result ~= e; return result; } struct Range { int* ptr; int front = 3; enum empty = true; void popFront() @safe scope {} } auto f() @safe { scope Range r; return r.array; } /************************************/ // Test that there's no endless loop forwarding `__appendtmp1 => __appendtmp1.this(null)` struct SD { int* p; this(int*) return scope {} } auto fsd() @safe { SD[] a; a ~= SD(null); } /************************************/ // Test that `return scope` inference from assignment doesn't force the function to be `scope` struct Scape { int* p; this()(int* input) { p = input; // return scope inferred here notScope(); // not-scope inferred here } void notScope() @safe { static int* g; g = p; } } @safe testScape() { Scape(null); } /************************************/ // Test `scope` inference in presence of nested function returning `this`: // `save()` can still be called on a `scope Result` struct Result { int* source; auto save() { int* saveI() { return this.source; } auto saveResult = Result(saveI()); } } @safe escapeNested() { int s; auto r = Result(&s); r.save(); } ./ldc-1.42.0-src/tests/dmd/compilable/test10993.d0000644000175000017500000000124615205374126017763 0ustar fabiofabiomodule test10993; import core.demangle : demangleType; auto foo(T)(T a) { static immutable typeof(a) q; // pragma(msg, "foo: " ~ typeof(q).mangleof); return q; } struct test(alias fn) { bool ini = true; void* p; } auto fun() { auto x = foo!()(test!(a=>a)()); // pragma(msg, "fun: " ~ typeof(x).mangleof); return x; } void main() { const x = fun(); enum mangle_x = typeof(x).mangleof; // pragma(msg, "x : " ~ mangle_x); auto y = cast()x; enum mangle_y = typeof(y).mangleof; // pragma(msg, "y : " ~ mangle_y); enum demangle_x = demangleType(mangle_x); enum demangle_y = demangleType(mangle_y); static assert ("immutable(" ~ demangle_y ~ ")" == demangle_x); } ./ldc-1.42.0-src/tests/dmd/compilable/issue24316.d0000644000175000017500000000020315205374126020116 0ustar fabiofabiostruct S { int i; } int f(immutable S *s) { return s.i; } immutable S globalS = S(5); static assert (f(&globalS) == 5); ./ldc-1.42.0-src/tests/dmd/compilable/minimal.d0000644000175000017500000000064415205374126020025 0ustar fabiofabio// DFLAGS: // PERMUTE_ARGS: // POST_SCRIPT: compilable/extra-files/minimal/verify_symbols.sh // REQUIRED_ARGS: -defaultlib= // EXTRA_SOURCES: extra-files/minimal/object.d // This test ensures an empty main with a struct and enum, built with a minimal // runtime, does not generate ModuleInfo or exception handling code, and does not // require TypeInfo struct S { } enum E { e0 = 0, e1 = 1 } void main() { } ./ldc-1.42.0-src/tests/dmd/compilable/test22699.c0000644000175000017500000000020015205374126017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22699 int foo(int x, int y) { for (; x = y;) return (x = y) ? x : y; } ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_1723.d0000644000175000017500000000065015205374126021154 0ustar fabiofabiointerface IBase {} class Impl(T): IBase { T value; } void main() { IBase x = new Impl!uint; IBase y = new Impl!string; IBase z = new Impl!double; IBase[string] fldFormats1 = [ "Key": x, "Name": y, "Percent": z ]; IBase[string] fldFormats2 = cast(IBase[string])[ "Key": new Impl!uint, "Name": new Impl!string, "Percent": new Impl!double ]; } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc15475.d0000644000175000017500000000074315205374126017716 0ustar fabiofabio/* PERMUTE_ARGS: REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh */ /** My module ---- // Computes the interval [x,y) auto interval = computeInterval(x, y); ---- Backslash-escape parentheses with `\(` and `\)`. --- ( --- --- ) --- --- Here are some nested `backticks` // Another interval [x,y) --- --- This won't end the code block: --- ) // Yet another interval [x,y) --- */ module ddoc15475; ./ldc-1.42.0-src/tests/dmd/compilable/test22632.d0000644000175000017500000000017115205374126017750 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22632 static assert(["one": 1] != null); static assert(null != ["one": 1]); ./ldc-1.42.0-src/tests/dmd/compilable/exception.d0000644000175000017500000000033715205374126020374 0ustar fabiofabioclass E2 : Exception { this() { super(null); } } class E3 : Exception { this() { super(null); } } void main() { try { } catch (E3) { } catch (E2) { } catch (Exception) { } } ./ldc-1.42.0-src/tests/dmd/compilable/test21282.d0000644000175000017500000000034515205374126017753 0ustar fabiofabio/* TEST_OUTPUT: --- AliasSeq!(func) --- */ // https://issues.dlang.org/show_bug.cgi?id=21282 template I(T...) { alias I = T; } template Bug(T...) { alias Bug = mixin("I!(T[0])"); } void func() {} pragma(msg, Bug!func); ./ldc-1.42.0-src/tests/dmd/compilable/deprecationlimit.d0000644000175000017500000000103315205374126021724 0ustar fabiofabio/* REQUIRED_ARGS: -verrors=simple -verrors=3 TEST_OUTPUT: --- compilable/deprecationlimit.d(18): Deprecation: function `deprecationlimit.f` is deprecated compilable/deprecationlimit.d(19): Deprecation: function `deprecationlimit.f` is deprecated compilable/deprecationlimit.d(20): Deprecation: function `deprecationlimit.f` is deprecated 1 deprecation warning omitted, use `-verrors=0` to show all --- */ deprecated void f() { } void main() { f(); f(); f(); static assert("1"); // also surpress deprecationSupplemental } ./ldc-1.42.0-src/tests/dmd/compilable/warn12809.d0000644000175000017500000000303415205374126017746 0ustar fabiofabio// REQUIRED_ARGS: -o- -w /* Warning removed in: https://github.com/dlang/dmd/pull/15568 --- fail_compilation/warn12809.d(25): Warning: statement is not reachable fail_compilation/warn12809.d(33): Warning: statement is not reachable --- */ //void test_unrachable1() //{ // try assert(0); // finally // { // int x = 1; // unreachable // } //} void test_unrachable2() { try assert(0); finally {} int x = 1; // unreachable } void test_unrachable3() { try {} finally assert(0); int x = 1; // unreachable } /********************************************/ /* --- 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; } // https://issues.dlang.org/show_bug.cgi?id=14835 bool isEven(int i)() { static if (i % 2) return true; return false; } enum x = isEven!0; // https://issues.dlang.org/show_bug.cgi?id=10532 alias Seq(T...) = T; void f() { foreach (e; Seq!(10, 20)) { if (e == 10) continue; // lots of code follows.. auto x = 1; } } ./ldc-1.42.0-src/tests/dmd/compilable/test313g.d0000644000175000017500000000064315205374126017753 0ustar fabiofabio// REQUIRED_ARGS: -de // COMPILED_IMPORTS: imports/g313.d // EXTRA_FILES: imports/g313public.d imports/g313staticif.d imports/g313stringmixin.d imports/g313templatemixin.d import imports.g313; void test15900() { // publically imported modules from g313 should be available here imports.g313public.bug(); imports.g313staticif.bug(); imports.g313stringmixin.bug(); imports.g313templatemixin.bug(); } ./ldc-1.42.0-src/tests/dmd/compilable/test8802.d0000644000175000017500000000053115205374126017673 0ustar fabiofabio// PERMUTE_ARGS: enum A : typeof(null)* { a = null } enum B : typeof(null)** { a = null } enum C : void* { a = null } enum D : void** { a = null } enum NullEn : void* { z = null } enum E : NullEn { a = null } void main() { auto a = A.a; auto b = B.a; auto c = C.a; auto d = D.a; auto e = E.a; } ./ldc-1.42.0-src/tests/dmd/compilable/test19954.d0000644000175000017500000000033115205374126017763 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19954 template AliasSeq(TList...) { alias AliasSeq = TList; } void fun(string[]){} void main() { fun(cast(string[])AliasSeq!""); auto a = cast(char[][])""; } ./ldc-1.42.0-src/tests/dmd/compilable/test16183.d0000644000175000017500000000023015205374126017750 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16183 void main() { const string g(const string s) { return s; } enum string y = ['f'] ~ g("g"); } ./ldc-1.42.0-src/tests/dmd/compilable/nested_struct_20499.c0000644000175000017500000000254015205374126022030 0ustar fabiofabio// https://github.com/dlang/dmd/issues/20499 struct Outer { struct __attribute__((aligned(8))) { int x; } n; enum {A}; enum {B} b; }; struct Outer2 { struct __attribute__((aligned(8))) Nested { int x; } n; }; const int x = A; const int y = B; struct Outer o = {3}; _Static_assert(_Alignof(typeof(o.n)) == 8, ""); _Static_assert(_Alignof(struct Outer) == 8, ""); _Static_assert(_Alignof(struct Outer2) == 8, ""); _Static_assert(_Alignof(struct Nested) == 8, ""); void test(void){ struct Outer { struct __attribute__((aligned(16))) { int x; } n; enum {A=2}; enum {B=3} b; }; struct Outer2 { struct __attribute__((aligned(16))) Nested { int x; } n; }; const int x = A; const int y = B; struct Outer o = {3}; _Static_assert(_Alignof(typeof(o.n)) == 16, ""); _Static_assert(_Alignof(struct Outer) == 16, ""); _Static_assert(_Alignof(struct Outer2) == 16, ""); _Static_assert(_Alignof(struct Nested) == 16, ""); } void test2(void){ const int x = A; const int y = B; struct Outer o = {3}; _Static_assert(_Alignof(typeof(o.n)) == 8, ""); _Static_assert(_Alignof(struct Outer) == 8, ""); _Static_assert(_Alignof(struct Outer2) == 8, ""); _Static_assert(_Alignof(struct Nested) == 8, ""); } ./ldc-1.42.0-src/tests/dmd/compilable/test22607.c0000644000175000017500000000016515205374126017754 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22607 float x = 0.f + 0.F + 0.l + 0.L; float y = 1.f + 2.F + 3.l + 4.L; ./ldc-1.42.0-src/tests/dmd/compilable/test21196.d0000644000175000017500000000204115205374126017752 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21674 // REQUIRED_ARGS: -de struct Module { CachedString data; } struct CachedString { private size_t len; this (string data) { this.len = data.length; } public string str () const { return null; } public void str (string value) { this.len = value.length; } alias str this; } void test21674a() { Module m; m.data = "Hello World"; } ////////////////////////////////////////// struct StaticGetter(T) { private static T _impl; static ref T value() { return _impl; } alias value this; } struct StaticWrapper { StaticGetter!int get; alias get this; } void test21674b() { StaticGetter!float sg; sg = 4.2; StaticWrapper sw; sw = 42; } ////////////////////////////////////////// EntryType arr; auto getPtr() { return &arr; } struct EntryType { bool _state; alias _state this; } struct S19441 { @property auto ref entry() { return *getPtr(); } alias entry this; } void test19441() { S19441 s19441; s19441 = true; } ./ldc-1.42.0-src/tests/dmd/compilable/covariant_override.d0000644000175000017500000000103115205374126022253 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21538 // REQUIRED_ARGS: -preview=dip1000 interface I { void f(void delegate() @safe dg) @safe; } class CI : I { override void f(void delegate() @system dg) @safe { } } abstract class A { void f(void delegate() @safe dg) @safe; } class CA : A { override void f(void delegate() @system dg) @safe { } } // https://issues.dlang.org/show_bug.cgi?id=20904 auto blah(void delegate()) { } void delegate()[string] r; void main() { void delegate() nothrow a; r["v"] = a; } ./ldc-1.42.0-src/tests/dmd/compilable/test8631.d0000644000175000017500000000043015205374126017671 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -de class B { int foo() immutable { return 2; } int foo() const { return 2; } } class D : B { override int foo() immutable { return 2; } int foo() const shared { return 2; } override int foo() const { return 2; } } ./ldc-1.42.0-src/tests/dmd/compilable/test10312.d0000644000175000017500000000026015205374126017737 0ustar fabiofabio static if (__traits(compiles, __vector(float[4]))) { const __vector(float[4]) si = [1f, 1f, 1f, 1f]; void main() { auto arr = si; return; } } ./ldc-1.42.0-src/tests/dmd/compilable/test16798.d0000644000175000017500000000043315205374126017771 0ustar fabiofabio/* REQUIRED_ARGS: -mv=its.a.dessert.topping=imports/imp16798.d -mv=its.a.floorwax=imports/ EXTRA_FILES: imports/imp16798.d imports/wax16798.d PERMUTE_ARGS: TEST_OUTPUT: --- it's a floor wax it's a dessert topping --- */ import its.a.floorwax.wax16798; import its.a.dessert.topping; ./ldc-1.42.0-src/tests/dmd/compilable/test10375.d0000644000175000017500000000042215205374126017750 0ustar fabiofabio// REQUIRED_ARGS: -o- // EXTRA_FILES: imports/test10375a.d import imports.test10375a; void packIt(Pack)(Pack p){ } //3 void main() { alias p = packIt!(int); p(2); // OK <- NG packIt(2); // OK <- NG packIt!(int)(2); // OK <- NG } ./ldc-1.42.0-src/tests/dmd/compilable/test22480.d0000644000175000017500000000014415205374126017751 0ustar fabiofabioimport imports.test22480b; @nogc nothrow: enum a = parseAA(); extern(C) int main() { return 0; } ./ldc-1.42.0-src/tests/dmd/compilable/debugInference.d0000644000175000017500000000137015205374126021301 0ustar fabiofabio/* REQUIRED_ARGS: -debug https://issues.dlang.org/show_bug.cgi?id=20507 */ void main() pure nothrow @safe @nogc { debug foo(); bar!()(); } void foo() @system { // Just to be sure its neither @nogc, pure or nothrow __gshared int counter = 0; if (counter++) throw new Exception(new immutable(char)[counter]); } void bar()() { debug { foo(); auto fPtr = &S.f; auto f2Ptr = &f2; S s; destroy(s); int* ptr = cast(int*) 0; int[] slice = ptr[0 .. 4]; int val = ptr[1]; void[] bytes = slice; bytes[] = bytes[]; scope int n; int* pn = &n; } } class S { void f() @safe {} } ref int f2(return ref int i) { return i; } ./ldc-1.42.0-src/tests/dmd/compilable/test22410.d0000644000175000017500000000300115205374126017735 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22410 alias A(T...) = T; void fun0(const A!(int, string) x = A!(1, "asdf")) { static assert(is(typeof(x) == A!(const int, const string))); } void fun1(const A!(immutable int, string) x = A!(1, "asdf")) { static assert(is(typeof(x) == A!(immutable int, const string))); } void fun2(shared A!(int, string) x = A!(1, "asdf")) { static assert(is(typeof(x) == A!(shared int, shared string))); } void fun3(shared const A!(int, string) x = A!(1, "asdf")) { static assert(is(typeof(x) == A!(shared const int, shared const string))); } void fun4(inout A!(int, const string) x = A!(1, "asdf")) { static assert(is(typeof(x) == A!(inout int, inout const string))); } void fun5(ref const A!(int, string) x = A!(1, "asdf")) { static assert(is(typeof(x) == A!(const int, const string))); static assert(__traits(isRef, x[0]) && __traits(isRef, x[1])); } // Implicitly conversion is also fixed, for example: // from (ulong, double) to (int, float) // Integral narrowing here, ulong(uint.max + 1UL) would fail. void fun10(A!(uint, float) x = A!(ulong(uint.max), 3.14)) { static assert(is(typeof(x) == A!(uint, float))); } void fun11(A!(int, double) x = A!(byte(1), 2.5f)) { static assert(is(typeof(x) == A!(int, double))); } void fun12(A!(byte, float) x = A!(1, 'a')) { static assert(is(typeof(x) == A!(byte, float))); } A!(const int, shared char) tup = A!(1, 'a'); void fun13(A!(byte, float) x = tup) { static assert(is(typeof(x) == A!(byte, float))); } ./ldc-1.42.0-src/tests/dmd/compilable/test19376.sh0000755000175000017500000000016115205374126020154 0ustar fabiofabio#!/usr/bin/env bash $DMD -c -of${OUTPUT_BASE} ${EXTRA_FILES}/test19376.di ! ls ${OUTPUT_BASE}/test19376.${OBJ} ./ldc-1.42.0-src/tests/dmd/compilable/test22739.d0000644000175000017500000000017515205374126017764 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22739 extern(C++) auto f(T)() { return T.init; } void main() { f!int; } ./ldc-1.42.0-src/tests/dmd/compilable/test1170.d0000644000175000017500000000053715205374126017670 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=1170 type x; mixin("alias int type;"); // https://issues.dlang.org/show_bug.cgi?id=10739 template DECLARE_HANDLE() { struct HINTERNET { int h; } } const INTERNET_INVALID_STATUS_CALLBACK = cast(INTERNET_STATUS_CALLBACK) -1; mixin DECLARE_HANDLE; alias void function(HINTERNET) INTERNET_STATUS_CALLBACK; ./ldc-1.42.0-src/tests/dmd/compilable/sw_transition_tls.d0000644000175000017500000000034615205374126022163 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -transition=tls /* TEST_OUTPUT: --- compilable/sw_transition_tls.d(11): `x` is thread local compilable/sw_transition_tls.d(15): `y` is thread local --- */ int x; struct S { static int y; } ./ldc-1.42.0-src/tests/dmd/compilable/test23935.i0000644000175000017500000000042115205374126017762 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23935 typedef struct __declspec(align(16)) __pragma(warning(push)) __pragma(warning(disable:4845)) __declspec(no_init_all) __pragma(warning(pop)) _CONTEXT { int i; } _CONTEXT; ./ldc-1.42.0-src/tests/dmd/compilable/test13281.d0000644000175000017500000000322515205374126017753 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: /* TEST_OUTPUT: --- 123 123u 123L 123LU 123.5 123.5F 123.5L 123.5i 123.5Fi 123.5Li (123.5+5.5i) (123.5F+5.5Fi) (123.5L+5.5Li) --- */ pragma(msg, 123); pragma(msg, 123u); pragma(msg, 123L); pragma(msg, 123uL); pragma(msg, 123.5); pragma(msg, 123.5f); pragma(msg, 123.5L); pragma(msg, 123.5i); pragma(msg, 123.5fi); pragma(msg, 123.5Li); pragma(msg, 123.5 +5.5i); pragma(msg, 123.5f+5.5fi); pragma(msg, 123.5L+5.5Li); static assert((123 ).stringof == "123"); static assert((123u ).stringof == "123u"); static assert((123L ).stringof == "123L"); static assert((123uL).stringof == "123LU"); version (GNU) { static assert((123.5 ).stringof == "1.235e+2"); static assert((123.5f ).stringof == "1.235e+2F"); static assert((123.5L ).stringof == "1.235e+2L"); static assert((123.5i ).stringof == "1.235e+2i"); static assert((123.5fi).stringof == "1.235e+2Fi"); static assert((123.5Li).stringof == "1.235e+2Li"); static assert((123.5 +5.5i ).stringof == "1.235e+2 + 5.5e+0i"); static assert((123.5f+5.5fi).stringof == "1.235e+2F + 5.5e+0Fi"); static assert((123.5L+5.5Li).stringof == "1.235e+2L + 5.5e+0Li"); } else { static assert((123.5 ).stringof == "123.5"); static assert((123.5f ).stringof == "123.5F"); static assert((123.5L ).stringof == "123.5L"); static assert((123.5i ).stringof == "123.5i"); static assert((123.5fi).stringof == "123.5Fi"); static assert((123.5Li).stringof == "123.5Li"); static assert((123.5 +5.5i ).stringof == "123.5 + 5.5i"); static assert((123.5f+5.5fi).stringof == "123.5F + 5.5Fi"); static assert((123.5L+5.5Li).stringof == "123.5L + 5.5Li"); } ./ldc-1.42.0-src/tests/dmd/compilable/test20537.d0000644000175000017500000000055715205374126017762 0ustar fabiofabio// 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)); ./ldc-1.42.0-src/tests/dmd/compilable/test22875.i0000644000175000017500000000067315205374126017775 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22875 typedef union value_u { void *p; } value_t; typedef struct data_s { void *p; } data_t; void fn() { value_t a; const value_t b; // Error: cannot implicitly convert expression `b` of type `const(value_u)` to `value_u` a = b; data_t aa; const data_t bb; // Error: cannot implicitly convert expression `bb` of type `const(data_s)` to `data_s` aa = bb; } ./ldc-1.42.0-src/tests/dmd/compilable/ddocYear.d0000644000175000017500000000023415205374126020124 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocYear-postscript.sh /// $(YEAR) int year; ./ldc-1.42.0-src/tests/dmd/compilable/test24022.d0000644000175000017500000000111315205374126017740 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24022 // EXTRA_FILES: imports/imp24022.c import imports.imp24022; auto some_d_func(E v) { return v; } auto some_d_other_func() { const struct R { E r; this(in E vparam) { r = vparam; } } return R(A); } void main(string[] args) { E expected = E.A; E res = some_d_func(A); assert (res == A); assert (res == expected); res = some_d_func(E.B); assert (res == B); assert (res == E.B); auto res2 = some_d_other_func(); assert (res2.r == A); assert (res2.r == expected); } ./ldc-1.42.0-src/tests/dmd/compilable/test22626.d0000644000175000017500000000147115205374126017757 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22626 // REQUIRED_ARGS: -preview=nosharedaccess shared int k; class Oops { shared int a; shared int* pa; synchronized void oops() { // this should compile since the function is synchronized // and `a` is accessed through `this`. a = 2; // this shouldn't compile because synchronized guards // only accesses to the first level of dereferencing static assert (!__traits(compiles, *pa = 2)); // this shouldn't compile `k` is a field of class `Oops` static assert (!__traits(compiles, k = 2)); } // https://issues.dlang.org/show_bug.cgi?id=24705 synchronized void foo(int n) { // Error: direct access to shared `n` is not allowed, see `core.atomic` int a = n; } } ./ldc-1.42.0-src/tests/dmd/compilable/version.d0000644000175000017500000000030415205374126020055 0ustar fabiofabio/* REQUIRED_ARGS: */ version (D_ModuleInfo) { } else { static assert(0); } version (D_Exceptions) { } else { static assert(0); } version (D_TypeInfo) { } else { static assert(0); } ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_247.d0000644000175000017500000000007415205374126021074 0ustar fabiofabioimport imports.ldc_github_247a; class A { Value!double v; } ./ldc-1.42.0-src/tests/dmd/compilable/objc_gfunc.d0000644000175000017500000000007315205374126020472 0ustar fabiofabio// EXTRA_OBJC_SOURCES: extern (Objective-C) void NSLog(); ./ldc-1.42.0-src/tests/dmd/compilable/test70.d0000644000175000017500000000021715205374126017521 0ustar fabiofabio// EXTRA_FILES: imports/test70.d import imports.test70 : foo; void foo(int) // overloads with selective import { } void bar() { foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/test21812.d0000644000175000017500000000026715205374126017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21812 struct S(A...) { A args; } static assert(__traits(allMembers, S!(int, float)) == AliasSeq!("args")); alias AliasSeq(T...) = T; ./ldc-1.42.0-src/tests/dmd/compilable/test22904.c0000644000175000017500000000051715205374126017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22904 int fn1() { return 0; } void fn2() { long x = (long) (fn1) (); } // https://issues.dlang.org/show_bug.cgi?id=22912 typedef long my_long; void fn3() { long x = (my_long) (fn1) (); } // https://issues.dlang.org/show_bug.cgi?id=22913 void fn4() { int a[1]; int b = (a[0]); } ./ldc-1.42.0-src/tests/dmd/compilable/test20318.d0000644000175000017500000000027515205374126017754 0ustar fabiofabio// DISABLED: LDC // no support for -profile=gc yet // https://issues.dlang.org/show_bug.cgi?id=20318 // REQUIRED_ARGS: -dip1008 -profile=gc void main() { throw new Exception("msg"); } ./ldc-1.42.0-src/tests/dmd/compilable/test19873.d0000644000175000017500000000071315205374126017767 0ustar fabiofabio// PERMUTE_ARGS: -preview=dip1000 // https://issues.dlang.org/show_bug.cgi?id=19873 int* ed(scope int* x) { auto y = x; return y; } int* et(scope int* x) @trusted { auto y = x; return y; } int* es(scope int* x) @system { auto y = x; return y; } auto ad(scope int* x) { auto y = x; return y; } auto at(scope int* x) @trusted { auto y = x; return y; } auto as(scope int* x) @system { auto y = x; return y; } ./ldc-1.42.0-src/tests/dmd/compilable/test17991.d0000644000175000017500000000024715205374126017770 0ustar fabiofabio// 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; ./ldc-1.42.0-src/tests/dmd/compilable/test13242.d0000644000175000017500000000112615205374126017746 0ustar fabiofabio// REQUIRED_ARGS: -o- // EXTRA_FILES: imports/test13242a.d imports/test13242b.d /* TEST_OUTPUT: --- main +alias apiSym1 a.expensiveArgs: 1 a.expensiveTemplate: 1 -alias apiSym1 +alias apiSym3 b.expensiveArgs: 3 b.expensiveTemplate: 3 -alias apiSym3 --- */ import imports.test13242a; void main() { pragma(msg, "main"); cheapFunc(); pragma(msg, "+alias apiSym1"); alias apiSym1 = .apiSym1; pragma(msg, "-alias apiSym1"); // imports.test13242a.apiSym2 is not analyzed. pragma(msg, "+alias apiSym3"); alias apiSym3 = .apiSym3; pragma(msg, "-alias apiSym3"); } ./ldc-1.42.0-src/tests/dmd/compilable/b20833.d0000644000175000017500000000120615205374126017213 0ustar fabiofabiostruct A { void foo(T)(T t) {} void foo(long l) {} void bar(long l) {} void bar(T)(T t) {} } static assert(__traits(getOverloads, A, "foo").length == 1); static assert(__traits(getOverloads, A.init, "foo").length == 1); static assert(__traits(getOverloads, A, "foo", true).length == 2); static assert(__traits(getOverloads, A.init, "foo", true).length == 2); static assert(__traits(getOverloads, A, "bar").length == 1); static assert(__traits(getOverloads, A.init, "bar").length == 1); static assert(__traits(getOverloads, A, "bar", true).length == 2); static assert(__traits(getOverloads, A.init, "bar", true).length == 2); ./ldc-1.42.0-src/tests/dmd/compilable/test22698.c0000644000175000017500000000036615205374126017771 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22698 struct S { struct T { int x; }; }; struct T t; /*******/ struct Bar { struct Foo { int x; } f; }; struct Foo f = {3}; /*******/ struct Amy { int x; } *p; struct Amy b; ./ldc-1.42.0-src/tests/dmd/compilable/test22927.c0000644000175000017500000000017415205374126017761 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22927 struct block *tmp; struct block {}; void block(void); void block(void){} ./ldc-1.42.0-src/tests/dmd/compilable/diag11066.d0000644000175000017500000000017215205374126017675 0ustar fabiofabio// REQUIRED_ARGS: -w -profile void main() { string s; foreach (dchar c; s) // affected by dchar return; } ./ldc-1.42.0-src/tests/dmd/compilable/testdefines.d0000644000175000017500000000222715205374126020713 0ustar fabiofabio// EXTRA_FILES: imports/defines.c import imports.defines; static assert(CC == 'c'); static assert(I32 == 3); static assert(U32 == 4); static assert(I64 == 5); static assert(U64 == 6); static assert(F32 == 7.0f); static assert(F64 == 8.0); static assert(F80 == 9.0L); static assert(SSS == "hello"); static assert(ABC == 12); static assert(DEF == 17); static assert(ADD(3, 4) == 7); static assert(SUB() == 1); static assert(pr16199_skipped1(5) == 1); static assert(pr16199_skipped2(6) == 2); static assert(pr16199_ice == 3); static assert(pr16199d() == 7); static assert(pr16199c() == 8); // https://issues.dlang.org/show_bug.cgi?id=24639 static assert(NEGATIVE_I32 == -1); static assert(NEGATIVE_U32 == cast(uint)-2); static assert(NEGATIVE_I64 == -3); static assert(NEGATIVE_U64 == cast(ulong)-4L); static assert(NEGATIVE_F32 == -5f); static assert(NEGATIVE_F64 == -6); static assert(is(typeof(NEGATIVE_I32) == int)); static assert(is(typeof(NEGATIVE_U32) == uint)); static assert(is(typeof(NEGATIVE_I64) == long)); static assert(is(typeof(NEGATIVE_U64) == ulong)); static assert(is(typeof(NEGATIVE_F32) == float)); static assert(is(typeof(NEGATIVE_F64) == double)); ./ldc-1.42.0-src/tests/dmd/compilable/test24762.d0000644000175000017500000000040715205374126017760 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24762 struct S { int m; } string m() { return "m"; } @nogc void f() { S s; enum t = m(); auto x = __traits(getMember, s, m()); // Error: `@nogc` function `nogc.f` cannot call non-@nogc function `nogc.m` } ./ldc-1.42.0-src/tests/dmd/compilable/test22619.d0000644000175000017500000000030315205374126017752 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22619 struct W1 { int x; this(ref inout W1 rhs) inout { this.x = rhs.x; } } inout(W1) f(inout W1 x) { return x; } void g(W1 x) { auto r = f(x); } ./ldc-1.42.0-src/tests/dmd/compilable/test21475.c0000644000175000017500000000006015205374126017750 0ustar fabiofabiovoid test21745(void) { __check(__func__); } ./ldc-1.42.0-src/tests/dmd/compilable/issue22646.d0000644000175000017500000000523415205374126020133 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22646 static template logicalOr22646(T, const T name) { enum bool ok = name.length < 3 || name[0..3] != "pad"; } static template logicalAnd22646(T, const T name) { enum bool ok = name.length >= 3 && name[0..3] == "pad"; } bool runtime22646Or(T, const T name)() { return name.length < 3 || name[0..3] != "pad"; } // SCOPE.ctfe static assert(logicalOr22646!(string, "x").ok == true); static assert(logicalOr22646!(string, "foo").ok == true); static assert(logicalOr22646!(string, "pad").ok == false); static assert(logicalOr22646!(string, "pad123").ok == false); static assert(logicalOr22646!(char[1], "x").ok == true); static assert(logicalOr22646!(char[3], "foo").ok == true); static assert(logicalOr22646!(char[3], "pad").ok == false); static assert(logicalOr22646!(char[6], "pad123").ok == false); static assert(logicalAnd22646!(string, "x").ok == false); static assert(logicalAnd22646!(string, "foo").ok == false); static assert(logicalAnd22646!(string, "pad").ok == true); static assert(logicalAnd22646!(string, "pad123").ok == true); static assert(logicalAnd22646!(char[1], "x").ok == false); static assert(logicalAnd22646!(char[3], "foo").ok == false); static assert(logicalAnd22646!(char[3], "pad").ok == true); static assert(logicalAnd22646!(char[6], "pad123").ok == true); // SCOPE.compile enum char[1] x22646 = "x"; enum char[3] pad22646 = "pad"; static assert(__traits(compiles, x22646.length < 3 || x22646[0..3] != "pad") == true); static assert(__traits(compiles, x22646.length >= 3 || x22646[0..3] == "pad") == true); static assert(__traits(compiles, pad22646.length < 3 || pad22646[0..3] != "pad") == true); static assert(__traits(compiles, pad22646.length >= 3 || pad22646[0..3] == "pad") == true); // sc.intypeof typeof(x22646.length < 3 || x22646[0..3] != "pad") typeof22646or1; static assert(is(typeof(typeof22646or1) == bool)); typeof(pad22646.length < 3 || pad22646[0..3] != "pad") typeof22646or2; static assert(is(typeof(typeof22646or2) == bool)); typeof(x22646.length >= 3 && x22646[0..3] == "pad") typeof22646and1; static assert(is(typeof(typeof22646and1) == bool)); typeof(pad22646.length >= 3 && pad22646[0..3] == "pad") typeof22646and2; static assert(is(typeof(typeof22646and2) == bool)); // No SCOPE flags alias test22646a = runtime22646Or!(string, "x"); alias test22646b = runtime22646Or!(string, "foo"); alias test22646c = runtime22646Or!(string, "pad"); alias test22646d = runtime22646Or!(string, "pad123"); alias test22646e = runtime22646Or!(char[1], "x"); alias test22646f = runtime22646Or!(char[3], "foo"); alias test22646g = runtime22646Or!(char[3], "pad"); alias test22646h = runtime22646Or!(char[6], "pad123"); ./ldc-1.42.0-src/tests/dmd/compilable/test16213.d0000644000175000017500000000020115205374126017740 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16213 enum Id(size_t i) = i; void main() { int[5] y; y[ Id!($) - 1 ] = 3; } ./ldc-1.42.0-src/tests/dmd/compilable/scopeinfer.d0000644000175000017500000000112415205374126020526 0ustar fabiofabio// PERMUTE_ARGS: -preview=dip1000 // Mangling should be the same with or without inference of `return scope` @safe: auto foo(void* p) { return 0; } static assert(typeof(foo).mangleof == "FNaNbNiNfPvZi"); auto bar(void* p) { return p; } static assert(typeof(bar).mangleof == "FNaNbNiNfPvZQd"); // https://issues.dlang.org/show_bug.cgi?id=19857 struct Stack() { @safe: int** data; ref int* top() { return *data; } } alias S = Stack!(); //pragma(msg, S.top.mangleof); version (Win32) static assert(S.top.mangleof == "_D10scopeinfer__T5StackZQh3topMFNaNbNcNiNfZPi"); ./ldc-1.42.0-src/tests/dmd/compilable/testcorrectthis.d0000644000175000017500000000102215205374126021617 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=10886 struct A { @property int foo() { return 0; } int bar() { return 0; } } struct B { void bar() { alias f = typeof(A.foo); // NG alias b = typeof(A.bar); // ok } } // https://issues.dlang.org/show_bug.cgi?id=21288 struct XA { int p; } struct XB { XA a() { return XA.init; } alias a this; } struct XC { void foo() { static assert(XB.p.stringof == "p"); // Error: this for s needs to be type B not type C } } ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_ignored.d0000644000175000017500000000661715205374126021052 0ustar fabiofabio/++ REQUIRED_ARGS: -HC=verbose -c -o- -d PERMUTE_ARGS: TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler v$n$ #pragma once #include #include #include #include #ifdef CUSTOM_D_ARRAY_TYPE #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE #else /// Represents a D [] array template struct _d_dynamicArray final { size_t length; T *ptr; _d_dynamicArray() : length(0), ptr(NULL) { } _d_dynamicArray(size_t length_in, T *ptr_in) : length(length_in), ptr(ptr_in) { } T& operator[](const size_t idx) { assert(idx < length); return ptr[idx]; } const T& operator[](const size_t idx) const { assert(idx < length); return ptr[idx]; } }; #endif #if !defined(_d_real) #define _d_real long double #endif class WithImaginary { public: float memberIf; double memberId; _d_real memberIr; _Complex float memberCf; _Complex double memberCd; _Complex _d_real memberCr; _d_dynamicArray< float > nested; // Ignored function dtoh_ignored.WithImaginary.onReturn because its return type cannot be mapped to C++ private: virtual void __vtable_slot_0(); // Ignored function dtoh_ignored.WithImaginary.onParam because one of its parameters has type `ifloat` which cannot be mapped to C++ virtual void __vtable_slot_1(); }; template struct WithImaginaryTemplate final { float member; // Ignored function onReturn because its return type cannot be mapped to C++ // Ignored function onParam because one of its parameters has type `ifloat` which cannot be mapped to C++ // Ignored variable onVariable because its type cannot be mapped to C++ WithImaginaryTemplate() { } }; extern WithImaginaryTemplate instance; // Ignored variable dtoh_ignored.onVariable because its type cannot be mapped to C++ // Ignored variable dtoh_ignored.onVariablePointer because its type cannot be mapped to C++ // Ignored variable dtoh_ignored.onVariableSlice because its type cannot be mapped to C++ // Ignored variable dtoh_ignored.onVariableArray because its type cannot be mapped to C++ extern void* onVariableAssocArray; // Ignored variable dtoh_ignored.onVariableFunction because its type cannot be mapped to C++ // Ignored variable dtoh_ignored.onVariableFunctionParam because its type cannot be mapped to C++ // Ignored variable dtoh_ignored.onVariableDelegate because its type cannot be mapped to C++ // Ignored function dtoh_ignored.myExit because its return type cannot be mapped to C++ --- +/ extern (C++): class WithImaginary { ifloat memberIf; idouble memberId; ireal memberIr; cfloat memberCf; cdouble memberCd; creal memberCr; ifloat[] nested; ifloat onReturn() { return 0i; } void onParam(ifloat) {} } struct WithImaginaryTemplate(T) { ifloat member; ifloat onReturn() { return 0i; } void onParam(ifloat) { } __gshared ifloat onVariable; } __gshared WithImaginaryTemplate!int instance; __gshared ifloat onVariable; __gshared ifloat** onVariablePointer; __gshared ifloat[] onVariableSlice; __gshared ifloat[2] onVariableArray; __gshared ifloat[int] onVariableAssocArray; __gshared ifloat function() onVariableFunction; __gshared void function(ifloat) onVariableFunctionParam; __gshared ifloat delegate() onVariableDelegate; noreturn myExit() { assert(false); } ./ldc-1.42.0-src/tests/dmd/compilable/test8922b.d0000644000175000017500000000040615205374126020041 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/bug8922.d void test() { import imports.bug8922; static assert(!__traits(compiles, __traits(parent, imports))); enum x = __traits(parent, imports.bug8922).stringof; static assert(x == "package imports"); } ./ldc-1.42.0-src/tests/dmd/compilable/issue9884.d0000644000175000017500000000056415205374126020065 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=9884 module issue9884; const(int)[] data; static this() { data = new int[10]; foreach (ref x; data) x = 1; data[] = 1; } struct Foo { static const(int)[] data; static this() { this.data = new int[10]; foreach (ref x; this.data) x = 1; this.data[] = 1; } } void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_1211.d0000644000175000017500000000017215205374126021143 0ustar fabiofabiostruct Foo { long baz; } Foo foo(long x) { struct Bar { long y; } return cast(Foo)Bar(x); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc11.d0000644000175000017500000000170415205374126017450 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /// The various floating point exceptions enum { FE_INVALID = 1, /// FE_DENORMAL = 2, /// FE_DIVBYZERO = 4, /// FE_OVERFLOW = 8, /// FE_UNDERFLOW = 0x10, /// FE_INEXACT = 0x20, /// FE_ALL_EXCEPT = 0x3F, /// Mask of all the exceptions } alias int myint; /// myint bar; /// myint foo(myint x = myint.max) { return x; } /// class Foo { /// this(string s) { } } extern (C): /// struct div_t { int quot,rem; } /// struct ldiv_t { int quot,rem; } /// struct lldiv_t { long quot,rem; } div_t div(int,int); /// ldiv_t ldiv(int,int); /// lldiv_t lldiv(long, long); /// void *calloc(size_t, size_t); /// void *malloc(size_t); /// dittx /** Example: --- private: int i = 0; --- */ void test1() { } ./ldc-1.42.0-src/tests/dmd/compilable/test19731.d0000644000175000017500000000224515205374126017762 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19731 class Out19731 { static struct State { int flags_; } Object obj_; invariant (obj_ !is null); auto obj7(out State state) { return this.obj_; } enum compiles = __traits(compiles, &Out19731.init.obj7); } class Arguments19731 { Object obj_; invariant (obj_ !is null); import core.stdc.stdarg; auto obj7(...) { return this.obj_; } enum compiles = __traits(compiles, &Arguments19731.init.obj7); } class Require19731 { Object obj_; invariant (obj_ !is null); auto obj7(int a) in(a != 0) { return this.obj_; } enum compiles = __traits(compiles, &Require19731.init.obj7); } class Ensure19731 { Object obj_; invariant (obj_ !is null); auto obj7(int a) out(result; result is obj_) { return this.obj_; } enum compiles = __traits(compiles, &Ensure19731.init.obj7); } class Sync19731 { Object obj_; invariant (obj_ !is null); synchronized auto obj7() { return this.obj_; } enum compiles = __traits(compiles, &Sync19731.init.obj7); } ./ldc-1.42.0-src/tests/dmd/compilable/callconv.d0000644000175000017500000000113215205374126020171 0ustar fabiofabio// PERMUTE_ARGS: import core.stdc.stdarg; struct ABC { int[4] x; } ABC abc; int x,y,z; extern (C): ABC test2v(int xx, int yy, int zz, ...) { x = xx; y = yy; z = zz; return abc; } extern (C++): ABC test3(int xx, int yy, int zz) { x = xx; y = yy; z = zz; return abc; } ABC test3v(int xx, int yy, int zz, ...) { x = xx; y = yy; z = zz; return abc; } extern (D): ABC test4(int xx, int yy, int zz) { x = xx; y = yy; z = zz; return abc; } ABC test4v(int xx, int yy, int zz, ...) { x = xx; y = yy; z = zz; return abc; } ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_UnionDeclaration.d0000644000175000017500000000117415205374126022652 0ustar fabiofabio/+ REQUIRED_ARGS: -o- -HC TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler #pragma once #include #include #include #include union U1 { int32_t a; double d; }; union U2 { double d; char* ptr; }; struct S final { int32_t i; U1 u1; U2 u2; S() : i(), u1(), u2() { } S(int32_t i, U1 u1 = U1(0), U2 u2 = U2(NAN)) : i(i), u1(u1), u2(u2) {} }; --- +/ extern (C++): union U1 { int a; double d; } union U2 { double d; char* ptr; } struct S { int i; U1 u1; U2 u2; } ./ldc-1.42.0-src/tests/dmd/compilable/b12504.d0000644000175000017500000000217215205374126017212 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=12504 void main() { { int[0xFF + 1] sta; foreach (ubyte i; 0 .. sta.length) {} foreach (ubyte i, x; sta) {} } { int[0x7F + 1] sta; foreach (byte i; 0 .. sta.length) {} foreach (byte i, x; sta) {} } { int[0xFFFF + 1] sta; foreach (ushort i; 0 .. sta.length) {} foreach (ushort i, x; sta) {} } { int[0x7FFF + 1] sta; foreach (short i; 0 .. sta.length) {} foreach (short i, x; sta) {} } { immutable int[0xFF + 1] sta; static foreach (ubyte i; 0 .. sta.length) {} static foreach (ubyte i, x; sta) {} } { immutable int[0x7F + 1] sta; static foreach (byte i; 0 .. sta.length) {} static foreach (byte i, x; sta) {} } { immutable int[0xFFFF + 1] sta; static foreach (ushort i; 0 .. sta.length) {} static foreach (ushort i, x; sta) {} } { immutable int[0x7FFF + 1] sta; static foreach (short i; 0 .. sta.length) {} static foreach (short i, x; sta) {} } } ./ldc-1.42.0-src/tests/dmd/compilable/testheader12567a.d0000644000175000017500000000057515205374126021300 0ustar fabiofabio/* REQUIRED_ARGS: -o- -H -Hf${RESULTS_DIR}/compilable/testheader12567a.di PERMUTE_ARGS: OUTPUT_FILES: ${RESULTS_DIR}/compilable/testheader12567a.di TEST_OUTPUT: --- === ${RESULTS_DIR}/compilable/testheader12567a.di // D import file generated from 'compilable/testheader12567a.d' deprecated module header12567a; void main(); --- */ deprecated module header12567a; void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/test5227.d0000644000175000017500000000605515205374126017700 0ustar fabiofabio/* COMPILABLE_MATH_TEST REQUIRED_ARGS: PERMUTE_ARGS: TEST_OUTPUT: --- log() 1.70475L log2() 2.45943L log10() 0.740363L round() 6.0L floor() 5.0F 5.0 5.0L ceil() 6.0F 6.0 6.0L trunc() 5.0L exp() 244.692L expm1() 243.692L exp2() 45.2548L fmin() -3.2L fmax() 5.2L copysign() -2.5F -2.5 -2.5L pow() 9.88212F 9.88212 9.88212L 9.88212 fma() -12.84L --- */ // https://issues.dlang.org/show_bug.cgi?id=5227 import std.math; pragma(msg, "log()"); enum logf = log(5.5f); //pragma(msg, logf); enum logd = log(5.5 ); //pragma(msg, logd); enum logr = log(5.5L); pragma(msg, logr); pragma(msg, "log2()"); enum log2f = log2(5.5f); //pragma(msg, log2f); enum log2d = log2(5.5 ); //pragma(msg, log2d); enum log2r = log2(5.5L); pragma(msg, log2r); pragma(msg, "log10()"); enum log10f = log10(5.5f); //pragma(msg, log10f); enum log10d = log10(5.5 ); //pragma(msg, log10d); enum log10r = log10(5.5L); pragma(msg, log10r); pragma(msg, "round()"); enum roundf = round(5.5f); //pragma(msg, roundf); enum roundd = round(5.5 ); //pragma(msg, roundd); enum roundr = round(5.5L); pragma(msg, roundr); pragma(msg, "floor()"); enum floorf = floor(5.5f); pragma(msg, floorf); enum floord = floor(5.5 ); pragma(msg, floord); enum floorr = floor(5.5L); pragma(msg, floorr); pragma(msg, "ceil()"); enum ceilf = ceil(5.5f); pragma(msg, ceilf); enum ceild = ceil(5.5 ); pragma(msg, ceild); enum ceilr = ceil(5.5L); pragma(msg, ceilr); pragma(msg, "trunc()"); enum truncf = trunc(5.5f); //pragma(msg, truncf); enum truncd = trunc(5.5 ); //pragma(msg, truncd); enum truncr = trunc(5.5L); pragma(msg, truncr); pragma(msg, "exp()"); enum expf = exp(5.5f); //pragma(msg, expf); enum expd = exp(5.5 ); //pragma(msg, expd); enum expr = exp(5.5L); pragma(msg, expr); pragma(msg, "expm1()"); enum expm1f = expm1(5.5f); //pragma(msg, expm1f); enum expm1d = expm1(5.5 ); //pragma(msg, expm1d); enum expm1r = expm1(5.5L); pragma(msg, expm1r); pragma(msg, "exp2()"); enum exp2f = exp2(5.5f); //pragma(msg, exp2f); enum exp2d = exp2(5.5 ); //pragma(msg, exp2d); enum exp2r = exp2(5.5L); pragma(msg, exp2r); pragma(msg, "fmin()"); enum fminf = fmin(-3.2f, 5.2f); //pragma(msg, fminf); enum fmind = fmin(-3.2 , 5.2 ); //pragma(msg, fmind); enum fminr = fmin(-3.2L, 5.2L); pragma(msg, fminr); pragma(msg, "fmax()"); enum fmaxf = fmax(-3.2f, 5.2f); //pragma(msg, fmaxf); enum fmaxd = fmax(-3.2 , 5.2 ); //pragma(msg, fmaxd); enum fmaxr = fmax(-3.2L, 5.2L); pragma(msg, fmaxr); pragma(msg, "copysign()"); enum csf = copysign(2.5f, -3.0f); pragma(msg, csf); static assert(csf == -2.5); enum csd = copysign(2.5 , -3.0 ); pragma(msg, csd); static assert(csd == -2.5); enum csr = copysign(2.5L, -3.0L); pragma(msg, csr); static assert(csr == -2.5); pragma(msg, "pow()"); enum powf = pow(2.5f, 2.5f); pragma(msg, powf); enum powd = pow(2.5 , 2.5 ); pragma(msg, powd); enum powr = pow(2.5L, 2.5L); pragma(msg, powr); enum powctfe = 2.5 ^^ 2.5; pragma(msg, powctfe); pragma(msg, "fma()"); enum fmaf = fma(-3.2f, 5.2f, 3.8f); //pragma(msg, fmaf); enum fmad = fma(-3.2 , 5.2 , 3.8 ); //pragma(msg, fmad); enum fmar = fma(-3.2L, 5.2L, 3.8L); pragma(msg, fmar); ./ldc-1.42.0-src/tests/dmd/compilable/test19482.d0000644000175000017500000000322215205374126017761 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19482 alias AliasSeq(T...) = T; extern (C++, "cppns") @("asd", 123) private deprecated immutable static foreach (i; 0 .. 1) { static assert(is(typeof(i) == int)); static assert(__traits(getLinkage, i) == "D"); static assert(__traits(isDeprecated, i) == false); static assert(__traits(getAttributes, i).length == 0); static assert(__traits(getCppNamespaces, i).length == 0); static assert(__traits(getVisibility, i) == "public"); pragma(mangle, "x") // immutable(int) cannot be C++-mangled extern int x; static assert(is(typeof(x) == immutable int)); static assert(__traits(getLinkage, x) == "C++"); static assert(__traits(isDeprecated, x) == true); static assert(__traits(getAttributes, x) == AliasSeq!("asd", 123)); static assert(__traits(getCppNamespaces, x) == AliasSeq!("cppns")); static assert(__traits(getVisibility, x) == "private"); } struct S { @disable static foreach (j; 0 .. 1) { int y; static assert(__traits(isDisabled, j) == false); static assert(__traits(isDisabled, S.y) == true); } } const static foreach (i, v; ['a']) { static assert(is(typeof(i) == size_t)); static assert(is(typeof(v) == char)); } const static foreach (i, s, f; Range()) { static assert(is(typeof(i) == int)); static assert(is(typeof(s) == string)); static assert(is(typeof(f) == float)); } struct Range { int i; auto front() { return Tup!(int, string, float)(123, "asd", 3.14f); } bool empty() { return i > 0; } void popFront() { ++i; } } struct Tup(T...) { T fields; alias fields this; } ./ldc-1.42.0-src/tests/dmd/compilable/arraytopointer.c0000644000175000017500000000154715205374126021463 0ustar fabiofabio /* Test conversion of expressions: * array of T => pointer to T * function => pointer to function */ int func(int *); int burg(int (*fp)()); int clog(); void testFunctionArguments() { int a[3]; func(a); int b[] = { 0 }; func(b); burg(clog); } void testIndexing() { int a[3]; a[0] = 1; } void testAdd() { int a[3]; int* p = a + 1; p = 1 + 1; } void testMin() { int a[3]; int* p = a - 1; } void testCond() { int i; int a[3]; int b[3]; int* p = i ? a : b; } int testIndexing2() { int *p; int i = p[1]; i = 2[p]; } void testAssign() { int a[3]; int *p = a; } void testComma() { int a[3]; int* p = (1, a) + 1; _Static_assert(sizeof((1, a)) == sizeof(int*), "testComma"); } int testArrow() { struct S { int m, n; }; struct S a[3]; return a->m; } ./ldc-1.42.0-src/tests/dmd/compilable/cppmangle3.d0000644000175000017500000000212215205374126020421 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=15512 // https://issues.dlang.org/show_bug.cgi?id=19893 // https://issues.dlang.org/show_bug.cgi?id=19920 module cppmangle3; version (CppRuntime_LLVM) version = CppMangle_Itanium; version (CppRuntime_GNU) version = CppMangle_Itanium; version (CppRuntime_Microsoft) version = CppMangle_MSVC; version (CppRuntime_Sun) version = CppMangle_Itanium; extern(C++, "true") { } extern(C++, "__traits") { } extern(C++, "foo") { } int foo; // no name clashing with above namespace extern(C++, "std", "chrono") { void func(); } version(CppMangle_MSVC) static assert(func.mangleof == "?func@chrono@std@@YAXXZ"); else static assert(func.mangleof == "_ZNSt6chrono4funcEv"); struct Foo { extern(C++, "namespace") { static void bar(); } } alias Alias(alias a) = a; alias Alias(T) = T; static assert(is(Alias!(__traits(parent, Foo.bar)) == Foo)); extern(C++, "std"): debug = def; version = def; extern(C++, "std") { debug = def; version = def; } extern(C++, "foo") extern(C++, "bar") version = baz; ./ldc-1.42.0-src/tests/dmd/compilable/test22970.c0000644000175000017500000000017215205374126017755 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22970 int xs[5]; void fn() { for (int *p = &xs[0]; p < &xs[5]; p++) ; } ./ldc-1.42.0-src/tests/dmd/compilable/b16976.d0000644000175000017500000000666115205374126017242 0ustar fabiofabio/* REQUIRED_ARGS: -verrors=simple -m64 TEST_OUTPUT: --- compilable/b16976.d(33): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` compilable/b16976.d(34): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` compilable/b16976.d(35): Deprecation: foreach: loop index implicitly converted from `size_t` to `char` compilable/b16976.d(36): Deprecation: foreach: loop index implicitly converted from `size_t` to `char` compilable/b16976.d(41): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` compilable/b16976.d(42): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` compilable/b16976.d(43): Deprecation: foreach: loop index implicitly converted from `size_t` to `char` compilable/b16976.d(44): Deprecation: foreach: loop index implicitly converted from `size_t` to `char` compilable/b16976.d(50): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` compilable/b16976.d(51): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` compilable/b16976.d(52): Deprecation: foreach: loop index implicitly converted from `size_t` to `char` compilable/b16976.d(53): Deprecation: foreach: loop index implicitly converted from `size_t` to `char` compilable/b16976.d(58): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` compilable/b16976.d(59): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` compilable/b16976.d(60): Deprecation: foreach: loop index implicitly converted from `size_t` to `char` compilable/b16976.d(61): Deprecation: foreach: loop index implicitly converted from `size_t` to `char` compilable/b16976.d(62): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` compilable/b16976.d(63): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` compilable/b16976.d(64): Deprecation: foreach: loop index implicitly converted from `size_t` to `char` compilable/b16976.d(65): Deprecation: foreach: loop index implicitly converted from `size_t` to `char` --- */ void main() { int[] dyn = [1,2,3,4,5]; int[5] sta = [1,2,3,4,5]; char[] str = ['1','2','3','4','5']; char[5] chr = ['1','2','3','4','5']; foreach(int i, v; dyn) { } foreach_reverse(int i, v; dyn) { } foreach(char i, v; dyn) { } foreach_reverse(char i, v; dyn) { } foreach(int i, v; sta) { } foreach_reverse(int i, v; sta) { } foreach(char i, v; sta) { } foreach_reverse(char i, v; sta) { } foreach(int i, v; str) { } foreach_reverse(int i, v; str) { } foreach(char i, v; str) { } foreach_reverse(char i, v; str) { } foreach(int i, v; chr) { } foreach_reverse(int i, v; chr) { } foreach(char i, v; chr) { } foreach_reverse(char i, v; chr) { } foreach(int i, dchar v; dyn) { } foreach_reverse(int i, dchar v; dyn) { } foreach(char i, dchar v; dyn) { } foreach_reverse(char i, dchar v; dyn) { } foreach(int i, dchar v; sta) { } foreach_reverse(int i, dchar v; sta) { } foreach(char i, dchar v; sta) { } foreach_reverse(char i, dchar v; sta) { } foreach(int i, dchar v; str) { } foreach_reverse(int i, dchar v; str) { } foreach(char i, dchar v; str) { } foreach_reverse(char i, dchar v; str) { } foreach(int i, dchar v; chr) { } foreach_reverse(int i, dchar v; chr) { } foreach(char i, dchar v; chr) { } foreach_reverse(char i, dchar v; chr) { } } ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_637.d0000644000175000017500000000007615205374126021101 0ustar fabiofabioextern(C): struct Value { this(string) {} string s; }./ldc-1.42.0-src/tests/dmd/compilable/test16495.d0000644000175000017500000001313515205374126017766 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16495 void types() { static assert(__traits(fullyQualifiedName, string) == "string"); static assert(__traits(fullyQualifiedName, wstring) == "wstring"); static assert(__traits(fullyQualifiedName, dstring) == "dstring"); static assert(__traits(fullyQualifiedName, typeof(null)) == "typeof(null)"); static assert(__traits(fullyQualifiedName, void) == "void"); static assert(__traits(fullyQualifiedName, const(void)) == "const(void)"); static assert(__traits(fullyQualifiedName, shared(void)) == "shared(void)"); static assert(__traits(fullyQualifiedName, shared const(void)) == "shared(const(void))"); static assert(__traits(fullyQualifiedName, shared inout(void)) == "shared(inout(void))"); static assert(__traits(fullyQualifiedName, shared inout const(void)) == "shared(inout(const(void)))"); static assert(__traits(fullyQualifiedName, inout(void)) == "inout(void)"); static assert(__traits(fullyQualifiedName, inout const(void)) == "inout(const(void))"); static assert(__traits(fullyQualifiedName, immutable(void)) == "immutable(void)"); } struct QualifiedNameTests { struct Inner { bool value; } ref const(Inner[string]) func( ref Inner var1, lazy scope string var2 ); ref const(Inner[string]) retfunc( return ref Inner var1 ); Inner inoutFunc(inout Inner) inout; shared(const(Inner[string])[]) data; const Inner delegate(double, string) @safe nothrow deleg; inout(int) delegate(inout int) inout inoutDeleg; Inner function(out double, string) funcPtr; extern(C) Inner function(double, string) cFuncPtr; extern(C) void cVarArg(int, ...); void dVarArg(...); void dVarArg2(int, ...); void typesafeVarArg(int[] ...); Inner[] array; Inner[16] sarray; Inner[Inner] aarray; const(Inner[const(Inner)]) qualAarray; shared(immutable(Inner) delegate(ref double, scope string) const shared @trusted nothrow) attrDeleg; struct Data(T) { int x; } void tfunc(T...)(T args) {} template Inst(alias A) { int x; } class Test12309(T, int x, string s) {} } void symbols() { alias qnTests = QualifiedNameTests; enum prefix = "test16495.QualifiedNameTests."; static assert(__traits(fullyQualifiedName, qnTests.Inner) == prefix ~ "Inner"); static assert(__traits(fullyQualifiedName, qnTests.func) == prefix ~ "func"); static assert(__traits(fullyQualifiedName, qnTests.Data!int) == prefix ~ "Data!int.Data"); static assert(__traits(fullyQualifiedName, qnTests.Data!int.x) == prefix ~ "Data!int.Data.x"); static assert(__traits(fullyQualifiedName, qnTests.tfunc!(int[])) == prefix ~ "tfunc!(int[]).tfunc"); static assert(__traits(fullyQualifiedName, qnTests.Inst!(Object)) == prefix ~ "Inst!(Object)"); static assert(__traits(fullyQualifiedName, qnTests.Inst!(Object).x) == prefix ~ "Inst!(Object).x"); static assert(__traits(fullyQualifiedName, qnTests.Test12309!(int, 10, "str")) == prefix ~ "Test12309!(int, 10, \"str\").Test12309"); } void names() { enum prefix = "test16495.QualifiedNameTests"; enum xx = prefix ~ ".Inner"; with (QualifiedNameTests) { // Basic qualified name static assert(__traits(fullyQualifiedName, Inner) == xx); // Array types static assert(__traits(fullyQualifiedName, typeof(array)) == xx ~ "[]"); static assert(__traits(fullyQualifiedName, typeof(sarray)) == xx ~ "[16]"); static assert(__traits(fullyQualifiedName, typeof(aarray)) == xx ~ "[" ~ xx ~ "]"); // qualified key for AA static assert(__traits(fullyQualifiedName, typeof(qualAarray)) == "const(" ~ xx ~ "[const(" ~ xx ~ ")])"); // Qualified composed data types static assert(__traits(fullyQualifiedName, typeof(data)) == "shared(const(" ~ xx ~ "[string])[])"); // Function types + function attributes static assert(__traits(fullyQualifiedName, typeof(func)) == "ref const(" ~ xx ~ "[string])(ref " ~ xx ~ ", lazy scope string)"); static assert(__traits(fullyQualifiedName, typeof(retfunc)) == "ref const(" ~ xx ~ "[string])(return ref " ~ xx ~ ")"); static assert(__traits(fullyQualifiedName, typeof(inoutFunc)) == "inout "~xx~"(inout("~xx~"))"); static assert(__traits(fullyQualifiedName, typeof(deleg)) == "const(" ~ xx ~ " delegate(double, string) nothrow @safe)"); static assert(__traits(fullyQualifiedName, typeof(inoutDeleg)) == "inout(int) delegate(inout(int)) inout"); static assert(__traits(fullyQualifiedName, typeof(funcPtr)) == "" ~ xx ~ " function(out double, string)"); static assert(__traits(fullyQualifiedName, typeof(cFuncPtr)) == "extern (C) " ~ xx ~ " function(double, string)"); // Delegate type with qualified function type static assert(__traits(fullyQualifiedName, typeof(attrDeleg)) == "shared(immutable(" ~ xx ~ ") "~ "delegate(ref double, scope string) shared const nothrow @trusted)"); // Variable argument function types static assert(__traits(fullyQualifiedName, typeof(cVarArg)) == "extern (C) void(int, ...)"); static assert(__traits(fullyQualifiedName, typeof(dVarArg)) == "void(...)"); static assert(__traits(fullyQualifiedName, typeof(dVarArg2)) == "void(int, ...)"); static assert(__traits(fullyQualifiedName, typeof(typesafeVarArg)) == "void(int[]...)"); // SIMD vector static if (is(__vector(float[4]))) { static assert(__traits(fullyQualifiedName, __vector(float[4])) == "__vector(float[4])"); } } } ./ldc-1.42.0-src/tests/dmd/compilable/betterCinline.d0000644000175000017500000000036615205374126021167 0ustar fabiofabio/* REQUIRED_ARGS: -betterC -inline PERMUTE_ARGS: */ struct InvBoneBindInfo { } struct Test(Value) { void test() { auto t = Value.init; } } extern(C) void main() { Test!(InvBoneBindInfo[32]) test; test.test(); } ./ldc-1.42.0-src/tests/dmd/compilable/test21414.d0000644000175000017500000000030115205374126017740 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=21414 struct State { string s; immutable this(string s) { this.s = s; } } immutable rootState = new immutable State("b"); ./ldc-1.42.0-src/tests/dmd/compilable/diag20916.d0000644000175000017500000000306015205374126017700 0ustar fabiofabio// REQUIRED_ARGS: -verrors=simple /* TEST_OUTPUT: --- compilable/diag20916.d(32): Deprecation: `alias fb this` is deprecated compilable/diag20916.d(37): instantiated from here: `jump2!(Foo)` compilable/diag20916.d(42): instantiated from here: `jump1!(Foo)` compilable/diag20916.d(32): Deprecation: function `diag20916.FooBar.toString` is deprecated compilable/diag20916.d(37): instantiated from here: `jump2!(Foo)` compilable/diag20916.d(42): instantiated from here: `jump1!(Foo)` compilable/diag20916.d(32): Deprecation: template `diag20916.Bar.toString()() const` is deprecated compilable/diag20916.d(37): instantiated from here: `jump2!(Bar)` compilable/diag20916.d(43): instantiated from here: `jump1!(Bar)` compilable/diag20916.d(21): Deprecation: variable `diag20916.Something.something` is deprecated compilable/diag20916.d(24): instantiated from here: `nestedCheck!(Something)` --- */ #line 1 struct FooBar { deprecated string toString() const { return "42"; } int value = 42; } struct Foo { FooBar fb; deprecated alias fb this; } struct Bar { deprecated string toString()() const { return "42"; } int value = 42; } template nestedCheck(T) { enum nestedCheck = T.something.init == 0; } struct Constraint (T) if(nestedCheck!T) { T value; } struct Something { deprecated int something; } void jump2(T) (T value) { assert(value.toString() == "42"); } void jump1(T) (T value) { jump2(value); } void main () { jump1(Foo.init); jump1(Bar.init); Constraint!Something c1; } ./ldc-1.42.0-src/tests/dmd/compilable/b20938.d0000644000175000017500000000072015205374126017221 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20938 // Cannot create const arrays mixing immutable and mutable structs with indirections struct S { int[] a; } enum A { a } enum B { b } void fun() { int* pi; immutable int* ipi; int[] ai; immutable int[] iai; S s; immutable S _is; Object o; immutable Object io; auto a = [pi, ipi]; auto b = [ai, iai]; auto c = [s, _is]; auto d = [o, io]; auto e = [A.a, B.b]; } ./ldc-1.42.0-src/tests/dmd/compilable/test16574.d0000644000175000017500000000140715205374126017763 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=16574 template Recursive(T) if (is(T == class)) { // fails because T is still forward referenced // speculative determineSize must not set type to error static assert (!__traits(compiles, { new T; })); // known size of class static assert (is(typeof(T.init) == T)); alias Recursive = T; } // must be resolvable class C { Recursive!C r; } template Recursive(T) if (is(T == struct)) { // fails because T is still forward referenced // speculative determineSize must not set type to error static assert (!__traits(compiles, { T t; })); // no size yet for struct static assert (!is(typeof(T.init))); alias Recursive = T*; } // must be resolvable struct S { Recursive!S r; } ./ldc-1.42.0-src/tests/dmd/compilable/test14781.d0000644000175000017500000000127415205374126017763 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: void impure() {} // impure auto fb1(T)() pure { int x; struct A(S) { void fc(T2)() { x = 1; // accessing pure function context is just ok impure(); // impure function call makes fc as impure } this(S a) {} } return A!int(); } auto fb2(T)() pure { int x; struct A(S) { void fc(T2)() { impure(); // impure function call makes fc as impure x = 1; // accessing pure function context is just ok } this(S a) {} } return A!int(); } void test1() { fb1!int().fc!int(); fb2!int().fc!int(); } ./ldc-1.42.0-src/tests/dmd/compilable/test18651a.d0000644000175000017500000000035715205374126020125 0ustar fabiofabio// REQUIRED_ARGS: -deps=${RESULTS_DIR}/compilable/test18651a.deps // EXTRA_SOURCES: imports/test18651/b.d // EXTRA_FILES: imports/test18651/c.d imports/test18651/algorithm.d imports/test18651/datetime.d import imports.test18651.datetime; ./ldc-1.42.0-src/tests/dmd/compilable/test10066.d0000644000175000017500000000224315205374126017750 0ustar fabiofabiovoid main() { alias Zoo = Foo!(1); } struct Foo(size_t N) { string bar() { Appender!(string) w; char[] buf; put(w, buf); return ""; } public bool opEquals(T)(T other) const // Add const, different from bug 10056 { alias Foo!(typeof(this), T, "CMP") P; return false; } } template Foo(T, U, string OP) { static if (T.ISEMPTY && U.ISEMPTY) enum bool S = false; else enum bool S = false; alias Foo = Foo!(0); } /**********************************************/ void put(R, E)(ref R r, E e) { static if (is(typeof(r.put(e)))) { r.put(e); } else { static assert(false, "Cannot put a "~E.stringof~" into a "~R.stringof); } } struct Appender(A : T[], T) { private template canPutItem(U) { enum bool canPutItem = is(U : T); } private template canPutRange(R) { enum bool canPutRange = is(typeof(Appender.init.put(R.init[0]))); } void put(U)(U item) if (canPutItem!U) { char[T.sizeof == 1 ? 4 : 2] encoded; put(encoded[]); } void put(R)(R items) if (canPutRange!R) { } } ./ldc-1.42.0-src/tests/dmd/compilable/mixinTemplateMangling.d0000644000175000017500000000212115205374126022664 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20012 mixin template mixinFoo() { extern(C) void cFoo() {} extern(C) int cVar; extern(D) int dVar; void dFoo() {} mixin(`mixin mixinBar;`); // test nesting and interaction with string mixins } mixin mixinFoo; mixin template mixinBar() { extern(C) void cBar() {} void dBar() {} } static assert(cFoo.mangleof == "cFoo"); static assert(dFoo.mangleof == "_D21mixinTemplateMangling8__mixin54dFooFZv"); static assert(cVar.mangleof == "cVar"); static assert(dVar.mangleof == "_D21mixinTemplateMangling8__mixin54dVari"); static assert(cBar.mangleof == "cBar"); static assert(dBar.mangleof == "_D21mixinTemplateMangling8__mixin5Qj4dBarFZv"); struct S { mixin mixinFoo; static assert(cFoo.mangleof == "_D21mixinTemplateMangling1S8__mixin14cFooMUZv"); static assert(cBar.mangleof == "_D21mixinTemplateMangling1S8__mixin18__mixin54cBarMUZv"); static assert(dBar.mangleof == "_D21mixinTemplateMangling1S8__mixin18__mixin54dBarMFZv"); static assert(dFoo.mangleof == "_D21mixinTemplateMangling1S8__mixin14dFooMFZv"); } ./ldc-1.42.0-src/tests/dmd/compilable/test20488.d0000644000175000017500000000035715205374126017765 0ustar fabiofabiomodule test20488; // https://issues.dlang.org/show_bug.cgi?id=20488 struct Bar { void opDispatch(string s, Args...) (Args args) { } void fun() { (bool[int]).init.length; this.f((int[int]).init.length); } } ./ldc-1.42.0-src/tests/dmd/compilable/sw_transition_field.d0000644000175000017500000000114615205374126022443 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -transition=field /* TEST_OUTPUT: --- compilable/sw_transition_field.d(15): `sw_transition_field.S1.ix` is `immutable` field compilable/sw_transition_field.d(16): `sw_transition_field.S1.cx` is `const` field compilable/sw_transition_field.d(21): `sw_transition_field.S2!(immutable(int)).S2.f` is `immutable` field compilable/sw_transition_field.d(21): `sw_transition_field.S2!(const(int)).S2.f` is `const` field --- */ struct S1 { immutable int ix = 1; const int cx = 2; } struct S2(F) { F f = F.init; } alias S2!(immutable int) S2I; alias S2!( const int) S2C; ./ldc-1.42.0-src/tests/dmd/compilable/test23639.d0000644000175000017500000000032415205374126017760 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23639 // REQUIRED_ARGS: -preview=nosharedaccess class T {} shared(T) allocClassMem() { void *p; // assume p is allocated here return cast(shared(T))p; } ./ldc-1.42.0-src/tests/dmd/compilable/test14275.d0000644000175000017500000000022215205374126017751 0ustar fabiofabio// REQUIRED_ARGS: -o- // EXTRA_FILES: protection/bug/bug14275.d protection/aggregate/mod14275.d // PERMUTE_ARGS: import protection.bug.bug14275; ./ldc-1.42.0-src/tests/dmd/compilable/test6056b.d0000644000175000017500000000016215205374126020034 0ustar fabiofabiotemplate X(T) { alias T X; } alias const(X!char*) A; alias const(X!int*) B; static assert(is(B == const(int*))); ./ldc-1.42.0-src/tests/dmd/compilable/test16460.d0000644000175000017500000000035115205374126017752 0ustar fabiofabio// EXTRA_FILES: imports/imp16460.d module imports.test16460; void bug() { auto d1 = (){ import imports.imp16460; return val; }; enum d2 = (){ import imports.imp16460; return val; }; } ./ldc-1.42.0-src/tests/dmd/compilable/test17373.d0000644000175000017500000000207615205374126017764 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=17373 interface Foo { void visit (int); } interface Bar { void visit(double); } interface FooBar : Foo, Bar {} static assert(__traits(getOverloads, FooBar, "visit").length == 2); interface Fbar { void visit(char); void visit(double); } interface Triple : Foo, Bar, Fbar {} static assert(__traits(getOverloads, Triple, "visit").length == 3); interface InheritanceMadness : FooBar, Triple {} static assert(__traits(getOverloads, Triple, "visit").length == 3); interface Simple { int square(int); real square(real); } static assert(__traits(getOverloads, Simple, "square").length == 2); // https://issues.dlang.org/show_bug.cgi?id=19064 interface InputStream {} interface OutputStream{} interface Stream : InputStream, OutputStream{} interface ConnectionStream : Stream { @property bool connected() const; void close(); } static assert(__traits(getOverloads, ConnectionStream, "connected").stringof == "AliasSeq!(connected)"); static assert(__traits(getOverloads, ConnectionStream, "close").stringof == "AliasSeq!(close)"); ./ldc-1.42.0-src/tests/dmd/compilable/test23174.d0000644000175000017500000000245715205374126017763 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23174 alias AliasSeq(T...) = T; template staticMap(alias fun, args...) { alias staticMap = AliasSeq!(); static foreach(arg; args) staticMap = AliasSeq!(staticMap, fun!arg); } template Filter(alias pred, args...) { alias Filter = AliasSeq!(); static foreach (arg; args) static if (pred!arg) Filter = AliasSeq!(Filter, arg); } struct Fields(T) { private static alias toField(alias e) = Field!(__traits(identifier, e)); alias fields = staticMap!(toField, T.tupleof); static alias map(alias F) = staticMap!(F, fields); static alias filter(alias pred) = Filter!(pred, fields); } struct Field(string n) { enum name = n; } struct Foo { int a; } void test23174() { Foo value; enum toName(alias e) = e.name; enum pred(alias e) = true; alias a = Fields!(Foo).filter!(pred); // works static assert(is(a == AliasSeq!(Field!"a"))); alias b = Fields!(Foo).map!(toName); // works static assert(b == AliasSeq!("a")); alias c = Fields!(Foo).init.filter!(pred); // works static assert(is(c == AliasSeq!(Field!"a"))); // OK <- Error: alias `d` cannot alias an expression `Fields().tuple("a")` alias d = Fields!(Foo).init.map!(toName); static assert(d == AliasSeq!("a")); } ./ldc-1.42.0-src/tests/dmd/compilable/test15389_x.d0000644000175000017500000000017015205374126020311 0ustar fabiofabio// EXTRA_FILES: test15389_y.d import test15389_y; //struct ns extern (C++, ns) { class X { test15389_y.ns.Y a; } } ./ldc-1.42.0-src/tests/dmd/compilable/test19463.sh0000755000175000017500000000031615205374126020153 0ustar fabiofabio#!/usr/bin/env bash $DMD -c -preview=dip1008 -m${MODEL} -of${OUTPUT_BASE}${OBJ} -I${EXTRA_FILES} ${EXTRA_FILES}/${TEST_NAME}.d !(nm ${OUTPUT_BASE}${OBJ} | grep _d_newclass) rm_retry ${OUTPUT_BASE}${OBJ} ./ldc-1.42.0-src/tests/dmd/compilable/test8041.d0000644000175000017500000000030215205374126017662 0ustar fabiofabio// PERMUTE_ARGS: struct Foo { } void main() { static Foo sf; // ok __gshared Foo gf; // was: Error: non-constant expression gf = 0 __gshared int[1][1] arr; // dup: Issue 6089 } ./ldc-1.42.0-src/tests/dmd/compilable/test6056c.d0000644000175000017500000000013515205374126020035 0ustar fabiofabioalias int T; static assert( is( T** : const(T**) )); static assert( is( T* : const(T* ) )); ./ldc-1.42.0-src/tests/dmd/compilable/test23342.i0000644000175000017500000000017415205374126017757 0ustar fabiofabio/* REQUIRED_ARGS: -betterC */ // https://issues.dlang.org/show_bug.cgi?id=23342 void test() { int* p = (int[]){4}; } ./ldc-1.42.0-src/tests/dmd/compilable/test23004.c0000644000175000017500000000102715205374126017742 0ustar fabiofabio/* https://issues.dlang.org/show_bug.cgi?id=22976 */ struct { void(*init)(); void(*stringof)(); void(*offsetof)(); void(*mangleof)(); } *sp; union { void(*init)(); void(*stringof)(); void(*offsetof)(); void(*mangleof)(); } *up; void fn() { sp->init(); sp->stringof(); sp->offsetof(); sp->mangleof(); up->init(); up->stringof(); up->offsetof(); sp->mangleof(); } struct S { int alignof, mangleof; }; union U { int alignof, mangleof; }; enum E { alignof, mangleof }; ./ldc-1.42.0-src/tests/dmd/compilable/ddoc9789.d0000644000175000017500000000030015205374126017636 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -w -o- -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh module ddoc9789; /// struct S {} /// alias A = S; ./ldc-1.42.0-src/tests/dmd/compilable/test23874.d0000644000175000017500000000034115205374126017760 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23874 // REQUIRED_ARGS: -profile=gc // DISABLED: LDC // -profile=gc not supported string myToString() { return ""; } enum x = myToString ~ ""; immutable x2 = myToString ~ ""; ./ldc-1.42.0-src/tests/dmd/compilable/test21667.d0000644000175000017500000000042115205374126017755 0ustar fabiofabio// Issue 21667 - scope parameter causes 'no size because of forward references' // https://issues.dlang.org/show_bug.cgi?id=21667 @safe: struct Foo { void delegate(scope Foo) dg; } struct M { F.Type f; } struct F { enum Type {a} void foo(scope M m) {} } ./ldc-1.42.0-src/tests/dmd/compilable/statictemplatethis.d0000644000175000017500000000174515205374126022315 0ustar fabiofabiomixin template Constructors(){ this(){ } this()immutable{ } this()shared{ } } class A { public: static T getInstance(this T)() { return new T(); } private: mixin Constructors; } class B : A { private: mixin Constructors; } void f(){ auto a = (new A).getInstance; auto b = (new B).getInstance; static assert(is(typeof(a) == A)); static assert(is(typeof(b) == B)); auto ca = (new immutable A).getInstance; auto sb = (new shared B).getInstance; static assert(is(typeof(ca) == immutable A)); static assert(is(typeof(sb) == shared B)); } // https://issues.dlang.org/show_bug.cgi?id=10488 version(none) void g(){ auto a = A.getInstance(); auto b = B.getInstance(); static assert(is(typeof(a)==A)); static assert(is(typeof(b)==B)); auto ai = (immutable(A)).getInstance(); auto bs = (shared(B)).getInstance(); static assert(is(typeof(ai)==immutable(A))); static assert(is(typeof(bs)==shared(B))); } ./ldc-1.42.0-src/tests/dmd/compilable/atomic_loadstore_shared_classes.d0000644000175000017500000000044715205374126024773 0ustar fabiofabio// REQUIRED_ARGS: -preview=nosharedaccess import core.atomic; class Foo { } shared Foo toLoad; void oops() { auto f0 = new shared Foo; auto f1 = new shared Foo; atomicStore(f0, f1); // https://issues.dlang.org/show_bug.cgi?id=24846 shared(Foo) f2 = atomicLoad(toLoad); } ./ldc-1.42.0-src/tests/dmd/compilable/test9639.d0000644000175000017500000000105315205374126017704 0ustar fabiofabioclass A { this(A) {} } class B {} class C {} // two sibling nested functions in main typeof(null) foo(alias fn)(A a) { fn(a); return foo!fn(B.init); } typeof(null) foo(alias fn)(B b) { return foo!fn(A.init); } // three sibling nested functions in main typeof(null) bar(alias fn)(A a) { fn(a); return bar!fn(B.init); } typeof(null) bar(alias fn)(B b) { return bar!fn(C.init); } typeof(null) bar(alias fn)(C c) { return bar!fn(A.init); } void main() { A a; foo!((stuff){ new A(a); })(a); bar!((stuff){ new A(a); })(a); } ./ldc-1.42.0-src/tests/dmd/compilable/checkimports3.d0000644000175000017500000000035215205374126021151 0ustar fabiofabio/* REQUIRED_ARGS: -de EXTRA_FILES: imports/checkimports3a.d imports/checkimports3b.d imports/checkimports3c.d */ import imports.checkimports3a; import imports.checkimports3b; import imports.checkimports3c; void test() { foo(); } ./ldc-1.42.0-src/tests/dmd/compilable/b20885.d0000644000175000017500000000037315205374126017226 0ustar fabiofabiomodule b20885; struct S { alias P = void*; } void main() { alias P = void*; alias PP = void**; PP[1] a = null; if (const void** b = a[0]){} // OK if (const P* b = a[0]){} // NG if (const S.P* b = a[0]){} // NG } ./ldc-1.42.0-src/tests/dmd/compilable/test14198.d0000644000175000017500000000022115205374126017754 0ustar fabiofabio/* REQUIRED_ARGS: runnable/extra-files/test14198.d -Irunnable/extra-files PERMUTE_ARGS: -version=bug14198 LINK: */ module compilable.test14198; ./ldc-1.42.0-src/tests/dmd/compilable/test20410.d0000644000175000017500000000033015205374126017735 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20410 enum E : string { foo = "foo" } static assert( is(E : string)); static assert( is(E : T[], T)); static assert(!is(E == string)); static assert(!is(E == T[], T)); ./ldc-1.42.0-src/tests/dmd/compilable/test20596.d0000644000175000017500000000062615205374126017764 0ustar fabiofabio// PERMUTE_ARGS: -preview=dip1000 // https://issues.dlang.org/show_bug.cgi?id=20596 struct S(T) { void delegate() dg; this(scope void delegate() dg) { this.dg = dg; } } @nogc void fooTemplate() { int num; void foo() { int dummy = num; } scope s = S!int(&foo); } void test3032() @nogc { int n = 1; scope fp = (){ n = 10; }; // no closure fp(); } ./ldc-1.42.0-src/tests/dmd/compilable/test20744.d0000644000175000017500000000042015205374126017747 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20744 struct A { struct S {} void f(@S int = 3); alias fun = Issue20744!f; } template Issue20744(func...) { static if (is(typeof(func[0]) PT == __parameters)) { alias Issue20744 = (PT args) {}; } } ./ldc-1.42.0-src/tests/dmd/compilable/test19652.d0000644000175000017500000000036515205374126017765 0ustar fabiofabiostruct Base { int i; } struct A { Base base; alias base this; } struct B { A a; alias a this; } auto asGeneric(inout ref Base block) @nogc { return █ } B* thingie; auto foo() { return asGeneric(*thingie); } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc5446a.d0000644000175000017500000000030615205374126017767 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- module ddoc5446a; /** */ struct A_Foo { } /** */ alias A_Foo A_Foo_Alias; /** */ alias int A_Int; /** */ enum A_Enum { x } ./ldc-1.42.0-src/tests/dmd/compilable/test20427.d0000644000175000017500000000022215205374126017745 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=20427 extern(C++) void test20427(T)(T) {} static assert(!__traits(compiles, { test20427([1, 2]); })); ./ldc-1.42.0-src/tests/dmd/compilable/ctod.i0000644000175000017500000000443015205374126017332 0ustar fabiofabio/* PERMUTE_ARGS: REQUIRED_ARGS: -Hf=${RESULTS_DIR}/compilable/ctod.di OUTPUT_FILES: ${RESULTS_DIR}/compilable/ctod.di TEST_OUTPUT: --- === ${RESULTS_DIR}/compilable/ctod.di // D import file generated from 'compilable/ctod.i' extern (C) { uint equ(double x, double y); enum SQLINTERVAL { SQL_IS_YEAR = 1, SQL_IS_MONTH = 2, } alias SQL_IS_YEAR = SQLINTERVAL.SQL_IS_YEAR; alias SQL_IS_MONTH = SQLINTERVAL.SQL_IS_MONTH; struct Foo { int x = void; } Foo abc(); union S { int x = void; } alias T = S; enum { A, } struct S24326 { int x = void; } const(S24326) fun(int y); struct foo { int x = void; } alias weird = int[(cast(foo*)cast(void*)0).x.sizeof]; alias ULONG = ulong; alias ULONG_Deluxe = ulong; alias ULONG_PTR = ulong*; alias Callback = void* function(); struct Test { ULONG_Deluxe d = void; ULONG_Deluxe* p = void; ULONG_PTR q = void; Callback cb = void; } extern __gshared int[cast(ULONG)3] arr; /+enum int __DATE__ = 1+/; /+enum int __TIME__ = 1+/; /+enum int __TIMESTAMP__ = 1+/; /+enum int __EOF__ = 1+/; /+enum int __VENDOR__ = 1+/; enum int DEF = 123; enum int SQL_DRIVER_STMT_ATTR_BASE = 16384; enum int ABC = 64; } --- */ unsigned equ(double x, double y) { return *(long long *)&x == *(long long *)&y; } typedef enum { SQL_IS_YEAR = 1, SQL_IS_MONTH = 2 } SQLINTERVAL; struct Foo { int x; }; struct Foo abc(void); // https://issues.dlang.org/show_bug.cgi?id=24276 union S { int x; }; typedef S T; // https://issues.dlang.org/show_bug.cgi?id=24200 #define __DATE__ 1 #define __TIME__ 1 #define __TIMESTAMP__ 1 #define __EOF__ 1 #define __VENDOR__ 1 // https://issues.dlang.org/show_bug.cgi?id=24326 enum { A }; // https://issues.dlang.org/show_bug.cgi?id=24670 struct S24326 { int x; }; const struct S24326 fun(int y); // https://issues.dlang.org/show_bug.cgi?id=24375 struct foo { int x; }; typedef int weird[sizeof(((struct foo *)((void*)0))->x)]; // https://github.com/dlang/dmd/issues/20889 typedef unsigned long long ULONG; typedef ULONG ULONG_Deluxe; typedef ULONG_Deluxe *ULONG_PTR; typedef void *(*Callback)(); struct Test { ULONG_Deluxe d; ULONG_Deluxe *p; ULONG_PTR q; Callback cb; }; int arr[(ULONG) 3]; #define DEF 123 #define SQL_DRIVER_STMT_ATTR_BASE 0x00004000 // 32-bit #define ABC 64 ./ldc-1.42.0-src/tests/dmd/compilable/test6461.sh0000755000175000017500000000057315205374126020072 0ustar fabiofabio#!/usr/bin/env bash src=${EXTRA_FILES}/${TEST_NAME} $DMD -lib -m${MODEL} -of${OUTPUT_BASE}a${LIBEXT} -I${src} ${src}/a.d $DMD -lib -m${MODEL} -of${OUTPUT_BASE}b${LIBEXT} -I${src} ${src}/b.d $DMD -m${MODEL} -of${OUTPUT_BASE}_main -I${src} ${src}/main.d ${OUTPUT_BASE}a${LIBEXT} ${OUTPUT_BASE}b${LIBEXT} rm_retry ${OUTPUT_BASE}{a${LIBEXT},b${LIBEXT},_main${EXE},_main${OBJ}} ./ldc-1.42.0-src/tests/dmd/compilable/test17853.d0000644000175000017500000000023415205374126017761 0ustar fabiofabio// Switch with no braces & empty case should compile int main() { int ob = 1; final switch (ob) case 0: case 1: break; return ob; } ./ldc-1.42.0-src/tests/dmd/compilable/test19713.d0000644000175000017500000000026715205374126017764 0ustar fabiofabioextern (C++) { double twice(double d) { return d * 2; } void* createFunction(R)(R function(double)); } void main() { const f = createFunction(&twice); } ./ldc-1.42.0-src/tests/dmd/compilable/emptystatement.d0000644000175000017500000000022215205374126021452 0ustar fabiofabio/* REQUIRED_ARGS: TEST_OUTPUT: --- --- */ void foo() { int x;; enum A { a, b, c }; void bar() {}; } ./ldc-1.42.0-src/tests/dmd/compilable/vcg_ast_compilable.d0000644000175000017500000000161315205374126022211 0ustar fabiofabio/* REQUIRED_ARGS: -vcg-ast -o- OUTPUT_FILES: compilable/vcg_ast_compilable.d.cg TEST_OUTPUT: --- === compilable/vcg_ast_compilable.d.cg import object; auto binaryFun(E)(E b) { return 'a' == b; } void find(Element)(Element needle) if (is(typeof(binaryFun(needle)))) { } void find()(string needle) { } void splitter() { find(3); find(""); } binaryFun!int { auto pure nothrow @nogc @safe bool binaryFun(int b) { return 97 == b; } } find!int { pure nothrow @nogc @safe void find(int needle) { } } binaryFun!string { auto _error_ binaryFun { __error__ } } find!() { pure nothrow @nogc @safe void find(string needle) { } } --- */ // https://issues.dlang.org/show_bug.cgi?id=24431 auto binaryFun(E)(E b) { return 'a' == b; } void find(Element)(Element needle) if (is(typeof(binaryFun(needle)))) { } void find()(string needle) { } void splitter() { find!int(3); find!()(""); } ./ldc-1.42.0-src/tests/dmd/compilable/infer_stc.d0000644000175000017500000000245415205374126020354 0ustar fabiofabio/// Test storage class inference on delegate parameters alias FPT = void function (in string, ref string, out string, scope string); alias DGT = void delegate (in string, ref string, out string, scope string); void f1 (FPT func) { string ro = "Hello World"; string ref_ = ro, out_ = ro; func(ro, ref_, out_, ro); } void f2 (DGT func) { string ro = "Hello World"; string ref_ = ro, out_ = ro; func(ro, ref_, out_, ro); } void test () { f1((in_, ref_, out_, scope_) { assert(in_ == "Hello World"); assert(in_ == scope_); assert(in_ == ref_); assert(out_ is null); }); f2((in_, ref_, out_, scope_) { assert(in_ == "Hello World"); assert(in_ == scope_); assert(in_ == ref_); assert(out_ is null); }); } // https://issues.dlang.org/show_bug.cgi?id=11316 void issue11316() { void delegate(const int x) F0; F0 = (const int x) {}; // OK F0 = (x) {}; // OK void delegate(in int x) F1; F1 = (in int x) {}; // OK F1 = (x) {}; // OK void delegate(ref int x) F2; F2 = (ref int x) {}; // OK F2 = (x) {}; // Error void delegate(out int x) F3; F3 = (out int x) {}; // OK F3 = (x) {}; // Error } ./ldc-1.42.0-src/tests/dmd/compilable/b16355.d0000644000175000017500000000112315205374126017215 0ustar fabiofabio// REQUIRED_ARGS: -c struct S0 { this(this) {} } struct S1 { S0[2] x; } struct S2 { S0[0] x; } // S0 has an explicit and a compiler-generated postblit static assert( __traits(hasMember, S0, "__postblit")); static assert( __traits(hasMember, S0, "__xpostblit")); // S1 has only the compiler-generated postblit static assert(!__traits(hasMember, S1, "__postblit")); static assert( __traits(hasMember, S1, "__xpostblit")); // S2 has no postblit at all since the x array has zero length static assert(!__traits(hasMember, S2, "__postblit")); static assert(!__traits(hasMember, S2, "__xpostblit")); ./ldc-1.42.0-src/tests/dmd/compilable/deprecatedinref.d0000644000175000017500000000005515205374126021517 0ustar fabiofabiovoid foo(in ref int); void foor(ref in int); ./ldc-1.42.0-src/tests/dmd/compilable/ice12554.d0000644000175000017500000000153015205374126017533 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: void main() pure { int[] foo; // if indirectly instantiated aggregate is struct (== MapResultS) foo.map!(MapResultS, x => foo.map!(MapResultS, y => x).array); // if indirectly instantiated aggregate is class (== MapResultC) foo.map!(MapResultC, x => foo.map!(MapResultC, y => x).array); } T array(T)(T a) { static int g; g = 1; // impure operation return a; } template map(alias MapResult, fun...) { auto map(Range)(Range r) { alias AppliedReturnType(alias f) = typeof(f(r[0])); static assert(!is(AppliedReturnType!fun == void)); return MapResult!(fun).init; } } struct MapResultS(alias fun) { @property front() { return fun(1); } } class MapResultC(alias fun) { @property front() { return fun(1); } } ./ldc-1.42.0-src/tests/dmd/compilable/cppflags.c0000644000175000017500000000010115205374126020161 0ustar fabiofabio/* REQUIRED_ARGS: -P=-DABC=3 */ _Static_assert(ABC == 3, "1"); ./ldc-1.42.0-src/tests/dmd/compilable/b15206.d0000644000175000017500000000040615205374126017212 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -O void main() { } struct Line { double slope; double intercept; } Line nLineProjection(double[] historicData) { Line projLine; projLine.intercept = historicData[$-1] + projLine.slope; return projLine; } ./ldc-1.42.0-src/tests/dmd/compilable/diag3243.d0000644000175000017500000000020115205374126017604 0ustar fabiofabio// REQUIRED_ARGS: -vtls // PERMUTE_ARGS: template T() { static this() {} } class C { alias ti = T!(); } void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/ident_all.c0000644000175000017500000000027315205374126020327 0ustar fabiofabio// REQUIRED_ARGS: -identifiers-importc=all // verify that the All identifier set is applied. int \u00F8ide\u00F9nt; int \u00AAide\u00B5nt; int \u00A8ide\u00AFnt; int \u00F8ide\u00F9nt; ./ldc-1.42.0-src/tests/dmd/compilable/bug21196.d0000644000175000017500000000130615205374126017553 0ustar fabiofabio/* REQUIRED_ARGS: -de */ // This test can be removed once the deprecation period is over deprecated void appendSlices ( Types ... ) ( ref void[][] slices, ref Types x ) { foreach (i, T; Types) { static if (is(T Element: Element[])) { static if (is(T == Element[])) { slices ~= (cast(void*)(&x[i]))[0 .. size_t.sizeof]; } // Append a slice to the array content. slices ~= x[i]; } else { slices ~= (cast(void*)(&x[i]))[0 .. x[i].sizeof]; } } } deprecated void myTest() { void[][] slices; char[] str = "Hello World!".dup; appendSlices(slices, str); } ./ldc-1.42.0-src/tests/dmd/compilable/test17590.d0000644000175000017500000000160515205374126017762 0ustar fabiofabio// REQUIRED_ARGS: -o- -preview=dip1000 void lazyfun(scope lazy int a) @nogc; // Test that returning a local _static_ struct does not lead to allocation of a closure. auto foo_static(int a, bool b) @nogc { static struct SInside {} SInside res; lazyfun(a); return res; } // Test that returning a local _non-static_ struct that does not reference any local variable does not lead to allocation of a closure. auto foo_nonstatic(int a, bool b) @nogc { struct SInside {} SInside res; lazyfun(a); return res; } // Test that returning a local non-static struct that references a local variable does lead to allocation of a closure. static assert(!__traits(compiles, () @nogc => goo(1))); static assert(__traits(compiles, () => goo(1))); auto goo(T)(T a) { struct SInside { T foo() { return a; } } SInside res; lazyfun(a); return res; } ./ldc-1.42.0-src/tests/dmd/compilable/testDIP42.d0000644000175000017500000000503415205374126020057 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: // enum ident(tpl) = Initializer; enum isIntegral(T) = is(T == int) || is(T == long); static assert( isIntegral!int); static assert( isIntegral!long); static assert(!isIntegral!double); static assert(!isIntegral!(int[])); version(none) { enum allSatisfy(alias pred, TL...) = TL.length == 0 || (pred!(TL[0]) && allSatisfy!(pred, TL[1..$])), anySatisfy(alias pred, TL...) = TL.length != 0 && (pred!(TL[0]) || anySatisfy!(pred, TL[1..$])) || false; static assert( allSatisfy!(isIntegral, int, long)); static assert(!allSatisfy!(isIntegral, int, double)); static assert( anySatisfy!(isIntegral, int, double)); static assert(!anySatisfy!(isIntegral, int[], double)); } void test1() { // statement enum isIntegral2(T) = is(T == int) || is(T == long); static assert(isIntegral2!int); } /******************************************/ // alias ident(tpl) = Type; alias TypeTuple(TL...) = TL; static assert(is(TypeTuple!(int, long)[0] == int)); static assert(is(TypeTuple!(int, long)[1] == long)); alias Id(T) = T, Id(alias A) = A; static assert(is(Id!int == int)); static assert(__traits(isSame, Id!TypeTuple, TypeTuple)); void test2() { // statement alias TypeTuple2(TL...) = TL; static assert(is(TypeTuple2!(int, long)[0] == int)); static assert(is(TypeTuple2!(int, long)[1] == long)); alias IdT(T) = T, IdA(alias A) = A; static assert(is(IdT!int == int)); static assert(__traits(isSame, IdA!TypeTuple, TypeTuple)); } /******************************************/ // template auto declaration auto tynameLen(T) = T.stringof.length; void test3() { assert(tynameLen!int == 3); assert(tynameLen!long == 4); tynameLen!int = 4; tynameLen!long = 5; assert(tynameLen!int == 4); assert(tynameLen!long == 5); // statement auto tynameLen2(T) = T.stringof.length; assert(tynameLen2!int == 3); assert(tynameLen2!long == 4); tynameLen2!int = 4; tynameLen2!long = 5; assert(tynameLen2!int == 4); assert(tynameLen2!long == 5); } /******************************************/ // template variable declaration static T math_pi(T) = cast(T)3.1415; enum bool isFloatingPoint(T) = is(T == float) || is(T == double); static assert( isFloatingPoint!double); static assert(!isFloatingPoint!string); void main() { assert(math_pi!int == 3); assert(math_pi!double == 3.1415); enum bool isFloatingPoint2(T) = is(T == float) || is(T == double); static assert( isFloatingPoint2!double); static assert(!isFloatingPoint2!string); } ./ldc-1.42.0-src/tests/dmd/compilable/test22226.d0000644000175000017500000000030515205374126017746 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22226 struct A {} A move(A a) { return A.init; } struct SumType { A a; this(A value) { a = __ctfe ? value : move(value); } } ./ldc-1.42.0-src/tests/dmd/compilable/test19809.d0000644000175000017500000000037215205374126017767 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19809 mixin template Impl(M...) { int opCmp(Object o) { return 0; } } class C { override { int function(int) fp = ((int x) => x); mixin Impl!("x", "y", ((int x) => x)); } } ./ldc-1.42.0-src/tests/dmd/compilable/ice11300.d0000644000175000017500000000016115205374126017516 0ustar fabiofabio// PERMUTE_ARGS: // EXTRA_FILES: imports/ice11300a.d module ice11300; import imports.ice11300a; enum value = 42; ./ldc-1.42.0-src/tests/dmd/compilable/test18584.d0000644000175000017500000000025115205374126017762 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=18584 struct S { int n; auto fun() { return tmp!(a => n)(); } } struct tmp(alias fns) { alias fun = fns!int; } ./ldc-1.42.0-src/tests/dmd/compilable/test17819.d0000644000175000017500000000071515205374126017767 0ustar fabiofabiostatic if (__traits(allMembers, __traits(parent,{}))[0]=="object") { enum test = 0; } static foreach (m; __traits(allMembers, __traits(parent,{}))) { mixin("enum new"~m~"=`"~m~"`;"); } static assert([__traits(allMembers, __traits(parent,{}))] == ["object", "test", "newobject", "newWorld", "newBuildStuff", "World", "BuildStuff"]); struct World { mixin BuildStuff; } template BuildStuff() { static foreach(elem; __traits(allMembers, typeof(this))) {} } ./ldc-1.42.0-src/tests/dmd/compilable/dtoh_unittest_block.d0000644000175000017500000000045115205374126022442 0ustar fabiofabio/* REQUIRED_ARGS: -HC -c -o- PERMUTE_ARGS: TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler #pragma once #include #include #include #include --- */ unittest { extern (C++) int foo(int x) { return x * 42; } } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc4162.d0000644000175000017500000000035415205374126017623 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /// interface A { /// static void staticHello() { } /// final void hello() { } } void main() { } ./ldc-1.42.0-src/tests/dmd/compilable/Test16206.d0000644000175000017500000000132515205374126017712 0ustar fabiofabiostruct S { static int foo()() { return 0; } static int foo()(int n) { return 1; } static int foo(string s) { return 2; } enum foo(int[] arr) = arr.length; } alias AliasSeq(T...) = T; alias allFoos = AliasSeq!(__traits(getOverloads, S, "foo", true)); static assert(allFoos.length == 4); static assert(allFoos[0]("") == 2); static assert(allFoos[1]() == 0); static assert(allFoos[2](1) == 1); alias foo3 = allFoos[3]; static assert(foo3!([]) == 0); static assert(S.foo() == 0); static assert(S.foo(1) == 1); static assert(S.foo("") == 2); static assert(S.foo!([]) == 0); alias fooFuns = AliasSeq!(__traits(getOverloads, S, "foo")); static assert(fooFuns.length == 1); static assert(fooFuns[0]("") == 2); ./ldc-1.42.0-src/tests/dmd/compilable/test2991.d0000644000175000017500000000021115205374126017671 0ustar fabiofabio// EXTRA_FILES: imports/test2991.d module test2991; void foo() { } class C { import imports.test2991; void bar() { foo(); } } ./ldc-1.42.0-src/tests/dmd/compilable/test19224.d0000644000175000017500000000062515205374126017757 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19224 static if (__traits(compiles, __vector(float[4]))) { float sum(const float[4] val) { float sum = 0; foreach (x; val) sum += x; return sum; } alias float4 = __vector(float[4]); enum x = sum(float4.init.array); static assert(x is float.nan); enum y = sum(float4(1).array); static assert(y == 4); } ./ldc-1.42.0-src/tests/dmd/compilable/transition_in.d0000644000175000017500000000076415205374126021262 0ustar fabiofabio// REQUIRED_ARGS: -transition=in /* TRANSFORM_OUTPUT: remove_lines(druntime) TEST_OUTPUT: --- compilable/transition_in.d(3): Usage of 'in' on parameter compilable/transition_in.d(3): Usage of 'in' on parameter compilable/transition_in.d(8): Usage of 'in' on parameter compilable/transition_in.d(13): Usage of 'in' on parameter --- */ #line 1 struct Foobar { void bar (in int a, in Object c); } version (none) { void barfoo (in string arg); } void main () { void nested (in char c) {} } ./ldc-1.42.0-src/tests/dmd/compilable/inliner.d0000644000175000017500000000041315205374126020031 0ustar fabiofabio// REQUIRED_ARGS: -inline -O -unittest struct Cent { ulong lo; ulong hi; } Cent add(Cent, Cent); Cent sub(Cent c1, Cent c2) { return add(c1, c2); } Cent udivmod(Cent c3, Cent c4) { Cent quotient; Cent rem = sub(c3, c4); return quotient; } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc9764.sh0000755000175000017500000000027715205374126020036 0ustar fabiofabio#!/usr/bin/env bash output_html=${OUTPUT_BASE}.html rm_retry ${output_html} $DMD -m${MODEL} -D -o- ${EXTRA_FILES}/ddoc9764.dd -Df${output_html} ${EXTRA_FILES}/ddocAny-postscript.sh 9764 ./ldc-1.42.0-src/tests/dmd/compilable/mangle1.d0000644000175000017500000000174215205374126017723 0ustar fabiofabio//spaces __gshared pragma(mangle, "test 9") ubyte test9_1; __gshared extern pragma(mangle, "test 9") ubyte test9_1_e; //\n chars __gshared pragma(mangle, "test\\\n9") ubyte test9_2; __gshared extern pragma(mangle, "test\\\n9") ubyte test9_2_e; //\a chars __gshared pragma(mangle, "test\a9") ubyte test9_3; __gshared extern pragma(mangle, "test\a9") ubyte test9_3_e; //\x01 chars __gshared pragma(mangle, "test\x019") ubyte test9_4; __gshared extern pragma(mangle, "test\x019") ubyte test9_4_e; //\xff chars __gshared pragma(mangle, "test\xff9") ubyte test9_6; __gshared extern pragma(mangle, "test\xff9") ubyte test9_6_e; //unicode __gshared pragma(mangle, "😀ÀÁÂÃÄÅßàáâãäaåbæçèéêcëìígîïð7ñ9__òóô4õöÆ3ÇÈÉÊËabcÌÍÎÏÐÑÒÓÔÕÖ😄😅🤣😂_ÿ") ubyte test9_7; __gshared extern pragma(mangle, "😀ÀÁÂÃÄÅßàáâãäaåbæçèéêcëìígîïð7ñ9__òóô4õöÆ3ÇÈÉÊËabcÌÍÎÏÐÑÒÓÔÕÖ😄😅🤣😂_ÿ") ubyte test9_7_e; ./ldc-1.42.0-src/tests/dmd/compilable/test8937.d0000644000175000017500000000254715205374126017715 0ustar fabiofabio mixin template X8937() { int value; } debug = test; void main() { // (static) import statement { static assert(!__traits(compiles, cos(0))); if (true) { static assert(!__traits(compiles, cos(0))); import core.stdc.math; static assert( __traits(compiles, cos(0))); } static assert(!__traits(compiles, cos(0))); if (true) import core.stdc.math; static assert(!__traits(compiles, cos(0))); // fails if (true) static import core.stdc.math; static assert(!__traits(compiles, core.stdc.math.cos(0))); // fails } static assert(!__traits(compiles, cos(0))); // mixin statement { if (true) mixin X8937!(); static assert(!__traits(compiles, value)); // fails } // enum declaration { if (true) enum E { x = 10 } static assert(!__traits(compiles, E)); // fails } // conditional declarations { if (true) static if (true) struct S1 {} static assert(!__traits(compiles, S1)); // fails if (true) version (all) struct S2 {} static assert(!__traits(compiles, S2)); // fails if (true) debug (test) struct S3 {} static assert(!__traits(compiles, S3)); // fails } } ./ldc-1.42.0-src/tests/dmd/compilable/objc_interface_final_19654.d0000644000175000017500000000021315205374126023245 0ustar fabiofabio// EXTRA_OBJC_SOURCES: import core.attribute : selector; extern (Objective-C) interface Bar { final void foo() @selector("foo") {} } ./ldc-1.42.0-src/tests/dmd/compilable/b16346.d0000644000175000017500000000013215205374126017214 0ustar fabiofabioenum A { B } static assert(is(typeof(A.B) == A)); static assert(is(typeof(A(A.B)) == A)); ./ldc-1.42.0-src/tests/dmd/compilable/test13668.d0000644000175000017500000000137015205374126017763 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: /* TEST_OUTPUT: --- AliasSeq!("id", "toString", "toHash", "opCmp", "opEquals", "Monitor", "factory") genProps --- */ class User : Entity!User { int id; } class Entity(T) { pragma(msg, generateProperties!T); /* Compiler runs pragma(msg) in semantic() phase, but it does not insert any members * in this class. Therefore getting __traits(allMembers, User) while evaluating * generateProperties!User should work. */ } template generateProperties(alias To) { string getProperties(alias Ta)() { string toRet = "genProps"; // This line is bad pragma(msg, __traits(allMembers, Ta)); return toRet; } enum generateProperties = getProperties!(To); } ./ldc-1.42.0-src/tests/dmd/compilable/test20138.d0000644000175000017500000000122215205374126017745 0ustar fabiofabioalias C = const int; static assert(is(shared(C) U == shared U) && is(U == C)); static assert(is(shared(C) == shared U, U) && is(U == C)); alias I = inout int; static assert(is(shared(I) U == shared U) && is(U == I)); static assert(is(shared(I) == shared U, U) && is(U == I)); alias IC = inout const int; static assert(is(shared(IC) U == shared U) && is(U == IC)); static assert(is(shared(IC) == shared U, U) && is(U == IC)); alias S = shared int; static assert(is(const(S) U == const U) && is(U == shared int)); static assert(is(inout(S) U == inout U) && is(U == shared int)); static assert(is(inout(const S) U == inout(const U)) && is(U == shared int)); ./ldc-1.42.0-src/tests/dmd/compilable/issue20995.d0000644000175000017500000000023215205374126020131 0ustar fabiofabio/* REQUIRED_ARGS: -preview=dip1021 https://issues.dlang.org/show_bug.cgi?id=20995 */ void foo() @live { throw new Exception(""); } void main () {} ./ldc-1.42.0-src/tests/dmd/compilable/test24013.d0000644000175000017500000000163615205374126017752 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=24013 struct PropDescriptor(T) { void define(T delegate() aGetter, string aName) {} } enum Get; mixin template PropertyPublisherImpl() { void collectPublicationsFromPairs(T)() { foreach (member; __traits(derivedMembers, T)) foreach (overload; __traits(getOverloads, T, member)) { alias Attributes = __traits(getAttributes, overload); static if (Attributes.length != 0) { auto descriptor = new PropDescriptor!size_t; auto dg = &overload; descriptor.define(dg, member); } } } } void main() { class Bar { size_t _field; mixin PropertyPublisherImpl; this() { collectPublicationsFromPairs!Bar; } @Get size_t field() { return _field; } } } ./ldc-1.42.0-src/tests/dmd/compilable/needsmods.d0000644000175000017500000000013715205374126020355 0ustar fabiofabio// ARG_SETS: -i // PERMUTE_ARGS: // LINK: import imports.foofunc2; void main() { foo2(); } ./ldc-1.42.0-src/tests/dmd/compilable/ident_UAX31.d0000644000175000017500000000015215205374126020355 0ustar fabiofabio// REQUIRED_ARGS: -identifiers=UAX31 // verify that the UAX31 identifier set is applied. int øideùnt; ./ldc-1.42.0-src/tests/dmd/compilable/test21831.d0000644000175000017500000000054615205374126017756 0ustar fabiofabio// REQUIRED_ARGS: -de -unittest deprecated struct S21831 { } auto test21831(T)(T t) // error: struct `S21831` is deprecated if (!__traits(isDeprecated, T)) { return T.init; } deprecated auto test21831(T)(T t) if (__traits(isDeprecated, T)) { return T.init; } deprecated unittest { auto b = test21831(S21831()); // instantiated from here } ./ldc-1.42.0-src/tests/dmd/compilable/quadratic.d0000644000175000017500000000143715205374126020355 0ustar fabiofabio/* PERMUTE_ARGS: -O * If not careful, this can produce exponential tree traversal times * when compiling the generated opEquals() function. */ struct Param { bool verbose; bool vcg_ast; bool showColumns; bool vtls; bool vtemplates; bool vgc; bool vfield; bool vcomplex; int useDeprecated; bool stackstomp; bool useUnitTests; bool useInline; bool useDIP25; bool noDIP25; bool useDIP1021; bool release; bool a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z; uint debuglevel; void* debugids; uint versionlevel; void* versionids; const(char)[] defaultlibname; const(char)[] debuglibname; const(char) mscrtlib; void* moduleDeps; int messageStyle = 1; } struct Global { Param params; } ./ldc-1.42.0-src/tests/dmd/compilable/test12979a.d0000644000175000017500000000007015205374126020124 0ustar fabiofabiovoid parse() { asm pure nothrow @nogc @trusted {} } ./ldc-1.42.0-src/tests/dmd/compilable/test19778.d0000644000175000017500000000011415205374126017766 0ustar fabiofabiostruct S { int[] data; } immutable X = S([]); enum len = X.data.length; ./ldc-1.42.0-src/tests/dmd/compilable/test12967.d0000644000175000017500000000437115205374126017770 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: void foo() {} alias F = typeof(foo); const { void block_c() {} } immutable { void block_i() {} } inout { void block_w() {} } shared { void block_s() {} } shared const { void block_sc() {} } shared inout { void block_sw() {} } static assert(is(typeof(block_c) == F)); static assert(is(typeof(block_i) == F)); static assert(is(typeof(block_w) == F)); static assert(is(typeof(block_s) == F)); static assert(is(typeof(block_sc) == F)); static assert(is(typeof(block_sw) == F)); version (all) { const: void label_c() {} } version (all) { immutable: void label_i() {} } version (all) { inout: void label_w() {} } version (all) { shared: void label_s() {} } version (all) { shared const: void label_sc() {} } version (all) { shared inout: void label_sw() {} } static assert(is(typeof(label_c) == F)); static assert(is(typeof(label_i) == F)); static assert(is(typeof(label_w) == F)); static assert(is(typeof(label_s) == F)); static assert(is(typeof(label_sc) == F)); static assert(is(typeof(label_sw) == F)); class C { const { static void block_c() {} } immutable { static void block_i() {} } inout { static void block_w() {} } shared { static void block_s() {} } shared const { static void block_sc() {} } shared inout { static void block_sw() {} } static assert(is(typeof(block_c) == F)); static assert(is(typeof(block_i) == F)); static assert(is(typeof(block_w) == F)); static assert(is(typeof(block_s) == F)); static assert(is(typeof(block_sc) == F)); static assert(is(typeof(block_sw) == F)); version (all) { const: static void label_c() {} } version (all) { immutable: static void label_i() {} } version (all) { inout: static void label_w() {} } version (all) { shared: static void label_s() {} } version (all) { shared const: static void label_sc() {} } version (all) { shared inout: static void label_sw() {} } static assert(is(typeof(label_c) == F)); static assert(is(typeof(label_i) == F)); static assert(is(typeof(label_w) == F)); static assert(is(typeof(label_s) == F)); static assert(is(typeof(label_sc) == F)); static assert(is(typeof(label_sw) == F)); } ./ldc-1.42.0-src/tests/dmd/compilable/ice13968.d0000644000175000017500000000021315205374126017542 0ustar fabiofabio// REQUIRED_ARGS: // PERMUTE_ARGS: union U { bool a; long b; } U test1() { return U(); } U* test2() { return new U(); } ./ldc-1.42.0-src/tests/dmd/compilable/test19499.d0000644000175000017500000000026315205374126017773 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=19499 enum __c_long_double : double; enum A(T : double) = true; enum A(T : __c_long_double) = false; static assert(A!double == true); ./ldc-1.42.0-src/tests/dmd/compilable/test22122.d0000644000175000017500000000133015205374126017740 0ustar fabiofabio// EXTRA_FILES: imports/imp22122.d module imports.test22122; struct S22122 { import imports.imp22122; Variant!(Imp22122)[] array; } void test22122_catch(S22122 s) { try { foreach(elem; s.array) { import imports.imp22122; with(elem.get!Imp22122) { } } } catch (Exception) { } } void test22122_finally(S22122 s) { try { foreach(elem; s.array) { import imports.imp22122; with(elem.get!Imp22122) { } } } finally { } } private struct Variant(T) { union Impl { } auto get(E)() { return Impl(); } } ./ldc-1.42.0-src/tests/dmd/compilable/testDIP37_10421.d0000644000175000017500000000046315205374126020613 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -Icompilable/extra-files // COMPILED_IMPORTS: extra-files/pkgDIP37_10421/algo/package.d // COMPILED_IMPORTS: extra-files/pkgDIP37_10421/algo/mod.d // COMPILED_IMPORTS: extra-files/pkgDIP37_10421/except.d module testDIP37_10421; import pkgDIP37_10421.algo; void main() {} ./ldc-1.42.0-src/tests/dmd/compilable/nogc.d0000644000175000017500000000573315205374126017331 0ustar fabiofabio// REQUIRED_ARGS: -o- /***************** Covariance ******************/ class C1 { void foo() @nogc; void bar(); } class D1 : C1 { override void foo(); // no error override void bar() @nogc; // no error } /******************************************/ // __traits(compiles) static assert(__traits(compiles, new Object())); void foo_compiles() {} @nogc void test_compiles() { auto fp = &foo_compiles; static assert(!__traits(compiles, foo_compiles())); static assert(!__traits(compiles, fp())); static assert(!__traits(compiles, (*fp)())); static assert(!__traits(compiles, [1,2,3])); static assert(!__traits(compiles, [1:1, 2:2])); struct Struct {} static assert(!__traits(compiles, new int)); static assert(!__traits(compiles, new Struct())); static assert(!__traits(compiles, new Object())); int[int] aa; static assert( __traits(compiles, aa[0])); static assert(!__traits(compiles, (aa[0] = 10))); int[] a; static assert(!__traits(compiles, a.length = 1)); static assert(!__traits(compiles, a.length += 1)); static assert(!__traits(compiles, a.length -= 1)); static assert(!__traits(compiles, a ~= 1)); static assert(!__traits(compiles, a ~ a)); } /******************************************/ // https://issues.dlang.org/show_bug.cgi?id=12630 void test12630() @nogc { // All of these declarations should cause no errors. static const ex1 = new Exception("invalid"); //enum ex2 = new Exception("invalid"); static const arr1 = [[1,2], [3, 4]]; enum arr2 = [[1,2], [3, 4]]; //static const aa1 = [1:1, 2:2]; enum aa2 = [1:1, 2:2]; //static const v1 = aa1[1]; enum v2 = aa2[1]; Object o; //static const del1 = (delete o).sizeof; //enum del2 = (delete o).sizeof; int[] a; static const len1 = (a.length = 1).sizeof; enum len2 = (a.length = 1).sizeof; static const cata1 = (a ~= 1).sizeof; enum cata2 = (a ~= 1).sizeof; static const cat1 = (a ~ a).sizeof; enum cat2 = (a ~ a).sizeof; } /******************************************/ // https://issues.dlang.org/show_bug.cgi?id=12642 static if (is(__vector(ulong[2]))) { import core.simd; ulong2 test12642() @nogc { return [0, 0]; } } /******************************************/ // https://issues.dlang.org/show_bug.cgi?id=13550 auto foo13550() @nogc { static int[] bar() { return new int[2]; } return &bar; } // https://issues.dlang.org/show_bug.cgi?id=19285 void f(bool cond, string s) @nogc { auto inner() { return s; } alias Unused1 = typeof(inner); // OK alias Unused2 = typeof(&inner); // (Does not) INFERS GC (anymore) enum Unused3 = __traits(compiles , &inner); } // https://issues.dlang.org/show_bug.cgi?id=24072 version (D_SIMD) void f24072() @nogc { alias int4 = __vector(int[4]); int4 b = cast(int4)[1, 2, 3, 4]; int4 c = cast(int4)[1, 2]; } ./ldc-1.42.0-src/tests/dmd/compilable/ice12956.d0000644000175000017500000000115515205374126017544 0ustar fabiofabio// REQUIRED_ARGS: -o- // PERMUTE_ARGS: template isCallable(T...) { static if (is(typeof(& T[0].opCall) == delegate)) { enum bool isCallable = true; } else static if (is(typeof(& T[0].opCall) V : V*) && is(V == function)) { enum bool isCallable = true; } else enum bool isCallable = false; } @property auto injectChain(Injectors...)() { return &ChainTemplates!(Injectors); } template ChainTemplates(Templates...) { alias Head = Templates[0]; alias Tail = Templates[1..$]; alias Head!(Tail) ChainTemplates; } static assert(!isCallable!(injectChain)); ./ldc-1.42.0-src/tests/dmd/compilable/test313b.d0000644000175000017500000000014315205374126017741 0ustar fabiofabio// REQUIRED_ARGS: -de void test1() { import core.stdc.stdio; core.stdc.stdio.printf(""); } ./ldc-1.42.0-src/tests/dmd/compilable/test23617.d0000644000175000017500000000055315205374126017760 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23617 struct S { void foo() {} } struct Wrapper { size_t currentIndex; S[] arrayOfS; auto opDispatch(string name, T ...)(T t) { return __traits(child, arrayOfS[this.currentIndex], __traits(getMember, S, name))(t); } } void main() { Wrapper w; w.opDispatch!"foo"(); } ./ldc-1.42.0-src/tests/dmd/compilable/test10186.d0000644000175000017500000000033115205374126017747 0ustar fabiofabiostruct S { @disable this(); this(int i) { } } class C { this() { s = S(1); } S s; } class CR { S s; this() { s = S(1); } } void main() { auto c = new C; } ./ldc-1.42.0-src/tests/dmd/compilable/test18493.d0000644000175000017500000000026115205374126017762 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=18493 // REQUIRED_ARGS: -betterC struct S { this(this) { } ~this() { } } struct C { S s1; S s2; } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc_markdown_headings.d0000644000175000017500000000141115205374126023045 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // TEST_OUTPUT_FILE: extra-files/ddoc_markdown_headings.html // OUTPUT_FILES: ${RESULTS_DIR}/compilable/ddoc_markdown_headings.html /++ # ATX-Style Headings # H1 ## H2 ### H3 #### H4 ##### H5 ###### H6 ### headings ## with initial # spaces ## heading with *emphasis* ## heading with trailing `#`'s ####### ## heading with trailing literal ##'s ## heading with another trailing literal# ## heading with backslash-escaped trailing #\## ## Some empty headers: ## # ### ### # Not Headings #hashtag not a heading because there's no space after the `#` ####### Not a heading because it has more than 6 `#`'s \## Not a heading because of the preceeding backslash +/ module ddoc_markdown_headings; ./ldc-1.42.0-src/tests/dmd/compilable/test18821.d0000644000175000017500000000034615205374126017761 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=18821 align(1) struct epoll_event { void* ptr; } template isAllZeroBits(epoll_event value) {} alias isInitAllZeroBits = isAllZeroBits!(epoll_event.init); epoll_event e = { null }; ./ldc-1.42.0-src/tests/dmd/compilable/issue19243.sh0000644000175000017500000000226015205374126020315 0ustar fabiofabio#! /usr/bin/env bash # this test would require -link-defaultlib-shared, which isn't available with BUILD_SHARED_LIBS=OFF # DISABLED: LDC # bypassing this test: # - on windows # - on FreeBSD 32 bits # test fails looling for liborig.so; don't know why but shouldn't block fixing all other platforms # - on Circle CI with no_pic. (need PIC to run the test) if [[ $OS = *"win"* ]]; then exit 0; fi if [[ $OS = *"freebsd"* ]] && [[ $MODEL = *"32"* ]]; then exit 0; fi if [ ${PIC:-1} == "0" ]; then exit 0; fi TEST_DIR=${OUTPUT_BASE} ORIG_D=$TEST_DIR/orig.d ORIG_SO=$TEST_DIR/liborig${SOEXT} OVERRIDE_D=$TEST_DIR/override.d OVERRIDE_SO=$TEST_DIR/liboverride${SOEXT} APP_D=$TEST_DIR/app.d mkdir -p $TEST_DIR cat << EOF | $DMD -m$MODEL -fPIC -shared -of$ORIG_SO - import core.stdc.stdio; extern(C) int func() { printf("liborig\n"); return 1; } EOF cat << EOF | $DMD -m$MODEL -fPIC -shared -of$OVERRIDE_SO - import core.stdc.stdio; extern(C) int func() { printf("liboverride\n"); return 2; } EOF cat << EOF | LD_LIBRARY_PATH=$TEST_DIR $DMD -m$MODEL -L-L$TEST_DIR -L$OVERRIDE_SO -run - extern(C) int func(); pragma(lib, "orig"); void main() { assert(func() == 2); } EOF ./ldc-1.42.0-src/tests/dmd/compilable/test15519_x.d0000644000175000017500000000015015205374126020302 0ustar fabiofabio// EXTRA_FILES: test15519_y.d import test15519_y; extern(C++, ns) { class X { test15519_y.ns.Y v; } } ./ldc-1.42.0-src/tests/dmd/compilable/enumbase.c0000644000175000017500000000101215205374126020163 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22631 enum E : char { A = 3, B }; _Static_assert(sizeof(enum E) == 1, "1"); _Static_assert(A == 3, "2"); // https://issues.dlang.org/show_bug.cgi?id=22705 enum L: long long { L_A = 1, }; enum U: unsigned long long { U_A = 1, }; enum U2: unsigned { U2_A = 1, }; enum U3: unsigned long { U3_A = 1, }; // https://issues.dlang.org/show_bug.cgi?id=23801 enum { X = ~1ull, Y, }; _Static_assert(X == ~1ull, "3"); _Static_assert(Y == ~1ull + 1, "4"); ./ldc-1.42.0-src/tests/dmd/compilable/test22006.d0000644000175000017500000000060715205374126017747 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=22006 void test22006() { alias AliasSeq(TList...) = TList; { alias aseq = AliasSeq!(0, 1, 2, 3); static foreach (ubyte i; 0 .. aseq.length) {} static foreach (ubyte i, x; aseq) {} } { static foreach (ubyte i; 0 .. [0, 1, 2, 3].length) {} static foreach (ubyte i, x; [0, 1, 2, 3]) {} } } ./ldc-1.42.0-src/tests/dmd/compilable/fix17686.d0000644000175000017500000000153315205374126017577 0ustar fabiofabio/* REQUIRED_ARGS: * PERMUTE_ARGS: */ // https://issues.dlang.org/show_bug.cgi?id=17686 interface INode { @property INode parentNode(); @property IDocument ownerDocument(); } interface IDocument: INode {} interface IEntityReference: INode {} class DOMImplementation(T) { abstract class Node: INode { override { @property Node parentNode() { return null; } @property Document ownerDocument() { return null; } } @property bool readonly() { return true; } } abstract class NodeWithChildren: Node {} class Document: NodeWithChildren, IDocument {} class EntityReference: NodeWithChildren, IEntityReference { override { @property bool readonly() { return true; } } } } void main() { alias aaa = DOMImplementation!string; } ./ldc-1.42.0-src/tests/dmd/compilable/99bottles.d0000644000175000017500000003260715205374126020241 0ustar fabiofabio// written by Don Clugston: // https://www.digitalmars.com/d/archives/digitalmars/D/announce/4374.html // http://www.99-bottles-of-beer.net/language-d-1212.html // Generates the "99 bottles of beer" song at compile time, // using the template metaprograming facilities of D. // No executable is generated. No libraries are used. // Illustrates template default values, template string value parameters, // compile-time concatenation of constant strings, static if. module bottles99; template decimaldigit(int n) { const string decimaldigit = "0123456789"[n..n+1]; } template itoa(ulong n) { static if ( n < 10L ) const string itoa = decimaldigit!(n); else const string itoa = itoa!( n / 10L ) ~ decimaldigit!( n % 10L ); } template showHowMany(int n, string where, bool needcapital = false) { static if ( n > 1 ) const string showHowMany = itoa!(n) ~ " bottles of beer" ~ where ~ "\n"; else static if ( n == 1 ) const string showHowMany = "1 bottle of beer" ~ where ~ "\n"; else static if ( needcapital ) const string showHowMany = "No more bottles of beer" ~ where ~ "\n"; else const string showHowMany = "no more bottles of beer" ~ where ~ "\n"; } template beer(int maxbeers, int n = maxbeers) { static if ( n > 0 ) const string beer = showHowMany!(n, " on the wall,", true) ~ showHowMany!(n, ".") ~ "Take one down and pass it around," ~ "\n" ~ showHowMany!( n - 1 , " on the wall.") ~ "\n" ~ beer!(maxbeers, n - 1); // recurse for subsequent verses. else const string beer = showHowMany!(n, " on the wall,", true) ~ showHowMany!(n, ".") ~ "Go to the store and buy some more," ~ "\n" ~ showHowMany!( maxbeers, " on the wall."); } enum expected = `99 bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, 98 bottles of beer on the wall. 98 bottles of beer on the wall, 98 bottles of beer. Take one down and pass it around, 97 bottles of beer on the wall. 97 bottles of beer on the wall, 97 bottles of beer. Take one down and pass it around, 96 bottles of beer on the wall. 96 bottles of beer on the wall, 96 bottles of beer. Take one down and pass it around, 95 bottles of beer on the wall. 95 bottles of beer on the wall, 95 bottles of beer. Take one down and pass it around, 94 bottles of beer on the wall. 94 bottles of beer on the wall, 94 bottles of beer. Take one down and pass it around, 93 bottles of beer on the wall. 93 bottles of beer on the wall, 93 bottles of beer. Take one down and pass it around, 92 bottles of beer on the wall. 92 bottles of beer on the wall, 92 bottles of beer. Take one down and pass it around, 91 bottles of beer on the wall. 91 bottles of beer on the wall, 91 bottles of beer. Take one down and pass it around, 90 bottles of beer on the wall. 90 bottles of beer on the wall, 90 bottles of beer. Take one down and pass it around, 89 bottles of beer on the wall. 89 bottles of beer on the wall, 89 bottles of beer. Take one down and pass it around, 88 bottles of beer on the wall. 88 bottles of beer on the wall, 88 bottles of beer. Take one down and pass it around, 87 bottles of beer on the wall. 87 bottles of beer on the wall, 87 bottles of beer. Take one down and pass it around, 86 bottles of beer on the wall. 86 bottles of beer on the wall, 86 bottles of beer. Take one down and pass it around, 85 bottles of beer on the wall. 85 bottles of beer on the wall, 85 bottles of beer. Take one down and pass it around, 84 bottles of beer on the wall. 84 bottles of beer on the wall, 84 bottles of beer. Take one down and pass it around, 83 bottles of beer on the wall. 83 bottles of beer on the wall, 83 bottles of beer. Take one down and pass it around, 82 bottles of beer on the wall. 82 bottles of beer on the wall, 82 bottles of beer. Take one down and pass it around, 81 bottles of beer on the wall. 81 bottles of beer on the wall, 81 bottles of beer. Take one down and pass it around, 80 bottles of beer on the wall. 80 bottles of beer on the wall, 80 bottles of beer. Take one down and pass it around, 79 bottles of beer on the wall. 79 bottles of beer on the wall, 79 bottles of beer. Take one down and pass it around, 78 bottles of beer on the wall. 78 bottles of beer on the wall, 78 bottles of beer. Take one down and pass it around, 77 bottles of beer on the wall. 77 bottles of beer on the wall, 77 bottles of beer. Take one down and pass it around, 76 bottles of beer on the wall. 76 bottles of beer on the wall, 76 bottles of beer. Take one down and pass it around, 75 bottles of beer on the wall. 75 bottles of beer on the wall, 75 bottles of beer. Take one down and pass it around, 74 bottles of beer on the wall. 74 bottles of beer on the wall, 74 bottles of beer. Take one down and pass it around, 73 bottles of beer on the wall. 73 bottles of beer on the wall, 73 bottles of beer. Take one down and pass it around, 72 bottles of beer on the wall. 72 bottles of beer on the wall, 72 bottles of beer. Take one down and pass it around, 71 bottles of beer on the wall. 71 bottles of beer on the wall, 71 bottles of beer. Take one down and pass it around, 70 bottles of beer on the wall. 70 bottles of beer on the wall, 70 bottles of beer. Take one down and pass it around, 69 bottles of beer on the wall. 69 bottles of beer on the wall, 69 bottles of beer. Take one down and pass it around, 68 bottles of beer on the wall. 68 bottles of beer on the wall, 68 bottles of beer. Take one down and pass it around, 67 bottles of beer on the wall. 67 bottles of beer on the wall, 67 bottles of beer. Take one down and pass it around, 66 bottles of beer on the wall. 66 bottles of beer on the wall, 66 bottles of beer. Take one down and pass it around, 65 bottles of beer on the wall. 65 bottles of beer on the wall, 65 bottles of beer. Take one down and pass it around, 64 bottles of beer on the wall. 64 bottles of beer on the wall, 64 bottles of beer. Take one down and pass it around, 63 bottles of beer on the wall. 63 bottles of beer on the wall, 63 bottles of beer. Take one down and pass it around, 62 bottles of beer on the wall. 62 bottles of beer on the wall, 62 bottles of beer. Take one down and pass it around, 61 bottles of beer on the wall. 61 bottles of beer on the wall, 61 bottles of beer. Take one down and pass it around, 60 bottles of beer on the wall. 60 bottles of beer on the wall, 60 bottles of beer. Take one down and pass it around, 59 bottles of beer on the wall. 59 bottles of beer on the wall, 59 bottles of beer. Take one down and pass it around, 58 bottles of beer on the wall. 58 bottles of beer on the wall, 58 bottles of beer. Take one down and pass it around, 57 bottles of beer on the wall. 57 bottles of beer on the wall, 57 bottles of beer. Take one down and pass it around, 56 bottles of beer on the wall. 56 bottles of beer on the wall, 56 bottles of beer. Take one down and pass it around, 55 bottles of beer on the wall. 55 bottles of beer on the wall, 55 bottles of beer. Take one down and pass it around, 54 bottles of beer on the wall. 54 bottles of beer on the wall, 54 bottles of beer. Take one down and pass it around, 53 bottles of beer on the wall. 53 bottles of beer on the wall, 53 bottles of beer. Take one down and pass it around, 52 bottles of beer on the wall. 52 bottles of beer on the wall, 52 bottles of beer. Take one down and pass it around, 51 bottles of beer on the wall. 51 bottles of beer on the wall, 51 bottles of beer. Take one down and pass it around, 50 bottles of beer on the wall. 50 bottles of beer on the wall, 50 bottles of beer. Take one down and pass it around, 49 bottles of beer on the wall. 49 bottles of beer on the wall, 49 bottles of beer. Take one down and pass it around, 48 bottles of beer on the wall. 48 bottles of beer on the wall, 48 bottles of beer. Take one down and pass it around, 47 bottles of beer on the wall. 47 bottles of beer on the wall, 47 bottles of beer. Take one down and pass it around, 46 bottles of beer on the wall. 46 bottles of beer on the wall, 46 bottles of beer. Take one down and pass it around, 45 bottles of beer on the wall. 45 bottles of beer on the wall, 45 bottles of beer. Take one down and pass it around, 44 bottles of beer on the wall. 44 bottles of beer on the wall, 44 bottles of beer. Take one down and pass it around, 43 bottles of beer on the wall. 43 bottles of beer on the wall, 43 bottles of beer. Take one down and pass it around, 42 bottles of beer on the wall. 42 bottles of beer on the wall, 42 bottles of beer. Take one down and pass it around, 41 bottles of beer on the wall. 41 bottles of beer on the wall, 41 bottles of beer. Take one down and pass it around, 40 bottles of beer on the wall. 40 bottles of beer on the wall, 40 bottles of beer. Take one down and pass it around, 39 bottles of beer on the wall. 39 bottles of beer on the wall, 39 bottles of beer. Take one down and pass it around, 38 bottles of beer on the wall. 38 bottles of beer on the wall, 38 bottles of beer. Take one down and pass it around, 37 bottles of beer on the wall. 37 bottles of beer on the wall, 37 bottles of beer. Take one down and pass it around, 36 bottles of beer on the wall. 36 bottles of beer on the wall, 36 bottles of beer. Take one down and pass it around, 35 bottles of beer on the wall. 35 bottles of beer on the wall, 35 bottles of beer. Take one down and pass it around, 34 bottles of beer on the wall. 34 bottles of beer on the wall, 34 bottles of beer. Take one down and pass it around, 33 bottles of beer on the wall. 33 bottles of beer on the wall, 33 bottles of beer. Take one down and pass it around, 32 bottles of beer on the wall. 32 bottles of beer on the wall, 32 bottles of beer. Take one down and pass it around, 31 bottles of beer on the wall. 31 bottles of beer on the wall, 31 bottles of beer. Take one down and pass it around, 30 bottles of beer on the wall. 30 bottles of beer on the wall, 30 bottles of beer. Take one down and pass it around, 29 bottles of beer on the wall. 29 bottles of beer on the wall, 29 bottles of beer. Take one down and pass it around, 28 bottles of beer on the wall. 28 bottles of beer on the wall, 28 bottles of beer. Take one down and pass it around, 27 bottles of beer on the wall. 27 bottles of beer on the wall, 27 bottles of beer. Take one down and pass it around, 26 bottles of beer on the wall. 26 bottles of beer on the wall, 26 bottles of beer. Take one down and pass it around, 25 bottles of beer on the wall. 25 bottles of beer on the wall, 25 bottles of beer. Take one down and pass it around, 24 bottles of beer on the wall. 24 bottles of beer on the wall, 24 bottles of beer. Take one down and pass it around, 23 bottles of beer on the wall. 23 bottles of beer on the wall, 23 bottles of beer. Take one down and pass it around, 22 bottles of beer on the wall. 22 bottles of beer on the wall, 22 bottles of beer. Take one down and pass it around, 21 bottles of beer on the wall. 21 bottles of beer on the wall, 21 bottles of beer. Take one down and pass it around, 20 bottles of beer on the wall. 20 bottles of beer on the wall, 20 bottles of beer. Take one down and pass it around, 19 bottles of beer on the wall. 19 bottles of beer on the wall, 19 bottles of beer. Take one down and pass it around, 18 bottles of beer on the wall. 18 bottles of beer on the wall, 18 bottles of beer. Take one down and pass it around, 17 bottles of beer on the wall. 17 bottles of beer on the wall, 17 bottles of beer. Take one down and pass it around, 16 bottles of beer on the wall. 16 bottles of beer on the wall, 16 bottles of beer. Take one down and pass it around, 15 bottles of beer on the wall. 15 bottles of beer on the wall, 15 bottles of beer. Take one down and pass it around, 14 bottles of beer on the wall. 14 bottles of beer on the wall, 14 bottles of beer. Take one down and pass it around, 13 bottles of beer on the wall. 13 bottles of beer on the wall, 13 bottles of beer. Take one down and pass it around, 12 bottles of beer on the wall. 12 bottles of beer on the wall, 12 bottles of beer. Take one down and pass it around, 11 bottles of beer on the wall. 11 bottles of beer on the wall, 11 bottles of beer. Take one down and pass it around, 10 bottles of beer on the wall. 10 bottles of beer on the wall, 10 bottles of beer. Take one down and pass it around, 9 bottles of beer on the wall. 9 bottles of beer on the wall, 9 bottles of beer. Take one down and pass it around, 8 bottles of beer on the wall. 8 bottles of beer on the wall, 8 bottles of beer. Take one down and pass it around, 7 bottles of beer on the wall. 7 bottles of beer on the wall, 7 bottles of beer. Take one down and pass it around, 6 bottles of beer on the wall. 6 bottles of beer on the wall, 6 bottles of beer. Take one down and pass it around, 5 bottles of beer on the wall. 5 bottles of beer on the wall, 5 bottles of beer. Take one down and pass it around, 4 bottles of beer on the wall. 4 bottles of beer on the wall, 4 bottles of beer. Take one down and pass it around, 3 bottles of beer on the wall. 3 bottles of beer on the wall, 3 bottles of beer. Take one down and pass it around, 2 bottles of beer on the wall. 2 bottles of beer on the wall, 2 bottles of beer. Take one down and pass it around, 1 bottle of beer on the wall. 1 bottle of beer on the wall, 1 bottle of beer. Take one down and pass it around, no more bottles of beer on the wall. No more bottles of beer on the wall, no more bottles of beer. Go to the store and buy some more, 99 bottles of beer on the wall. `; static assert(beer!(99) == expected); ./ldc-1.42.0-src/tests/dmd/compilable/test23169.d0000644000175000017500000000075515205374126017766 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23169 // Issue 23169 - [DIP1000] Mangling does not distinguish return and return scope struct Ptr { int* impl; void* fun0() return scope {return impl;} void* fun1() scope return ref {return impl;} void* fun2() return {return &this;} } static assert(Ptr.fun0.mangleof == "_D9test231693Ptr4fun0MFNjNlZPv"); static assert(Ptr.fun1.mangleof == "_D9test231693Ptr4fun1MFNlNjZPv"); static assert(Ptr.fun2.mangleof == "_D9test231693Ptr4fun2MFNjZPv"); ./ldc-1.42.0-src/tests/dmd/compilable/protection.d0000644000175000017500000000610615205374126020564 0ustar fabiofabio// REQUIRED_ARGS: -de // EXTRA_FILES: imports/protectionimp.d import imports.protectionimp; alias TypeTuple(T...) = T; private { void localF() {} class localC {} struct localS {} union localU {} interface localI {} enum localE { foo } mixin template localMT() {} class localTC(T) {} struct localTS(T) {} union localTU(T) {} interface localTI(T) {} void localTF(T)() {} } void main() { // Private non-template declarations static assert(!__traits(compiles, privF())); static assert(!__traits(compiles, privC)); static assert(!__traits(compiles, privS)); static assert(!__traits(compiles, privU)); static assert(!__traits(compiles, privI)); static assert(!__traits(compiles, privE)); static assert(!__traits(compiles, privMT)); // Private local non-template declarations. static assert( __traits(compiles, localF())); static assert( __traits(compiles, localC)); static assert( __traits(compiles, localS)); static assert( __traits(compiles, localU)); static assert( __traits(compiles, localI)); static assert( __traits(compiles, localE)); static assert( __traits(compiles, localMT)); // Private template declarations. static assert(!__traits(compiles, privTF!int())); static assert(!__traits(compiles, privTC!int)); static assert(!__traits(compiles, privTS!int)); static assert(!__traits(compiles, privTU!int)); static assert(!__traits(compiles, privTI!int)); // Private local template declarations. static assert( __traits(compiles, localTF!int())); static assert( __traits(compiles, localTC!int)); static assert( __traits(compiles, localTS!int)); static assert( __traits(compiles, localTU!int)); static assert( __traits(compiles, localTI!int)); // Public template function with private type parameters. static assert(!__traits(compiles, publF!privC())); static assert(!__traits(compiles, publF!privS())); static assert(!__traits(compiles, publF!privU())); static assert(!__traits(compiles, publF!privI())); static assert(!__traits(compiles, publF!privE())); // Public template function with private alias parameters. static assert(!__traits(compiles, publFA!privC())); static assert(!__traits(compiles, publFA!privS())); static assert(!__traits(compiles, publFA!privU())); static assert(!__traits(compiles, publFA!privI())); static assert(!__traits(compiles, publFA!privE())); // Private alias. static assert(!__traits(compiles, privA)); // Public template mixin. static assert( __traits(compiles, publMT)); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=14169 template staticMap14169(alias fun, T...) { static if (T.length > 0) alias staticMap14169 = TypeTuple!(fun!(T[0]), staticMap14169!(fun, T[1..$])); else alias staticMap14169 = TypeTuple!(); } class C14169 { private struct InnerStruct(string NameS) { alias Name = NameS; } alias DimensionNames = staticMap14169!(GetName14169, InnerStruct!"A"); } ./ldc-1.42.0-src/tests/dmd/compilable/iasm_labeloperand.d0000644000175000017500000000150015205374126022030 0ustar fabiofabio// LLVM mach-o backend: "32-bit absolute addressing is not supported in 64-bit mode" // DISABLED: LDC_not_x86 LDC_osx version (D_InlineAsm_X86) version = TestInlineAsm; else version (D_InlineAsm_X86_64) version = TestInlineAsm; else pragma(msg, "Inline asm not supported, not testing."); version (TestInlineAsm) { void testInlineAsm() { asm { L1: nop; nop; nop; nop; mov EAX, dword ptr L1; // Check back references mov EAX, dword ptr L2; // Check forward references mov EAX, dword ptr DS:L1; // Not really useful in standard use, but who knows. mov EAX, dword ptr FS:L2; // Once again, not really useful, but it is valid. mov EAX, dword ptr CS:L1; // This is what the first test case should implicitly be. L2: nop; nop; nop; nop; } } } ./ldc-1.42.0-src/tests/dmd/compilable/ldc_github_257.d0000644000175000017500000000017315205374126021075 0ustar fabiofabioclass Baz { this(Bar[] a) {} } class Foo { Bar[] foo(){ return []; } } class Bar { Foo bar(){ return null; } } ./ldc-1.42.0-src/tests/dmd/compilable/ddoc14383.d0000644000175000017500000000036115205374126017707 0ustar fabiofabio// PERMUTE_ARGS: // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh /** * Module docs. */ module ddoc14383; /// Ddoc'd unittest unittest { int iShouldAppearInTheDocs; } ./ldc-1.42.0-src/tests/dmd/compilable/test3673.d0000644000175000017500000000143715205374126017702 0ustar fabiofabioclass Base {} class Foo(T) if (is(T == int)) : Base { } class Bar(T) : Base if (is(T == bool)) { } interface OutputRange(T...) if (T.length == 1) { void put(T[0] value); } interface OutputRange(T...) : OutputRange!(T[0]), OutputRange!(T[1 .. $]) if (T.length > 1) { } alias OutputRange!(int, float) OR; class COR : OR { void put(int) { } void put(float) { } } class A {}; class B(T) : A if (true) {} class C(T) if (false) : A {} alias Foo!int FooInt; alias Bar!bool BarBool; static assert(!__traits(compiles, Foo!bool)); static assert(!__traits(compiles, Bar!int)); void main() { auto fi = new FooInt; auto bb = new BarBool; auto cor = new COR; auto a = new A(); auto b = new B!int(); static assert(!__traits(compiles, new C!int())); } ./ldc-1.42.0-src/tests/dmd/compilable/test15780.d0000644000175000017500000000063215205374126017760 0ustar fabiofabio// PERMUTE_ARGS: // https://issues.dlang.org/show_bug.cgi?id=15780 void foo(alias fields)() { foreach(i, field; fields) { enum string a = fields[i]; // OK enum string b = field; // not OK with 2.069.2 ??? } } void main() { foo!(tuple("H", "I"))(); } Tuple!T tuple(T...)(T values) { return Tuple!T(values); } struct Tuple(T...) { T values; alias values this; } ./ldc-1.42.0-src/tests/dmd/compilable/test23082.d0000644000175000017500000000031215205374126017745 0ustar fabiofabio// https://issues.dlang.org/show_bug.cgi?id=23082 /* TEST_OUTPUT: --- bar --- */ void foo()() {} alias bar = foo; void bar() { } void main() { pragma(msg, __traits(parent, main).bar.stringof); } ./ldc-1.42.0-src/tests/dmd/compilable/test16776.d0000644000175000017500000000015215205374126017763 0ustar fabiofabio// ARG_SETS: -i // PERMUTE_ARGS: // LINK: import imports.cstuff3; void main() { int s = squared(2); } ./ldc-1.42.0-src/tests/dmd/compilable/issue23391.d0000644000175000017500000000063615205374126020132 0ustar fabiofabiostruct MyTuple { string s; } inout(string) myfront(inout(string)[] a) { return a[0]; } MyTuple[] myarray(MyZip r) { MyTuple[] result; foreach (e; r) result ~= e; return result; } struct MyZip { bool empty = false; MyTuple front() { return MyTuple([""].myfront); } void popFront() { empty = true; } } static foreach(t; MyZip().myarray) {} ./ldc-1.42.0-src/tests/dmd/compilable/test24130.c0000644000175000017500000000074615205374126017752 0ustar fabiofabio/* * DISABLED: freebsd32 freebsd64 linux32 linux64 osx32 osx64 win64 dragonflybsd openbsd * DISABLED: LDC // LDC's DMD-style inline assembler chokes on lowercase register names etc. */ // https://issues.dlang.org/show_bug.cgi?id=24130 void test(int ShiftCount, int Value) { #ifdef _MSC_VER __asm { mov ecx, ShiftCount mov eax, dword ptr [Value] mov edx, dword ptr [Value+4] shrd eax, edx, cl shr edx, cl } #endif } ./ldc-1.42.0-src/tests/dmd/compilable/testhelp.d0000644000175000017500000000132215205374126020221 0ustar fabiofabio/* DISABLED: LDC REQUIRED_ARGS: -conf=compilable/extra-files/empty.conf --help PERMUTE_ARGS: TEST_OUTPUT: ---- $r:DMD(32|64) D Compiler .*$ Copyright (C) 1999-$n$ by The D Language Foundation, All Rights Reserved written by Walter Bright Documentation: https://dlang.org/ Config file: $p:compilable/extra-files/empty.conf$ Usage: dmd [