diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-28 21:05:46 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-28 21:05:46 +0800 |
commit | 2b580da3472e3f7f1bc79b3b0766c00010307453 (patch) | |
tree | 49337a82244e1f5d6ed07153988b14da16eb31e5 /src | |
parent | d7b52a8373ecf3d1756d627b288c17e10bba5b7d (diff) | |
download | mrust-2b580da3472e3f7f1bc79b3b0766c00010307453.tar.gz |
Const Eval - Allow pointer casts
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_conv/constant_evaluation.cpp | 10 |
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); + } ) ) ), |