[vulkan] Skip values array for empty enum symtabs

Fixes an unused warning/error when the enum has no interesting values
(eg, VkRenderPassCreateFlagBits on older versions of the vulkan api).
This commit is contained in:
Bill Currie 2021-04-03 00:06:54 +09:00
parent 9ac4cdc6bd
commit 64bfaeca6c

View file

@ -65,6 +65,20 @@ skip_value(string name)
|| str_str (name, "_RANGE_SIZE") >= 0);
}
-(int) isEmpty
{
int num_values = 0;
for (int i = 0, index = 0; i < type.strct.num_fields; i++) {
qfot_var_t *var = &type.strct.fields[i];
if (skip_value (var.name)) {
continue;
}
num_values++;
}
return !num_values;
}
-(void) writeTable
{
int strip_bit = 0;
@ -84,17 +98,19 @@ skip_value(string name)
}
fprintf (output_file, "};\n");
fprintf (output_file, "static %s %s_values[] = {\n", [self name], [self name]);
for (int i = 0, index = 0; i < type.strct.num_fields; i++) {
qfot_var_t *var = &type.strct.fields[i];
if (skip_value (var.name)) {
continue;
if (![self isEmpty]) {
fprintf (output_file, "static %s %s_values[] = {\n", [self name], [self name]);
for (int i = 0, index = 0; i < type.strct.num_fields; i++) {
qfot_var_t *var = &type.strct.fields[i];
if (skip_value (var.name)) {
continue;
}
fprintf (output_file, "\t%s, // %d 0x%x\n",
var.name, var.offset, var.offset);
index++;
}
fprintf (output_file, "\t%s, // %d 0x%x\n",
var.name, var.offset, var.offset);
index++;
fprintf (output_file, "};\n");
}
fprintf (output_file, "};\n");
fprintf (output_file, "static exprsym_t %s_symbols[] = {\n", [self name]);
for (int i = 0, index = 0; i < type.strct.num_fields; i++) {
qfot_var_t *var = &type.strct.fields[i];