Skip to content

Commit

Permalink
Cast function pointers without prototype before calling them (#2842)
Browse files Browse the repository at this point in the history
clang complained that this is deprecated in all versions of standard C,
and unsupported in C2x.
  • Loading branch information
emanuele6 authored Aug 13, 2023
1 parent 3fa10e8 commit 4cf1408
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down

0 comments on commit 4cf1408

Please sign in to comment.