2020-06-27 19:11:04 -05:00
|
|
|
#![allow(clashing_extern_declarations)]
|
2019-10-27 18:29:23 -05:00
|
|
|
// check-pass
|
|
|
|
|
|
|
|
// In this test we check that the parser accepts an ABI string when it
|
2020-03-16 17:36:14 -05:00
|
|
|
// comes from a macro `literal` or `expr` fragment as opposed to a hardcoded string.
|
2019-10-27 18:29:23 -05:00
|
|
|
|
|
|
|
fn main() {}
|
|
|
|
|
|
|
|
macro_rules! abi_from_lit_frag {
|
|
|
|
($abi:literal) => {
|
|
|
|
extern $abi {
|
|
|
|
fn _import();
|
|
|
|
}
|
|
|
|
|
|
|
|
extern $abi fn _export() {}
|
|
|
|
|
|
|
|
type _PTR = extern $abi fn();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-16 17:36:14 -05:00
|
|
|
macro_rules! abi_from_expr_frag {
|
|
|
|
($abi:expr) => {
|
|
|
|
extern $abi {
|
|
|
|
fn _import();
|
|
|
|
}
|
|
|
|
|
|
|
|
extern $abi fn _export() {}
|
|
|
|
|
|
|
|
type _PTR = extern $abi fn();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-10-27 18:29:23 -05:00
|
|
|
mod rust {
|
|
|
|
abi_from_lit_frag!("Rust");
|
|
|
|
}
|
|
|
|
|
|
|
|
mod c {
|
|
|
|
abi_from_lit_frag!("C");
|
|
|
|
}
|
2020-03-16 17:36:14 -05:00
|
|
|
|
|
|
|
mod rust_expr {
|
|
|
|
abi_from_expr_frag!("Rust");
|
|
|
|
}
|
|
|
|
|
|
|
|
mod c_expr {
|
|
|
|
abi_from_expr_frag!("C");
|
|
|
|
}
|