summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-09-28 21:05:46 +0800
committerJohn Hodge <tpg@mutabah.net>2016-09-28 21:05:46 +0800
commit2b580da3472e3f7f1bc79b3b0766c00010307453 (patch)
tree49337a82244e1f5d6ed07153988b14da16eb31e5 /src
parentd7b52a8373ecf3d1756d627b288c17e10bba5b7d (diff)
downloadmrust-2b580da3472e3f7f1bc79b3b0766c00010307453.tar.gz
Const Eval - Allow pointer casts
Diffstat (limited to 'src')
-rw-r--r--src/hir_conv/constant_evaluation.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/hir_conv/constant_evaluation.cpp b/src/hir_conv/constant_evaluation.cpp
index 286c124f..2d2736fe 100644
--- a/src/hir_conv/constant_evaluation.cpp
+++ b/src/hir_conv/constant_evaluation.cpp
@@ -771,6 +771,7 @@ namespace {
uint64_t mask;
switch(te)
{
+ // Integers mask down
case ::HIR::CoreType::I8:
case ::HIR::CoreType::U8:
mask = 0xFF;
@@ -800,6 +801,15 @@ namespace {
default:
TODO(sp, "RValue::Cast to " << e.type << ", val = " << inval);
}
+ ),
+ // Allow casting any integer value to a pointer (TODO: Ensure that the pointer is sized?)
+ (Pointer,
+ TU_IFLET( ::HIR::Literal, inval, Integer, i,
+ val = ::HIR::Literal(i);
+ )
+ else {
+ BUG(sp, "Invalid cast of " << inval.tag_str() << " to " << e.type);
+ }
)
)
),