Add test-suite comment to preprocessor21.
[smatch.git] / validation / builtin_safe1.c
blobd95e46b0086fedb460c9d45f5dcf8423d0bed69f
1 #define MY_MACRO(a) do { \
2 __builtin_warning(!__builtin_safe_p(a), "Macro argument with side effects"); \
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;