summaryrefslogtreecommitdiff
path: root/include/compiler.h
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2018-12-15 20:21:09 +0300
committerCyrill Gorcunov <gorcunov@gmail.com>2018-12-15 20:33:25 +0300
commit7d23d8d26f2c68c0fab7e9f1e1fab7efefd52dd4 (patch)
tree6a414f827fe2dd713a7ab3354989fcbc59497d08 /include/compiler.h
parent6f33dbb0876a809bee1439246c511aebaf6362c8 (diff)
downloadnasm-7d23d8d26f2c68c0fab7e9f1e1fab7efefd52dd4.tar.gz
compier: Zap __builtin_constant_p on gcc 4.x series
It is been discovered that on gcc-4.8.4 compiler can't properly evaluate __builtin_constant_p. | gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4 | | In file included from asm/nasm.c:38:0: | asm/nasm.c: In function ‘assemble_file’: | ./include/compiler.h:377:27: error: first argument to ‘__builtin_choose_expr’ not a constant | # define if_constant(x,y) __builtin_choose_expr(is_constant(x),(x),(y)) | ^ | ./include/nasmlib.h:145:23: note: in expansion of macro ‘if_constant’ | static_assert(if_constant(x, 1), #x); \ | ^ | ./include/nasmlib.h:167:9: note: in expansion of macro ‘nasm_try_static_assert’ | nasm_try_static_assert(x); \ | ^ | asm/nasm.c:1544:17: note: in expansion of macro ‘nasm_assert’ | nasm_assert(output_ins.times >= 0); | Zap it for 4.x series so we could run our tests. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'include/compiler.h')
-rw-r--r--include/compiler.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/compiler.h b/include/compiler.h
index aab93566..7a80e2e4 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -353,7 +353,11 @@ size_t strnlen(const char *s, size_t maxlen);
/* Determine probabilistically if something is a compile-time constant */
#ifdef HAVE___BUILTIN_CONSTANT_P
-# define is_constant(x) __builtin_constant_p((x))
+# if defined(__GNUC__) && (__GNUC__ >= 5)
+# define is_constant(x) __builtin_constant_p((x))
+# else
+# define is_constant(x) false
+# endif
#else
# define is_constant(x) false
#endif