From 451b8ccc79c524f65445cf2ae25657f2a34f0725 Mon Sep 17 00:00:00 2001 From: Spoike Date: Wed, 11 Apr 2007 22:45:34 +0000 Subject: [PATCH] Moved a chunk of code. This will prevent the temp from a calculation in the argument from overwriting the actual return value. a()+b(c+d) should now compile fine. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2490 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/qclib/qcc_pr_comp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index 7bf23d762..92b99821e 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -2526,6 +2526,20 @@ QCC_def_t *QCC_PR_ParseFunctionCall (QCC_def_t *func) //warning, the func could else np = t->num_parms; + if (def_ret.temp->used) + { + old = QCC_GetTemp(def_ret.type); + if (def_ret.type->size == 3) + QCC_FreeTemp(QCC_PR_Statement(&pr_opcodes[OP_STORE_V], &def_ret, old, NULL)); + else + QCC_FreeTemp(QCC_PR_Statement(&pr_opcodes[OP_STORE_F], &def_ret, old, NULL)); + QCC_UnFreeTemp(old); + QCC_UnFreeTemp(&def_ret); + QCC_PR_ParseWarning(WARN_FIXEDRETURNVALUECONFLICT, "Return value conflict - output is inefficient"); + } + else + old = NULL; + if (opt_vectorcalls && (t->num_parms == 1 && t->param->type == ev_vector)) { //if we're using vectorcalls //if it's a function, takes a vector @@ -2750,20 +2764,6 @@ QCC_def_t *QCC_PR_ParseFunctionCall (QCC_def_t *func) //warning, the func could } } - if (def_ret.temp->used) - { - old = QCC_GetTemp(def_ret.type); - if (def_ret.type->size == 3) - QCC_FreeTemp(QCC_PR_Statement(&pr_opcodes[OP_STORE_V], &def_ret, old, NULL)); - else - QCC_FreeTemp(QCC_PR_Statement(&pr_opcodes[OP_STORE_F], &def_ret, old, NULL)); - QCC_UnFreeTemp(old); - QCC_UnFreeTemp(&def_ret); - QCC_PR_ParseWarning(WARN_FIXEDRETURNVALUECONFLICT, "Return value conflict - output is inefficient"); - } - else - old = NULL; - if (strchr(func->name, ':') && laststatement && statements[laststatement-1].op == OP_LOAD_FNC && statements[laststatement-1].c == func->ofs) { //we're entering C++ code with a different self.