xref: /illumos-gate/usr/src/tools/smatch/src/validation/preprocessor/has-builtin.c (revision 8222814ef8560ee0ba222eca8ca5acffc6cd0e44)
1 #ifndef __has_builtin
2 __has_builtin()??? Quesako?
3 #define __has_builtin(x) 0
4 #else
5 "has __has_builtin(), yeah!"
6 #endif
7 
8 #if __has_builtin(nothing)
9 #error "not a builtin!"
10 #endif
11 
12 #if __has_builtin(__builtin_offsetof)		\
13  || __has_builtin(__builtin_types_compatible_p)
14 #error "builtin ops are not builtin functions!"
15 #endif
16 
17 #if __has_builtin(__builtin_va_list)		\
18  || __has_builtin(__builtin_ms_va_list)
19 #error "builtin types are not builtin functions!"
20 #endif
21 
22 #if __has_builtin(__builtin_abs)
23 abs
24 #endif
25 
26 #if __has_builtin(__builtin_constant_p)
27 constant_p
28 #endif
29 
30 123 __has_builtin(abc) def
31 
32 /*
33  * check-name: has-builtin
34  * check-command: sparse -E $file
35  *
36  * check-output-start
37 
38 "has __has_builtin(), yeah!"
39 abs
40 constant_p
41 123 0 def
42  * check-output-end
43  */
44