Cast function pointers without prototype before calling them (#2842)

clang complained that this is deprecated in all versions of standard C,
and unsupported in C2x.
This commit is contained in:
Emanuele Torre authored and GitHub committed 2023-08-13 22:39:54 +09:00
1 parent 3fa10e8cc1
commit 4cf1408e0b
1 file changed
+5 -5
+5 -5
View File
@@ -921,11 +921,11 @@ jv jq_next(jq_state *jq) {
}
struct cfunction* function = &frame_current(jq)->bc->globals->cfunctions[*pc++];
switch (function->nargs) {
case 1: top = function->fptr(jq, in[0]); break;
case 2: top = function->fptr(jq, in[0], in[1]); break;
case 3: top = function->fptr(jq, in[0], in[1], in[2]); break;
case 4: top = function->fptr(jq, in[0], in[1], in[2], in[3]); break;
case 5: top = function->fptr(jq, in[0], in[1], in[2], in[3], in[4]); break;
case 1: top = ((jv (*)(jq_state *, jv))function->fptr)(jq, in[0]); break;
case 2: top = ((jv (*)(jq_state *, jv, jv))function->fptr)(jq, in[0], in[1]); break;
case 3: top = ((jv (*)(jq_state *, jv, jv, jv))function->fptr)(jq, in[0], in[1], in[2]); break;
case 4: top = ((jv (*)(jq_state *, jv, jv, jv, jv))function->fptr)(jq, in[0], in[1], in[2], in[3]); break;
case 5: top = ((jv (*)(jq_state *, jv, jv, jv, jv, jv))function->fptr)(jq, in[0], in[1], in[2], in[3], in[4]); break;
// FIXME: a) up to 7 arguments (input + 6), b) should assert
// because the compiler should not generate this error.
default: return jv_invalid_with_msg(jv_string("Function takes too many arguments"));