>From ef7aeccd11851716c4f4451a933be17d4cb46b76 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Mon, 21 Oct 2013 22:15:29 +0200 Subject: [PATCH] Use "noreturn" attribute in newer clang versions and get rid of a clang warning. The division procedure C_2_divide would try to call C_fix on the uninitialised variable "iresult" in the case where either of the divident or the divisor values are flonums ("fflag" will be 1 then). In the situation where neither value is a flonum, it'll either barf (which is declared "noreturn"), or properly initialise iresult. This means the C_unfix() call on an uninitialised value which gets C_fix()ed later is pure overhead in the case either value is a flonum. --- chicken.h | 7 ++++++- runtime.c | 7 ++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/chicken.h b/chicken.h index aea58fe..cb9320e 100644 --- a/chicken.h +++ b/chicken.h @@ -229,11 +229,16 @@ void *alloca (); #define HAVE_STATEMENT_EXPRESSIONS 1 #endif +#if !defined(__clang__) && !defined(__has_attribute) +/* Define so it won't error on other compilers with keywords like "noreturn" */ +#define __has_attribute(x) 0 +#endif + #if defined(__GNUC__) || defined(__INTEL_COMPILER) # ifndef __cplusplus # define C_cblock ({ # define C_cblockend }) -# ifdef __clang__ +# if defined(__clang__) && !__has_attribute(noreturn) # define C_noret # else # define C_noret __attribute__ ((noreturn)) diff --git a/runtime.c b/runtime.c index 0ed18de..c518bc5 100644 --- a/runtime.c +++ b/runtime.c @@ -6730,11 +6730,8 @@ C_regparm C_word C_fcall C_2_divide(C_word **ptr, C_word x, C_word y) } else barf(C_BAD_ARGUMENT_TYPE_ERROR, "/", x); - iresult = C_fix(iresult); - - if(fflag || (double)C_unfix(iresult) != fresult) return C_flonum(ptr, fresult); - - return iresult; + if(fflag || (double)iresult != fresult) return C_flonum(ptr, fresult); + else return C_fix(iresult); } -- 1.8.3.4