Skip to content

Commit ddd3131

Browse files
GuillaumeGomezantoyo
authored andcommitted
Add missing cast for function_ptr arguments
1 parent ec1efbf commit ddd3131

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/builder.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,19 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
252252
{
253253
self.context.new_cast(self.location, actual_val, expected_ty)
254254
} else if on_stack_param_indices.contains(&index) {
255-
actual_val.dereference(self.location).to_rvalue()
255+
let ty = actual_val.get_type();
256+
if let Some(pointee_val) = ty.get_pointee()
257+
&& pointee_val != expected_ty
258+
{
259+
let new_val = self.context.new_cast(
260+
self.location,
261+
actual_val,
262+
expected_ty.make_pointer(),
263+
);
264+
new_val.dereference(self.location).to_rvalue()
265+
} else {
266+
actual_val.dereference(self.location).to_rvalue()
267+
}
256268
} else {
257269
assert!(
258270
(!expected_ty.is_vector() || actual_ty.is_vector())

src/consts.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,13 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
254254
}
255255

256256
let is_tls = fn_attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);
257-
let global =
258-
self.declare_global(sym, gcc_type, GlobalKind::Exported, is_tls, fn_attrs.link_section);
257+
let global = self.declare_global(
258+
sym,
259+
gcc_type,
260+
GlobalKind::Exported,
261+
is_tls,
262+
fn_attrs.link_section,
263+
);
259264

260265
if !self.tcx.is_reachable_non_generic(def_id) {
261266
#[cfg(feature = "master")]

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#![allow(internal_features)]
1717
#![doc(rust_logo)]
1818
#![feature(rustdoc_internals)]
19-
#![feature(rustc_private, decl_macro, never_type, trusted_len, hash_raw_entry)]
19+
#![feature(rustc_private, decl_macro, never_type, trusted_len, hash_raw_entry, let_chains)]
2020
#![allow(broken_intra_doc_links)]
2121
#![recursion_limit = "256"]
2222
#![warn(rust_2018_idioms)]

0 commit comments

Comments
 (0)