Skip to content

Commit 1ef5ce1

Browse files
committed
---
yaml --- r: 48116 b: refs/heads/incoming c: 514fd3e h: refs/heads/master v: v3
1 parent 3eecc91 commit 1ef5ce1

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: 5f0a123f0d1c8718b015c973b3780bc9353e9159
9+
refs/heads/incoming: 514fd3efecccdaf311ee4549c75d948348f6d319
1010
refs/heads/dist-snap: 8b98e5a296d95c5e832db0756828e5bec31c6f50
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/librustc/middle/trans/consts.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use middle::trans::expr;
2020
use middle::trans::machine;
2121
use middle::trans::type_of;
2222
use middle::ty;
23+
use util::ppaux::{expr_repr, ty_to_str};
2324

2425
use core::libc::c_uint;
2526
use syntax::{ast, ast_util, codemap, ast_map};
@@ -150,6 +151,24 @@ pub fn get_const_val(cx: @CrateContext, def_id: ast::def_id) -> ValueRef {
150151
}
151152

152153
pub fn const_expr(cx: @CrateContext, e: @ast::expr) -> ValueRef {
154+
let ety = ty::expr_ty_adjusted(cx.tcx, e);
155+
let llty = type_of::sizing_type_of(cx, ety);
156+
let llconst = const_expr_unchecked(cx, e);
157+
let csize = machine::llsize_of_alloc(cx, val_ty(llconst));
158+
let tsize = machine::llsize_of_alloc(cx, llty);
159+
if csize != tsize {
160+
unsafe {
161+
llvm::LLVMDumpValue(llconst);
162+
llvm::LLVMDumpValue(C_null(llty));
163+
}
164+
cx.sess.bug(fmt!("const %s of type %s has size %u instead of %u",
165+
expr_repr(cx.tcx, e), ty_to_str(cx.tcx, ety),
166+
csize, tsize));
167+
}
168+
llconst
169+
}
170+
171+
fn const_expr_unchecked(cx: @CrateContext, e: @ast::expr) -> ValueRef {
153172
unsafe {
154173
let _icx = cx.insn_ctxt("const_expr");
155174
return match /*bad*/copy e.node {

0 commit comments

Comments
 (0)