mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
More correct alignment. Foreach added. Removed dynamic designated array initialization. Use 16 byte alignment on arrays >= 16 for x64
This commit is contained in:
committed by
Christoffer Lerno
parent
26d25e3f74
commit
45c4f205bb
@@ -1,3 +1,4 @@
|
||||
// #target: x64_darwin
|
||||
module testing;
|
||||
|
||||
func double test(uint x)
|
||||
@@ -13,14 +14,14 @@ func double test(uint x)
|
||||
|
||||
// #expect: array_literal.ll
|
||||
|
||||
@0 = constant [30 x double] [double 0.000000e+00, double 1.270600e+01, double 4.303000e+00, double 3.182000e+00, double 2.776000e+00, double 2.571000e+00, double 2.447000e+00, double 2.365000e+00, double 2.306000e+00, double 2.262000e+00, double 2.228000e+00, double 2.201000e+00, double 2.179000e+00, double 2.160000e+00, double 2.145000e+00, double 2.131000e+00, double 2.120000e+00, double 2.110000e+00, double 2.101000e+00, double 2.093000e+00, double 2.086000e+00, double 2.080000e+00, double 2.074000e+00, double 2.069000e+00, double 2.064000e+00, double 2.060000e+00, double 2.056000e+00, double 2.052000e+00, double 2.048000e+00, double 2.045000e+00], align 8
|
||||
@0 = constant [30 x double] [double 0.000000e+00, double 1.270600e+01, double 4.303000e+00, double 3.182000e+00, double 2.776000e+00, double 2.571000e+00, double 2.447000e+00, double 2.365000e+00, double 2.306000e+00, double 2.262000e+00, double 2.228000e+00, double 2.201000e+00, double 2.179000e+00, double 2.160000e+00, double 2.145000e+00, double 2.131000e+00, double 2.120000e+00, double 2.110000e+00, double 2.101000e+00, double 2.093000e+00, double 2.086000e+00, double 2.080000e+00, double 2.074000e+00, double 2.069000e+00, double 2.064000e+00, double 2.060000e+00, double 2.056000e+00, double 2.052000e+00, double 2.048000e+00, double 2.045000e+00], align 16
|
||||
|
||||
entry:
|
||||
%x = alloca i32, align 4
|
||||
%student_t = alloca [30 x double], align 8
|
||||
%student_t = alloca [30 x double], align 16
|
||||
store i32 %0, i32* %x, align 4
|
||||
%1 = bitcast [30 x double]* %student_t to i8*
|
||||
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %1, i8* align 8 bitcast ([30 x double]* @0 to i8*), i32 240, i1 false)
|
||||
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %1, i8* align 16 bitcast ([30 x double]* @0 to i8*), i32 240, i1 false)
|
||||
%2 = load i32, i32* %x, align 4
|
||||
%arridx = getelementptr inbounds [30 x double], [30 x double]* %student_t, i32 0, i32 %2
|
||||
%3 = load double, double* %arridx, align 8
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// #target: x64_darwin
|
||||
module test;
|
||||
|
||||
struct Foo
|
||||
@@ -9,4 +10,4 @@ Foo[10] array;
|
||||
|
||||
// #expect: array_struct.ll
|
||||
|
||||
@array = protected global [10 x %test.Foo] zeroinitializer, align 4
|
||||
@array = protected global [10 x %test.Foo] zeroinitializer, align 16
|
||||
@@ -1,3 +1,4 @@
|
||||
// #target: x64_darwin
|
||||
module test;
|
||||
|
||||
struct Connection
|
||||
@@ -17,4 +18,4 @@ Connection[3] link
|
||||
@0 = internal constant [6 x i8] c"link1\00"
|
||||
@1 = internal constant [6 x i8] c"link2\00"
|
||||
@2 = internal constant [6 x i8] c"link3\00"
|
||||
@link = protected global [3 x %test.Connection] [%test.Connection { i64 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i32 0, i32 0), i64 10 }, %test.Connection { i64 2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i32 0, i32 0), i64 20 }, %test.Connection { i64 3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i32 0, i32 0), i64 30 }], align 8
|
||||
@link = protected global [3 x %test.Connection] [%test.Connection { i64 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i32 0, i32 0), i64 10 }, %test.Connection { i64 2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i32 0, i32 0), i64 20 }, %test.Connection { i64 3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i32 0, i32 0), i64 30 }], align 16
|
||||
|
||||
@@ -3,9 +3,9 @@ func void syntaxErrors()
|
||||
int! i = 0;
|
||||
while (i + 1) {} // #error: 'int!' cannot be converted into 'bool'
|
||||
if (i + 1) {} // #error: 'int!' cannot be converted into 'bool'
|
||||
for (int x = i;;) {} // #error: 'int!' cannot be implicitly cast to 'int'.
|
||||
for (int x = 0; x < i + 1;) {} // #error: 'bool!' cannot be implicitly cast to 'bool'
|
||||
for (int x = 0; x < 10; x += i + 1) {} // #error: 'int!' cannot be implicitly cast to 'int'
|
||||
for (int x = i;;) {} // #error: 'int!' cannot be converted into 'int'.
|
||||
for (int x = 0; x < i + 1;) {} // #error: 'bool!' cannot be converted into 'bool'
|
||||
for (int x = 0; x < 10; x += i + 1) {} // #error: 'int!' cannot be converted into 'int'
|
||||
switch (i + 1) // #error: 'int!' cannot be converted into 'int'
|
||||
{
|
||||
default:
|
||||
|
||||
@@ -106,7 +106,7 @@ void @test.setInternalFPFZero(%test.InternalFPF* %0)
|
||||
store %test.InternalFPF* %0, %test.InternalFPF** %dest, align 8
|
||||
%1 = load %test.InternalFPF*, %test.InternalFPF** %dest, align 8
|
||||
%2 = getelementptr inbounds %test.InternalFPF, %test.InternalFPF* %1, i32 0, i32 0
|
||||
store i8 0, i8* %2, align 1
|
||||
store i8 0, i8* %2, align 8
|
||||
ret void
|
||||
|
||||
void @test.denormalize(%test.InternalFPF* %0)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// #target: x64_darwin
|
||||
|
||||
module test;
|
||||
|
||||
double foo = 17;
|
||||
@@ -11,4 +13,4 @@ void*[3] data = { &foo, &bar, &xx };
|
||||
@foo = protected global double 1.700000e+01, align 8
|
||||
@bar = protected global double 1.200000e+01, align 8
|
||||
@xx = protected global float 1.200000e+01, align 4
|
||||
@data = protected global [3 x i8*] [i8* bitcast (double* @foo to i8*), i8* bitcast (double* @bar to i8*), i8* bitcast (float* @xx to i8*)], align 8
|
||||
@data = protected global [3 x i8*] [i8* bitcast (double* @foo to i8*), i8* bitcast (double* @bar to i8*), i8* bitcast (float* @xx to i8*)], align 16
|
||||
|
||||
51
test/test_suite/statements/foreach_break.c3t
Normal file
51
test/test_suite/statements/foreach_break.c3t
Normal file
@@ -0,0 +1,51 @@
|
||||
module test;
|
||||
|
||||
func void test()
|
||||
{
|
||||
int[3] x;
|
||||
int g = 0;
|
||||
foreach (z : x)
|
||||
{
|
||||
if (z > 0) break;
|
||||
if (z == 1) continue;
|
||||
g += z;
|
||||
}
|
||||
}
|
||||
|
||||
// #expect: foreach_break.ll
|
||||
|
||||
store i32 0, i32* %g, align 4
|
||||
store i64 0, i64* %idx, align 8
|
||||
br label %foreach.cond
|
||||
foreach.cond:
|
||||
%1 = load i64, i64* %idx, align 8
|
||||
%lt = icmp ult i64 %1, 3
|
||||
br i1 %lt, label %foreach.body, label %foreach.exit
|
||||
|
||||
foreach.body:
|
||||
%2 = getelementptr inbounds i32, [3 x i32]* %x, i64 %1
|
||||
%3 = load i32, i32* %2, align 4
|
||||
store i32 %3, i32* %z, align 4
|
||||
%4 = load i32, i32* %z, align 4
|
||||
%gt = icmp sgt i32 %4, 0
|
||||
br i1 %gt, label %if.then, label %if.exit
|
||||
if.then:
|
||||
br label %foreach.exit
|
||||
if.exit:
|
||||
%5 = load i32, i32* %z, align 4
|
||||
%eq = icmp eq i32 %5, 1
|
||||
br i1 %eq, label %if.then1, label %if.exit2
|
||||
if.then1:
|
||||
br label %foreach.inc
|
||||
if.exit2:
|
||||
%6 = load i32, i32* %g, align 4
|
||||
%7 = load i32, i32* %z, align 4
|
||||
%add = add nsw i32 %6, %7
|
||||
store i32 %add, i32* %g, align 4
|
||||
br label %foreach.inc
|
||||
foreach.inc:
|
||||
%8 = load i64, i64* %idx, align 8
|
||||
%9 = add i64 %8, 1
|
||||
store i64 %9, i64* %idx, align 8
|
||||
br label %foreach.cond
|
||||
foreach.exit:
|
||||
210
test/test_suite/statements/foreach_common.c3t
Normal file
210
test/test_suite/statements/foreach_common.c3t
Normal file
@@ -0,0 +1,210 @@
|
||||
module test;
|
||||
|
||||
extern func void printf(char*, ...);
|
||||
|
||||
func void main()
|
||||
{
|
||||
float[3] foo = { 2, 4.5, 8 };
|
||||
foreach (a : foo)
|
||||
{
|
||||
printf("Value: %f\n", a);
|
||||
}
|
||||
foreach (float* &a : foo)
|
||||
{
|
||||
*a *= 2;
|
||||
printf("Value: %f\n", *a);
|
||||
}
|
||||
foreach (void* &a : foo)
|
||||
{
|
||||
printf("Value: %f\n", *(cast(a as float*)));
|
||||
}
|
||||
foreach (i, a : foo)
|
||||
{
|
||||
printf("Value[%d]: %f\n", i, a);
|
||||
}
|
||||
foreach (byte i, double a : foo)
|
||||
{
|
||||
printf("Value2[%d]: %f\n", i, a);
|
||||
}
|
||||
foreach (double a : foo)
|
||||
{
|
||||
printf("Value3: %f\n", a);
|
||||
}
|
||||
}
|
||||
|
||||
// #expect: foreach_common.ll
|
||||
|
||||
entry:
|
||||
%foo = alloca [3 x float], align 4
|
||||
%idx = alloca i64, align 8
|
||||
%a = alloca float, align 4
|
||||
%idx1 = alloca i64, align 8
|
||||
%a2 = alloca float*, align 8
|
||||
%idx9 = alloca i64, align 8
|
||||
%a10 = alloca i8*, align 8
|
||||
%i = alloca i64, align 8
|
||||
%a18 = alloca float, align 4
|
||||
%i25 = alloca i8, align 1
|
||||
%idx26 = alloca i64, align 8
|
||||
%a27 = alloca double, align 8
|
||||
%idx34 = alloca i64, align 8
|
||||
%a35 = alloca double, align 8
|
||||
%0 = bitcast [3 x float]* %foo to i8*
|
||||
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([3 x float]* @0 to i8*), i32 12, i1 false)
|
||||
store i64 0, i64* %idx, align 8
|
||||
br label %foreach.cond
|
||||
|
||||
foreach.cond:
|
||||
%1 = load i64, i64* %idx, align 8
|
||||
%lt = icmp ult i64 %1, 3
|
||||
br i1 %lt, label %foreach.body, label %foreach.exit
|
||||
|
||||
foreach.body:
|
||||
%2 = getelementptr inbounds float, [3 x float]* %foo, i64 %1
|
||||
%3 = load float, float* %2, align 4
|
||||
store float %3, float* %a, align 4
|
||||
%4 = load float, float* %a, align 4
|
||||
%fpfpext = fpext float %4 to double
|
||||
call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @1, i32 0, i32 0), double %fpfpext)
|
||||
br label %foreach.inc
|
||||
|
||||
foreach.inc:
|
||||
%5 = load i64, i64* %idx, align 8
|
||||
%6 = add i64 %5, 1
|
||||
store i64 %6, i64* %idx, align 8
|
||||
br label %foreach.cond
|
||||
|
||||
foreach.exit:
|
||||
store i64 0, i64* %idx1, align 8
|
||||
br label %foreach.cond3
|
||||
|
||||
foreach.cond3:
|
||||
%7 = load i64, i64* %idx1, align 8
|
||||
%lt4 = icmp ult i64 %7, 3
|
||||
br i1 %lt4, label %foreach.body5, label %foreach.exit8
|
||||
|
||||
foreach.body5:
|
||||
%8 = getelementptr inbounds float, [3 x float]* %foo, i64 %7
|
||||
store float* %8, float** %a2, align 8
|
||||
%9 = load float*, float** %a2, align 8
|
||||
%10 = load float, float* %9, align 8
|
||||
%fmul = fmul float %10, 2.000000e+00
|
||||
store float %fmul, float* %9, align 8
|
||||
%11 = load float*, float** %a2, align 8
|
||||
%12 = load float, float* %11, align 8
|
||||
%fpfpext6 = fpext float %12 to double
|
||||
call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @2, i32 0, i32 0), double %fpfpext6)
|
||||
br label %foreach.inc7
|
||||
|
||||
foreach.inc7:
|
||||
%13 = load i64, i64* %idx1, align 8
|
||||
%14 = add i64 %13, 1
|
||||
store i64 %14, i64* %idx1, align 8
|
||||
br label %foreach.cond3
|
||||
|
||||
foreach.exit8:
|
||||
store i64 0, i64* %idx9, align 8
|
||||
br label %foreach.cond11
|
||||
|
||||
foreach.cond11:
|
||||
%15 = load i64, i64* %idx9, align 8
|
||||
%lt12 = icmp ult i64 %15, 3
|
||||
br i1 %lt12, label %foreach.body13, label %foreach.exit17
|
||||
|
||||
foreach.body13:
|
||||
%16 = getelementptr inbounds float, [3 x float]* %foo, i64 %15
|
||||
%ptrptr = bitcast float* %16 to i8*
|
||||
store i8* %ptrptr, i8** %a10, align 8
|
||||
%17 = load i8*, i8** %a10, align 8
|
||||
%ptrptr14 = bitcast i8* %17 to float*
|
||||
%18 = load float, float* %ptrptr14, align 8
|
||||
%fpfpext15 = fpext float %18 to double
|
||||
call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @3, i32 0, i32 0), double %fpfpext15)
|
||||
br label %foreach.inc16
|
||||
|
||||
foreach.inc16:
|
||||
%19 = load i64, i64* %idx9, align 8
|
||||
%20 = add i64 %19, 1
|
||||
store i64 %20, i64* %idx9, align 8
|
||||
br label %foreach.cond11
|
||||
|
||||
foreach.exit17:
|
||||
store i64 0, i64* %i, align 8
|
||||
br label %foreach.cond19
|
||||
|
||||
foreach.cond19:
|
||||
%21 = load i64, i64* %i, align 8
|
||||
%lt20 = icmp ult i64 %21, 3
|
||||
br i1 %lt20, label %foreach.body21, label %foreach.exit24
|
||||
|
||||
foreach.body21:
|
||||
%22 = getelementptr inbounds float, [3 x float]* %foo, i64 %21
|
||||
%23 = load float, float* %22, align 4
|
||||
store float %23, float* %a18, align 4
|
||||
%24 = load i64, i64* %i, align 8
|
||||
%25 = load float, float* %a18, align 4
|
||||
%fpfpext22 = fpext float %25 to double
|
||||
call void (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @4, i32 0, i32 0), i64 %24, double %fpfpext22)
|
||||
br label %foreach.inc23
|
||||
|
||||
foreach.inc23:
|
||||
%26 = load i64, i64* %i, align 8
|
||||
%27 = add i64 %26, 1
|
||||
store i64 %27, i64* %i, align 8
|
||||
br label %foreach.cond19
|
||||
|
||||
foreach.exit24:
|
||||
store i8 0, i8* %i25, align 1
|
||||
store i64 0, i64* %idx26, align 8
|
||||
br label %foreach.cond28
|
||||
|
||||
foreach.cond28:
|
||||
%28 = load i64, i64* %idx26, align 8
|
||||
%lt29 = icmp ult i64 %28, 3
|
||||
br i1 %lt29, label %foreach.body30, label %foreach.exit33
|
||||
|
||||
foreach.body30:
|
||||
%29 = trunc i64 %28 to i8
|
||||
store i8 %29, i8* %i25, align 1
|
||||
%30 = getelementptr inbounds float, [3 x float]* %foo, i64 %28
|
||||
%31 = load float, float* %30, align 4
|
||||
%fpfpext31 = fpext float %31 to double
|
||||
store double %fpfpext31, double* %a27, align 8
|
||||
%32 = load i8, i8* %i25, align 1
|
||||
%uisiext = zext i8 %32 to i32
|
||||
%33 = load double, double* %a27, align 8
|
||||
call void (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @5, i32 0, i32 0), i32 %uisiext, double %33)
|
||||
br label %foreach.inc32
|
||||
|
||||
foreach.inc32:
|
||||
%34 = load i64, i64* %idx26, align 8
|
||||
%35 = add i64 %34, 1
|
||||
store i64 %35, i64* %idx26, align 8
|
||||
br label %foreach.cond28
|
||||
|
||||
foreach.exit33:
|
||||
store i64 0, i64* %idx34, align 8
|
||||
br label %foreach.cond36
|
||||
|
||||
foreach.cond36:
|
||||
%36 = load i64, i64* %idx34, align 8
|
||||
%lt37 = icmp ult i64 %36, 3
|
||||
br i1 %lt37, label %foreach.body38, label %foreach.exit41
|
||||
|
||||
foreach.body38:
|
||||
%37 = getelementptr inbounds float, [3 x float]* %foo, i64 %36
|
||||
%38 = load float, float* %37, align 4
|
||||
%fpfpext39 = fpext float %38 to double
|
||||
store double %fpfpext39, double* %a35, align 8
|
||||
%39 = load double, double* %a35, align 8
|
||||
call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @6, i32 0, i32 0), double %39)
|
||||
br label %foreach.inc40
|
||||
|
||||
foreach.inc40:
|
||||
%40 = load i64, i64* %idx34, align 8
|
||||
%41 = add i64 %40, 1
|
||||
store i64 %41, i64* %idx34, align 8
|
||||
br label %foreach.cond36
|
||||
|
||||
foreach.exit41:
|
||||
ret void
|
||||
59
test/test_suite/statements/foreach_errors.c3
Normal file
59
test/test_suite/statements/foreach_errors.c3
Normal file
@@ -0,0 +1,59 @@
|
||||
module test;
|
||||
|
||||
extern func void foo();
|
||||
int[3] z;
|
||||
|
||||
func void test1()
|
||||
{
|
||||
int x;
|
||||
foreach (a : x) // #error: It's not possible to enumerate an expression of type 'int'.
|
||||
{
|
||||
foo();
|
||||
}
|
||||
}
|
||||
|
||||
func void test2()
|
||||
{
|
||||
foreach (a : z) foo();
|
||||
foreach (i, a : z) foo();
|
||||
foreach (double i, a : z); // #error: Index must be an integer type, 'double' is not valid.
|
||||
}
|
||||
|
||||
func void test3()
|
||||
{
|
||||
foreach (&a : z) foo();
|
||||
foreach (&i, &a : z) foo(); // #error: The index cannot be held by reference, did you accidentally add a '&'?
|
||||
}
|
||||
|
||||
func void test4()
|
||||
{
|
||||
foreach (&a : z) foo();
|
||||
foreach (&i, a : z) foo(); // #error: The index cannot be held by reference, did you accidentally add a '&'?
|
||||
}
|
||||
|
||||
func void test5()
|
||||
{
|
||||
foreach (int! y : z) foo(); // #error: The variable may not be a failable.
|
||||
}
|
||||
|
||||
func void test6()
|
||||
{
|
||||
foreach (int! i, y : z) foo(); // #error: The index may not be a failable.
|
||||
}
|
||||
|
||||
func void test7()
|
||||
{
|
||||
foreach (int a : { 1, 2, 3 }) foo();
|
||||
foreach (a : { 1, 2, 3 }) foo(); // #error: Add the type of your variable here if you want to iterate over
|
||||
}
|
||||
|
||||
func void test8()
|
||||
{
|
||||
foreach (int a : { z }) foo(); // #error: Cannot implicitly cast 'int[3]' to 'int'
|
||||
}
|
||||
|
||||
func void test9()
|
||||
{
|
||||
foreach (int a : { [2] = 1 }) foo();
|
||||
foreach (int a : { [2] = 2, 1 }) foo(); // #error: The initializer mixes designated initialization with array initialization
|
||||
}
|
||||
68
test/test_suite/statements/foreach_with_error.c3t
Normal file
68
test/test_suite/statements/foreach_with_error.c3t
Normal file
@@ -0,0 +1,68 @@
|
||||
module test;
|
||||
|
||||
func void test()
|
||||
{
|
||||
int[3]! x;
|
||||
int g;
|
||||
foreach (z : x)
|
||||
{
|
||||
g += z;
|
||||
x[0] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// #expect: foreach_with_error.ll
|
||||
|
||||
entry:
|
||||
%x = alloca [3 x i32], align 4
|
||||
%x1 = alloca { i64, i64 }, align 8
|
||||
%g = alloca i32, align 4
|
||||
%idx = alloca i64, align 8
|
||||
%z = alloca i32, align 4
|
||||
store { i64, i64 } zeroinitializer, { i64, i64 }* %x1, align 8
|
||||
%0 = bitcast [3 x i32]* %x to i8*
|
||||
call void @llvm.memset.p0i8.i64(i8* align 4 %0, i8 0, i64 12, i1 false)
|
||||
store i32 0, i32* %g, align 4
|
||||
%1 = load { i64, i64 }, { i64, i64 }* %x1, align 8
|
||||
%2 = extractvalue { i64, i64 } %1, 0
|
||||
%noerr = icmp eq i64 %2, 0
|
||||
br i1 %noerr, label %after_check, label %foreach.exit
|
||||
|
||||
after_check:
|
||||
store i64 0, i64* %idx, align 8
|
||||
br label %foreach.cond
|
||||
|
||||
foreach.cond:
|
||||
%3 = load i64, i64* %idx, align 8
|
||||
%lt = icmp ult i64 %3, 3
|
||||
br i1 %lt, label %foreach.body, label %foreach.exit
|
||||
|
||||
foreach.body:
|
||||
%4 = getelementptr inbounds i32, [3 x i32]* %x, i64 %3
|
||||
%5 = load i32, i32* %4, align 4
|
||||
store i32 %5, i32* %z, align 4
|
||||
%6 = load i32, i32* %g, align 4
|
||||
%7 = load i32, i32* %z, align 4
|
||||
%add = add nsw i32 %6, %7
|
||||
store i32 %add, i32* %g, align 4
|
||||
%8 = load { i64, i64 }, { i64, i64 }* %x1, align 8
|
||||
%9 = extractvalue { i64, i64 } %8, 0
|
||||
%noerr2 = icmp eq i64 %9, 0
|
||||
br i1 %noerr2, label %after_check3, label %voiderr
|
||||
|
||||
after_check3:
|
||||
%arridx = getelementptr inbounds [3 x i32], [3 x i32]* %x, i32 0, i32 0
|
||||
store i32 1, i32* %arridx, align 4
|
||||
br label %voiderr
|
||||
|
||||
voiderr:
|
||||
br label %foreach.inc
|
||||
|
||||
foreach.inc:
|
||||
%10 = load i64, i64* %idx, align 8
|
||||
%11 = add i64 %10, 1
|
||||
store i64 %11, i64* %idx, align 8
|
||||
br label %foreach.cond
|
||||
|
||||
foreach.exit:
|
||||
ret void
|
||||
34
test/test_suite/statements/if_while_do_error.c3
Normal file
34
test/test_suite/statements/if_while_do_error.c3
Normal file
@@ -0,0 +1,34 @@
|
||||
module test;
|
||||
|
||||
func void test1()
|
||||
{
|
||||
bool! x = 0;
|
||||
if (x) // #error: 'bool!' cannot be converted into 'bool'
|
||||
{
|
||||
x = 100;
|
||||
}
|
||||
}
|
||||
|
||||
func void test2()
|
||||
{
|
||||
bool! x = 0;
|
||||
while (x) // #error: 'bool!' cannot be converted into 'bool'
|
||||
{
|
||||
x = false;
|
||||
}
|
||||
}
|
||||
|
||||
func void test3()
|
||||
{
|
||||
bool! x = 0;
|
||||
double y = 1;
|
||||
do
|
||||
{
|
||||
y = y + 1;
|
||||
} while (y);
|
||||
do
|
||||
{
|
||||
x = !x;
|
||||
}
|
||||
while (x); // #error: 'bool!' cannot be converted into 'bool'
|
||||
}
|
||||
@@ -20,5 +20,5 @@ func void test1()
|
||||
entry:
|
||||
%p = alloca %test.Point, align 4
|
||||
%0 = bitcast %test.Point* %p to i8*
|
||||
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 8 bitcast (%test.Point* @0 to i8*), i32 8, i1 false)
|
||||
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast (%test.Point* @0 to i8*), i32 8, i1 false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user