2020-06-28 00:11:04 +00:00
|
|
|
#![allow(clashing_extern_declarations)]
|
2024-02-16 20:02:50 +00:00
|
|
|
//@ check-pass
|
2019-10-27 23:29:23 +00:00
|
|
|
|
|
|
|
// In this test we check that the parser accepts an ABI string when it
|
2020-03-16 22:36:14 +00:00
|
|
|
// comes from a macro `literal` or `expr` fragment as opposed to a hardcoded string.
|
2019-10-27 23:29:23 +00: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 22:36:14 +00: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 23:29:23 +00:00
|
|
|
mod rust {
|
|
|
|
abi_from_lit_frag!("Rust");
|
|
|
|
}
|
|
|
|
|
|
|
|
mod c {
|
|
|
|
abi_from_lit_frag!("C");
|
|
|
|
}
|
2020-03-16 22:36:14 +00:00
|
|
|
|
|
|
|
mod rust_expr {
|
|
|
|
abi_from_expr_frag!("Rust");
|
|
|
|
}
|
|
|
|
|
|
|
|
mod c_expr {
|
|
|
|
abi_from_expr_frag!("C");
|
|
|
|
}
|