From 84117d83c79d5442247f44f9a9fefa7d886709f9 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Sat, 9 Nov 2024 05:48:52 +0000 Subject: [PATCH] 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`.) --- applets/paren/paren.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applets/paren/paren.py b/applets/paren/paren.py index 7e46d38f..1dd121a7 100755 --- a/applets/paren/paren.py +++ b/applets/paren/paren.py @@ -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:]