On Fri Nov 17 12:08:09 2023 +0000, Giovanni Mascellani wrote:
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.
This raises a subtle point: if `is_constant` is false, it is invalid if the current `type` is a struct. It's fine otherwise though. I added a check.
Also, I'd keep the check that if `i == 0` then `elem_idx == 0`, which you had before.
A GEP source must be a pointer, and this is validated, so when `i == 0`, `sm6_type_get_element_or_pointee_type_at_index()` only accepts an `elem_idx` of zero because `type` is a pointer.