From 37e1c88d78ffc49bebf3541af730916343a9ca1e Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Sun, 10 Aug 2025 22:02:44 +0200 Subject: [PATCH] Convert float to double for old function code. --- tccgen.c | 3 +++ tests/tests2/133_old_func.c | 23 +++++++++++++++++++++++ tests/tests2/133_old_func.expect | 2 ++ 3 files changed, 28 insertions(+) create mode 100644 tests/tests2/133_old_func.c create mode 100644 tests/tests2/133_old_func.expect diff --git a/tccgen.c b/tccgen.c index c85db9ee..afb1567a 100644 --- a/tccgen.c +++ b/tccgen.c @@ -8693,6 +8693,9 @@ static int decl(int l) if (sym->type.t != VT_VOID) tcc_error("redefinition of parameter '%s'", get_tok_str(v, NULL)); + if (func_vt.ref->f.func_type == FUNC_OLD && + type.t == VT_FLOAT) + type.t = VT_DOUBLE; convert_parameter_type(&type); sym->type = type; } else if (type.t & VT_TYPEDEF) { diff --git a/tests/tests2/133_old_func.c b/tests/tests2/133_old_func.c new file mode 100644 index 00000000..81b9b75a --- /dev/null +++ b/tests/tests2/133_old_func.c @@ -0,0 +1,23 @@ +int printf(const char *s, ...); + +float fx(x) +float x; +{ + return 2.0 * x; +} + +int +main(void) +{ + float fy(); + + printf("%g %g\n", fx(2.0), fy(10.0)); + printf("%g %g\n", fx(2.0f), fy(10.0f)); +} + +float fy(x) +float x; +{ + return 3.0 * x; +} + diff --git a/tests/tests2/133_old_func.expect b/tests/tests2/133_old_func.expect new file mode 100644 index 00000000..e93760b6 --- /dev/null +++ b/tests/tests2/133_old_func.expect @@ -0,0 +1,2 @@ +4 30 +4 30