From 82e09fa92b9873f89fb550e21b8bceb85cc18459 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Fri, 9 Aug 2019 14:06:36 +0300 Subject: [PATCH] Avoid clang warnings about undefined signed shift behavior Calls to fixnum(-1) would cause them. --- flisp.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flisp.h b/flisp.h index 7eed78d..52ddbf9 100644 --- a/flisp.h +++ b/flisp.h @@ -6,6 +6,7 @@ typedef uptrint_t value_t; typedef int_t fixnum_t; +typedef uint_t ufixnum_t; #ifdef BITS64 #define T_FIXNUM T_INT64 #else @@ -52,7 +53,7 @@ typedef struct { #define tag(x) ((x)&0x7) #define ptr(x) ((void *)((x) & (~(value_t)0x7))) #define tagptr(p, t) (((value_t)(p)) | (t)) -#define fixnum(x) ((value_t)(((fixnum_t)(x)) << 2)) +#define fixnum(x) ((value_t)(((ufixnum_t)(fixnum_t)(x)) << 2)) #define numval(x) (((fixnum_t)(x)) >> 2) #ifdef BITS64 #define fits_fixnum(x) (((x) >> 61) == 0 || (~((x) >> 61)) == 0)