let this = self.eval_context_mut();
let param_env = ty::ParamEnv::reveal_all(); // in Miri this is always the param_env we use... and this.param_env is private.
let callee_abi = f.ty(*this.tcx, param_env).fn_sig(*this.tcx).abi();
- if callee_abi != caller_abi {
+ if this.machine.enforce_abi && callee_abi != caller_abi {
throw_ub_format!(
"calling a function with ABI {} using caller ABI {}",
callee_abi.name(),
Ok(wchars)
}
+
+ /// Check that the ABI is what we expect.
+ fn check_abi<'a>(&self, abi: Abi, exp_abi: Abi) -> InterpResult<'a, ()> {
+ if self.eval_context_ref().machine.enforce_abi && abi != exp_abi {
+ throw_ub_format!(
+ "calling a function with ABI {} using caller ABI {}",
+ exp_abi.name(),
+ abi.name()
+ )
+ }
+ Ok(())
+ }
+
+ fn in_std(&self) -> bool {
+ let this = self.eval_context_ref();
+ this.tcx.def_path(this.frame().instance.def_id()).krate
+ == this.tcx.def_path(this.tcx.lang_items().start_fn().unwrap()).krate
+ }
}
/// Check that the number of args is what we expect.
throw_ub_format!("incorrect number of arguments: got {}, expected {}", args.len(), N)
}
-/// Check that the ABI is what we expect.
-pub fn check_abi<'a>(abi: Abi, exp_abi: Abi) -> InterpResult<'a, ()> {
- if abi == exp_abi {
- Ok(())
- } else {
- throw_ub_format!(
- "calling a function with ABI {} using caller ABI {}",
- exp_abi.name(),
- abi.name()
- )
- }
-}
-
pub fn isolation_error(name: &str) -> InterpResult<'static> {
throw_machine_stop!(TerminationInfo::UnsupportedInIsolation(format!(
"{} not available when isolation is enabled",