mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Assertion failed when casting argument to enum #1196
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
- Casting a slice address to its pointer type should not compile #1193.
|
||||
- Union is not properly zero-initialized with designated initializer #1194.
|
||||
- Compile time fmod evaluates to 0 #1195.
|
||||
- Assertion failed when casting (unsigned) argument to enum #1196
|
||||
|
||||
### Stdlib changes
|
||||
- Add 'zstr' variants for `string::new_format` / `string::tformat`.
|
||||
|
||||
@@ -1576,6 +1576,7 @@ void llvm_emit_cast(GenContext *c, CastKind cast_kind, Expr *expr, BEValue *valu
|
||||
llvm_value_set(value, llvm_zext_trunc(c, value->value, llvm_get_type(c, to_type)), to_type);
|
||||
return;
|
||||
}
|
||||
value->type = type_lowering(to_type);
|
||||
return;
|
||||
case CAST_SABOOL:
|
||||
llvm_value_fold_optional(c, value);
|
||||
|
||||
27
test/test_suite/enumerations/enum_signed_cast_swap.c3t
Normal file
27
test/test_suite/enumerations/enum_signed_cast_swap.c3t
Normal file
@@ -0,0 +1,27 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
enum Abc : char { ABC }
|
||||
|
||||
enum Mouse_Button {
|
||||
LEFT,
|
||||
RIGHT,
|
||||
MIDDLE,
|
||||
}
|
||||
|
||||
fn void foo(Mouse_Button button)
|
||||
{
|
||||
}
|
||||
|
||||
fn int main() {
|
||||
uint x = 1;
|
||||
foo((Mouse_Button)x);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
%x = alloca i32, align 4
|
||||
store i32 1, ptr %x, align 4
|
||||
%0 = load i32, ptr %x, align 4
|
||||
call void @test.foo(i32 %0)
|
||||
ret i32 0
|
||||
Reference in New Issue
Block a user