Skip to content

Commit

Permalink
Fix incorrect type for lib extern static array
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Feb 8, 2018
1 parent ab8ed5c commit 3086419
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spec/compiler/codegen/lib_spec.cr
Expand Up @@ -227,4 +227,14 @@ describe "Code gen: lib" do
LibFoo.foo(x)
))
end

it "uses static array in lib extern (#5688)" do
codegen(%(
lib LibFoo
$x : Int32[10]
end
LibFoo.x
))
end
end
6 changes: 6 additions & 0 deletions src/compiler/crystal/codegen/llvm_typer.cr
Expand Up @@ -452,6 +452,12 @@ module Crystal
end
end

# StaticArray can only be "returned" in lib externs,
# not in C functions, and there it must not be a pointer.
def llvm_c_return_type(type : StaticArrayInstanceType)
llvm_struct_type(type)
end

def llvm_c_return_type(type : NilType)
@llvm_context.void
end
Expand Down

0 comments on commit 3086419

Please sign in to comment.