Skip to content

Commit a00e8b0

Browse files
committed
treat incomplete array as zero length array
fix issue #455
1 parent 7d995d7 commit a00e8b0

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/ir/ty.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -816,15 +816,22 @@ impl Type {
816816
}
817817
// XXX DependentSizedArray is wrong
818818
CXType_VariableArray |
819-
CXType_DependentSizedArray |
820-
CXType_IncompleteArray => {
819+
CXType_DependentSizedArray => {
821820
let inner = Item::from_ty(ty.elem_type().as_ref().unwrap(),
822821
location,
823822
parent_id,
824823
ctx)
825824
.expect("Not able to resolve array element?");
826825
TypeKind::Pointer(inner)
827826
}
827+
CXType_IncompleteArray => {
828+
let inner = Item::from_ty(ty.elem_type().as_ref().unwrap(),
829+
location,
830+
parent_id,
831+
ctx)
832+
.expect("Not able to resolve array element?");
833+
TypeKind::Array(inner, 0)
834+
}
828835
CXType_FunctionNoProto |
829836
CXType_FunctionProto => {
830837
let signature = try!(FunctionSig::from_ty(ty,

tests/expectations/tests/class.rs

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
3232
pub struct C {
3333
pub a: ::std::os::raw::c_int,
3434
pub big_array: [::std::os::raw::c_char; 33usize],
35+
pub zero_length_array: [::std::os::raw::c_char; 0usize],
36+
pub incomplete_array: [::std::os::raw::c_char; 0usize],
3537
}
3638
#[test]
3739
fn bindgen_test_layout_C() {

tests/expectations/tests/var-tracing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct Baz {
3636
}
3737
extern "C" {
3838
#[link_name = "_ZN3Baz3FOOE"]
39-
pub static mut Baz_FOO: *const Bar;
39+
pub static mut Baz_FOO: [Bar; 0usize];
4040
}
4141
#[test]
4242
fn bindgen_test_layout_Baz() {

tests/headers/class.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ class C {
22
int a;
33
// More than rust limits (32)
44
char big_array[33];
5+
char zero_length_array[0];
6+
char incomplete_array[];
57
};
68

79
class WithDtor {

0 commit comments

Comments
 (0)