smdb.py: print the return_implies value
[smatch.git] / validation / builtin_safe1.c
blobeeddcc82f7b0082b64d35f81d2c274a6bf9464cb
1 #define MY_MACRO(a) do { \
2 __builtin_warning(!__builtin_safe_p(a), "Macro argument with side effects: " #a); \
3 a; \
4 } while (0)
6 int g(int);
7 int h(int) __attribute__((pure));
8 int i(int) __attribute__((const));
10 static int foo(int x, int y)
12 /* unsafe: */
13 MY_MACRO(x++);
14 MY_MACRO(x+=1);
15 MY_MACRO(x=x+1);
16 MY_MACRO(x%=y);
17 MY_MACRO(x=y);
18 MY_MACRO(g(x));
19 MY_MACRO((y,g(x)));
20 /* safe: */
21 MY_MACRO(x+1);
22 MY_MACRO(h(x));
23 MY_MACRO(i(x));
24 return x;
28 * check-name: __builtin_safe
29 * check-error-start
30 builtin_safe1.c:13:3: warning: Macro argument with side effects: x++
31 builtin_safe1.c:14:3: warning: Macro argument with side effects: x+=1
32 builtin_safe1.c:15:3: warning: Macro argument with side effects: x=x+1
33 builtin_safe1.c:16:3: warning: Macro argument with side effects: x%=y
34 builtin_safe1.c:17:3: warning: Macro argument with side effects: x=y
35 builtin_safe1.c:18:3: warning: Macro argument with side effects: g(x)
36 builtin_safe1.c:19:3: warning: Macro argument with side effects: (y,g(x))
37 * check-error-end