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