mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Compiler assert when passing returning CT failure immediately rethrown #2689.
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
- Incorrectly using LLVMStructType when emitting dynamic functions on MachO #2666
|
- Incorrectly using LLVMStructType when emitting dynamic functions on MachO #2666
|
||||||
- FixedThreadPool join did not work correctly.
|
- FixedThreadPool join did not work correctly.
|
||||||
- Fix bug when creating bool vectors in certain cases.
|
- Fix bug when creating bool vectors in certain cases.
|
||||||
|
- Compiler assert when passing returning CT failure immediately rethrown #2689.
|
||||||
|
|
||||||
### Stdlib changes
|
### Stdlib changes
|
||||||
- Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads.
|
- Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads.
|
||||||
|
|||||||
@@ -2369,6 +2369,12 @@ static inline void llvm_emit_deref(GenContext *c, BEValue *value, Expr *inner, T
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
llvm_emit_expr(c, value, inner);
|
llvm_emit_expr(c, value, inner);
|
||||||
|
if (!c->current_block)
|
||||||
|
{
|
||||||
|
value->type = type_void;
|
||||||
|
*value = (BEValue) { .type = type_void, .kind = BE_VALUE, .value = NULL };
|
||||||
|
return;
|
||||||
|
}
|
||||||
llvm_value_rvalue(c, value);
|
llvm_value_rvalue(c, value);
|
||||||
AlignSize alignment = type_abi_alignment(type);
|
AlignSize alignment = type_abi_alignment(type);
|
||||||
bool is_const = expr_is_const(inner);
|
bool is_const = expr_is_const(inner);
|
||||||
|
|||||||
48
test/test_suite/errors/sure_fail_in_assign.c3t
Normal file
48
test/test_suite/errors/sure_fail_in_assign.c3t
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
// #target: macos-x64
|
||||||
|
module test;
|
||||||
|
import std::io;
|
||||||
|
|
||||||
|
faultdef OH_NO;
|
||||||
|
const int C = 1;
|
||||||
|
|
||||||
|
fn void main()
|
||||||
|
{
|
||||||
|
(void)do_thing();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn void? do_thing()
|
||||||
|
{
|
||||||
|
int* a_value;
|
||||||
|
// Change 'C' below to any integer value and the assert goes away.
|
||||||
|
*a_value = may_fault(C)!;
|
||||||
|
io::printfn("Value: %d", *a_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
macro may_fault($incoming)
|
||||||
|
{
|
||||||
|
$switch $incoming:
|
||||||
|
$case 1: return OH_NO?;
|
||||||
|
$default: return 0;
|
||||||
|
$endswitch
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #expect: test.ll
|
||||||
|
|
||||||
|
%"char[]" = type { ptr, i64 }
|
||||||
|
|
||||||
|
@test.C = local_unnamed_addr constant i32 1, align 4
|
||||||
|
@test.OH_NO = linkonce constant %"char[]" { ptr @test.OH_NO.nameof, i64 11 }, align 8
|
||||||
|
@test.OH_NO.nameof = internal constant [12 x i8] c"test::OH_NO\00", align 1
|
||||||
|
|
||||||
|
define i64 @test.do_thing() #0 {
|
||||||
|
entry:
|
||||||
|
%a_value = alloca ptr, align 8
|
||||||
|
%error_var = alloca i64, align 8
|
||||||
|
store ptr null, ptr %a_value, align 8
|
||||||
|
store i64 ptrtoint (ptr @test.OH_NO to i64), ptr %error_var, align 8
|
||||||
|
br label %guard_block
|
||||||
|
|
||||||
|
guard_block: ; preds = %entry
|
||||||
|
%0 = load i64, ptr %error_var, align 8
|
||||||
|
ret i64 %0
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user