Skip to content

Commit

Permalink
support statics of Option<fn> types
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzlbg committed Oct 30, 2018
1 parent ffb619c commit ee2fd33
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ impl<'a> Generator<'a> {
fn __test_static_{name}() -> {ty};
}}
unsafe {{
same({name} as usize,
same(*(&{name} as *const _ as *const {ty}) as usize,
__test_static_{name}() as usize,
"{name} static");
}}
Expand Down
4 changes: 4 additions & 0 deletions testcrate/src/t1.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ const int16_t* T1_sref = (void*)(1337);
const int32_t* T1_mut_opt_ref = NULL;
int32_t* T1_mut_opt_mut_ref = NULL;
const int32_t* T1_const_opt_const_ref = NULL;

void (*const T1_opt_fn1)(void) = baz;
uint32_t (*(*T1_opt_fn2)(uint8_t))(uint16_t) = nested;
uint32_t (*(*T1_opt_fn3)(uint8_t(*arg0)(uint8_t), uint16_t(*arg1)(uint16_t)))(uint16_t) = nested2;
5 changes: 5 additions & 0 deletions testcrate/src/t1.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ extern const int32_t* T1_mut_opt_ref;
extern int32_t* T1_mut_opt_mut_ref;
extern const int32_t* T1_const_opt_const_ref;

extern void (*const T1_opt_fn1)(void);
uint32_t (*(*T1_opt_fn2)(uint8_t))(uint16_t);
uint32_t (*(*T1_opt_fn3)(uint8_t(*)(uint8_t), uint16_t(*)(uint16_t)))(uint16_t);


struct Q {
uint8_t* q0;
uint8_t** q1;
Expand Down
7 changes: 7 additions & 0 deletions testcrate/src/t1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ extern "C" {
pub static mut T1_mut_opt_ref: Option<&'static i32>;
pub static mut T1_mut_opt_mut_ref: Option<&'static mut i32>;
pub static T1_const_opt_const_ref: Option<&'static i32>;

pub static T1_opt_fn1: Option<unsafe extern "C" fn() -> ()>;
pub static T1_opt_fn2: Option<unsafe extern "C" fn(u8) -> extern "C" fn(u16) -> u32>;
pub static T1_opt_fn3: Option<
unsafe extern "C" fn(extern "C" fn(u8) -> u8, extern "C" fn(u16) -> u16)
-> extern "C" fn(u16) -> u32,
>;
}

#[repr(C)]
Expand Down

0 comments on commit ee2fd33

Please sign in to comment.