[qfcc] Set struct member ids

The id matches the member's order in the struct's fields (needed for
spir-v access chains).
This commit is contained in:
Bill Currie 2024-11-13 14:25:25 +09:00
parent 14f428a81d
commit 52d38ce8a6

View file

@ -171,6 +171,7 @@ build_struct (int su, symbol_t *tag, symtab_t *symtab, const type_t *type,
error (0, "%s defined as wrong kind of tag", tag->name); error (0, "%s defined as wrong kind of tag", tag->name);
return sym; return sym;
} }
int index = 0;
for (s = symtab->symbols; s; s = s->next) { for (s = symtab->symbols; s; s = s->next) {
if (s->sy_type != sy_offset) if (s->sy_type != sy_offset)
continue; continue;
@ -214,10 +215,13 @@ build_struct (int su, symbol_t *tag, symtab_t *symtab, const type_t *type,
s->offset += offset; s->offset += offset;
s->table = symtab; s->table = symtab;
s->no_auto_init = true; s->no_auto_init = true;
s->id = index++;
Hash_Add (symtab->tab, s); Hash_Add (symtab->tab, s);
} }
} }
s->next = t; s->next = t;
} else {
s->id = index++;
} }
} }
if (!type) if (!type)