From ab489b168098391037c9b854012cd8fe1ac49b20 Mon Sep 17 00:00:00 2001 From: Spoike Date: Wed, 13 Mar 2013 23:05:17 +0000 Subject: [PATCH] with dupe similar definitions, favour the function type with the most specified arguments. should probably do the same with .functions too, but meh. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4255 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/qclib/qcc_pr_comp.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index 27a16780d..e389bef29 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -8640,15 +8640,28 @@ QCC_def_t *QCC_PR_GetDef (QCC_type_t *type, char *name, QCC_def_t *scope, pbool if (type && typecmp(def->type, type)) { - if (!pr_scope) + if (pr_scope || typecmp_lax(def->type, type)) { - if (typecmp_lax(def->type, type)) + //unequal even when we're lax + QCC_PR_ParseError (ERR_TYPEMISMATCHREDEC, "Type mismatch on redeclaration of %s. %s, should be %s",name, TypeName(type, typebuf1, sizeof(typebuf1)), TypeName(def->type, typebuf2, sizeof(typebuf2))); + } + else + { + int d=0, t=0; + QCC_type_t *p; + QCC_PR_ParseWarning (WARN_LAXCAST, "Optional arguments differ on redeclaration of %s. %s, should be %s",name, TypeName(type, typebuf1, sizeof(typebuf1)), TypeName(def->type, typebuf2, sizeof(typebuf2))); + QCC_PR_ParsePrintDef(WARN_DUPLICATEDEFINITION, def); + + if (type->type == ev_function) { - //unequal even when we're lax - QCC_PR_ParseError (ERR_TYPEMISMATCHREDEC, "Type mismatch on redeclaration of %s. %s, should be %s",name, TypeName(type, typebuf1, sizeof(typebuf1)), TypeName(def->type, typebuf2, sizeof(typebuf2))); + //update the def's type to the new one if the mandatory argument count is longer + for (p = def->type->param; p; p = p->next) + d++; + for (p = type->param; p; p = p->next) + t++; + if (t > d) + def->type = type; } - else - QCC_PR_ParseWarning (WARN_LAXCAST, "Optional arguments differ on redeclaration of %s. %s, should be %s",name, TypeName(type, typebuf1, sizeof(typebuf1)), TypeName(def->type, typebuf2, sizeof(typebuf2))); } } if (def->arraysize != arraysize && arraysize>=0)