1*1f5207b7SJohn Levon #include "check_debug.h"
2*1f5207b7SJohn Levon 
3*1f5207b7SJohn Levon #define add(x, y) x + y
4*1f5207b7SJohn Levon #define sub(x, y) x - y
5*1f5207b7SJohn Levon 
6*1f5207b7SJohn Levon int x;
func(int * p)7*1f5207b7SJohn Levon void func(int *p)
8*1f5207b7SJohn Levon {
9*1f5207b7SJohn Levon 	int a = 1;
10*1f5207b7SJohn Levon 	int b = 2;
11*1f5207b7SJohn Levon 
12*1f5207b7SJohn Levon 	x = 4 * add(2, 3);
13*1f5207b7SJohn Levon 	x = 4 + add(2, 3);
14*1f5207b7SJohn Levon 	x = 4 * add(2, 3) * 8;
15*1f5207b7SJohn Levon 	x = add(2, 3) * 4;
16*1f5207b7SJohn Levon 	x = add(2, 3) - 4;
17*1f5207b7SJohn Levon 	x = -sub(2, 3);
18*1f5207b7SJohn Levon 	x = sub(2, 3)++;
19*1f5207b7SJohn Levon }
20*1f5207b7SJohn Levon /*
21*1f5207b7SJohn Levon  * check-name: Smatch macro precedence bugs
22*1f5207b7SJohn Levon  * check-command: smatch -I.. sm_macros.c
23*1f5207b7SJohn Levon  *
24*1f5207b7SJohn Levon  * check-output-start
25*1f5207b7SJohn Levon sm_macros.c:12 func() warn: the 'add' macro might need parens
26*1f5207b7SJohn Levon sm_macros.c:14 func() warn: the 'add' macro might need parens
27*1f5207b7SJohn Levon sm_macros.c:14 func() warn: the 'add' macro might need parens
28*1f5207b7SJohn Levon sm_macros.c:15 func() warn: the 'add' macro might need parens
29*1f5207b7SJohn Levon sm_macros.c:17 func() warn: the 'sub' macro might need parens
30*1f5207b7SJohn Levon sm_macros.c:18 func() warn: the 'sub' macro might need parens
31*1f5207b7SJohn Levon  * check-output-end
32*1f5207b7SJohn Levon  */
33