diff --git a/ChangeLog b/ChangeLog index 5fd453a..98aa999 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Dec 14 21:04:56 2008 Minero Aoki + + * test: test alloca more. + Sun Dec 14 20:43:47 2008 Minero Aoki * net/loveruby/cflat/compiler/CodeGenerator.java diff --git a/test/alloca2.cb b/test/alloca2.cb new file mode 100644 index 0000000..39f26dd --- /dev/null +++ b/test/alloca2.cb @@ -0,0 +1,60 @@ +import stdio; +import string; +import alloca; + +int +main(int argc, char **argv) +{ + fa(); + puts(""); + return 0; +} + +static int +fa(void) +{ + int[10] junk; + int x = 4 * 4 - 13; + char* s = alloca(10); + + fb(); + strcpy(s, ";%d"); + printf(s, 14 + x); +} + +static int +fb(void) +{ + int[10] junk; + int x = (61 - 1) / 4; + char* s = alloca(15); + x += 4; + + fc(); + strcpy(s, ";%d"); + printf(s, x - 2); +} + +static int +fc(void) +{ + int[10] junk; + int x = 4 * 4; + char* s = alloca(20); + x--; + + fd(); + strcpy(s, ";%d"); + printf(s, x + 2); +} + +static int +fd(void) +{ + int[10] junk; + int x = 88 / 4; + char* s = alloca(25); + + strcpy(s, "%d"); + printf(s, -5 + x); +} diff --git a/test/test_cbc.sh b/test/test_cbc.sh index 1ee8d55..04f3c6e 100644 --- a/test/test_cbc.sh +++ b/test/test_cbc.sh @@ -279,6 +279,10 @@ test_28_syntax() { test_29_import() { assert_compile_success duplicated-import.cb + assert_compile_success vardecl.cb && + assert_status 0 ./vardecl + assert_compile_success -fPIC vardecl.cb && + assert_status 0 ./vardecl } test_30_staticfunction() { @@ -314,6 +318,9 @@ test_35_invalidstmt() { test_36_alloca() { assert_out "<>" ./alloca + assert_out "17;17;17;17" ./alloca2 + assert_compile_success -fPIE -pie alloca2.cb && + assert_out "17;17;17;17" ./alloca2 } ###