Skip to content

ir: Remove an assertion that happens to be invalid. #1290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ir/comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,9 +1290,10 @@ impl CompInfo {
return CXChildVisit_Continue;
}

// Even if this is a definition, we may not be the semantic
// parent, see #1281.
let inner = Item::parse(cur, Some(potential_id), ctx)
.expect("Inner ClassDecl");
assert_eq!(ctx.resolve_item(inner).parent_id(), potential_id);

let inner = inner.expect_type_id(ctx);

Expand Down
74 changes: 74 additions & 0 deletions tests/expectations/tests/issue-1281.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* automatically generated by rust-bindgen */

#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]

#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct bar {
pub u: foo,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct foo {
pub foo: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_foo() {
assert_eq!(
::std::mem::size_of::<foo>(),
4usize,
concat!("Size of: ", stringify!(foo))
);
assert_eq!(
::std::mem::align_of::<foo>(),
4usize,
concat!("Alignment of ", stringify!(foo))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<foo>())).foo as *const _ as usize },
0usize,
concat!("Offset of field: ", stringify!(foo), "::", stringify!(foo))
);
}
#[test]
fn bindgen_test_layout_bar() {
assert_eq!(
::std::mem::size_of::<bar>(),
4usize,
concat!("Size of: ", stringify!(bar))
);
assert_eq!(
::std::mem::align_of::<bar>(),
4usize,
concat!("Alignment of ", stringify!(bar))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<bar>())).u as *const _ as usize },
0usize,
concat!("Offset of field: ", stringify!(bar), "::", stringify!(u))
);
}
pub type bar_t = bar;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct baz {
pub f: foo,
}
#[test]
fn bindgen_test_layout_baz() {
assert_eq!(
::std::mem::size_of::<baz>(),
4usize,
concat!("Size of: ", stringify!(baz))
);
assert_eq!(
::std::mem::align_of::<baz>(),
4usize,
concat!("Alignment of ", stringify!(baz))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<baz>())).f as *const _ as usize },
0usize,
concat!("Offset of field: ", stringify!(baz), "::", stringify!(f))
);
}
11 changes: 11 additions & 0 deletions tests/headers/issue-1281.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
struct foo;

typedef struct bar {
struct foo {
int foo;
} u;
} bar_t;

struct baz {
struct foo f;
};