mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fixed bug generating $c += 1 when $c was derived from a pointer but behind a cast.
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
- Compiler assertion when defining a function with return type untyped_list #2368.
|
- Compiler assertion when defining a function with return type untyped_list #2368.
|
||||||
- Compiler assert when using generic parameters list without any parameters. #2369
|
- Compiler assert when using generic parameters list without any parameters. #2369
|
||||||
- Parsing difference between "0x00." and "0X00." literals #2371
|
- Parsing difference between "0x00." and "0X00." literals #2371
|
||||||
|
- Fixed bug generating `$c += 1` when `$c` was derived from a pointer but behind a cast.
|
||||||
|
|
||||||
### Stdlib changes
|
### Stdlib changes
|
||||||
- Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`.
|
- Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`.
|
||||||
|
|||||||
@@ -6764,13 +6764,13 @@ static bool sema_binary_analyse_ct_op_assign(SemaContext *context, Expr *expr, E
|
|||||||
if (!sema_expr_analyse_binary(context, NULL, expr, NULL)) return false;
|
if (!sema_expr_analyse_binary(context, NULL, expr, NULL)) return false;
|
||||||
expr->resolve_status = RESOLVE_DONE;
|
expr->resolve_status = RESOLVE_DONE;
|
||||||
|
|
||||||
if (!sema_cast_const(expr))
|
if (!expr_is_runtime_const(expr))
|
||||||
{
|
{
|
||||||
RETURN_SEMA_ERROR(exprptr(expr->binary_expr.right), "Expected a constant expression.");
|
RETURN_SEMA_ERROR(expr, "Expected this to result in a constant expression.");
|
||||||
}
|
}
|
||||||
|
|
||||||
left_var->var.init_expr = expr;
|
left_var->var.init_expr = expr;
|
||||||
left->type = expr->type;
|
left_var->type = expr->type;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
test/test_suite/compile_time/compile_time_pointer_offset.c3t
Normal file
19
test/test_suite/compile_time/compile_time_pointer_offset.c3t
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
// #target: macos-x64
|
||||||
|
module test;
|
||||||
|
macro checker()
|
||||||
|
{
|
||||||
|
long $b = (iptr) ((uint*) bool.typeid);
|
||||||
|
$b += 1;
|
||||||
|
return $b;
|
||||||
|
}
|
||||||
|
fn int main()
|
||||||
|
{
|
||||||
|
long x = checker();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #expect: test.ll
|
||||||
|
|
||||||
|
%x = alloca i64, align 8
|
||||||
|
store i64 ptrtoint (ptr getelementptr (i8, ptr @"$ct.bool", i64 1) to i64), ptr %x, align 8
|
||||||
|
ret i32 0
|
||||||
Reference in New Issue
Block a user