diff --git a/test/addressof.cb b/test/addressof.cb new file mode 100644 index 0000000..10e36ac --- /dev/null +++ b/test/addressof.cb @@ -0,0 +1,35 @@ +import stdio; +import string; + +struct s { + char[8] str; +}; + +int +main(int argc, char** argv) +{ + struct s s; + struct s * sp; + char *str; + + str = s.str; + strcpy(str, "OK"); + printf("%s", str); + + str = &s.str; + strcpy(str, "OK"); + printf(";%s", str); + + sp = &s; + str = sp->str; + strcpy(str, "OK"); + printf(";%s", str); + + sp = &s; + str = &sp->str; + strcpy(str, "OK"); + printf(";%s", str); + + puts(""); + return 0; +} diff --git a/test/test_cbc.sh b/test/test_cbc.sh index 97c7490..a652c58 100644 --- a/test/test_cbc.sh +++ b/test/test_cbc.sh @@ -206,6 +206,7 @@ test_22_pointer() { assert_out "777" ./pointer4 assert_out "1;2;3;4;5;6;77;78" ./ptrmemb assert_out "7" ./ptrmemb2 + assert_out "OK;OK;OK;OK" ./addressof assert_compile_error deref-semcheck1.cb assert_compile_error deref-semcheck2.cb assert_compile_error deref-semcheck3.cb