check for additional stack allocations and varargs in the whole function, not just the first block. fixes #544

This commit is contained in:
Alon Zakai 2012-08-24 17:53:20 -07:00
Родитель 0c2e620f5e
Коммит aab3e76b94
2 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -1391,6 +1391,9 @@ function analyzer(data, sidePass) {
// Allocas // Allocas
var finishedInitial = false; var finishedInitial = false;
lines = func.lines; // We need to consider all the function lines now, not just the first label
for (var i = 0; i < lines.length; i++) { for (var i = 0; i < lines.length; i++) {
var item = lines[i]; var item = lines[i];
if (!item.assignTo || item.intertype != 'alloca' || !isNumber(item.allocatedNum)) { if (!item.assignTo || item.intertype != 'alloca' || !isNumber(item.allocatedNum)) {

Просмотреть файл

@ -2288,6 +2288,25 @@ c5,de,15,8a
Settings.TOTAL_STACK = 1024 Settings.TOTAL_STACK = 1024
self.do_run(src, 'ok!') self.do_run(src, 'ok!')
def test_stack_void(self):
src = r'''
#include <stdio.h>
static char s[100]="aaaaa";
static int func(void) {
if(s[0]!='a') return 0;
printf("iso open %s\n", s, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001);
return 0;
}
int main(){
int i;
for(i=0;i<5000;i++)
func();
printf(".ok.\n");
}
'''
self.do_run(src, '.ok.\n')
def test_array2(self): def test_array2(self):
src = ''' src = '''
#include <stdio.h> #include <stdio.h>