transpile: Unset needs_address in various places - #1973
Conversation
6a6d1a8 to
4d945e5
Compare
|
I think |
I have already been looking into the overall issue. Some context flags should be "inherited", others should reset back to a default whenever they are passed to a subexpression.
The problem isn't the copying, it's that the modified context of a parent expression gets passed to all the subexpressions too. So in this case, if |
| let arg_expr_kind = &self.ast_context.index_unwrap_parens(arg).kind; | ||
|
|
||
| if let &CExprKind::Unary(_, CUnOp::AddressOf, arg, _) = arg_expr_kind { | ||
| return self.convert_expr(ctx.used(), arg, None); |
There was a problem hiding this comment.
Do we want set_needs_address(false) for this one?
There might be a regression here for this test case:
int *deref_addrof_compound(void) {
return *&(int[]){1, 2, 3};
}
Can you reproduce it?
There was a problem hiding this comment.
I added a regression test for it and fixed the issue.
Ah I understand now, it's in the opposite direction of what I thought. |
4d945e5 to
f187cf4
Compare
f187cf4 to
0cc2795
Compare
needs_addressis being set, but it is then passed down to all subexpressions, even those whose address is never actually taken.