A parameter of a macro is used next to an operator without parentheses around it

tx0/c:macro-parameter-unparenthesizedstrictwarningbug

What it finds

#define SQUARE(x) x * x: the argument replaces the parameter as text, so SQUARE(a + 1) becomes a + 1 * a + 1. Parentheses around each use of the parameter, (x) * (x), keep the argument whole.

The body must consist only of names, integer literals, parentheses and arithmetic or bitwise operators, so that it is an expression and not a statement or a declaration.

From the rule's source, macro_parameter_unparenthesized.rs.

Example from the rule's tests
#define SQUARE(x) x * xtx0 reports: x is used without parentheses in the body of SQUARE#define SAFE(x) ((x) * (x))#define STMT(x) do { x = 1; } while (0)#define CALL(x) f(x)
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/c:macro-parameter-unparenthesized" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/c:macro-parameter-unparenthesized] reason="..."

tx0 explain tx0/c:macro-parameter-unparenthesized shows the same in the terminal. Found a false positive? Report it.