diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index feb65923273a..a3b2db74af4c 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -6d5b853d30908638d49210ebe600917296b8ab9b +cd2034cd7b157dd8f3e94c684061bb1aa630b2b6 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/iasmgcc.c b/gcc/d/dmd/iasmgcc.c index 3c0494d5717c..cecbdefe41a0 100644 --- a/gcc/d/dmd/iasmgcc.c +++ b/gcc/d/dmd/iasmgcc.c @@ -224,7 +224,7 @@ Lerror: static GccAsmStatement *parseGccAsm(Parser *p, GccAsmStatement *s) { s->insn = p->parseExpression(); - if (p->token.value == TOKsemicolon) + if (p->token.value == TOKsemicolon || p->token.value == TOKeof) goto Ldone; // No semicolon followed after instruction template, treat as extended asm. @@ -254,7 +254,7 @@ static GccAsmStatement *parseGccAsm(Parser *p, GccAsmStatement *s) assert(0); } - if (p->token.value == TOKsemicolon) + if (p->token.value == TOKsemicolon || p->token.value == TOKeof) goto Ldone; } Ldone: @@ -288,6 +288,7 @@ Statement *gccAsmSemantic(GccAsmStatement *s, Scope *sc) *ptoklist = NULL; } p.token = *toklist; + p.scanloc = s->loc; // Parse the gcc asm statement. s = parseGccAsm(&p, s); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d0611e3bc37b..373f39d2a8b2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2019-01-14 Iain Buclaw + + * gdc.dg/asm1.d: New test. + * gdc.dg/asm2.d: New test. + * gdc.dg/asm3.d: New test. + * gdc.dg/asm4.d: New test. + * lib/gdc.exp (gdc_init): Set gcc_error_prefix and gcc_warning_prefix. + 2019-01-13 Jerry DeLisle PR libfortran/88776 diff --git a/gcc/testsuite/gdc.dg/asm1.d b/gcc/testsuite/gdc.dg/asm1.d new file mode 100644 index 000000000000..7b00e4d54ec8 --- /dev/null +++ b/gcc/testsuite/gdc.dg/asm1.d @@ -0,0 +1,82 @@ +// { dg-do compile } +module asm1; + +void parse1() +{ + asm + { + ""h; // { dg-error "found 'h' when expecting ':'" } + } +} + +void parse2() +{ + asm + { + "" : : "g" 1 ? 2 : 3; + "" : : "g" 1 ? 2 : : 3; + // { dg-error "expression expected, not ':'" "" { target *-*-* } .-1 } + // { dg-error "expected constant string constraint for operand" "" { target *-*-* } .-2 } + } +} + +void parse3() +{ + asm { "" [; } + // { dg-error "expression expected, not ';'" "" { target *-*-* } .-1 } + // { dg-error "found 'EOF' when expecting ','" "" { target *-*-* } .-2 } + // { dg-error "found 'EOF' when expecting ']'" "" { target *-*-* } .-3 } + // { dg-error "found 'EOF' when expecting ';'" "" { target *-*-* } .-4 } +} + +void semantic1() +{ + { + int one; + L1: + ; + } + asm { "" : : : : L1, L2; } + // { dg-error "goto skips declaration of variable asm1.semantic1.one" "" { target *-*-* } .-1 } + // { dg-error "goto skips declaration of variable asm1.semantic1.two" "" { target *-*-* } .-2 } + { + int two; + L2: + ; + } +} + +void semantic2a(X...)(X expr) +{ + alias X[0] var1; + asm { "%0" : "=m" var1; } // { dg-error "double 'double' is a type, not an lvalue" } +} + +void semantic2() +{ + semantic2a(3.6); // { dg-error "template instance asm1.semantic2a!double error instantiating" } +} + +void semantic3() +{ + asm + { + unknown; // { dg-error "undefined identifier" } + } +} + +struct S4 +{ + template opDispatch(string Name, P...) + { + static void opDispatch(P) {} + } +} + +void semantic4() +{ + asm + { + "%0" : : "m" S4.foo; // { dg-error "template instance opDispatch!\"foo\" has no value" } + } +} diff --git a/gcc/testsuite/gdc.dg/asm2.d b/gcc/testsuite/gdc.dg/asm2.d new file mode 100644 index 000000000000..bce0e41a60fb --- /dev/null +++ b/gcc/testsuite/gdc.dg/asm2.d @@ -0,0 +1,8 @@ +// { dg-do compile } +module asm2; + +void test() +{ + asm const shared { } // { dg-error "const/immutable/shared/inout attributes are not allowed on asm blocks" } +} + diff --git a/gcc/testsuite/gdc.dg/asm3.d b/gcc/testsuite/gdc.dg/asm3.d new file mode 100644 index 000000000000..333d83ec99b7 --- /dev/null +++ b/gcc/testsuite/gdc.dg/asm3.d @@ -0,0 +1,24 @@ +// { dg-do compile } +// { dg-options "-Wall -Wdeprecated -Werror" } +module asm3; + +void test1() nothrow // { dg-error "nothrow function 'asm3.test1' may throw" } +{ + asm { } // { dg-error "asm statement is assumed to throw - mark it with 'nothrow' if it does not" } +} + +void test2() pure +{ + asm { } // { dg-error "asm statement is assumed to be impure - mark it with 'pure' if it is not" } +} + +void test3() @nogc +{ + asm { } // { dg-error "asm statement is assumed to use the GC - mark it with '@nogc' if it does not" } +} + +void test4() @safe +{ + asm { } // { dg-error "asm statement is assumed to be @system - mark it with '@trusted' if it is not" } +} + diff --git a/gcc/testsuite/gdc.dg/asm4.d b/gcc/testsuite/gdc.dg/asm4.d new file mode 100644 index 000000000000..e243c0820ac8 --- /dev/null +++ b/gcc/testsuite/gdc.dg/asm4.d @@ -0,0 +1,40 @@ +// https://issues.dlang.org/show_bug.cgi?id=12979 +// { dg-do compile } +// { dg-options "-Wall -Wdeprecated -Werror" } +module asm4; + +void test1() +{ + asm pure nothrow @nogc @trusted {} + asm @safe {} +} + +void test2() pure nothrow @nogc @safe +{ + asm pure nothrow @nogc @trusted {} +} + +void test3()() +{ + asm pure nothrow @nogc @trusted {} +} + +static assert(__traits(compiles, () pure nothrow @nogc @safe => test3())); + +void test4()() +{ + asm {} +} + +// wait for deprecation of asm pure inference +// static assert(!__traits(compiles, () pure => test4())); +static assert(!__traits(compiles, () nothrow => test4())); +// wait for deprecation of asm @nogc inference +// static assert(!__traits(compiles, () @nogc => test4())); +static assert(!__traits(compiles, () @safe => test4())); + +@safe +void test5() +{ + static assert(!__traits(compiles, { asm { ""; } }() )); +} diff --git a/gcc/testsuite/gdc.test/compilable/deprecate12979a.d b/gcc/testsuite/gdc.test/compilable/deprecate12979a.d deleted file mode 100644 index afe919af13d0..000000000000 --- a/gcc/testsuite/gdc.test/compilable/deprecate12979a.d +++ /dev/null @@ -1,27 +0,0 @@ -// REQUIRED_ARGS: -dw -// PERMUTE_ARGS: - -/* -TEST_OUTPUT: ---- -compilable/deprecate12979a.d(13): Deprecation: asm statement is assumed to throw - mark it with `nothrow` if it does not ---- -*/ - -void foo() nothrow -{ - version(GNU) - { - asm - { - ""; - } - } - else - { - asm - { - ret; - } - } -} diff --git a/gcc/testsuite/gdc.test/compilable/iasm_labeloperand.d b/gcc/testsuite/gdc.test/compilable/iasm_labeloperand.d deleted file mode 100644 index f88fd16511a8..000000000000 --- a/gcc/testsuite/gdc.test/compilable/iasm_labeloperand.d +++ /dev/null @@ -1,48 +0,0 @@ - -version (D_InlineAsm_X86) - version = TestInlineAsm; -else version (D_InlineAsm_X86_64) - version = TestInlineAsm; -else version (GNU) - version = TestInlineAsm; -else - pragma(msg, "Inline asm not supported, not testing."); - -version (TestInlineAsm) -{ - void testInlineAsm() - { - version (GNU) - { - L1: - asm { ""; } - asm { "" : : : : L1, L2; } - L2: - asm { ""; } - } - else - { - 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; - - } - } - } -} diff --git a/gcc/testsuite/gdc.test/compilable/test11471.d b/gcc/testsuite/gdc.test/compilable/test11471.d deleted file mode 100644 index 1df7e80f20a7..000000000000 --- a/gcc/testsuite/gdc.test/compilable/test11471.d +++ /dev/null @@ -1,10 +0,0 @@ -// REQUIRED_ARGS: -profile - -void main() nothrow -{ - // Error: asm statements are assumed to throw - version(GNU) - asm { ""; } - else - asm { nop; } -} diff --git a/gcc/testsuite/gdc.test/compilable/test12979a.d b/gcc/testsuite/gdc.test/compilable/test12979a.d deleted file mode 100644 index 14ca6efc0eed..000000000000 --- a/gcc/testsuite/gdc.test/compilable/test12979a.d +++ /dev/null @@ -1,5 +0,0 @@ -void parse() -{ - asm pure nothrow @nogc @trusted {} - asm @safe {} -} diff --git a/gcc/testsuite/gdc.test/compilable/test12979b.d b/gcc/testsuite/gdc.test/compilable/test12979b.d deleted file mode 100644 index 41c76a251e81..000000000000 --- a/gcc/testsuite/gdc.test/compilable/test12979b.d +++ /dev/null @@ -1,64 +0,0 @@ -// REQUIRED_ARGS: -w -de - -void foo() pure nothrow @nogc @safe -{ - version(GNU) - { - asm pure nothrow @nogc @trusted - { - ""; - } - } - else - { - asm pure nothrow @nogc @trusted - { - ret; - } - } -} - -void bar()() -{ - version(GNU) - { - asm pure nothrow @nogc @trusted - { - ""; - } - } - else - { - asm pure nothrow @nogc @trusted - { - ret; - } - } -} - -static assert(__traits(compiles, () pure nothrow @nogc @safe => bar())); - -void baz()() -{ - version(GNU) - { - asm - { - ""; - } - } - else - { - 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())); diff --git a/gcc/testsuite/gdc.test/fail_compilation/deprecate12979a.d b/gcc/testsuite/gdc.test/fail_compilation/deprecate12979a.d deleted file mode 100644 index 5b2cd56c9f96..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/deprecate12979a.d +++ /dev/null @@ -1,18 +0,0 @@ -// REQUIRED_ARGS: -de -// PERMUTE_ARGS: - -/* -TEST_OUTPUT: ---- -fail_compilation/deprecate12979a.d(14): Deprecation: asm statement is assumed to throw - mark it with `nothrow` if it does not -fail_compilation/deprecate12979a.d(12): Error: nothrow function `deprecate12979a.foo` may throw ---- -*/ - -void foo() nothrow -{ - asm - { - ret; - } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/deprecate12979b.d b/gcc/testsuite/gdc.test/fail_compilation/deprecate12979b.d deleted file mode 100644 index 0d675cb558fe..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/deprecate12979b.d +++ /dev/null @@ -1,17 +0,0 @@ -// REQUIRED_ARGS: -de -// PERMUTE_ARGS: - -/* -TEST_OUTPUT: ---- -fail_compilation/deprecate12979b.d(13): Deprecation: asm statement is assumed to be impure - mark it with 'pure' if it is not ---- -*/ - -void foo() pure -{ - asm - { - ret; - } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/deprecate12979c.d b/gcc/testsuite/gdc.test/fail_compilation/deprecate12979c.d deleted file mode 100644 index 782700469cdb..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/deprecate12979c.d +++ /dev/null @@ -1,17 +0,0 @@ -// REQUIRED_ARGS: -de -// PERMUTE_ARGS: - -/* -TEST_OUTPUT: ---- -fail_compilation/deprecate12979c.d(13): Deprecation: asm statement is assumed to use the GC - mark it with '@nogc' if it does not ---- -*/ - -void foo() @nogc -{ - asm - { - ret; - } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/deprecate12979d.d b/gcc/testsuite/gdc.test/fail_compilation/deprecate12979d.d deleted file mode 100644 index afff5671027a..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/deprecate12979d.d +++ /dev/null @@ -1,16 +0,0 @@ -// PERMUTE_ARGS: - -/* -TEST_OUTPUT: ---- -fail_compilation/deprecate12979d.d(12): Error: asm statement is assumed to be @system - mark it with '@trusted' if it is not ---- -*/ - -void foo() @safe -{ - asm - { - ret; - } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag6717.d b/gcc/testsuite/gdc.test/fail_compilation/diag6717.d deleted file mode 100644 index fe30f898293c..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/diag6717.d +++ /dev/null @@ -1,14 +0,0 @@ -/* -TEST_OUTPUT: ---- -fail_compilation/diag6717.d(12): Error: end of instruction expected, not 'h' ---- -*/ - -void main() -{ - asm - { - mov AX, 12h ; - } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail12635.d b/gcc/testsuite/gdc.test/fail_compilation/fail12635.d deleted file mode 100644 index b00cc47b3009..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/fail12635.d +++ /dev/null @@ -1,21 +0,0 @@ -/* -TEST_OUTPUT: ---- -fail_compilation/fail12635.d(19): Error: Cannot generate a segment prefix for a branching instruction ---- -*/ - -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 - jmp DS:L1; - } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail13938.d b/gcc/testsuite/gdc.test/fail_compilation/fail13938.d deleted file mode 100644 index bd18ef2808f5..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/fail13938.d +++ /dev/null @@ -1,16 +0,0 @@ -// REQUIRED_ARGS: -o- -/* -TEST_OUTPUT: ---- -fail_compilation/fail13938.d(14): Error: cannot directly load TLS variable 'val' ---- -*/ - -void test1() -{ - static int val; - asm - { - mov EAX, val; - } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail13939.d b/gcc/testsuite/gdc.test/fail_compilation/fail13939.d deleted file mode 100644 index 074c22c89aab..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/fail13939.d +++ /dev/null @@ -1,17 +0,0 @@ -// REQUIRED_ARGS: -o- -fPIC -// DISABLED: win32 win64 -/* -TEST_OUTPUT: ---- -fail_compilation/fail13939.d(15): Error: cannot directly load global variable 'val' with PIC code ---- -*/ -version(Windows) static assert(0); -void test1() -{ - __gshared int val; - asm - { - mov EAX, val; - } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail14009.d b/gcc/testsuite/gdc.test/fail_compilation/fail14009.d deleted file mode 100644 index 84f72c27f391..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/fail14009.d +++ /dev/null @@ -1,14 +0,0 @@ -/* -TEST_OUTPUT: ---- -fail_compilation/fail14009.d(12): Error: expression expected not : ---- -*/ - -void main() -{ - asm { - mov EAX, FS: 1 ? 2 : 3; // accepted - mov EAX, FS: 1 ? 2 : : 3; // rejected - } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail152.d b/gcc/testsuite/gdc.test/fail_compilation/fail152.d deleted file mode 100644 index 60cf4ce2782e..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/fail152.d +++ /dev/null @@ -1,29 +0,0 @@ -/* -TEST_OUTPUT: ---- -fail_compilation/fail152.d(15): Error: cannot use type double as an operand ---- -*/ - -// 1028 Segfault using tuple inside asm code. - -void a(X...)(X expr) -{ - alias X[0] var1; - version(GNU) - { - version(X86) asm {"fstpd %0;" : "=m" (var1) : : ;} - else version(X86_64) asm {"fstpd %0;" : "=m" (var1) : : ;} - else static assert(false, "ASM code not implemented for this architecture"); - } - else asm { - //fld double ptr X[0]; // (1) segfaults - fstp double ptr var1; // (2) ICE - } -} - -void main() -{ - a(3.6); -} - diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail2350.d b/gcc/testsuite/gdc.test/fail_compilation/fail2350.d deleted file mode 100644 index deb0ceb6a321..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/fail2350.d +++ /dev/null @@ -1,15 +0,0 @@ -/* -TEST_OUTPUT: ---- -fail_compilation/fail2350.d(8): Error: function fail2350.test2350 naked assembly functions with contracts are not supported ---- -*/ - -void test2350() -in -{ -} -body -{ - asm { naked; } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail274.d b/gcc/testsuite/gdc.test/fail_compilation/fail274.d deleted file mode 100644 index 5fa55962d18f..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/fail274.d +++ /dev/null @@ -1,11 +0,0 @@ -/* -TEST_OUTPUT: ---- -fail_compilation/fail274.d(10): Error: expression expected not ; ---- -*/ - -void main() -{ - asm { inc [; } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail327.d b/gcc/testsuite/gdc.test/fail_compilation/fail327.d deleted file mode 100644 index ab872357bac0..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/fail327.d +++ /dev/null @@ -1,17 +0,0 @@ -/* -TEST_OUTPUT: ---- -fail_compilation/fail327.d(10): Error: asm statement is assumed to be @system - mark it with '@trusted' if it is not ---- -*/ - -@safe void foo() -{ - version(GNU) - { - version(X86) asm {"xor %%EAX,%%EAX" : : : ;} - else version(X86_64) asm {"xor %%EAX,%%EAX" : : : ;} - else static assert(false, "ASM code not implemented for this architecture"); - } - else asm { xor EAX,EAX; } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail3354.d b/gcc/testsuite/gdc.test/fail_compilation/fail3354.d deleted file mode 100644 index bcf6368c4217..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/fail3354.d +++ /dev/null @@ -1,12 +0,0 @@ - -void main() -{ - version(D_InlineAsm_X86) {} - else version(D_InlineAsm_X64) {} - else static assert(0); - - asm { - fldz ST(0), ST(1), ST(2), ST(3); - fld ST(0), ST(1), ST(2), ST(3); - } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail353.d b/gcc/testsuite/gdc.test/fail_compilation/fail353.d deleted file mode 100644 index 56cda779d9fa..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/fail353.d +++ /dev/null @@ -1,42 +0,0 @@ -/* -TEST_OUTPUT: ---- -block displacement of -130 exceeds the maximum offset of -128 to 127. ---- -*/ - -void foo() -{ - enum NOP = 0x9090_9090_9090_9090; - - version(GNU) - { - version(X86) asm { - "L1:" - "dq %0,%0,%0,%0;" - "dq %0,%0,%0,%0;" - "dq %0,%0,%0,%0;" - "dq %0,%0,%0,%0;" - "loop L1;" : "n" (NOP) : : ; - } - else version(X86_64) asm { - "L1:" - "dq %0,%0,%0,%0;" - "dq %0,%0,%0,%0;" - "dq %0,%0,%0,%0;" - "dq %0,%0,%0,%0;" - "loop L1;" : "n" (NOP) : : ; - } - else static assert(false, "ASM code not implemented for this architecture"); - } - else 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; - } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail8168.d b/gcc/testsuite/gdc.test/fail_compilation/fail8168.d deleted file mode 100644 index ed1c307d4bc8..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/fail8168.d +++ /dev/null @@ -1,6 +0,0 @@ -void main() { - asm { - unknown; // wrong opcode - } -} - diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice15239.d b/gcc/testsuite/gdc.test/fail_compilation/ice15239.d deleted file mode 100644 index 6512d858c172..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/ice15239.d +++ /dev/null @@ -1,23 +0,0 @@ -/* -TEST_OUTPUT: ---- -fail_compilation/ice15239.d(21): Error: cannot interpret opDispatch!"foo" at compile time -fail_compilation/ice15239.d(21): Error: bad type/size of operands '__error' ---- -*/ - -struct T -{ - template opDispatch(string Name, P...) - { - static void opDispatch(P) {} - } -} - -void main() -{ - asm - { - call T.foo; - } -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/test12979.d b/gcc/testsuite/gdc.test/fail_compilation/test12979.d deleted file mode 100644 index 95cd3aae1e1a..000000000000 --- a/gcc/testsuite/gdc.test/fail_compilation/test12979.d +++ /dev/null @@ -1,16 +0,0 @@ -// PERMUTE_ARGS: - -/* -TEST_OUTPUT: ---- -fail_compilation/test12979.d(13): Error: const/immutable/shared/inout attributes are not allowed on `asm` blocks ---- -*/ - -void foo() -{ - asm const shared - { - ret; - } -} diff --git a/gcc/testsuite/gdc.test/runnable/argufilem.d b/gcc/testsuite/gdc.test/runnable/argufilem.d deleted file mode 100644 index 44d627005cc9..000000000000 --- a/gcc/testsuite/gdc.test/runnable/argufilem.d +++ /dev/null @@ -1,22 +0,0 @@ -// EXTRA_SOURCES: imports/argufile.d - -// NOTE: The bug only works when main.d and argufile.d are put in -// separate files and compiled like 'dmd main.d argufile.d' -// Also, I'm sure writefln is causing the crash cause when I -// use printf(), it doesn't crash. - -// main.d ------------------------------------------------------- - -import argufile; - -int main(string[] args) -{ - string message = arguments("bob is ", 7, " years old"); - - writefln(message); - - argufile.useargs(); // will crash here - - return 0; -} - diff --git a/gcc/testsuite/gdc.test/runnable/ctorpowtests.d b/gcc/testsuite/gdc.test/runnable/ctorpowtests.d index 2fb458e44f14..b193d3b1e028 100644 --- a/gcc/testsuite/gdc.test/runnable/ctorpowtests.d +++ b/gcc/testsuite/gdc.test/runnable/ctorpowtests.d @@ -5,18 +5,8 @@ int magicVariable() if (__ctfe) return 3; - version(GNU) - { - version(X86) - asm { "nop"; } - else version(X86_64) - asm { "nop"; } - else - static assert(""); - } - else - asm { nop; } - return 2; + shared int var = 2; + return var; } static assert(magicVariable()==3); @@ -122,20 +112,14 @@ struct StructWithCtor float x; } -int containsAsm() { - version(GNU) - { - version(X86) - asm { "nop"; } - else version(X86_64) - asm { "nop"; } - else - static assert(""); - } - else - asm { nop; } - return 0; - } +int containsAsm() +{ + version (D_InlineAsm_X86) + asm { nop; } + else version (D_InlineAsm_X86_64) + asm { nop; } + return 0; +} enum A = StructWithCtor(1); enum B = StructWithCtor(7, 2.3); diff --git a/gcc/testsuite/gdc.test/runnable/imports/argufile.d b/gcc/testsuite/gdc.test/runnable/imports/argufile.d deleted file mode 100644 index 2a85547d8ab4..000000000000 --- a/gcc/testsuite/gdc.test/runnable/imports/argufile.d +++ /dev/null @@ -1,146 +0,0 @@ -// argufile.d ---------------------------------------------------- - -public: - -import core.vararg; -import std.stdio; -import std.utf; - -dstring formatstring(TypeInfo[] arguments, va_list argptr) -{ - - dstring message = null; - - void putc(dchar c) - { - message ~= c; - } - - - doFormat(&putc, arguments, argptr); - - - return message; -} - -string arguments(...) // turns a bunch of arguments into a formatted char[] string -{ - return std.utf.toUTF8(formatstring(_arguments, _argptr)); -} - -void useargs(...) -{ - string crashage = arguments("why is 8 scared of 7? because", 7,8,9); - - //printf("%.*s\n", crashage); - writefln(crashage); -} - - -// dustmited version of the deprecated doFormat. -// See the full file at: -// https://github.com/dlang/undeaD/blob/master/src/undead/doformat.d -void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list ap) -{ - import core.stdc.stdlib : alloca, malloc; - import std.format ; - - size_t bufLength = 1024; - void* argBuffer = malloc(bufLength); - size_t bufUsed ; - foreach (ti; arguments) - { - auto pos = bufUsed; - // Align to next word boundary - bufUsed += ti.tsize + size_t.sizeof - 1; - bufUsed -= bufUsed& size_t.sizeof - 1; - // Copy argument into buffer - va_arg(ap, ti, argBuffer + pos); - } - - auto argptr = argBuffer; - void* skipArg(TypeInfo ti) - { - auto p = argptr; - // Align to next word boundary - argptr += ti.tsize + size_t.sizeof - 1; - argptr -= cast(size_t)argptr & size_t.sizeof - 1; - return p; - } - auto getArg(T)() - { - return *cast(T*)skipArg(typeid(T)); - } - - TypeInfo ti; - Mangle m; - void formatArg() - { - ulong vnumber; - char vchar; - Mangle m2; - int signed ; - string s; - - void putstr(const char[] s) - { - foreach (c; s) - putc(c); - - } - - //printf("formatArg(fc = '%c', m = '%c')\n", fc, m); - int mi; - switch (m) - { - L2: - putstr((&vchar)[0 .. 1]); - return; - - case Mangle.Tint: - signed = 1; - vnumber = getArg!int; - goto Lnumber; - - case Mangle.Tarray: - mi = 10; -while (1) - { - m2 = cast(Mangle)typeid(ti).name[mi]; - switch (m2) - { - case Mangle.Tchar: - s = getArg!string; - putstr(s); - break; - - case Mangle.Timmutable: - mi++; - continue; - - default: - {} - } - return; - } - default: - {} - } - - Lnumber: -; -vchar = cast(char)('0' + vnumber); - goto L2; - } - - for (int j ; j < arguments.length; ) - { - ti = arguments[j++]; - int mi = 9; - do - m = cast(Mangle)typeid(ti).name[mi++]; -while (m == Mangle.Tconst ); - - formatArg; - } -} diff --git a/gcc/testsuite/gdc.test/runnable/test23.d b/gcc/testsuite/gdc.test/runnable/test23.d index 3a7beaf187e8..ee17be0b00fe 100644 --- a/gcc/testsuite/gdc.test/runnable/test23.d +++ b/gcc/testsuite/gdc.test/runnable/test23.d @@ -357,36 +357,22 @@ void test16() void test17() { + version(D_InlineAsm_X86_64) + enum AsmX86 = true; + else version(D_InlineAsm_X86) + enum AsmX86 = true; + else + enum AsmX86 = false; + version (OSX) { } else { - /*const*/ float f = 1.2f; + const f = 1.2f; float g = void; - - version(D_SoftFloat) - { - g = f; - } - else version(GNU) - { - version(X86) asm - { - "flds %1; fstps %0;" : "=m" (g) : "m" (f) : ; - } - else version(X86_64) asm - { - "flds %1; fstps %0;" : "=m" (g) : "m" (f) : ; - } - else version(ARM) asm - { - "vldr d0, %1; vstr d0, %0;" : "=m" (g) : "m" (f), : "d0"; - } - else static assert(false, "ASM code not implemented for this architecture"); - } - else + static if (AsmX86) { asm { @@ -394,6 +380,10 @@ void test17() fstp g; } } + else + { + g = f; + } assert(g == 1.2f); } } diff --git a/gcc/testsuite/gdc.test/runnable/test34.d b/gcc/testsuite/gdc.test/runnable/test34.d index 003024db9777..5c28d0f82524 100644 --- a/gcc/testsuite/gdc.test/runnable/test34.d +++ b/gcc/testsuite/gdc.test/runnable/test34.d @@ -707,24 +707,7 @@ void foo35() c = 3; xxx = cast(typeof(xxx))(a + b); - version(GNU) - { - version(X86) asm - { - "int $3;" : : : ; - } - else version(X86_64) asm - { - "int $3;" : : : ; - } - else - { - import gcc.builtins; - __builtin_trap(); - } - } - else - asm { int 3; } + throw new Exception("xxx"); xxx( 4, 5, 6 ); } diff --git a/gcc/testsuite/gdc.test/runnable/test36.d b/gcc/testsuite/gdc.test/runnable/test36.d deleted file mode 100644 index 9f5b140127d8..000000000000 --- a/gcc/testsuite/gdc.test/runnable/test36.d +++ /dev/null @@ -1,109 +0,0 @@ -// PERMUTE_ARGS: - -import std.stdio; -interface IUnknown{ - extern(Windows): - void func(); -} -class ComObject :IUnknown -{ -extern (Windows): - void func() - {writefln(`comobject`); - } -} -interface IDataObject: IUnknown -{ - extern(Windows): - void method(); -} -package class invarianttest:ComObject, IDataObject -{ - invariant() - { - writefln(`hello invariant`); - } - -extern (Windows): - override void func() - { - int esp; - version(GNU) - { - version(X86) asm - { - "mov %%ESP,%0" : "=r" esp : : ; - } - else version(X86_64) asm - { - "mov %%ESP,%0" : "=r" esp : : ; - } - else version(ARM) asm - { - "str sp,%0" : "=m" esp : : ; - } - else static assert(false, "ASM code not implemented for this architecture"); - } - else asm - { - mov esp,ESP; - } - printf("\n%d",esp); - printf(`func`); - } - void method() - { - writefln(`method`); - } -} -int main() -{ - auto inst= new invarianttest; - int esp; - version(GNU) - { - version(X86) asm - { - "mov %%ESP,%0" : "=r" esp : : ; - } - else version(X86_64) asm - { - "mov %%ESP,%0" : "=r" esp : : ; - } - else version(ARM) asm - { - "str sp,%0" : "=m" esp : : ; - } - else static assert(false, "ASM code not implemented for this architecture"); - } - else asm - { - mov esp,ESP; - } - inst.func(); - inst.method(); - writefln("\n%d",esp); - version(GNU) - { - version(X86) asm - { - "mov %%ESP,%0" : "=r" esp : : ; - } - else version(X86_64) asm - { - "mov %%ESP,%0" : "=r" esp : : ; - } - else version(ARM) asm - { - "str sp,%0" : "=m" esp : : ; - } - else static assert(false, "ASM code not implemented for this architecture"); - } - else asm - { - mov esp,ESP; - } - writefln("\n%d",esp); - return 0; -} - diff --git a/gcc/testsuite/gdc.test/runnable/test42.d b/gcc/testsuite/gdc.test/runnable/test42.d index e75eb70da97b..b9619c992ff1 100644 --- a/gcc/testsuite/gdc.test/runnable/test42.d +++ b/gcc/testsuite/gdc.test/runnable/test42.d @@ -2469,40 +2469,21 @@ bool foo150() void crash(int x) { if (x==200) return; - - version(GNU) - { - version(X86) asm - { - "int $3;" : : :; - } - else version(X86_64) asm - { - "int $3;" : : :; - } - else - { - import gcc.builtins; - __builtin_trap(); - } - } - else - { - asm { int 3; } - } + assert(0); } void test151() { - int x; - bug3521(&x); + int x; + bug3521(&x); } -void bug3521(int *a){ +void bug3521(int *a) +{ int c = 0; *a = 0; if ( *a || (*a != (c = 200)) ) - crash(c); + crash(c); } /***************************************************/ @@ -4236,28 +4217,22 @@ void oddity4001() } /***************************************************/ +// https://issues.dlang.org/show_bug.cgi?id=3809 int bug3809() { - version(GNU) - { - version(X86) - asm { "nop"; } - else version(X86_64) - asm { "nop"; } - else version(ARM) - asm { "nop"; } - else - static assert(false, "ASM code not implemented for this architecture"); - } - else - { - asm { nop; } - } - return 0; + static int a = 0; + return a; } -struct BUG3809 { int xx; } -void bug3809b() { + +struct BUG3809 +{ + int xx; +} + +void bug3809b() +{ + BUG3809 b = { bug3809() }; } /***************************************************/ diff --git a/gcc/testsuite/gdc.test/runnable/testsafe.d b/gcc/testsuite/gdc.test/runnable/testsafe.d index 543fef589ab3..cec4c0f7fa43 100644 --- a/gcc/testsuite/gdc.test/runnable/testsafe.d +++ b/gcc/testsuite/gdc.test/runnable/testsafe.d @@ -207,18 +207,9 @@ void safeexception() @safe void inlineasm() { - version(GNU) - { - version(X86) - static assert(!__traits(compiles, { asm { "nop"; } }() )); - else version(X86_64) - static assert(!__traits(compiles, { asm { "nop"; } }() )); - else version(ARM) - static assert(!__traits(compiles, { asm { "nop"; } }() )); - else - static assert(false, "ASM code not implemented for this architecture"); - } - else + version (D_InlineAsm_X86) + static assert(!__traits(compiles, { asm { int 3; } }() )); + else version (D_InlineAsm_X86_64) static assert(!__traits(compiles, { asm { int 3; } }() )); } diff --git a/gcc/testsuite/lib/gdc.exp b/gcc/testsuite/lib/gdc.exp index e64b7708520e..c749c4c055d6 100644 --- a/gcc/testsuite/lib/gdc.exp +++ b/gcc/testsuite/lib/gdc.exp @@ -192,6 +192,8 @@ proc gdc_init { args } { global GDC_UNDER_TEST global TESTING_IN_BUILD_TREE global TEST_ALWAYS_FLAGS + global gcc_warning_prefix + global gcc_error_prefix # We set LC_ALL and LANG to C so that we get the same error messages as expected. setenv LC_ALL C @@ -250,6 +252,9 @@ proc gdc_init { args } { verbose -log "ALWAYS_DFLAGS set to $ALWAYS_DFLAGS" + set gcc_warning_prefix "warning:" + set gcc_error_prefix "(fatal )?error:" + verbose "gdc is initialized" 3 }