Skip to content

Commit ae33144

Browse files
kulpAatif Syed
authored and
Aatif Syed
committed
tests: Enable a test with a const template param
This should have been added in rust-lang#2155 but was missed then.
1 parent 1bafbfb commit ae33144

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

tests/expectations/tests/template.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ pub struct C {
6464
pub mBConstRef: B<*const ::std::os::raw::c_int>,
6565
pub mPtrRef: B<*mut *mut ::std::os::raw::c_int>,
6666
pub mArrayRef: B<*mut [::std::os::raw::c_int; 1usize]>,
67+
pub mBConstArray: B<[::std::os::raw::c_int; 1usize]>,
6768
}
6869
#[test]
6970
fn bindgen_test_layout_C() {
7071
assert_eq!(
7172
::std::mem::size_of::<C>(),
72-
96usize,
73+
104usize,
7374
concat!("Size of: ", stringify!(C))
7475
);
7576
assert_eq!(
@@ -236,6 +237,18 @@ fn bindgen_test_layout_C() {
236237
stringify!(mArrayRef)
237238
)
238239
);
240+
assert_eq!(
241+
unsafe {
242+
&(*(::std::ptr::null::<C>())).mBConstArray as *const _ as usize
243+
},
244+
96usize,
245+
concat!(
246+
"Offset of field: ",
247+
stringify!(C),
248+
"::",
249+
stringify!(mBConstArray)
250+
)
251+
);
239252
}
240253
impl Default for C {
241254
fn default() -> Self {
@@ -877,6 +890,25 @@ fn __bindgen_test_layout_B_open0_ref_array1_int_close0_instantiation() {
877890
);
878891
}
879892
#[test]
893+
fn __bindgen_test_layout_B_open0_array1_const_int_close0_instantiation() {
894+
assert_eq!(
895+
::std::mem::size_of::<B<[::std::os::raw::c_int; 1usize]>>(),
896+
4usize,
897+
concat!(
898+
"Size of template specialization: ",
899+
stringify!(B<[::std::os::raw::c_int; 1usize]>)
900+
)
901+
);
902+
assert_eq!(
903+
::std::mem::align_of::<B<[::std::os::raw::c_int; 1usize]>>(),
904+
4usize,
905+
concat!(
906+
"Alignment of template specialization: ",
907+
stringify!(B<[::std::os::raw::c_int; 1usize]>)
908+
)
909+
);
910+
}
911+
#[test]
880912
fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation_1() {
881913
assert_eq!(
882914
::std::mem::size_of::<Foo<::std::os::raw::c_int>>(),

tests/headers/template.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ struct C {
3232
B<const int&> mBConstRef;
3333
B<int*&> mPtrRef;
3434
B<int(&)[1]> mArrayRef;
35-
// clang 3.x ignores const in this case, so they generate different
36-
// result than clang 4.0.
37-
// B<const int[1]> mBConstArray;
35+
B<const int[1]> mBConstArray;
3836
};
3937

4038
template<typename T>

0 commit comments

Comments
 (0)