Add missing cast for function_ptr arguments

This commit is contained in:
Guillaume Gomez 2024-05-21 16:57:53 +02:00 committed by Antoni Boucher
parent 30ee7ba862
commit ca654047fb
3 changed files with 21 additions and 4 deletions

View File

@ -252,7 +252,19 @@ fn check_ptr_call<'b>(
{
self.context.new_cast(self.location, actual_val, expected_ty)
} else if on_stack_param_indices.contains(&index) {
let ty = actual_val.get_type();
if let Some(pointee_val) = ty.get_pointee()
&& pointee_val != expected_ty
{
let new_val = self.context.new_cast(
self.location,
actual_val,
expected_ty.make_pointer(),
);
new_val.dereference(self.location).to_rvalue()
} else {
actual_val.dereference(self.location).to_rvalue()
}
} else {
assert!(
!((actual_ty.is_vector() && !expected_ty.is_vector())

View File

@ -254,8 +254,13 @@ pub(crate) fn get_static_inner(&self, def_id: DefId, gcc_type: Type<'gcc>) -> LV
}
let is_tls = fn_attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);
let global =
self.declare_global(sym, gcc_type, GlobalKind::Exported, is_tls, fn_attrs.link_section);
let global = self.declare_global(
sym,
gcc_type,
GlobalKind::Exported,
is_tls,
fn_attrs.link_section,
);
if !self.tcx.is_reachable_non_generic(def_id) {
#[cfg(feature = "master")]

View File

@ -16,7 +16,7 @@
#![allow(internal_features)]
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![feature(rustc_private, decl_macro, never_type, trusted_len, hash_raw_entry)]
#![feature(rustc_private, decl_macro, never_type, trusted_len, hash_raw_entry, let_chains)]
#![allow(broken_intra_doc_links)]
#![recursion_limit = "256"]
#![warn(rust_2018_idioms)]