Skip to content

Commit 3086419

Browse files
committedFeb 8, 2018
Fix incorrect type for lib extern static array
1 parent ab8ed5c commit 3086419

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

Diff for: ‎spec/compiler/codegen/lib_spec.cr

+10
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,14 @@ describe "Code gen: lib" do
227227
LibFoo.foo(x)
228228
))
229229
end
230+
231+
it "uses static array in lib extern (#5688)" do
232+
codegen(%(
233+
lib LibFoo
234+
$x : Int32[10]
235+
end
236+
237+
LibFoo.x
238+
))
239+
end
230240
end

Diff for: ‎src/compiler/crystal/codegen/llvm_typer.cr

+6
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,12 @@ module Crystal
452452
end
453453
end
454454

455+
# StaticArray can only be "returned" in lib externs,
456+
# not in C functions, and there it must not be a pointer.
457+
def llvm_c_return_type(type : StaticArrayInstanceType)
458+
llvm_struct_type(type)
459+
end
460+
455461
def llvm_c_return_type(type : NilType)
456462
@llvm_context.void
457463
end

0 commit comments

Comments
 (0)