Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/dxil.c:
WARN("Invalid GEP on type class %u.\n", type->class);
vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND,
"Source type of a GEP instruction is not a pointer or aggregate.");
return;
}
if (!(elem_value = sm6_parser_get_value_by_ref(sm6, record, NULL, &operand_idx)))
return;
is_constant = sm6_value_is_constant(elem_value);
elem_idx = is_constant ? sm6_value_get_constant_uint(elem_value) : 0;
type = sm6_type_get_element_or_pointee_type_at_index(type, elem_idx);
/* The first index is always a simple pointer dereference, i.e. zero. */
if (!type || (!i && !is_constant))
Hmm, I'm not convinced yet. Suppose that `i == 1`, type is an aggregate (with at least a field) and `is_constant` is false. Then `elem_idx == 0` and `type` will become the type of the first field of the aggregate, so it will be non-NULL. The `if` condition then becomes `(!non-NULL || (!1 && !false))`, which is `false`, so no error will be raised. Am I making a mistake somewhere?
Also, I'd keep the check that if `i == 0` then `elem_idx == 0`, which you had before.