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