tinycc/tests/tests2/122_vla_reuse.c
herman ten brugge afc0917f88 Bound checking fixes
tccgen.c:
- Fix 'tcc -b conftest.s'
- Add offset during bound checking for struct return

lib/bcheck.c:
- Check overlap when reusing vla/alloca

arm-gen.c:
arm64-gen.c:
riscv64-gen.c:
lib/alloca86-bt.S:
- add space for vla/alloca during bound checking

tests/tests2/Makefile:
tests/tests2/121_struct_return:
tests/tests2/122_vla_reuse:
- New test cases with bound checking enabled to test vla and struct return
2020-10-01 17:09:09 +02:00

32 lines
503 B
C

#include <stdio.h>
int
main (void)
{
int n = 0;
int first=1;
int *p[101];
if (0) {
lab:;
}
int x[n % 100 + 1];
if (first == 0) {
if (&x[0] != p[n % 100 + 1]) {
printf ("ERROR: %d %p $p\n", &x[0], p[n % 100 + 1]);
return(1);
}
}
else {
p[n % 100 + 1] = &x[0];
first = n < 100;
}
x[0] = 1;
x[n % 100] = 2;
n++;
if (n < 100000)
goto lab;
printf ("OK\n");
return 0;
}