diff options
| author | hfcc <42674143+hcff@users.noreply.github.com> | 2018-09-05 23:31:25 +0200 |
|---|---|---|
| committer | hfcc <42674143+hcff@users.noreply.github.com> | 2018-09-05 23:31:25 +0200 |
| commit | 768d1fc539e425280acba5b30256e3b1267ddfbb (patch) | |
| tree | 84ce94293869ea0d9706d9125f7ca38190ec3e97 /src/ir.cpp | |
| parent | ffb3b1576b1c02942bce89ef05eaf05fe2f026ac (diff) | |
| download | zig-768d1fc539e425280acba5b30256e3b1267ddfbb.tar.gz zig-768d1fc539e425280acba5b30256e3b1267ddfbb.zip | |
Added compilation error when a non-float is given to @floatToInt()
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 3184561ebc..e928dc4f7b 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -18497,6 +18497,12 @@ static TypeTableEntry *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrIns if (type_is_invalid(target->value.type)) return ira->codegen->builtin_types.entry_invalid; + if (target->value.type->id != TypeTableEntryIdFloat && target->value.type->id != TypeTableEntryIdComptimeFloat) { + ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", + buf_ptr(&target->value.type->name))); + return ira->codegen->builtin_types.entry_invalid; + } + IrInstruction *result = ir_resolve_cast(ira, &instruction->base, target, dest_type, CastOpFloatToInt, false); ir_link_new_instruction(result, &instruction->base); return dest_type; |
