Skip to content

Commit

Permalink
Merge pull request #49176 from Tokazama/llvm-ptr
Browse files Browse the repository at this point in the history
Fix LLVMPtr subtyping
  • Loading branch information
vchuravy authored Mar 31, 2023
2 parents 77de8db + 887ff5a commit cd394eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2739,8 +2739,9 @@ void jl_init_types(void) JL_GC_DISABLED
jl_pointer_typename = ((jl_datatype_t*)jl_unwrap_unionall((jl_value_t*)jl_pointer_type))->name;

// LLVMPtr{T, AS} where {T, AS}
tv = jl_svec2(tvar("T"), tvar("AS"));
jl_svec_t *tv_base = jl_svec1(tvar("T"));
jl_tvar_t *elvar = tvar("T");
tv = jl_svec2(elvar, tvar("AS"));
jl_svec_t *tv_base = jl_svec1(elvar);
jl_llvmpointer_type = (jl_unionall_t*)
jl_new_primitivetype((jl_value_t*)jl_symbol("LLVMPtr"), core,
(jl_datatype_t*)jl_apply_type((jl_value_t*)jl_ref_type, jl_svec_data(tv_base), 1), tv,
Expand Down
2 changes: 2 additions & 0 deletions test/llvmcall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,7 @@ MyStruct(kern) = MyStruct(kern, reinterpret(Core.LLVMPtr{UInt8,1}, 0))
MyStruct() = MyStruct(0)
s = MyStruct()

# ensure LLVMPtr properly subtypes
@test eltype(supertype(Core.LLVMPtr{UInt8,1})) <: UInt8
@test s.kern == 0
@test reinterpret(Int, s.ptr) == 0

0 comments on commit cd394eb

Please sign in to comment.