Closed wrongnull closed 4 days ago
It's not a bad idea but we already have a specialized function for it; you can just use ty.isVoidStar()
It's not a bad idea but we already have a specialized function for it; you can just use
ty.isVoidStar()
I agree. Implementation of such a function is out of this pull requests scope
We'll also need a check in the .add
branch of the switch where the current check is, to handle things like ptr + 1
or 1 + ptr
. In the .sub
branch, I just realized we only need to check for a.ty.isVoidStar()
because you can only subtract a pointer from a same-type pointer. So there's no valid subtraction where b
is void *
and a
is not. But for addition either one could be void *
.
One final area to add the checks would be for .plus_plus
and .minus_minus
in the suffixExpr
and unExpr
functions to handle the case of ptr++/ptr--/++ptr/--ptr
when ptr
is void *
.
We'll also need a check in the
.add
branch of the switch where the current check is, to handle things likeptr + 1
or1 + ptr
. In the.sub
branch, I just realized we only need to check fora.ty.isVoidStar()
because you can only subtract a pointer from a same-type pointer. So there's no valid subtraction whereb
isvoid *
anda
is not. But for addition either one could bevoid *
.One final area to add the checks would be for
.plus_plus
and.minus_minus
in thesuffixExpr
andunExpr
functions to handle the case ofptr++/ptr--/++ptr/--ptr
whenptr
isvoid *
.
done
Closes https://github.com/Vexu/arocc/issues/759 In this request I implemented the
Type.isPtrTo
function but only for the.pointer
type specifier. I'm not sure if it is right approach to do that. Maybe other specifiers should be considered as well. I'm open for the conversation.