Skip to content

Commit 6af3a76

Browse files
authored
Fix asmcall macro hygiene. (#338)
1 parent 3785467 commit 6af3a76

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

src/interop/asmcall.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,21 @@ macro asmcall(asm::String, constraints::String, side_effects::Bool,
4343
argtyp::Union{Expr,Type}=:(Tuple{}), args...)
4444
asm_val = Val{Symbol(asm)}()
4545
constraints_val = Val{Symbol(constraints)}()
46-
return esc(:(LLVM.Interop._asmcall($asm_val, $constraints_val,
47-
Val{$side_effects}(), Val{$rettyp}(), Val{$argtyp}(),
48-
$(args...))))
46+
return esc(:($Interop._asmcall($asm_val, $constraints_val,
47+
Val{$side_effects}(), Val{$rettyp}(), Val{$argtyp}(),
48+
$(args...))))
4949
end
5050

5151
# shorthand: no side_effects
5252
macro asmcall(asm::String, constraints::String,
5353
rettyp::Union{Expr,Symbol,Type}=:(Nothing),
5454
argtyp::Union{Expr,Type}=:(Tuple{}), args...)
55-
esc(:(LLVM.Interop.@asmcall $asm $constraints false $rettyp $argtyp $(args...)))
55+
esc(:($Interop.@asmcall $asm $constraints false $rettyp $argtyp $(args...)))
5656
end
5757

5858
# shorthand: no side_effects or constraints
5959
macro asmcall(asm::String,
6060
rettyp::Union{Expr,Symbol,Type}=:(Nothing),
6161
argtyp::Union{Expr,Type}=:(Tuple{}), args...)
62-
esc(:(LLVM.Interop.@asmcall $asm "" $rettyp $argtyp $(args...)))
62+
esc(:($Interop.@asmcall $asm "" $rettyp $argtyp $(args...)))
6363
end

test/interop.jl

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,35 +51,35 @@ end
5151
# only asm
5252

5353
a1() = @asmcall("nop")
54-
@test a1() == nothing
54+
@test a1() === nothing
5555

5656
a2() = @asmcall("nop", Nothing)
57-
@test a2() == nothing
57+
@test a2() === nothing
5858

5959
a3() = @asmcall("nop", Nothing, Tuple{})
60-
@test a3() == nothing
60+
@test a3() === nothing
6161

6262
# asm + constraints
6363

6464
b1() = @asmcall("nop", "")
65-
@test b1() == nothing
65+
@test b1() === nothing
6666

6767
b2() = @asmcall("nop", "", Nothing)
68-
@test b2() == nothing
68+
@test b2() === nothing
6969

7070
b3() = @asmcall("nop", "", Nothing, Tuple{})
71-
@test b3() == nothing
71+
@test b3() === nothing
7272

7373
# asm + constraints + side-effects
7474

7575
c1() = @asmcall("nop", "", false)
76-
@test c1() == nothing
76+
@test c1() === nothing
7777

7878
c2() = @asmcall("nop", "", false, Nothing)
79-
@test c2() == nothing
79+
@test c2() === nothing
8080

8181
c3() = @asmcall("nop", "", false, Nothing, Tuple{})
82-
@test c3() == nothing
82+
@test c3() === nothing
8383

8484
if Sys.ARCH == :x86 || Sys.ARCH == :x86_64
8585

@@ -97,6 +97,18 @@ e1() = @asmcall("mov \$\$1, \$0; mov \$\$2, \$1;", "=r,=r", Tuple{Int16,Int32})
9797

9898
end
9999

100+
@testset "macro hygiene" begin
101+
mod = @eval module $(gensym())
102+
module Inner
103+
using LLVM, LLVM.Interop
104+
end
105+
106+
foo() = Inner.@asmcall("nop")
107+
end
108+
109+
@test mod.foo() === nothing
110+
end
111+
100112
end
101113

102114

0 commit comments

Comments
 (0)