From 8c82a837786c59966410d53aaa128917f7d94c36 Mon Sep 17 00:00:00 2001 From: pommicket Date: Sat, 12 Feb 2022 23:44:48 -0500 Subject: fix casting arguments to parameter type --- 05/main.c | 3 ++- 05/parse.b | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/05/main.c b/05/main.c index 30ce557..2f40441 100644 --- a/05/main.c +++ b/05/main.c @@ -12,6 +12,7 @@ long fibonacci(long x) { } int main(int argc, char **argv) { - return 1 || -0.1; + double x = 3.5; + return factorial(x); } diff --git a/05/parse.b b/05/parse.b index 96941b9..fbdf955 100644 --- a/05/parse.b +++ b/05/parse.b @@ -2803,8 +2803,12 @@ function parse_expression :call_args_loop if *1p == SYMBOL_RPAREN goto call_args_loop_end n = token_next_semicolon_comma_rbracket(p) + *1out = EXPRESSION_CAST ; generate cast to proper argument type arg_type = out + 4 + out += 8 + b = out + 4 out = parse_expression(p, n, out) + *4arg_type = type_create_copy(*4b) b = types + param_type if *1b == 0 goto arg_is_varargs ; reached the end of arguments (so presumably this function has varargs) ; set argument type to parameter type. this is necessary because: -- cgit v1.2.3