diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Makefile | 5 | ||||
| -rw-r--r-- | tests/tcctest.c | 14 |
2 files changed, 17 insertions, 2 deletions
diff --git a/tests/Makefile b/tests/Makefile index 61df559..ddd4932 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -37,7 +37,8 @@ libtcc_test$(EXESUF): libtcc_test.c ../libtcc.a # test.ref - generate using gcc test.ref: tcctest.c - $(CC) -o tcctest.gcc $< -w -I.. -I../include $(CFLAGS) + cp -u ../include/tcclib.h . + $(CC) -o tcctest.gcc $< -I. -w $(CFLAGS) ./tcctest.gcc > $@ # auto test @@ -141,4 +142,4 @@ cache: tcc_g # clean clean: rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.gcc \ - tcctest[1234] ex? libtcc_test$(EXESUF) tcc_g + tcctest[1234] ex? libtcc_test$(EXESUF) tcc_g tcclib.h diff --git a/tests/tcctest.c b/tests/tcctest.c index 55e356e..a2d481a 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -75,6 +75,7 @@ void stdarg_test(void); void whitespace_test(void); void relocation_test(void); void old_style_function(void); +void alloca_test(void); void sizeof_test(void); void typeof_test(void); void local_label_test(void); @@ -529,6 +530,7 @@ int main(int argc, char **argv) whitespace_test(); relocation_test(); old_style_function(); + alloca_test(); sizeof_test(); typeof_test(); statement_expr_test(); @@ -1935,6 +1937,18 @@ void old_style_function(void) decl_func2(NULL); } +void alloca_test() +{ +#if defined __i386__ || defined __x86_64__ + char *p = alloca(16); + strcpy(p,"123456789012345"); + printf("alloca: p is %s\n", p); + char *demo = "This is only a test.\n"; + /* Test alloca embedded in a larger expression */ + printf("alloca: %s\n", strcpy(alloca(strlen(demo)+1),demo) ); +#endif +} + void sizeof_test(void) { int a; |
