aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/17-misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/17-misc.c')
-rw-r--r--test/17-misc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/17-misc.c b/test/17-misc.c
index ecff06c..521b948 100644
--- a/test/17-misc.c
+++ b/test/17-misc.c
@@ -13,6 +13,19 @@ int fn1(uvlong p_9) {
return q;
}
+/* Excerpt from linux/kernel.h */
+/*
+ * This returns a constant expression while determining if an argument is
+ * a constant expression, most importantly without evaluating the argument.
+ * Glory to Martin Uecker <Martin.Uecker@med.uni-goettingen.de>
+ */
+#define __is_constexpr(x) \
+ (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
+
+_Static_assert(__is_constexpr(5 &&(1<<3) || 0/0), "");
+_Static_assert(!__is_constexpr(5/0), "");
+_Static_assert(!__is_constexpr(fn1(0)), "");
+
extern int printf(const char *, ...);
int main() {
printf("%d\n", fn1(-77ull));