Skip to content

Commit

Permalink
Fix handling of ignored arguments in FFI wrappers for rust functions
Browse files Browse the repository at this point in the history
Fixes #16441.
  • Loading branch information
dotdash committed Aug 13, 2014
1 parent 9d55421 commit 4df0430
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/librustc/middle/trans/foreign.rs
Expand Up @@ -741,6 +741,12 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
let llforeign_arg_ty = *tys.fn_ty.arg_tys.get(i);
let foreign_indirect = llforeign_arg_ty.is_indirect();

if llforeign_arg_ty.is_ignore() {
debug!("skipping ignored arg #{}", i);
llrust_args.push(C_undef(llrust_ty));
continue;
}

// skip padding
let foreign_index = next_foreign_arg(llforeign_arg_ty.pad.is_some());
let mut llforeign_arg = get_param(llwrapfn, foreign_index);
Expand Down
17 changes: 17 additions & 0 deletions src/test/run-pass/issue-16441.rs
@@ -0,0 +1,17 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

struct Empty;

// This used to cause an ICE
extern "C" fn ice(_a: Empty) {}

fn main() {
}

5 comments on commit 4df0430

@bors
Copy link
Contributor

@bors bors commented on 4df0430 Aug 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from luqmana
at dotdash@4df0430

@bors
Copy link
Contributor

@bors bors commented on 4df0430 Aug 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging dotdash/rust/empty_struct_wrapper_arg = 4df0430 into auto

@bors
Copy link
Contributor

@bors bors commented on 4df0430 Aug 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotdash/rust/empty_struct_wrapper_arg = 4df0430 merged ok, testing candidate = 56b86aa

@bors
Copy link
Contributor

@bors bors commented on 4df0430 Aug 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 56b86aa

Please sign in to comment.