From 92229e769e5ec1356c3858a522037025a010c4dc Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Thu, 2 Feb 2023 11:07:09 -0800 Subject: [PATCH] qclib: add sanity check for mixed usage of nonvirtual and virtual as it's currently unsupported. --- engine/qclib/qcc_pr_lex.c | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/engine/qclib/qcc_pr_lex.c b/engine/qclib/qcc_pr_lex.c index f51d00ab2..49359ccee 100644 --- a/engine/qclib/qcc_pr_lex.c +++ b/engine/qclib/qcc_pr_lex.c @@ -6095,6 +6095,50 @@ QCC_type_t *QCC_PR_ParseType (int newtype, pbool silentfail) } } } + + + /* iterate over every parent-class and see if our method already exists in conflicting nonvirtual type form */ + if (isvirt) + { + for(pc = newt; pc && !found; pc = pc->parentclass) + { + struct QCC_typeparam_s *pp; + int numpc; + int i; + found = false; + + if (pc == newt) + continue; + + pp = parms; + numpc = numparms; + + /* iterate over all of the virtual methods */ + for (i = 0; i < numpc; i++) + { + if (pp[i].type->type == newparm->type) + { + /* if we found it, abandon this loop - we still have to check the other classes however */ + if (!strcmp(pp[i].paramname, parmname)) + { + found = true; + break; + } + } + } + + /* we didn't find it as a field... so check if it exists as a nonvirtual method */ + if (found == false) + { + QC_snprintfz(membername, sizeof(membername), "%s::%s", pc->name, parmname); + + /* if we found it, game over */ + if (QCC_PR_GetDef(NULL, membername, NULL, false, 0, 0)) + QCC_PR_ParseError(0, "%s defined as virtual in %s, but nonvirtual in %s\n", parmname, newt->name, pc->name); + } + } + } + parms[numparms].ofs = basicindex; //ulp, its new numparms++;