Files
c3c/test/test_suite/errors/error_introspect.c3t
Christoffer Lerno fc849c1440 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. Unify expression and macro blocks in the middle end. 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.
2024-05-22 18:22:04 +02:00

73 lines
3.9 KiB
C

// #target: macos-x64
module foo;
import std::io;
fault Foo
{
BAR,
BAZ
}
fn void main()
{
String[] x = Foo.names;
io::printfn("Foo.names: %s", x);
io::printfn("Foo.values: %s", Foo.values);
io::printfn("Foo.elements: %s", Foo.elements);
}
/* #expect: foo.ll
@"foo.Foo$BAR" = linkonce constant %.fault { i64 ptrtoint (ptr @"$ct.foo.Foo" to i64), %"char[]" { ptr @.fault, i64 3 }, i64 1 }, align 8
@.fault = internal constant [4 x i8] c"BAR\00", align 1
@"foo.Foo$BAZ" = linkonce constant %.fault { i64 ptrtoint (ptr @"$ct.foo.Foo" to i64), %"char[]" { ptr @.fault.1, i64 3 }, i64 2 }, align 8
@.fault.1 = internal constant [4 x i8] c"BAZ\00", align 1
@"$ct.foo.Foo" = linkonce global %.introspect { i8 9, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@.str = private unnamed_addr constant [4 x i8] c"BAR\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"BAZ\00", align 1
@.__const = private unnamed_addr constant [2 x %"char[]"] [%"char[]" { ptr @.str, i64 3 }, %"char[]" { ptr @.str.2, i64 3 }], align 16
@.str.3 = private unnamed_addr constant [14 x i8] c"Foo.names: %s\00", align 1
@"$ct.sa$String" = linkonce global %.introspect { i8 16, i64 0, ptr null, i64 16, i64 ptrtoint (ptr @"$ct.String" to i64), i64 0, [0 x i64] zeroinitializer }, align 8
@"$ct.String" = linkonce global %.introspect { i8 18, i64 ptrtoint (ptr @"$ct.sa$char" to i64), ptr null, i64 16, i64 ptrtoint (ptr @"$ct.sa$char" to i64), i64 0, [0 x i64] zeroinitializer }, align 8
@"$ct.sa$char" = linkonce global %.introspect { i8 16, i64 0, ptr null, i64 16, i64 ptrtoint (ptr @"$ct.char" to i64), i64 0, [0 x i64] zeroinitializer }, align 8
@"$ct.char" = linkonce global %.introspect { i8 3, i64 0, ptr null, i64 1, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8
@.str.4 = private unnamed_addr constant [15 x i8] c"Foo.values: %s\00", align 1
@.__const.5 = private unnamed_addr constant [2 x i64] [i64 ptrtoint (ptr @"foo.Foo$BAR" to i64), i64 ptrtoint (ptr @"foo.Foo$BAZ" to i64)], align 16
@"$ct.a2$foo.Foo" = linkonce global %.introspect { i8 15, i64 0, ptr null, i64 16, i64 ptrtoint (ptr @"$ct.foo.Foo" to i64), i64 2, [0 x i64] zeroinitializer }, align 8
@.str.6 = private unnamed_addr constant [17 x i8] c"Foo.elements: %s\00", align 1
@"$ct.long" = linkonce global %.introspect { i8 2, i64 0, ptr null, i64 8, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8
; Function Attrs:
define void @foo.main() #0 {
entry:
%x = alloca %"char[][]", align 8
%literal = alloca [2 x %"char[]"], align 16
%varargslots = alloca [1 x %any], align 16
%retparam = alloca i64, align 8
%varargslots1 = alloca [1 x %any], align 16
%literal2 = alloca [2 x i64], align 16
%retparam3 = alloca i64, align 8
%varargslots4 = alloca [1 x %any], align 16
%taddr = alloca i64, align 8
%retparam5 = alloca i64, align 8
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %literal, ptr align 16 @.__const, i32 32, i1 false)
%0 = insertvalue %"char[][]" undef, ptr %literal, 0
%1 = insertvalue %"char[][]" %0, i64 2, 1
store %"char[][]" %1, ptr %x, align 8
%2 = insertvalue %any undef, ptr %x, 0
%3 = insertvalue %any %2, i64 ptrtoint (ptr @"$ct.sa$String" to i64), 1
store %any %3, ptr %varargslots, align 16
%4 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.3, i64 13, ptr %varargslots, i64 1)
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %literal2, ptr align 16 @.__const.5, i32 16, i1 false)
%5 = insertvalue %any undef, ptr %literal2, 0
%6 = insertvalue %any %5, i64 ptrtoint (ptr @"$ct.a2$foo.Foo" to i64), 1
store %any %6, ptr %varargslots1, align 16
%7 = call i64 @std.io.printfn(ptr %retparam3, ptr @.str.4, i64 14, ptr %varargslots1, i64 1)
store i64 2, ptr %taddr, align 8
%8 = insertvalue %any undef, ptr %taddr, 0
%9 = insertvalue %any %8, i64 ptrtoint (ptr @"$ct.long" to i64), 1
store %any %9, ptr %varargslots4, align 16
%10 = call i64 @std.io.printfn(ptr %retparam5, ptr @.str.6, i64 16, ptr %varargslots4, i64 1)
ret void
}