From 8eca0d40721bf89a871c022cd2ff9094333f8f07 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Fri, 10 Feb 2023 16:00:25 +0800 Subject: [PATCH] fix issue #I6E9GC: return error when use 4 values in multi-return-values function. --- examples/multi_retvals2.c | 18 ++++++++++++++++++ parse/scf_dfa_expr.c | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 examples/multi_retvals2.c diff --git a/examples/multi_retvals2.c b/examples/multi_retvals2.c new file mode 100644 index 0000000..f5a89f2 --- /dev/null +++ b/examples/multi_retvals2.c @@ -0,0 +1,18 @@ +int printf(const char* fmt, ...); + +int, int, int, int ret3value(int i, int j, int k, int l) +{ + return i, k, j, l; +} + +int main() +{ + int a, b, c, d; + + a, b, c, d = ret3value(1, 2, 3, 4); + + printf("%d, %d, %d, %d\n", a, b, c, d); + + return 0; +} + diff --git a/parse/scf_dfa_expr.c b/parse/scf_dfa_expr.c index c924860..d10b9c0 100644 --- a/parse/scf_dfa_expr.c +++ b/parse/scf_dfa_expr.c @@ -683,8 +683,6 @@ int _expr_multi_rets(scf_expr_t* e) assert(call->nb_nodes > 0); - scf_loge("parent->nb_nodes: %d\n", parent->nb_nodes); - scf_node_t* ret; scf_block_t* b; @@ -712,7 +710,9 @@ int _expr_multi_rets(scf_expr_t* e) j = 0; k = b->node.nb_nodes - 1; while (j < k) { - SCF_XCHG(b->node.nodes[j++], b->node.nodes[k--]); + SCF_XCHG(b->node.nodes[j], b->node.nodes[k]); + j++; + k--; } scf_node_add_child((scf_node_t*)b, assign->nodes[0]); -- 2.25.1