Skip to content

Commit ab49eba

Browse files
authored
[spec/iasm] asm cannot be marked @safe (#3843)
1 parent 4decab6 commit ab49eba

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

spec/iasm.dd

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,28 @@ $(GNAME AsmInstructionList):
4141

4242
$(P Assembler instructions must be located inside an `asm` block.
4343
Like functions, `asm` statements must be anotated with adequate function attributes to be compatible with the caller.
44-
Asm statements attributes must be explicitly defined, they are not infered.
44+
Asm statements attributes must be explicitly defined, they are not inferred.
4545
)
46+
$(P `@safe` is not allowed as an attribute, as the compiler does no safety checking of
47+
assembly statements - use `@trusted` instead.)
4648

49+
$(SPEC_RUNNABLE_EXAMPLE_FAIL
4750
---
48-
void func1() pure nothrow @safe @nogc
51+
void ok() pure nothrow @safe @nogc
4952
{
5053
asm pure nothrow @trusted @nogc
5154
{}
5255
}
5356

54-
void func2() @safe @nogc
57+
void error() @safe @nogc
5558
{
5659
asm @nogc // Error: asm statement is assumed to be @system - mark it with '@trusted' if it is not
5760
{}
61+
asm @safe @nogc // Deprecation: asm statement cannot be @safe, use @trusted instead
62+
{}
5863
}
5964
---
65+
)
6066

6167
$(H2 $(LNAME2 asminstruction, Asm instruction))
6268

0 commit comments

Comments
 (0)