Files
c3c/test/test_suite/compile_time/compile_time_access_subscript.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

99 lines
2.9 KiB
C

// #target: macos-x64
module test;
import std::io;
struct Abc
{
float m00, m01, m10, m11;
}
Abc a = flip(Abc { 1, 2, 3, 4 });
macro flip($init)
{
return Abc { $init.m01, $init.m10, $init.m11, $init.m00 };
}
macro check_type($Type)
{
var $b = $Type[4][4] {};
$Type z = $b[2][2];
return z;
}
enum Blurb { FOO }
distinct Bdd = Abc;
fn void main()
{
var $i = int[4] { 1, 2, 3, 4 };
var $b = Abc[2] { Abc {}, Abc { 11, 22, 33, 44 }};
var $c = any[4] {};
check_type(int);
check_type(Abc);
check_type(anyfault);
check_type(Blurb);
check_type(int*);
check_type(bool);
check_type(typeid);
check_type(int[<3>]);
check_type(Bdd);
check_type(int[2]);
check_type(int[]);
io::printfn("%d", $b[0].m11);
}
/* #expect: test.ll
%z = alloca i32, align 4
%z1 = alloca %Abc, align 4
%z4 = alloca i64, align 8
%z5 = alloca i32, align 4
%z6 = alloca ptr, align 8
%z7 = alloca i8, align 1
%z8 = alloca i64, align 8
%z9 = alloca <3 x i32>, align 16
%z10 = alloca %Abc, align 4
%z14 = alloca [2 x i32], align 4
%z16 = alloca %"int[]", align 8
%varargslots = alloca [1 x %any], align 16
%literal = alloca %Abc, align 4
%retparam = alloca i64, align 8
store i32 0, ptr %z, align 4
store float 0.000000e+00, ptr %z1, align 4
%ptradd = getelementptr inbounds i8, ptr %z1, i64 4
store float 0.000000e+00, ptr %ptradd, align 4
%ptradd2 = getelementptr inbounds i8, ptr %z1, i64 8
store float 0.000000e+00, ptr %ptradd2, align 4
%ptradd3 = getelementptr inbounds i8, ptr %z1, i64 12
store float 0.000000e+00, ptr %ptradd3, align 4
store i64 0, ptr %z4, align 8
store i32 0, ptr %z5, align 4
store ptr null, ptr %z6, align 8
store i8 0, ptr %z7, align 1
store i64 0, ptr %z8, align 8
store <3 x i32> zeroinitializer, ptr %z9, align 16
store float 0.000000e+00, ptr %z10, align 4
%ptradd11 = getelementptr inbounds i8, ptr %z10, i64 4
store float 0.000000e+00, ptr %ptradd11, align 4
%ptradd12 = getelementptr inbounds i8, ptr %z10, i64 8
store float 0.000000e+00, ptr %ptradd12, align 4
%ptradd13 = getelementptr inbounds i8, ptr %z10, i64 12
store float 0.000000e+00, ptr %ptradd13, align 4
store i32 0, ptr %z14, align 4
%ptradd15 = getelementptr inbounds i8, ptr %z14, i64 4
store i32 0, ptr %ptradd15, align 4
call void @llvm.memset.p0.i64(ptr align 8 %z16, i8 0, i64 16, i1 false)
store float 0.000000e+00, ptr %literal, align 4
%ptradd17 = getelementptr inbounds i8, ptr %literal, i64 4
store float 0.000000e+00, ptr %ptradd17, align 4
%ptradd18 = getelementptr inbounds i8, ptr %literal, i64 8
store float 0.000000e+00, ptr %ptradd18, align 4
%ptradd19 = getelementptr inbounds i8, ptr %literal, i64 12
store float 0.000000e+00, ptr %ptradd19, align 4
%0 = insertvalue %any undef, ptr %literal, 0
%1 = insertvalue %any %0, i64 ptrtoint (ptr @"$ct.test.Abc" to i64), 1
store %any %1, ptr %varargslots, align 16
%2 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 2, ptr %varargslots, i64 1)
ret void
}