selfhost: structlookup/enumlookup mod-filter (mirror aliaslookup)

Tags structinfo/enumtype with originating module; exact-match first,
then split pkg.X and filter by smod/emod. Without this, two modules
with same-leaf-name struct/enum types collapsed to whichever entry
appeared first in the chain.

Wired into 696_modtype_leaf_collision via a wwstage run_pos using
ww_ww (negative case omitted: w6c_ww has no checkfile pass). Updated
the test's Makefile deps to include the wwstage binaries.

Audited the rest of the lookup family — fnretlookup, fnparamslookup,
deflookup don't need the same treatment: the parser emits N_DOT.str
(call/field name) as the leaf only, and fnparamslookup is only
invoked with N_IDENT.str. Dotted module-qualified function calls go
through the module-mangling path instead.
This commit is contained in:
2026-05-15 13:58:56 +09:00
parent 0ef94eef04
commit 9d85aa4142
6 changed files with 202 additions and 46 deletions

View File

@@ -97,6 +97,8 @@ main(void)
char cdrv[1024];
snprintf(cdrv, sizeof cdrv, "%s/ww", bin);
char wdrv[1024];
snprintf(wdrv, sizeof wdrv, "%s/ww_ww", bin);
char fixdir[1024];
if (getcwd(fixdir, sizeof fixdir) == NULL) return 1;
@@ -108,12 +110,18 @@ main(void)
int fail = 0;
fail += run_pos(cdrv, fixdir, "cstage");
fail += run_neg(cdrv, fixdir, "cstage");
fail += run_pos(wdrv, fixdir, "wwstage");
/* No wwstage neg case: w6c_ww has no checkfile pass, so a
* missing-field reference doesn't surface as a build error.
* The positive case alone pins the structlookup mod-filter
* (without it, `mod2.stream` would either fail to resolve or
* silently bind to mod1.stream and miscompute the exit). */
if (fail) {
fprintf(stderr,
"modtype_leaf_collision: %d case(s) failed\n", fail);
return 1;
}
printf("modtype_leaf_collision: 2/2 ok\n");
printf("modtype_leaf_collision: 3/3 ok\n");
return 0;
}