mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
- Empty enums would return the values as zero sized arrays #2838
This commit is contained in:
6
test/test_suite/enumerations/empty_enum_reflection.c3
Normal file
6
test/test_suite/enumerations/empty_enum_reflection.c3
Normal file
@@ -0,0 +1,6 @@
|
||||
import std;
|
||||
enum Foo
|
||||
{
|
||||
}
|
||||
EnumMap{Foo, int} map; // #error: Parameter(s) would violate constraint: @require "Enum.values.len > 0" violated
|
||||
fn int main() => 1;
|
||||
@@ -9,7 +9,7 @@ enum Foo
|
||||
}
|
||||
|
||||
Foo zfok = Foo.values[0];
|
||||
Foo[] zw = &&Foo.values;
|
||||
Foo[] zw = Foo.values;
|
||||
|
||||
fn void test(int x)
|
||||
{
|
||||
@@ -19,17 +19,21 @@ fn void test(int x)
|
||||
/* #expect: test.ll
|
||||
|
||||
@test.zfok = local_unnamed_addr global i32 0, align 4
|
||||
@.taddr = private unnamed_addr global [2 x i32] [i32 0, i32 1], align 4
|
||||
@test.zw = local_unnamed_addr global %"int[]" { ptr @.taddr, i64 2 }, align 8
|
||||
@.__const_slice = private unnamed_addr global [2 x i32] [i32 0, i32 1], align 4
|
||||
@test.zw = local_unnamed_addr global %"int[]" { ptr @.__const_slice, i64 2 }, align 8
|
||||
@.__const = private unnamed_addr constant [2 x i32] [i32 0, i32 1], align 4
|
||||
|
||||
define void @test.test(i32 %0) #0 {
|
||||
entry:
|
||||
%zonk = alloca i32, align 4
|
||||
%literal = alloca [2 x i32], align 4
|
||||
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %literal, ptr align 4 @.__const, i32 8, i1 false)
|
||||
%1 = insertvalue %"int[]" undef, ptr %literal, 0
|
||||
%2 = insertvalue %"int[]" %1, i64 2, 1
|
||||
%3 = extractvalue %"int[]" %2, 0
|
||||
%sext = sext i32 %0 to i64
|
||||
%ptroffset = getelementptr inbounds [4 x i8], ptr %literal, i64 %sext
|
||||
%1 = load i32, ptr %ptroffset, align 4
|
||||
store i32 %1, ptr %zonk, align 4
|
||||
%ptroffset = getelementptr inbounds [4 x i8], ptr %3, i64 %sext
|
||||
%4 = load i32, ptr %ptroffset, align 4
|
||||
store i32 %4, ptr %zonk, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ fn void basic_streamed()
|
||||
x'e7660e67549435c62141e51c9ab1dcc3b1ee9f65c0b3e561ae8f58c5dba3d21997781cd1cc6fbc34'
|
||||
};
|
||||
char[] phrase = "The quick brown fox jumps over the lazy dog";
|
||||
$foreach $i, $bits : ripemd::PERMISSIBLE_SIZES_BITS{128}:
|
||||
$foreach $i, $bits : ripemd::PERMISSIBLE_SIZES_BITS:
|
||||
{ // le scope
|
||||
RipeMd{$bits} r @noinit;
|
||||
r.init();
|
||||
@@ -83,7 +83,7 @@ fn void large_input_streamed()
|
||||
};
|
||||
char[] one_mb = mem::talloc_array(char, 1024*1024);
|
||||
one_mb[..] = 0xA5;
|
||||
$foreach $i, $bits : ripemd::PERMISSIBLE_SIZES_BITS{128}:
|
||||
$foreach $i, $bits : ripemd::PERMISSIBLE_SIZES_BITS:
|
||||
{
|
||||
RipeMd{$bits} r @noinit;
|
||||
r.init();
|
||||
@@ -106,7 +106,7 @@ fn void large_input_streamed_per_byte()
|
||||
};
|
||||
char[] one_mb = mem::talloc_array(char, 1024*1024);
|
||||
one_mb[..] = 0xA5;
|
||||
$foreach $i, $bits : ripemd::PERMISSIBLE_SIZES_BITS{128}:
|
||||
$foreach $i, $bits : ripemd::PERMISSIBLE_SIZES_BITS:
|
||||
{
|
||||
RipeMd{$bits} r @noinit;
|
||||
r.init();
|
||||
@@ -132,7 +132,7 @@ fn void walk_lengths_streamed()
|
||||
{
|
||||
foreach (arr : CALCULATED_HASHES)
|
||||
{
|
||||
$foreach $i, $bits : ripemd::PERMISSIBLE_SIZES_BITS{128}:
|
||||
$foreach $i, $bits : ripemd::PERMISSIBLE_SIZES_BITS:
|
||||
{
|
||||
RipeMd{$bits} r @noinit;
|
||||
r.init();
|
||||
|
||||
Reference in New Issue
Block a user