Add some functions to handle tracker lists.
[smatch.git] / validation / builtin_safe1.c
blob8a8b9794f7f4a2f076736178080fb34059b9ab30
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;