Files
c3c/test/test_suite/enumerations/enum_conversions.c3t
Christoffer Lerno e293c435af 0.6.0: init_new/init_temp removed. LinkedList API rewritten. List "pop" and "remove" function now return Optionals. RingBuffer API rewritten. Allocator interface changed. Deprecated Allocator, DString and mem functions removed. "identity" functions are now constants for Matrix and Complex numbers. @default implementations for interfaces removed. any* => any, same for interfaces. Emit local/private globals as "private" in LLVM, following C "static". Updated enum syntax. Add support [rgba] properties in vectors. Improved checks of aliased "void". Subarray -> slice. Fix of llvm codegen enum check. Improved alignment handling. Add --output-dir #1155. Removed List/Object append. GenericList renamed AnyList. Remove unused "unwrap". Fixes to cond. Optimize output in dead branches. Better checking of operator methods. Disallow any from implementing dynamic methods. Check for operator mismatch. Remove unnecessary bitfield. Remove numbering in --list* commands Old style enum declaration for params/type, but now the type is optional. Add note on #1086. Allow making distinct types out of "void", "typeid", "anyfault" and faults. Remove system linker build options. "Try" expressions must be simple expressions. Add optimized build to Mac tests. Register int. assert(false) only allowed in unused branches or in tests. Compile time failed asserts is a compile time error. Remove current_block_is_target. Bug when assigning an optional from an optional. Remove unused emit_zstring. Simplify phi code. Remove unnecessary unreachable blocks and remove unnecessary current_block NULL assignments. Proper handling of '.' and Win32 '//server' paths. Add "no discard" to expression blocks with a return value. Detect "unsigned >= 0" as errors. Fix issue with distinct void as a member #1147. Improve callstack debug information #1184. Fix issue with absolute output-dir paths. Lambdas were not type checked thoroughly #1185. Fix compilation warning #1187. Request jump table using @jump for switches. Path normalization - fix possible null terminator out of bounds. Improved error messages on inlined macros.
Upgrade of mingw in CI. Fix problems using reflection on interface types #1203. Improved debug information on defer. $foreach doesn't create an implicit syntactic scope.
Error if `@if` depends on `@if`. Updated Linux stacktrace. Fix of default argument stacktrace. Allow linking libraries directly by file path. Improve inlining warning messages. Added `index_of_char_from`. Compiler crash using enum nameof from different module #1205. Removed unused fields in find_msvc. Use vswhere to find msvc. Update tests for LLVM 19
2024-06-12 10:14:26 +02:00

156 lines
6.7 KiB
C

// #safe: yes
// #target: macos-x64
module test;
enum Abc : char { ABC }
fn void main()
{
int a;
Abc x = (Abc)a;
long z;
Abc y = (Abc)z;
a = 256;
y = (Abc)a;
a = -1;
y = (Abc)a;
}
/* #expect: test.ll
define void @test.main() #0 {
entry:
%a = alloca i32, align 4
%x = alloca i8, align 1
%z = alloca i64, align 8
%y = alloca i8, align 1
store i32 0, ptr %a, align 4
%0 = load i32, ptr %a, align 4
%lt = icmp slt i32 %0, 0
%1 = call i1 @llvm.expect.i1(i1 %lt, i1 false)
br i1 %1, label %panic, label %checkok
checkok: ; preds = %entry
%ge = icmp sge i32 %0, 1
%2 = call i1 @llvm.expect.i1(i1 %ge, i1 false)
br i1 %2, label %panic1, label %checkok6
checkok6: ; preds = %checkok
%trunc = trunc i32 %0 to i8
store i8 %trunc, ptr %x, align 1
store i64 0, ptr %z, align 8
%3 = load i64, ptr %z, align 8
%lt7 = icmp slt i64 %3, 0
%4 = call i1 @llvm.expect.i1(i1 %lt7, i1 false)
br i1 %4, label %panic8, label %checkok13
checkok13: ; preds = %checkok6
%ge14 = icmp sge i64 %3, 1
%5 = call i1 @llvm.expect.i1(i1 %ge14, i1 false)
br i1 %5, label %panic15, label %checkok20
checkok20: ; preds = %checkok13
%trunc21 = trunc i64 %3 to i8
store i8 %trunc21, ptr %y, align 1
store i32 256, ptr %a, align 4
%6 = load i32, ptr %a, align 4
%lt22 = icmp slt i32 %6, 0
%7 = call i1 @llvm.expect.i1(i1 %lt22, i1 false)
br i1 %7, label %panic23, label %checkok28
checkok28: ; preds = %checkok20
%ge29 = icmp sge i32 %6, 1
%8 = call i1 @llvm.expect.i1(i1 %ge29, i1 false)
br i1 %8, label %panic30, label %checkok35
checkok35: ; preds = %checkok28
%trunc36 = trunc i32 %6 to i8
store i8 %trunc36, ptr %y, align 1
store i32 -1, ptr %a, align 4
%9 = load i32, ptr %a, align 4
%lt37 = icmp slt i32 %9, 0
%10 = call i1 @llvm.expect.i1(i1 %lt37, i1 false)
br i1 %10, label %panic38, label %checkok43
checkok43: ; preds = %checkok35
%ge44 = icmp sge i32 %9, 1
%11 = call i1 @llvm.expect.i1(i1 %ge44, i1 false)
br i1 %11, label %panic45, label %checkok50
checkok50: ; preds = %checkok43
%trunc51 = trunc i32 %9 to i8
store i8 %trunc51, ptr %y, align 1
ret void
panic: ; preds = %entry
store i32 %0, ptr %taddr, align 4
%12 = insertvalue %any undef, ptr %taddr, 0
%13 = insertvalue %any %12, i64 ptrtoint (ptr @"$ct.int" to i64), 1
store %any %13, ptr %varargslots, align 16
%14 = insertvalue %"any[]" undef, ptr %varargslots, 0
%"$$temp" = insertvalue %"any[]" %14, i64 1, 1
store %"any[]" %"$$temp", ptr %indirectarg, align 8
call void @std.core.builtin.panicf(ptr @.panic_msg
unreachable
panic1: ; preds = %checkok
store i32 %0, ptr %taddr2, align 4
%15 = insertvalue %any undef, ptr %taddr2, 0
%16 = insertvalue %any %15, i64 ptrtoint (ptr @"$ct.int" to i64), 1
store %any %16, ptr %varargslots3, align 16
%17 = insertvalue %"any[]" undef, ptr %varargslots3, 0
%"$$temp4" = insertvalue %"any[]" %17, i64 1, 1
store %"any[]" %"$$temp4", ptr %indirectarg5, align 8
call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 87, ptr @.file, i64 19, ptr @.func, i64 4, i32 7, ptr byval(%"any[]") align 8 %indirectarg5)
unreachable
panic8: ; preds = %checkok6
store i64 %3, ptr %taddr9, align 8
%18 = insertvalue %any undef, ptr %taddr9, 0
%19 = insertvalue %any %18, i64 ptrtoint (ptr @"$ct.long" to i64), 1
store %any %19, ptr %varargslots10, align 16
%20 = insertvalue %"any[]" undef, ptr %varargslots10, 0
%"$$temp11" = insertvalue %"any[]" %20, i64 1, 1
store %"any[]" %"$$temp11", ptr %indirectarg12, align 8
call void @std.core.builtin.panicf(ptr @.panic_msg,
unreachable
panic15: ; preds = %checkok13
store i64 %3, ptr %taddr16, align 8
%21 = insertvalue %any undef, ptr %taddr16, 0
%22 = insertvalue %any %21, i64 ptrtoint (ptr @"$ct.long" to i64), 1
store %any %22, ptr %varargslots17, align 16
%23 = insertvalue %"any[]" undef, ptr %varargslots17, 0
%"$$temp18" = insertvalue %"any[]" %23, i64 1, 1
store %"any[]" %"$$temp18", ptr %indirectarg19, align 8
call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 87, ptr @.file, i64 19, ptr @.func, i64 4, i32 9, ptr byval(%"any[]") align 8 %indirectarg19)
unreachable
panic23: ; preds = %checkok20
store i32 %6, ptr %taddr24, align 4
%24 = insertvalue %any undef, ptr %taddr24, 0
%25 = insertvalue %any %24, i64 ptrtoint (ptr @"$ct.int" to i64), 1
store %any %25, ptr %varargslots25, align 16
%26 = insertvalue %"any[]" undef, ptr %varargslots25, 0
%"$$temp26" = insertvalue %"any[]" %26, i64 1, 1
store %"any[]" %"$$temp26", ptr %indirectarg27, align 8
call void @std.core.builtin.panicf(ptr @.panic_msg,
unreachable
panic30: ; preds = %checkok28
store i32 %6, ptr %taddr31, align 4
%27 = insertvalue %any undef, ptr %taddr31, 0
%28 = insertvalue %any %27, i64 ptrtoint (ptr @"$ct.int" to i64), 1
store %any %28, ptr %varargslots32, align 16
%29 = insertvalue %"any[]" undef, ptr %varargslots32, 0
%"$$temp33" = insertvalue %"any[]" %29, i64 1, 1
store %"any[]" %"$$temp33", ptr %indirectarg34, align 8
call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 87, ptr @.file, i64 19, ptr @.func, i64 4, i32 11, ptr byval(%"any[]") align 8 %indirectarg34)
unreachable
panic38: ; preds = %checkok35
store i32 %9, ptr %taddr39, align 4
%30 = insertvalue %any undef, ptr %taddr39, 0
%31 = insertvalue %any %30, i64 ptrtoint (ptr @"$ct.int" to i64), 1
store %any %31, ptr %varargslots40, align 16
%32 = insertvalue %"any[]" undef, ptr %varargslots40, 0
%"$$temp41" = insertvalue %"any[]" %32, i64 1, 1
store %"any[]" %"$$temp41", ptr %indirectarg42, align 8
call void @std.core.builtin.panicf(ptr @.panic_msg,
unreachable
panic45: ; preds = %checkok43
store i32 %9, ptr %taddr46, align 4
%33 = insertvalue %any undef, ptr %taddr46, 0
%34 = insertvalue %any %33, i64 ptrtoint (ptr @"$ct.int" to i64), 1
store %any %34, ptr %varargslots47, align 16
%35 = insertvalue %"any[]" undef, ptr %varargslots47, 0
%"$$temp48" = insertvalue %"any[]" %35, i64 1, 1
store %"any[]" %"$$temp48", ptr %indirectarg49, align 8
call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 87, ptr @.file, i64 19, ptr @.func, i64 4, i32 13, ptr byval(%"any[]") align 8 %indirectarg49)
unreachable
}