| ... | ... | @@ -3627,22 +3627,25 @@ static TypeTableEntry *analyze_prefix_op_expr(CodeGen *g, ImportTableEntry *impo |
| 3627 | 3627 | expr_node); |
| 3628 | 3628 | if (expr_type->id == TypeTableEntryIdInvalid) { |
| 3629 | 3629 | return expr_type; |
| 3630 | | } else if (expr_type->id == TypeTableEntryIdInt && |
| 3631 | | expr_type->data.integral.is_signed) |
| 3630 | } else if ((expr_type->id == TypeTableEntryIdInt && |
| 3631 | expr_type->data.integral.is_signed) || |
| 3632 | expr_type->id == TypeTableEntryIdFloat || |
| 3633 | expr_type->id == TypeTableEntryIdNumLitInt || |
| 3634 | expr_type->id == TypeTableEntryIdNumLitFloat) |
| 3632 | 3635 | { |
| 3633 | | return expr_type; |
| 3634 | | } else if (expr_type->id == TypeTableEntryIdFloat) { |
| 3635 | | return expr_type; |
| 3636 | | } else if (expr_type->id == TypeTableEntryIdNumLitInt) { |
| 3637 | | return expr_type; |
| 3638 | | } else if (expr_type->id == TypeTableEntryIdNumLitFloat) { |
| 3636 | ConstExprValue *target_const_val = &get_resolved_expr(expr_node)->const_val; |
| 3637 | if (!target_const_val->ok) { |
| 3638 | return expr_type; |
| 3639 | } |
| 3640 | ConstExprValue *const_val = &get_resolved_expr(node)->const_val; |
| 3641 | const_val->ok = true; |
| 3642 | bignum_negate(&const_val->data.x_bignum, &target_const_val->data.x_bignum); |
| 3639 | 3643 | return expr_type; |
| 3640 | 3644 | } else { |
| 3641 | 3645 | add_node_error(g, node, buf_sprintf("invalid negation type: '%s'", |
| 3642 | 3646 | buf_ptr(&expr_type->name))); |
| 3643 | 3647 | return g->builtin_types.entry_invalid; |
| 3644 | 3648 | } |
| 3645 | | // TODO const expr eval |
| 3646 | 3649 | } |
| 3647 | 3650 | case PrefixOpAddressOf: |
| 3648 | 3651 | case PrefixOpConstAddressOf: |