mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Fix broken enum inline -> bool conversions #2094.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
- ABI bug on x64 Linux / MacOS when passing a union containing a struct of 3 floats. #2087
|
||||
- Bug with slice acces as inline struct member #2088.
|
||||
- `@if` now does implicit conversion to bool like `$if`. #2086
|
||||
- Fix broken enum inline -> bool conversions #2094.
|
||||
|
||||
### Stdlib changes
|
||||
- Hash functions for integer vectors and arrays.
|
||||
|
||||
@@ -1729,7 +1729,7 @@ static void cast_enum_to_value(Expr* expr, Type *to_type)
|
||||
if (decl->enums.inline_value)
|
||||
{
|
||||
sema_expr_convert_enum_to_int(expr);
|
||||
cast_int_to_int(expr, to_type);
|
||||
cast_no_check(expr, to_type, IS_OPTIONAL(expr));
|
||||
return;
|
||||
}
|
||||
if (expr_is_const_enum(expr))
|
||||
|
||||
33
test/test_suite/enumerations/enum_to_bool_inline.c3t
Normal file
33
test/test_suite/enumerations/enum_to_bool_inline.c3t
Normal file
@@ -0,0 +1,33 @@
|
||||
// #target: macos-aarch64
|
||||
module test;
|
||||
|
||||
enum Enum : inline int {A, B, C}
|
||||
|
||||
fn void main()
|
||||
{
|
||||
int i = Enum.C;
|
||||
assert(i); // Good
|
||||
|
||||
Enum e = C;
|
||||
assert(e);
|
||||
|
||||
// In addition
|
||||
assert(Enum.C);
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
define void @test.main() #0 {
|
||||
entry:
|
||||
%i = alloca i32, align 4
|
||||
%e = alloca i32, align 4
|
||||
store i32 2, ptr %i, align 4
|
||||
%0 = load i32, ptr %i, align 4
|
||||
%i2b = icmp ne i32 %0, 0
|
||||
call void @llvm.assume(i1 %i2b)
|
||||
store i32 2, ptr %e, align 4
|
||||
%1 = load i32, ptr %e, align 4
|
||||
%i2b1 = icmp ne i32 %1, 0
|
||||
call void @llvm.assume(i1 %i2b1)
|
||||
ret void
|
||||
}
|
||||
Reference in New Issue
Block a user