-6d5b853d30908638d49210ebe600917296b8ab9b
+cd2034cd7b157dd8f3e94c684061bb1aa630b2b6
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
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.
assert(0);
}
- if (p->token.value == TOKsemicolon)
+ if (p->token.value == TOKsemicolon || p->token.value == TOKeof)
goto Ldone;
}
Ldone:
*ptoklist = NULL;
}
p.token = *toklist;
+ p.scanloc = s->loc;
// Parse the gcc asm statement.
s = parseGccAsm(&p, s);
+2019-01-14 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ * 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 <jvdelisle@gcc.gnu.org>
PR libfortran/88776
--- /dev/null
+// { 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" }
+ }
+}
--- /dev/null
+// { dg-do compile }
+module asm2;
+
+void test()
+{
+ asm const shared { } // { dg-error "const/immutable/shared/inout attributes are not allowed on asm blocks" }
+}
+
--- /dev/null
+// { 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" }
+}
+
--- /dev/null
+// 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 { ""; } }() ));
+}
+++ /dev/null
-// 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;
- }
- }
-}
+++ /dev/null
-
-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;
-
- }
- }
- }
-}
+++ /dev/null
-// REQUIRED_ARGS: -profile
-
-void main() nothrow
-{
- // Error: asm statements are assumed to throw
- version(GNU)
- asm { ""; }
- else
- asm { nop; }
-}
+++ /dev/null
-void parse()
-{
- asm pure nothrow @nogc @trusted {}
- asm @safe {}
-}
+++ /dev/null
-// 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()));
+++ /dev/null
-// 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;
- }
-}
+++ /dev/null
-// 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;
- }
-}
+++ /dev/null
-// 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;
- }
-}
+++ /dev/null
-// 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;
- }
-}
+++ /dev/null
-/*
-TEST_OUTPUT:
----
-fail_compilation/diag6717.d(12): Error: end of instruction expected, not 'h'
----
-*/
-
-void main()
-{
- asm
- {
- mov AX, 12h ;
- }
-}
+++ /dev/null
-/*
-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;
- }
-}
+++ /dev/null
-// 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;
- }
-}
+++ /dev/null
-// 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;
- }
-}
+++ /dev/null
-/*
-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
- }
-}
+++ /dev/null
-/*
-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);
-}
-
+++ /dev/null
-/*
-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; }
-}
+++ /dev/null
-/*
-TEST_OUTPUT:
----
-fail_compilation/fail274.d(10): Error: expression expected not ;
----
-*/
-
-void main()
-{
- asm { inc [; }
-}
+++ /dev/null
-/*
-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; }
-}
+++ /dev/null
-
-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);
- }
-}
+++ /dev/null
-/*
-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;
- }
-}
+++ /dev/null
-void main() {
- asm {
- unknown; // wrong opcode
- }
-}
-
+++ /dev/null
-/*
-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;
- }
-}
+++ /dev/null
-// 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;
- }
-}
+++ /dev/null
-// 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;
-}
-
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);
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);
+++ /dev/null
-// 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;
- }
-}
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
{
fstp g;
}
}
+ else
+ {
+ g = f;
+ }
assert(g == 1.2f);
}
}
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 );
}
+++ /dev/null
-// 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;
-}
-
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);
}
/***************************************************/
}
/***************************************************/
+// 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() };
}
/***************************************************/
@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; } }() ));
}
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
verbose -log "ALWAYS_DFLAGS set to $ALWAYS_DFLAGS"
+ set gcc_warning_prefix "warning:"
+ set gcc_error_prefix "(fatal )?error:"
+
verbose "gdc is initialized" 3
}