File misc.c changed (mode: 100644) (index cd63063..f4e48ee) |
... |
... |
void validateGlobalAssignment(const char *varname) |
307 |
307 |
} |
} |
308 |
308 |
} |
} |
309 |
309 |
|
|
|
310 |
|
void check_too_many_params(int num_params, const struct paramlist *inp, const struct funcdecl *fd) |
|
311 |
|
{ |
|
312 |
|
// We use exact comparison to only report it once |
|
313 |
|
if(num_params == 32 && inp) |
|
314 |
|
{ |
|
315 |
|
char buf[1024]; |
|
316 |
|
snprintf(buf, 1024, "A function call can have at most 31 arguments"); |
|
317 |
|
yyerrorex(runtimeerror, buf); |
|
318 |
|
} |
|
319 |
|
} |
|
320 |
|
|
310 |
321 |
void checkParameters(const struct funcdecl *fd, const struct paramlist *inp, bool mustretbool) |
void checkParameters(const struct funcdecl *fd, const struct paramlist *inp, bool mustretbool) |
311 |
322 |
{ |
{ |
312 |
323 |
const struct paramlist *func = fd->p; |
const struct paramlist *func = fd->p; |
313 |
324 |
const struct typeandname *fi = func->head; |
const struct typeandname *fi = func->head; |
314 |
325 |
const struct typeandname *pi = inp->head; |
const struct typeandname *pi = inp->head; |
|
326 |
|
|
|
327 |
|
int num_params = 1; |
315 |
328 |
while(true) { |
while(true) { |
|
329 |
|
check_too_many_params(num_params, pi, fd); |
316 |
330 |
if (fi == NULL && pi == NULL) |
if (fi == NULL && pi == NULL) |
317 |
331 |
return; |
return; |
318 |
332 |
if (fi == NULL && pi != NULL) { |
if (fi == NULL && pi != NULL) { |
|
... |
... |
void checkParameters(const struct funcdecl *fd, const struct paramlist *inp, boo |
349 |
363 |
} |
} |
350 |
364 |
pi = pi->next; |
pi = pi->next; |
351 |
365 |
fi = fi->next; |
fi = fi->next; |
|
366 |
|
num_params++; |
352 |
367 |
} |
} |
353 |
368 |
} |
} |
354 |
369 |
|
|
File tests/should-check/function-call-with-31-args.j added (mode: 100644) (index 0000000..1d3c9b2) |
|
1 |
|
|
|
2 |
|
function a takes integer a1, integer a2, integer a3, integer a4, integer a5, integer a6, integer a7, integer a8, integer a9, integer a10, integer a11, integer a12, integer a13, integer a14, integer a15, integer a16, integer a17, integer a18, integer a19, integer a20, integer a21, integer a22, integer a23, integer a24, integer a25, integer a26, integer a27, integer a28, integer a29, integer a30, integer a31 returns nothing |
|
3 |
|
endfunction |
|
4 |
|
|
|
5 |
|
function b takes nothing returns nothing |
|
6 |
|
call a(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31) |
|
7 |
|
endfunction |
File tests/should-check/function-definition-with-32-args.j added (mode: 100644) (index 0000000..86209bb) |
|
1 |
|
function a takes integer a1, integer a2, integer a3, integer a4, integer a5, integer a6, integer a7, integer a8, integer a9, integer a10, integer a11, integer a12, integer a13, integer a14, integer a15, integer a16, integer a17, integer a18, integer a19, integer a20, integer a21, integer a22, integer a23, integer a24, integer a25, integer a26, integer a27, integer a28, integer a29, integer a30, integer a31, integer a32 returns nothing |
|
2 |
|
endfunction |
File tests/should-fail/function-call-with-32-params.j added (mode: 100644) (index 0000000..6491d32) |
|
1 |
|
|
|
2 |
|
function a takes integer a1, integer a2, integer a3, integer a4, integer a5, integer a6, integer a7, integer a8, integer a9, integer a10, integer a11, integer a12, integer a13, integer a14, integer a15, integer a16, integer a17, integer a18, integer a19, integer a20, integer a21, integer a22, integer a23, integer a24, integer a25, integer a26, integer a27, integer a28, integer a29, integer a30, integer a31, integer a32 returns nothing |
|
3 |
|
endfunction |
|
4 |
|
|
|
5 |
|
function b takes nothing returns nothing |
|
6 |
|
call a(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32) |
|
7 |
|
endfunction |
|
8 |
|
|
File tests/should-fail/function-call-with-33-params.j added (mode: 100644) (index 0000000..17e20bf) |
|
1 |
|
|
|
2 |
|
function a takes integer a1, integer a2, integer a3, integer a4, integer a5, integer a6, integer a7, integer a8, integer a9, integer a10, integer a11, integer a12, integer a13, integer a14, integer a15, integer a16, integer a17, integer a18, integer a19, integer a20, integer a21, integer a22, integer a23, integer a24, integer a25, integer a26, integer a27, integer a28, integer a29, integer a30, integer a31, integer a32, integer a33 returns nothing |
|
3 |
|
endfunction |
|
4 |
|
|
|
5 |
|
function b takes nothing returns nothing |
|
6 |
|
call a(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33) |
|
7 |
|
endfunction |
|
8 |
|
|
|
9 |
|
|