Skip to content

Commit 3d7ec59

Browse files
committed
Fix for check_ptr_call for variadic functions
1 parent 8560b07 commit 3d7ec59

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

build_sysroot/build_sysroot.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
3030
cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
3131

3232
# Since we can't override the sysroot for the UI tests anymore, we create a new toolchain and manually overwrite the sysroot directory.
33-
rust_toolchain=$(cat ../rust-toolchain | grep channel | sed 's/channel = "\(.*\)"/\1/')
34-
my_toolchain_dir=$HOME/.rustup/toolchains/codegen_gcc_ui_tests-$rust_toolchain-$TARGET_TRIPLE
35-
rm -rf $my_toolchain_dir
36-
cp -r $HOME/.rustup/toolchains/$rust_toolchain-$TARGET_TRIPLE $my_toolchain_dir
37-
rm -rf $my_toolchain_dir/lib/rustlib/$TARGET_TRIPLE/
38-
cp -r ../build_sysroot/sysroot/* $my_toolchain_dir
33+
# TODO: to remove.
34+
#rust_toolchain=$(cat ../rust-toolchain | grep channel | sed 's/channel = "\(.*\)"/\1/')
35+
#my_toolchain_dir=$HOME/.rustup/toolchains/codegen_gcc_ui_tests-$rust_toolchain-$TARGET_TRIPLE
36+
#rm -rf $my_toolchain_dir
37+
#cp -r $HOME/.rustup/toolchains/$rust_toolchain-$TARGET_TRIPLE $my_toolchain_dir
38+
#rm -rf $my_toolchain_dir/lib/rustlib/$TARGET_TRIPLE/
39+
#cp -r ../build_sysroot/sysroot/* $my_toolchain_dir

src/builder.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
181181
})
182182
.collect();
183183

184+
debug_assert_eq!(casted_args.len(), args.len());
185+
184186
Cow::Owned(casted_args)
185187
}
186188

@@ -207,7 +209,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
207209

208210
let func_name = format!("{:?}", func_ptr);
209211

210-
let casted_args: Vec<_> = param_types
212+
let mut casted_args: Vec<_> = param_types
211213
.into_iter()
212214
.zip(args.iter())
213215
.enumerate()
@@ -237,6 +239,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
237239
})
238240
.collect();
239241

242+
// NOTE: to take into account variadic functions.
243+
for i in casted_args.len()..args.len() {
244+
casted_args.push(args[i]);
245+
}
246+
240247
Cow::Owned(casted_args)
241248
}
242249

0 commit comments

Comments
 (0)