Skip to content

Commit

Permalink
Fix ICE when calling static and static function pointers
Browse files Browse the repository at this point in the history
Fixes #8588
  • Loading branch information
bytwise committed Aug 18, 2013
1 parent 7503396 commit a106613
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustc/middle/trans/callee.rs
Expand Up @@ -132,6 +132,7 @@ pub fn trans(bcx: @mut Block, expr: @ast::expr) -> Callee {
ast::def_struct(def_id) => {
fn_callee(bcx, trans_fn_ref(bcx, def_id, ref_expr.id))
}
ast::def_static(*) |
ast::def_arg(*) |
ast::def_local(*) |
ast::def_binding(*) |
Expand All @@ -140,7 +141,7 @@ pub fn trans(bcx: @mut Block, expr: @ast::expr) -> Callee {
datum_callee(bcx, ref_expr)
}
ast::def_mod(*) | ast::def_foreign_mod(*) | ast::def_trait(*) |
ast::def_static(*) | ast::def_ty(*) | ast::def_prim_ty(*) |
ast::def_ty(*) | ast::def_prim_ty(*) |
ast::def_use(*) | ast::def_typaram_binder(*) |
ast::def_region(*) | ast::def_label(*) | ast::def_ty_param(*) |
ast::def_self_ty(*) | ast::def_method(*) => {
Expand Down
19 changes: 19 additions & 0 deletions src/test/run-pass/static-function-pointer.rs
@@ -0,0 +1,19 @@
// Copyright 2012 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.

fn f(x: int) -> int { x }

static F: extern fn(int) -> int = f;
static mut G: extern fn(int) -> int = f;

fn main() {
F(42);
unsafe { G(7); }
}

0 comments on commit a106613

Please sign in to comment.