Skip to content

Commit a106613

Browse files
committed
Fix ICE when calling static and static function pointers
Fixes #8588
1 parent 7503396 commit a106613

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/librustc/middle/trans/callee.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ pub fn trans(bcx: @mut Block, expr: @ast::expr) -> Callee {
132132
ast::def_struct(def_id) => {
133133
fn_callee(bcx, trans_fn_ref(bcx, def_id, ref_expr.id))
134134
}
135+
ast::def_static(*) |
135136
ast::def_arg(*) |
136137
ast::def_local(*) |
137138
ast::def_binding(*) |
@@ -140,7 +141,7 @@ pub fn trans(bcx: @mut Block, expr: @ast::expr) -> Callee {
140141
datum_callee(bcx, ref_expr)
141142
}
142143
ast::def_mod(*) | ast::def_foreign_mod(*) | ast::def_trait(*) |
143-
ast::def_static(*) | ast::def_ty(*) | ast::def_prim_ty(*) |
144+
ast::def_ty(*) | ast::def_prim_ty(*) |
144145
ast::def_use(*) | ast::def_typaram_binder(*) |
145146
ast::def_region(*) | ast::def_label(*) | ast::def_ty_param(*) |
146147
ast::def_self_ty(*) | ast::def_method(*) => {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn f(x: int) -> int { x }
12+
13+
static F: extern fn(int) -> int = f;
14+
static mut G: extern fn(int) -> int = f;
15+
16+
fn main() {
17+
F(42);
18+
unsafe { G(7); }
19+
}

0 commit comments

Comments
 (0)