Improved variable length array support.
VLA storage is now freed when it goes out of scope. This makes it possible to use a VLA inside a loop without consuming an unlimited amount of memory. Combining VLAs with alloca() should work as in GCC - when a VLA is freed, memory allocated by alloca() after the VLA was created is also freed. There are some exceptions to this rule when using goto: if a VLA is in scope at the goto, jumping to a label will reset the stack pointer to where it was immediately after the last VLA was created prior to the label, or to what it was before the first VLA was created if the label is outside the scope of any VLA. This means that in some cases combining alloca() and VLAs will free alloca() memory where GCC would not.
This commit is contained in:
@ -14,6 +14,7 @@ TESTS = \
|
||||
libtest \
|
||||
test3 \
|
||||
abitest \
|
||||
vla_test-run \
|
||||
moretests
|
||||
|
||||
# test4 -- problem with -static
|
||||
@ -31,6 +32,10 @@ endif
|
||||
ifeq ($(TARGETOS),Darwin)
|
||||
TESTS := $(filter-out hello-exe test3 btest,$(TESTS))
|
||||
endif
|
||||
ifeq ($(ARCH),i386)
|
||||
else ifneq ($(ARCH),x86-64)
|
||||
TESTS := $(filter-out vla_test-run,$(TESTS))
|
||||
endif
|
||||
|
||||
ifdef DISABLE_STATIC
|
||||
export LD_LIBRARY_PATH:=$(CURDIR)/..
|
||||
@ -190,6 +195,12 @@ abitest: abitest-cc$(EXESUF) abitest-tcc$(EXESUF)
|
||||
./abitest-cc$(EXESUF) lib_path=.. include="$(top_srcdir)/include"
|
||||
./abitest-tcc$(EXESUF) lib_path=.. include="$(top_srcdir)/include"
|
||||
|
||||
vla_test$(EXESUF): vla_test.c
|
||||
$(TCC) -o $@ $^ $(CPPFLAGS) $(CFLAGS)
|
||||
vla_test-run: vla_test$(EXESUF)
|
||||
@echo ------------ $@ ------------
|
||||
./vla_test$(EXESUF)
|
||||
|
||||
# targets for development
|
||||
%.bin: %.c tcc
|
||||
$(TCC) -g -o $@ $<
|
||||
|
||||
Reference in New Issue
Block a user