Fix some issues in the typedef test

It wasn't being strict enough in the test (but was good enough to catch
the relocation error, at least) and was printing the alias name
incorrectly.
This commit is contained in:
Bill Currie 2020-02-22 23:41:09 +09:00
parent 3aabfa71d9
commit 52d54f98bf
1 changed files with 9 additions and 5 deletions

View File

@ -22,10 +22,12 @@ next_type (qfot_type_t *type)
}
int
check_alias (qfot_type_t *alias)
check_alias (string name, qfot_type_t *alias)
{
if (alias.meta != ty_basic && alias.t.type != ev_pointer) {
printf ("%s is not a *int alias\n", alias.t.alias.name);
if (alias.meta != ty_basic || alias.t.type != ev_pointer
|| alias.t.fldptr.aux_type.meta != ty_basic
|| alias.t.fldptr.aux_type.t.type != ev_integer) {
printf ("%s is not a *int alias\n", name);
return 0;
}
return 1;
@ -47,10 +49,12 @@ main (void)
type = next_type (type)) {
if (type.meta == ty_alias) {
if (type.t.alias.name == "foo") {
found_foo = check_alias (type.t.alias.aux_type);
found_foo = check_alias (type.t.alias.name,
type.t.alias.aux_type);
}
if (type.t.alias.name == "bar") {
found_bar = check_alias (type.t.alias.aux_type);
found_bar = check_alias (type.t.alias.name,
type.t.alias.aux_type);
}
}
}