Skip to content
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

Layout test can contain whitespace inside the function name which causes unexpected token error #844

Closed
upsuper opened this issue Jul 23, 2017 · 2 comments
Labels

Comments

@upsuper
Copy link
Contributor

upsuper commented Jul 23, 2017

Input C/C++ Header

template<typename T>
class Foo {
  T* m;
};

class Bar {
  Foo<const char> m;
};

Bindgen Invocation

$ bindgen input.hpp

Actual Results

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Foo<T> {
    pub m: *mut T,
    pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Bar {
    pub m: Foo<::std::os::raw::c_char>,
}
#[test]
fn bindgen_test_layout_Bar() {
    assert_eq!(::std::mem::size_of::<Bar>() , 8usize , concat ! (
               "Size of: " , stringify ! ( Bar ) ));
    assert_eq! (::std::mem::align_of::<Bar>() , 8usize , concat ! (
                "Alignment of " , stringify ! ( Bar ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const Bar ) ) . m as * const _ as usize } ,
                0usize , concat ! (
                "Alignment of field: " , stringify ! ( Bar ) , "::" ,
                stringify ! ( m ) ));
}
impl Clone for Bar {
    fn clone(&self) -> Self { *self }
}
#[test]
fn __bindgen_test_layout_Foo_open0_const char_close0_instantiation() {
    assert_eq!(::std::mem::size_of::<Foo<::std::os::raw::c_char>>() , 8usize ,
               concat ! (
               "Size of template specialization: " , stringify ! (
               Foo<::std::os::raw::c_char> ) ));
    assert_eq!(::std::mem::align_of::<Foo<::std::os::raw::c_char>>() , 8usize
               , concat ! (
               "Alignment of template specialization: " , stringify ! (
               Foo<::std::os::raw::c_char> ) ));
}

The last layout test function contains a whitespace in its name.

Expected Results

It should generate valid function name.

@upsuper
Copy link
Contributor Author

upsuper commented Jul 23, 2017

This is likely a regression from #829. cc @Manishearth

@upsuper
Copy link
Contributor Author

upsuper commented Jul 23, 2017

Pointed by @emilio that this is fixed by a commit in #841.

bors-servo pushed a commit that referenced this issue Jul 23, 2017
Never use spaces in generated name (fixes #844)

None
Manishearth added a commit to Manishearth/rust-bindgen that referenced this issue Jul 23, 2017
bors-servo pushed a commit that referenced this issue Jul 23, 2017
Never use spaces in generated name (fixes #844)

None
bors-servo pushed a commit that referenced this issue Jul 23, 2017
Never use spaces in generated name (fixes #844)

None
Manishearth added a commit to Manishearth/rust-bindgen that referenced this issue Jul 23, 2017
bors-servo pushed a commit that referenced this issue Jul 23, 2017
Never use spaces in generated name (fixes #844)

None
tmfink pushed a commit to tmfink/rust-bindgen that referenced this issue Aug 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant