{
const struct parsed_proto *pp, *pp_sym;
char fp_sym[256], fp_var[256];
- int i, bad = 0;
pp = proto_parse(fhdr, varname, 1);
if (pp == NULL) {
return pp;
}
- if (pp->argc != pp_sym->argc || pp->argc_reg != pp_sym->argc_reg)
- bad = 1;
- else {
- for (i = 0; i < pp->argc; i++) {
- if ((pp->arg[i].reg != NULL) != (pp_sym->arg[i].reg != NULL)) {
- bad = 1;
- break;
- }
- if ((pp->arg[i].reg != NULL)
- && !IS(pp->arg[i].reg, pp_sym->arg[i].reg))
- {
- bad = 1;
- break;
- }
- }
- }
-
- if (bad) {
+ if (pp_cmp_func(pp, pp_sym)) {
pp_print(fp_sym, sizeof(fp_sym), pp_sym);
anote("var: %s\n", fp_var);
anote("sym: %s\n", fp_sym);
return pp;
}
+
+static inline int pp_cmp_func(const struct parsed_proto *pp1,
+ const struct parsed_proto *pp2)
+{
+ int i;
+
+ if (pp1->argc != pp2->argc || pp1->argc_reg != pp2->argc_reg)
+ return 1;
+ else {
+ for (i = 0; i < pp1->argc; i++) {
+ if ((pp1->arg[i].reg != NULL) != (pp2->arg[i].reg != NULL))
+ return 1;
+
+ if ((pp1->arg[i].reg != NULL)
+ && !IS(pp1->arg[i].reg, pp2->arg[i].reg))
+ {
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
static inline void pp_print(char *buf, size_t buf_size,
const struct parsed_proto *pp)
{
if (wordc_in == 2) {
if (IS(words[w], "offset")) {
opr->type = OPT_OFFSET;
+ opr->lmod = OPLM_DWORD;
strcpy(opr->name, words[w + 1]);
- return wordc;
+ pp = proto_parse(g_fhdr, opr->name, 1);
+ goto do_label;
}
if (IS(words[w], "(offset")) {
p = strchr(words[w + 1], ')');
}
}
}
+ else if (po->op == OP_MOV && po->operand[0].pp != NULL
+ && po->operand[1].pp != NULL)
+ {
+ // <var> = offset <something>
+ if ((po->operand[1].pp->is_func || po->operand[1].pp->is_fptr)
+ && !IS_START(po->operand[1].name, "off_"))
+ {
+ if (!po->operand[0].pp->is_fptr)
+ ferr(po, "%s not declared as fptr when it should be\n",
+ po->operand[0].name);
+ if (pp_cmp_func(po->operand[0].pp, po->operand[1].pp)) {
+ pp_print(buf1, sizeof(buf1), po->operand[0].pp);
+ pp_print(buf2, sizeof(buf2), po->operand[1].pp);
+ fnote(po, "var: %s\n", buf1);
+ fnote(po, "func: %s\n", buf2);
+ ferr(po, "^ mismatch\n");
+ }
+ }
+ }
else if (po->op == OP_RET && !IS(g_func_pp->ret_type.name, "void"))
regmask |= 1 << xAX;
else if (po->op == OP_DIV || po->op == OP_IDIV) {