3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-22 18:52:40 +01:00

applets/paren: Disambiguate *f(x) = *(f(x)) from (*f)(x) (#74)

Also remove the explicit check for `ArrayRef`, which is obsolete since the 2014 addition of the `_is_simple_node` override in commit ba59edb04. (Upstream `_is_simple_node` returns `True` for an `ArrayRef`.)
This commit is contained in:
JustAnotherArchivist 2024-11-09 05:48:52 +00:00 committed by GitHub
parent a11dc12861
commit 84117d83c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,7 +47,7 @@ class CGenerator(c_generator.CGenerator):
return 'sizeof %s' % self._parenthesize_unless_simple(n.expr)
else:
operand = self.visit(n.expr)
if isinstance(n.expr, c_ast.ArrayRef) or not self._is_simple_node(n.expr):
if not self._is_simple_node(n.expr) or (n.op == '*' and isinstance(n.expr, c_ast.FuncCall)):
operand = '(%s)' % operand
if n.op in ('p++', 'p--'):
return operand + n.op[1:]